Action
Code Block (```)
Apply Markdown fenced code block (“`) around selection, or insert empty block if no selection.
Steps
-
script
// Apply Markdown bold to selection, or insert ** if no selection let markup = "```"; let sel = editor.getSelectedText(); let [st, len] = editor.getSelectedRange(); let [lnSt, lnLen] = editor.getSelectedLineRange(); if (!sel || sel.length == 0) { // no selected text if (st != lnSt) { // not beginning of line, make block editor.setSelectedText("\n\n"+markup+"\n\n"+markup+"\n\n"); editor.setSelectedRange(st+markup.length+3,0); } else { // beginning of line editor.setSelectedText(markup+"\n\n"+markup+"\n"); editor.setSelectedRange(st+markup.length+1,0); } } else { editor.setSelectedText("\n\n"+markup+"\n"+sel+"\n"+markup+"\n\n"); editor.setSelectedRange(st+len+(markup.length*2)+6,0); }
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.