draft8
February 21, 2018, 3:54am
1
I may just be missing something, but I can’t find a scripting interface to Row Numbering in the omniJS API for OmniOutliner 5.3 test (v189.2 r304855)
In JXA and Applescript, row prefixes and suffixes are accessible through a set of 3 style attributes:
heading-type
heading-prefix
heading-suffix
but I don’t seem to find any matching attributes among the omniJS list of Style.Attributes.
Perhaps not yet implemented ?
draft8
February 21, 2018, 1:01pm
2
Got it – just a documentation gap, I think.
The numbering attributes don’t appear in the documented list of Style.Attributes, but the undocumented styles do show up if (assuming OO test build: 189.2.0.304855 and onwards):
I select an item with bracketed italic numbering like (iii) , and then
run the following code in Script Editor:
(() => {
// OMNIJS CODE -----------------------------------------------------------
// ooJSContext :: () -> String
const ooJSContext = () =>
'OO test build: ' + app.version + '\n\n' +
document.editors[0].selection.items[0]
.style.locallyDefinedAttributes.map(x => x.key)
.join('\n');
// JXA CODE --------------------------------------------------------------
// String -> String
return Application('OmniOutliner')
.evaluateJavascript(
'(' + ooJSContext + ')()'
);
})();
-->
OO test build: 189.2.0.304855
heading-type(com.omnigroup.OmniOutliner)
heading-lowercase(com.omnigroup.OmniOutliner)
heading-prefix(com.omnigroup.OmniOutliner)
heading-suffix(com.omnigroup.OmniOutliner)
draft8
February 21, 2018, 1:15pm
3
Or, to read the style values, as well as their keys, again from Script Editor, (and assuming OO test build: 189.2.0.304855 and onwards) :
(() => {
// OMNIJS CODE -----------------------------------------------------------
// ooJSContext :: () -> String
const ooJSContext = () => {
const style = document.editors[0]
.selection.items[0]
.style;
return 'OO test build: ' + app.version + '\n\n' +
JSON.stringify(
style.locallyDefinedAttributes.reduce((a, x) =>
Object.assign(a, {
[x.key]: style.get(x)
}), {}),
null, 2
);
};
// JXA CODE --------------------------------------------------------------
// String -> String
return Application('OmniOutliner')
.evaluateJavascript(
'(' + ooJSContext + ')()'
);
})();
OO test build: 189.2.0.304855
{
"heading-type(com.omnigroup.OmniOutliner)": "Roman",
"heading-lowercase(com.omnigroup.OmniOutliner)": true,
"heading-prefix(com.omnigroup.OmniOutliner)": "(",
"heading-suffix(com.omnigroup.OmniOutliner)": ")"
}