Action

Simple Extraction to new Draft

Posted by Chris Grieser (armenaton), Last update over 2 years ago

UPDATES

over 2 years ago

scissor icon

Extract selected text to a new Draft without creating any backlins.

For simple cases of draft refactoring.

Steps

  • script

    draft.saveVersion()
    
    if (editor.getSelectedText().length < 1) {
      app.displayErrorMessage("No selection made");
    } else {
    	newContent = editor.getSelectedText();
    	
    	//delete selection
    	editor.setSelectedText("");
    
    	//create new draft
    	let d = Draft.create();
    	d.content = "# \n" + newContent + "\n";
    	d.addTag("extraction");
    	d.update();
    	editor.load(d);
    	editor.setSelectedRange (2,0);
    	app.displaySuccessMessage("Selection extracted");
    }
    

Options

  • After Success Nothing , Tags: extracted-from
    Notification Info
    Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.