×

Plug-In: Open Note in BBEdit

Opens the text content of the note of the selected task or project as a markdown document in the BBEdit application from Bare Bones software.

NOTE: The name of the task/project is the name fo the file.

Return to: OmniFocus Plug-In Collection

Open Note in BBEdit
 

/*{ "type": "action", "targets": ["omnifocus"], "author": "Otto Automator", "identifier": "com.omni-automation.of.open-note-in-bbedit", "version": "1.0", "description": "Opens the text content of the note of the selected task or project as a markdown document in the BBEdit application from Bare Bones software. NOTE: The name of the task/project is the name fo the file.\n<https://www.barebones.com/products/bbedit>", "label": "Open Note in BBEdit", "shortLabel": "Open Note in BBEdit", "paletteLabel": "Open Note in BBEdit", "image": "gearshape" }*/ (() => { var action = new PlugIn.Action(function(selection, sender){ // action code // selection options: tasks, projects, folders, tags, allObjects try { if (selection.tasks.length === 1){ var item = selection.tasks[0] } else { var item = selection.projects[0] } var noteText = item.note if(!noteText || noteText.length === 0){ throw {"name":"Missing Resource", "message":"The selected item has no note text."} } var encodedItemName = encodeURIComponent(item.name) var encodedString = encodeURIComponent(noteText) var BBEditURLStr = `x-bbedit://new-document/?language=md&name=${encodedItemName}.md&text=` + encodedString URL.fromString(BBEditURLStr).open() } catch(err){ new Alert(err.name, err.message).show() } }); action.validate = function(selection, sender){ // validation code // selection options: tasks, projects, folders, tags, databaseObjects, allObjects return ( selection.databaseObjects.length === 1 && (selection.databaseObjects[0] instanceof Project || selection.databaseObjects[0] instanceof Task) ) }; return action; })();