Action
Expand template
Designed to insert text and leave the cursor at the position indicated by ||
Don’t call this directly, create a script action defining a variable named template, and include this afterwards. E.g. const template =‘[||]’;
This will insert the brackets, leaving the cursor between them.
Steps
-
script
// Apply a template to selection, or insert the template if no selection, leaving the cursor indicated by || const sel = editor.getSelectedText(); const selRange = editor.getSelectedRange(); const [start, end]=template.split('||'); if (!sel || sel.length == 0) { editor.setSelectedText(start+end); editor.setSelectedRange(selRange[0]+start.length,0); } else { editor.setSelectedText(start+sel+end); editor.setSelectedRange(selRange[0]+selRange[1]+start.length+end.length,0); }
Options
-
After Success Default Notification Error Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.