×

Plug-In: Import TaskPaper from Clipboard

This plug-in will import the TaskPaper contents from the clipboard to either the Inbox or Projects folder.

Return to: OmniFocus Plug-In Collection

Import TaskPaper from Clipboard
 

/*{ "type": "action", "targets": ["omnifocus"], "author": "Otto Automator", "identifier": "com.omni-automation.of.import-taskpaper-from-clipboard", "version": "1.0", "description": "This plug-in will import the TaskPaper contents from the clipboard.", "label": "Import TaskPaper from Clipboard", "shortLabel": "TaskPaper from Clipboard", "paletteLabel": "TaskPaper from Clipboard", "image": "arrow.right.doc.on.clipboard" }*/ (() => { var action = new PlugIn.Action(function(selection, sender){ (async () => { // action code // selection options: tasks, projects, folders, tags, databaseObjects, allObjects let clipboardText = Pasteboard.general.string let destinations = ["Inbox", "Projects"] let destinationMenu = new Form.Field.Option( "destination", null, [0,1], destinations, 0 ) let inputForm = new Form() inputForm.addField(destinationMenu) let formPrompt = "Import destination:" let buttonTitle = "Continue" let formObject = await inputForm.show(formPrompt, buttonTitle) // PROCESS FORM RESULTS let destinationIndex = formObject.values['destination'] let destination = destinations[destinationIndex].toLowerCase() clipboardText = encodeURIComponent(clipboardText) let urlStr = `omnifocus:///paste?target=${destination}&content=${clipboardText}` console.log(urlStr) URL.fromString(urlStr).open() })().catch(err => { new Alert(err.name, err.message).show() console.error(err) }) }); action.validate = function(selection, sender){ // validation code // selection options: tasks, projects, folders, tags, databaseObjects, allObjects return (Pasteboard.general.hasStrings) }; return action; })();