Editors

To change how an outline looks or is organized, scripts address an Editor.

An element of the Document class, an instance of the Editor class is the entity that controls the display of the outline and its items. By addressing an editor, a script can select, expand, and collapse rows, as well as control the display of columns.

The current editor object is referenced as editor zero (0), meaning it is the first editor in the array of editors currently in use by open document windows. (see below)

editor = document.editors[0] tree = document.outline editor.setVisibilityOfColumn(tree.outlineColumn,true) editor.setVisibilityOfColumn(tree.statusColumn,false) editor.setVisibilityOfColumn(tree.noteColumn,false)
omnioutliner:///omnijs-run?script=editor%20%3D%20document%2Eeditors%5B0%5D%0Atree%20%3D%20document%2Eoutline%0Aeditor%2EsetVisibilityOfColumn%28tree%2EoutlineColumn%2Ctrue%29%0Aeditor%2EsetVisibilityOfColumn%28tree%2EstatusColumn%2Cfalse%29%0Aeditor%2EsetVisibilityOfColumn%28tree%2EnoteColumn%2Cfalse%29

Editor Properties

Here are the properties of an instance of the Editor class:

Row Text Folding

An example script of setting the property of the current Editor for truncating the text of outline rows:

document.editors[0].foldingEnabled = true
omnioutliner:///omnijs-run?script=document%2Eeditors%5B0%5D%2EfoldingEnabled%20%3D%20true
folding-menu

Nodes

In terms of an Editor, the individual items of the outline column are called nodes, and references to them are used with commands like the select command that accepts an array of node references as the objects to select.

editor = document.editors[0] node = editor.rootNode.children[0] editor.select([node])
omnioutliner:///omnijs-run?script=editor%20%3D%20document%2Eeditors%5B0%5D%0Anode%20%3D%20editor%2ErootNode%2Echildren%5B0%5D%0Aeditor%2Eselect%28%5Bnode%5D%29

In the following example, the top-level items of the outline (children) are examined to determine the state of their corresponding status checkboxes. If selected, the item is expanded to reveal its descendants, otherwise the item is collapsed.

editor = document.editors[0] editor.rootNode.children.forEach(function(node){ nodeState = node.valueForColumn(document.outline.statusColumn) if (nodeState === State.Checked){ node.expand() } else { node.collapse() } })
omnioutliner:///omnijs-run?script=editor%20%3D%20document%2Eeditors%5B0%5D%0Aeditor%2ErootNode%2Echildren%2EforEach%28function%28node%29%7B%0A%09nodeState%20%3D%20node%2EvalueForColumn%28document%2Eoutline%2EstatusColumn%29%0A%09if%20%28nodeState%20%3D%3D%3D%20State%2EChecked%29%7B%0A%09%09node%2Eexpand%28%29%0A%09%7D%20else%20%7B%0A%09%09node%2Ecollapse%28%29%0A%09%7D%0A%7D%29

A useful feature of OmniOutliner is the ability to focus the outline display to only show specific items, temporarily hiding the other elements of the outline. Omni Automation scripts have the ability to focus and unfocuse the outline display.

As shown in the following example (line 4), a reference to a node’s corresponding item is the value of the node’s object property.

function focusSelectedItems(){ editor = document.editors[0] nodes = editor.selectedNodes items = nodes.map(function(node){return node.object}) editor.focusedItems = items }
omnioutliner:///omnijs-run?script=function%20focusSelectedItems%28%29%7B%0A%09editor%20%3D%20document%2Eeditors%5B0%5D%0A%09nodes%20%3D%20editor%2EselectedNodes%0A%09items%20%3D%20nodes%2Emap%28function%28node%29%7Breturn%20node%2Eobject%7D%29%0A%09editor%2EfocusedItems%20%3D%20items%0A%7D%0AfocusSelectedItems%28%29
function unfocus(){ if (document.editors[0].focusedItems != []){ document.editors[0].focusedItems = [] } }
omnioutliner:///omnijs-run?script=function%20unfocus%28%29%7B%0A%09if%20%28document%2Eeditors%5B0%5D%2EfocusedItems%20%21%3D%20%5B%5D%29%7B%0A%09%09document%2Eeditors%5B0%5D%2EfocusedItems%20%3D%20%5B%5D%0A%09%7D%0A%7D%0Aunfocus%28%29

Editor Methods (functions)

Here are the methods used with an instance of the Editor class:

Here’s an example script using the scrollToNode() method to scroll the outline document to the top:

editor = document.editors[0] editor.scrollToNode(editor.rootNode.children[0])
omnioutliner:///omnijs-run?script=editor%20%3D%20document%2Eeditors%5B0%5D%0Aeditor%2EscrollToNode%28editor%2ErootNode%2Echildren%5B0%5D%29

Here’s an example script using the outdentNodes() method to move the selected row to the top-level in the outline:

editor = document.editors[0] node = editor.selectedNodes[0] while (node.level != 1){ editor.outdentNodes([node]) node = editor.selectedNodes[0] }
omnioutliner:///omnijs-run?script=editor%20%3D%20document%2Eeditors%5B0%5D%0Anode%20%3D%20editor%2EselectedNodes%5B0%5D%0Awhile%20%28node%2Elevel%20%21%3D%201%29%7B%0A%09editor%2EoutdentNodes%28%5Bnode%5D%29%0A%09node%20%3D%20editor%2EselectedNodes%5B0%5D%0A%7D

Here’s a script that uses the visibilityOfColumn() method to derive references to the visible columns:

editor = document.editors[0] visibleColumns = columns.map(function(column){ if (editor.visibilityOfColumn(column)){return column} })
 

EditorColumnPosition

Instances of the EditorColumnPosition class are generated by using one of the following methods with an instance of the Editor class:

columnPosition = document.editors[0].afterColumn(document.outline.outlineColumn)
 

SortOrdering Properties

The SortOrdering properties are the value for the sorting methods sortOrderingForColumn and setSortOrderingForColumn of the Editor class:

editor = document.editors[0] column = document.outline.outlineColumn sortStatus = editor.sortOrderingForColumn(column) if (sortStatus != SortOrdering.Descending){ editor.setSortOrderingForColumn(column, SortOrdering.Descending) }
omnioutliner:///omnijs-run?script=editor%20%3D%20document%2Eeditors%5B0%5D%0Acolumn%20%3D%20document%2Eoutline%2EoutlineColumn%0AsortStatus%20%3D%20editor%2EsortOrderingForColumn%28column%29%0Aif%20%28sortStatus%20%21%3D%20SortOrdering%2EDescending%29%7B%0A%09editor%2EsetSortOrderingForColumn%28column%2C%20SortOrdering%2EDescending%29%0A%7D
 

NoteDisplay Properties

The NoteDisplay properties are the value for the noteDisplay property (note lowercase n) of the Editor class:

Editors can be used to control the manner in which notes are displayed:

var alert = new Alert("NOTES DISPLAY", "Display item notes inline or at the bottom of the pane?") alert.addOption("Inline") alert.addOption("Pane") alert.show(function(result){ if (result == 0){ document.editors[0].noteDisplay = NoteDisplay.Inline } else { document.editors[0].noteDisplay = NoteDisplay.Pane } })
omnioutliner:///omnijs-run?script=var%20alert%20%3D%20new%20Alert%28%22NOTES%20DISPLAY%22%2C%20%22Display%20item%20notes%20inline%20or%20at%20the%20bottom%20of%20the%20pane%3F%22%29%0Aalert%2EaddOption%28%22Inline%22%29%0Aalert%2EaddOption%28%22Pane%22%29%0Aalert%2Eshow%28function%28result%29%7B%0A%09if%20%28result%20%3D%3D%200%29%7B%0A%09%09document%2Eeditors%5B0%5D%2EnoteDisplay%20%3D%20NoteDisplay%2EInline%0A%09%7D%20else%20%7B%0A%09%09document%2Eeditors%5B0%5D%2EnoteDisplay%20%3D%20NoteDisplay%2EPane%0A%09%7D%0A%7D%29
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