Action

Quick Draft

Posted by agiletortoise, Last update almost 4 years ago

Prompt for text and optional tags, and create a new draft with that text.

Useful for capturing another draft quickly without having to leave the draft you are currently working on.

Steps

  • script

    // prompt for text and create a draft with the input
    let p = Prompt.create();
    p.title = "Quick Draft"
    p.addTextView("content", "Draft content", "", {
    	height: 160,
    	wantsFocus: true
    });
    p.addTextField("tags", "Tags", "", {
    	autocapitalization: false,
    	placeholder: "optional tags"
    });
    p.addButton("Create Draft");
    if (p.show()) {
    	let d = Draft.create();
    	d.content = p.fieldValues["content"];
    	let tagStr = p.fieldValues["tags"];
    	if (tagStr.length > 0) {
    		let tags = tagStr.split(",");
    		for (let tag of tags) {
    			d.addTag(tag);
    		}
    	}
    	d.update();
    	console.log("Draft created");
    }
    else {
    	context.cancel();
    }
    
    editor.activate();

Options

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