omniJS API – row numbering not scriptable?


#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)

57

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 ?


#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):

  1. I select an item with bracketed italic numbering like (iii), and then
  2. 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)

#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)": ")"
}