Pasteboard

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:

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:

editor = document.editors[0] editor.copyNodes(editor.selectedNodes, Pasteboard.general)
omnioutliner:///omnijs-run?script=editor%20%3D%20document%2Eeditors%5B0%5D%0Aeditor%2EcopyNodes%28editor%2EselectedNodes%2C%20Pasteboard%2Egeneral%29

And here's a script for pasting the current OmniOutliner selection into OmniFocus:

editor = document.editors[0] editor.copyNodes(editor.selectedNodes, Pasteboard.general) url = URL.fromString('omnifocus://localhost/paste') url.open()
omnioutliner://localhost/omnijs-run?script=editor%20%3D%20document%2Eeditors%5B0%5D%0Aeditor%2EcopyNodes%28editor%2EselectedNodes%2C%20Pasteboard%2Egeneral%29%0Aurl%20%3D%20URL%2EfromString%28%27omnifocus%3A%2F%2Flocalhost%2Fpaste%27%29%0Aurl%2Ecall%28function%28reply%29%7B%7D%29

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()
omnioutliner:///omnijs-run?script=editor%20%3D%20document%2Eeditors%5B0%5D%0Aeditor%2EcopyNodes%28editor%2EselectedNodes%2C%20Pasteboard%2Egeneral%29%0Anew%20Email%28%29%2Egenerate%28%29
message-clipboard
editor = document.editors[0] editor.copyNodes(editor.selectedNodes, Pasteboard.general) urlStr = 'workflow://run-workflow?name=Clipboard%20to%20PDF&input=clipboard' URL.fromString(urlStr).open()
omnioutliner:///omnijs-run?script=editor%20%3D%20document%2Eeditors%5B0%5D%0Aeditor%2EcopyNodes%28editor%2EselectedNodes%2C%20Pasteboard%2Egeneral%29%0AurlStr%20%3D%20%27workflow%3A%2F%2Frun-workflow%3Fname%3DClipboard%2520to%2520PDF%26input%3Dclipboard%27%0AURL%2EfromString%28urlStr%29%2Ecall%28function%28msg%29%7B%7D%29
/*{ "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:

Clipboard to PDF Workflow

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:

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.

editor = document.editors[0] nodes = editor.selectedNodes if (nodes.length > 0){ pb = Pasteboard.makeUnique() editor.copyNodes(nodes,pb) editor.paste(pb,editor.rootNode,0) }
omnioutliner:///omnijs-run?script=editor%20%3D%20document%2Eeditors%5B0%5D%0Anodes%20%3D%20editor%2EselectedNodes%0Aif%20%28nodes%2Elength%20%3E%200%29%7B%0A%09pb%20%3D%20Pasteboard%2EmakeUnique%28%29%0A%09editor%2EcopyNodes%28nodes%2Cpb%29%0A%09editor%2Epaste%28pb%2Ceditor%2ErootNode%2C0%29%0A%7D
editor = document.editors[0] nodes = editor.selectedNodes if (nodes.length > 0){ pb = Pasteboard.makeUnique() editor.copyNodes(nodes,pb) editor.paste(pb) }
omnioutliner:///omnijs-run?script=editor%20%3D%20document%2Eeditors%5B0%5D%0Anodes%20%3D%20editor%2EselectedNodes%0Aif%20%28nodes%2Elength%20%3E%200%29%7B%0A%09pb%20%3D%20Pasteboard%2EmakeUnique%28%29%0A%09editor%2EcopyNodes%28nodes%2Cpb%29%0A%09editor%2Epaste%28pb%29%0A%7D

If an insertion destination is not specified when using the paste() method, the pasteboard content is placed at the end of the outline:

UNDER CONSTRUCTION

This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.

DISCLAIMER