Skip to content

Instantly share code, notes, and snippets.

@colinf
Created January 9, 2018 16:24
Show Gist options
  • Save colinf/6d182493da6dfb07460235a65e8c5948 to your computer and use it in GitHub Desktop.
Save colinf/6d182493da6dfb07460235a65e8c5948 to your computer and use it in GitHub Desktop.
Read the top level rows of the outline
const runJxa = require('run-jxa')
let resultPromise = getRows()
resultPromise.then(rows => {
console.log(rows)
})
async function getRows () {
let rows = await runJxa(readChildren)
return rows
}
function readChildren () {
let oo = Application('OmniOutliner')
let doc = oo.documents[0]
let childRows = doc.children
let idList = childRows.id()
let nameList = childRows.name()
let hasChildrenList = childRows.hasSubtopics()
return idList.map((id, i) => {
return {id, name: nameList[i], hasChildren: hasChildrenList[i]}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment