Skip to content

Instantly share code, notes, and snippets.

@juandesant
Last active March 12, 2021 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juandesant/34cdf64845b5d4c78f1caa5d9ca5f05e to your computer and use it in GitHub Desktop.
Save juandesant/34cdf64845b5d4c78f1caa5d9ca5f05e to your computer and use it in GitHub Desktop.
This script takes selected rows in OmniOutliner, and tries to split topics that have multiple lines into multiple rows, and leaves one-liner items alone.
// Based on information provided on
// https://omni-automation.com/omnioutliner/item.html
// Get selected nodes in foremost window (editors[0])
var nodes = document.editors[0].selectedNodes
// Split all selected topics in paragraphs
nodes.forEach(
function(node) {
// for each individual node
var selectedItem = node.object
// we get the parent so that we keep the relationship
var selectedItemParent = selectedItem.parent
// item.topic contains the outliner's text
var selectedTopics = selectedItem.topic
// split the topic in multiple lines per \n character
var splitTopics = selectedTopics.split("\n")
// for topics with more than one entry after splitting
if (splitTopics.length > 1) {
splitTopics.forEach(
function(theTopic) {
selectedItemParent.addChild(
selectedItem.before,
function(item) {
item.topic = theTopic
}
)
}
)
// we remove the item after having added the split topics
selectedItem.remove()
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment