Cross link drafts

Posted by @jsamlarose, Last update 23 days ago

Prompt to select an existing draft, insert link to selected draft at the last cursor position and append link for current draft to selected draft

Slight tweak of Insert Draft at Cursor

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 link to target draft
    	let [st, len] = editor.getSelectedRange();
    	editor.setSelectedText("["+d.title+"]("+d.permalink+")");
    	editor.setSelectedRange(st+4+d.title.length+d.permalink.length, 0);
    	// append link for current draft to target
    	d.content = d.content + "\n" + "["+draft.title+"]("+draft.permalink+")";
    	d.update();
    	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.