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.1", "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" }*/ (() => { const action = new PlugIn.Action(async function(selection, sender){ try { clipboardText = Pasteboard.general.string destinations = ["Inbox", "Projects"] destinationMenu = new Form.Field.Option( "destination", null, [0,1], destinations, 0 ) inputForm = new Form() inputForm.addField(destinationMenu) formPrompt = "Import destination:" buttonTitle = "Continue" formObject = await inputForm.show(formPrompt, buttonTitle) // PROCESS FORM RESULTS destinationIndex = formObject.values['destination'] destination = destinations[destinationIndex].toLowerCase() clipboardText = encodeURIComponent(clipboardText) urlStr = `omnifocus:///paste?target=${destination}&content=${clipboardText}` console.log(urlStr) URL.fromString(urlStr).open() } catch(err){ if(!err.causedByUserCancelling){ new Alert(err.name, err.message).show() } } }); action.validate = function(selection, sender){ return (Pasteboard.general.hasStrings) }; return action; })();