OneNote.Outline class

Represents a container for Paragraph objects.

Extends

Remarks

[ API set: OneNoteApi 1.1 ]

Properties

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

id

Gets the ID of the Outline object. Read-only.

pageContent

Gets the PageContent object that contains the Outline. This object defines the position of the Outline on the page. Read-only.

paragraphs

Gets the collection of Paragraph objects in the Outline. Read-only.

Methods

appendHtml(html)

Adds the specified HTML to the bottom of the Outline.

appendImage(base64EncodedImage, width, height)

Adds the specified image to the bottom of the Outline.

appendRichText(paragraphText)

Adds the specified text to the bottom of the Outline.

appendTable(rowCount, columnCount, values)

Adds a table with the specified number of rows and columns to the bottom of the outline.

isTitle()

Check if the outline is title outline.

load(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original OneNote.Outline object is an API object, the toJSON method returns a plain JavaScript object (typed as OneNote.Interfaces.OutlineData) that contains shallow copies of any loaded child properties from the original object.

track()

Track the object for automatic adjustment based on surrounding changes in the document. This call is a shorthand for context.trackedObjects.add(thisObject). If you are using this object across .sync calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you needed to have added the object to the tracked object collection when the object was first created.

untrack()

Release the memory associated with this object, if it has previously been tracked. This call is shorthand for context.trackedObjects.remove(thisObject). Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call context.sync() before the memory release takes effect.

Property Details

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

context: RequestContext;

Property Value

id

Gets the ID of the Outline object. Read-only.

readonly id: string;

Property Value

string

Remarks

[ API set: OneNoteApi 1.1 ]

pageContent

Gets the PageContent object that contains the Outline. This object defines the position of the Outline on the page. Read-only.

readonly pageContent: OneNote.PageContent;

Property Value

Remarks

[ API set: OneNoteApi 1.1 ]

paragraphs

Gets the collection of Paragraph objects in the Outline. Read-only.

readonly paragraphs: OneNote.ParagraphCollection;

Property Value

Remarks

[ API set: OneNoteApi 1.1 ]

Method Details

appendHtml(html)

Adds the specified HTML to the bottom of the Outline.

appendHtml(html: string): void;

Parameters

html

string

The HTML string to append. See Supported HTML for the OneNote add-ins JavaScript API.

Returns

void

Remarks

[ API set: OneNoteApi 1.1 ]

Examples

await OneNote.run(async (context) => {

    // Gets the active page.
    const activePage = context.application.getActivePage();

    // Get pageContents of the activePage.
    const pageContents = activePage.contents;

    // Queue a command to load the pageContents to access its data.
    context.load(pageContents);

    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();
    if (pageContents.items.length != 0 && pageContents.items[0].type == "Outline")
    {
        // First item is an outline.
        const outline = pageContents.items[0].outline;

        // Queue a command to append a paragraph to the outline.
        outline.appendHtml("<p>new paragraph</p>");

        // Run the queued commands.
        await context.sync();
    }
});

appendImage(base64EncodedImage, width, height)

Adds the specified image to the bottom of the Outline.

appendImage(base64EncodedImage: string, width: number, height: number): OneNote.Image;

Parameters

base64EncodedImage

string

HTML string to append.

width

number

Optional. Width in the unit of Points. The default value is null and image width will be respected.

height

number

Optional. Height in the unit of Points. The default value is null and image height will be respected.

Returns

Remarks

[ API set: OneNoteApi 1.1 ]

appendRichText(paragraphText)

Adds the specified text to the bottom of the Outline.

appendRichText(paragraphText: string): OneNote.RichText;

Parameters

paragraphText

string

HTML string to append.

Returns

Remarks

[ API set: OneNoteApi 1.1 ]

appendTable(rowCount, columnCount, values)

Adds a table with the specified number of rows and columns to the bottom of the outline.

appendTable(rowCount: number, columnCount: number, values?: string[][]): OneNote.Table;

Parameters

rowCount

number

Required. The number of rows in the table.

columnCount

number

Required. The number of columns in the table.

values

string[][]

Optional 2D array. Cells are filled if the corresponding strings are specified in the array.

Returns

Remarks

[ API set: OneNoteApi 1.1 ]

Examples

await OneNote.run(async (context) => {

    // Gets the active page.
    const activePage = context.application.getActivePage();

    // Get pageContents of the activePage.
    const pageContents = activePage.contents;

    // Queue a command to load the pageContents to access its data.
    context.load(pageContents);

    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();
    if (pageContents.items.length != 0 && pageContents.items[0].type == "Outline") {
        // First item is an outline.
        const outline = pageContents.items[0].outline;

        // Queue a command to append a paragraph to the outline.
        outline.appendTable(2, 2, [["1", "2"],["3", "4"]]);

        // Run the queued commands.
        await context.sync();
    }
});

isTitle()

Check if the outline is title outline.

isTitle(): OfficeExtension.ClientResult<boolean>;

Returns

Remarks

[ API set: OneNoteApi 1.1 ]

load(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(options?: OneNote.Interfaces.OutlineLoadOptions): OneNote.Outline;

Parameters

options
OneNote.Interfaces.OutlineLoadOptions

Provides options for which properties of the object to load.

Returns

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames?: string | string[]): OneNote.Outline;

Parameters

propertyNames

string | string[]

A comma-delimited string or an array of strings that specify the properties to load.

Returns

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): OneNote.Outline;

Parameters

propertyNamesAndPaths

{ select?: string; expand?: string; }

propertyNamesAndPaths.select is a comma-delimited string that specifies the properties to load, and propertyNamesAndPaths.expand is a comma-delimited string that specifies the navigation properties to load.

Returns

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original OneNote.Outline object is an API object, the toJSON method returns a plain JavaScript object (typed as OneNote.Interfaces.OutlineData) that contains shallow copies of any loaded child properties from the original object.

toJSON(): OneNote.Interfaces.OutlineData;

Returns

track()

Track the object for automatic adjustment based on surrounding changes in the document. This call is a shorthand for context.trackedObjects.add(thisObject). If you are using this object across .sync calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you needed to have added the object to the tracked object collection when the object was first created.

track(): OneNote.Outline;

Returns

untrack()

Release the memory associated with this object, if it has previously been tracked. This call is shorthand for context.trackedObjects.remove(thisObject). Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call context.sync() before the memory release takes effect.

untrack(): OneNote.Outline;

Returns