A pasteboard is essentially the same thing as the clipboard you’re already accustomed to using with “Copy” and “Paste” commands.
Using Omni Automation you can copy content to and from the user clipboard, and you can create instances of pasteboards (clipboards) for temporary use as well.
Pasteboard Properties
Here are the properties of an instance of the Pasteboard class:
general (Pasteboard) • The Pasteboard used for user-initiated copy/paste support.
The general property can be used to access the clipboard (pasteboard) used by the user. For example, here is a script that uses the copyNodes() method of the Editor class to set the contents of the general pasteboard (clipboard) to the currently selected outline content:
Here’s a variation of the previous script that will copy the selection to the general clipboard and generate a new mail message in which you can manually paste the content of the document selection:
editor = document.editors[0]
editor.copyNodes(editor.selectedNodes, Pasteboard.general)
new Email().generate()
/*{
"type": "action",
"targets": ["omnioutliner"],
"author": "Your Name or Company",
"identifier": "com.YouOrCompany.oo.actionName",
"description": "Description of this action.",
"label": "The menu item text",
"shortLabel": "Palette Text"
}*/
(() => {
var action = new PlugIn.Action(function(selection, sender) {
// action code
// selection options: columns, document, editor, items, nodes, styles
editor.copyNodes(selection.nodes, Pasteboard.general)
urlStr = 'workflow://run-workflow?name=YOUR%WORKFLOW%20NAME&input=clipboard'
URL.fromString(urlStr).open()
});
action.validate = function(selection, sender) {
// validation code
// selection options: columns, document, editor, items, nodes, styles
return (selection.nodes.length > 0)
};
return action;
})();
Here's a script for iOS that puts the selected items on the user clipboard and calls an Apple Workflow workflow (named “Clipboard to PDF”) that uses the clipboard as input:
A workflow that converts the clipboard to a PDF file and opens it in Adobe Acrobat:
Documentation concerning the Workflow URL scheme is available here. Note that there is no need to begin with workflow actions retrieving the clipboard contents, as the clipboard’s contents are automatically passed to the first action in the workflow.
Pasteboard Methods (functions)
Here are the methods used with an instance of the Pasteboard class:
makeUnique() (--> Pasteboard) • Creates a new unique pasteboard.
Copy and Paste with Pasteboard
Here’s an example script that uses properties and methods of the Editor and Pasteboard classes to copy the selected items and paste copies of them into the outline at the beginning.