Plug-In: Save Shape Text to File
This action will save the text contents of the selected shape to a plain text file on disk.
On macOS systems, the option to open the saved file will be presented.
Return to: OmniGraffle Plug-In Collection
Save Shape Text to File
/*{"type": "action","targets": ["omnigraffle"],"author": "Otto Automator","identifier": "com.omni-automation.og.shape-text-to-file","version": "1.3","description": "This plug-in will save the text contents of the selected shape to a file on disk.","label": "Save Shape Text to File","shortLabel": "Text to File","paletteLabel": "Text to File","image": "note.text"}*/(() => {const action = new PlugIn.Action(async function(selection, sender){selection = document.windows[0].selectionshape = selection.solids[0]shapeText = shape.textdata = Data.fromString(shapeText)wrapper = FileWrapper.withContents('Shape Text.txt', data)filesaver = new FileSaver()urlObj = await filesaver.show(wrapper)console.log(urlObj.string)if (Device.current.type === DeviceType.mac){alert = new Alert("Text Saved", urlObj.string)alert.addOption("Done")alert.addOption("Open File")buttonIndex = await alert.show()if(buttonIndex === 1){urlObj.open()}}});action.validate = function(selection, sender){selection = document.windows[0].selectionif (selection.solids.length === 1){return (selection.solids[0].text.length > 0)}return false};return action;})();