Next Placeholder <|>

Posted by agiletortoise, Last update over 1 year ago

Find and select the next placeholder text in draft. Mean for use with templates as described in this forum tip

Placeholders are any text matching <|fieldname>, where “fieldname” is optional.


  • script

    // define the placeholder to find
    const placeholderRe = /<\|.*?>/gm
    // grab values to use
    let [st, len] = editor.getSelectedRange()
    const text = editor.getText()
    // function to locate the next matching placeholder
    function findNext(str, st) {
    	while(match = placeholderRe.exec(text)) {
    		let pos = match["index"]
    		if (pos > st) {
    			return [pos, match[0].length]
    	return [null, null]
    // find next placeholder and select it
    let [placeSt, placeLn] = findNext(text, st)
    if (placeSt) {
    	editor.setSelectedRange(placeSt, placeLn)


  • 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.