Markdown Bold (**)

Posted by agiletortoise, Last update 25 days ago

Apply Markdown bold (*) around selection, or insert * if no selection.

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 Default
    Notification Error
    Log Level Error
Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.