Action

Discord Spoiler Tags (||)

Posted by David Blue, Last update over 1 year ago

A direct duplicate of agiletortoise’s Markdown scripting actions which wrap standard formatting around selected text. For the sake of “Spoiler Tags” formatting on Discord, this action adds || on both sides of selected text. If no text is selected, a single set is added at the cursor’s position.

Steps

  • script

    // Apply Markdown bold to selection, or insert ** if no selection
    const markup = "||";
    
    const sel = editor.getSelectedText();
    const [st, len] = editor.getSelectedRange();
    
    if (!sel || sel.length == 0) {
      editor.setSelectedText(markup);
      editor.setSelectedRange(st + markup.length,0);
    }
    else {
      editor.setSelectedText(markup + sel + markup);
      editor.setSelectedRange(st + len + (markup.length*2),0);
    }
    

Options

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