Insert Draft at Cursor

Posted by agiletortoise, Last update 8 months ago

Prompt to select and existing draft, insert content of selected draft at the last cursor position (replacing selection).

Steps

  • script

    // select and existing draft
    // insert its content in the current draft
    // at the cursor position
    
    let f = () => {
    	// select an existing draft
    	let d = app.selectDraft();
    	if (!d) {
    		return false;
    	}
    	
    	// insert content
    	let [st, len] = editor.getSelectedRange();
    	editor.setSelectedText(d.content);
    	editor.setSelectedRange(st+d.content.length, 0);
    	return true;	
    }
    
    if (!f()) {
    	context.cancel();
    }
    

Options

  • After Success Nothing
    Notification Error
    Log Level Info
Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.