Action

Fix Linebreaks for Instagram

Posted by garbonsai, Last update almost 2 years ago

Inserts a hidden unicode character at the end of each line to ensure linebreaks are displayed properly in Instagram captions and comments.

Steps

  • script

    // insert a hidden character before each line break
    try {
    	var text = editor.getSelectedText();
    	if ( text.length === 0 ) text = editor.getText();
    	if ( text.length === 0 ) throw( 'No selected text or draft is blank.' );
    	text = text.replace( /\n/gm, '\u2063\n' );
    	app.setClipboard( text );
    
    	// diplay warning or success message
    	text.length > 2200 ?
    		app.displayWarningMessage( 'Text copied to the clipboard. Text is overset by ' + ( text.length - 2200 ) + ' characters.') :
    		app.displaySuccessMessage( 'Text copied to the clipboard.' );
    
    // log and display any errors
    } catch( e ) {
    	console.log( e );
    	alert( e );
    }

Options

  • After Success Nothing
    Notification Error
    Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.