Here’s a variation on the previous appending script that prepends draft paragraphs, in order, to the beginning of an OmniOutliner outline, as rows.
stringsArray = XXXXX
stringsArray.reverse().forEach(function(string){
if (rootItem.children.length === 0){
rootItem.addChild(null,function(item){
item.topic = string
})
} else {
insertPosition = rootItem.children[0].before
rootItem.addChild(insertPosition,function(item){
item.topic = string
})
}
})
| Prepend Paragraphs to Outline |
|
| | | |
| 01 | | stringsArray = XXXXX |
| 02 | | stringsArray.reverse().forEach(function(string){ |
| 03 | | if (rootItem.children.length === 0){ |
| 04 | | rootItem.addChild(null,function(item){ |
| 05 | | item.topic = string |
| 06 | | }) |
| 07 | | } else { |
| 08 | | insertPosition = rootItem.children[0].before |
| 09 | | rootItem.addChild(insertPosition,function(item){ |
| 10 | | item.topic = string |
| 11 | | }) |
| 12 | | } |
| 13 | | }) |
And here is the Omni Automation script placed within a function in the JavaScript action template:
(() => {
function prependParagraphsToOutline(stringsArray){
stringsArray.reverse().forEach(function(string){
if (rootItem.children.length === 0){
rootItem.addChild(null,function(item){
item.topic = string
})
} else {
insertPosition = rootItem.children[0].before
rootItem.addChild(insertPosition,function(item){
item.topic = string
})
}
})
};
const stringsArray = editor.getText().split('\n');
app.openURL(
'omnioutliner://localhost/omnijs-run?script=' +
encodeURIComponent(
'(' + prependParagraphsToOutline + ')' +
'(' + JSON.stringify(stringsArray) + ')'
)
);
})();
| Action: Prepend Paragraphs to Outline |
|
| | | |
| 01 | | (() => { |
| 02 | | function prependParagraphsToOutline(stringsArray){ |
| 03 | | stringsArray.reverse().forEach(function(string){ |
| 04 | | if (rootItem.children.length === 0){ |
| 05 | | rootItem.addChild(null,function(item){ |
| 06 | | item.topic = string |
| 07 | | }) |
| 08 | | } else { |
| 09 | | insertPosition = rootItem.children[0].before |
| 10 | | rootItem.addChild(insertPosition,function(item){ |
| 11 | | item.topic = string |
| 12 | | }) |
| 13 | | } |
| 14 | | }) |
| 15 | | }; |
| 16 | | |
| 17 | | const stringsArray = editor.getText().split('\n'); |
| 18 | | |
| 19 | | app.openURL( |
| 20 | | 'omnioutliner://localhost/omnijs-run?script=' + |
| 21 | | encodeURIComponent( |
| 22 | | '(' + prependParagraphsToOutline + ')' + |
| 23 | | '(' + JSON.stringify(stringsArray) + ')' |
| 24 | | ) |
| 25 | | ); |
| 26 | | })(); |
And the script action in use:
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