Skip to content

Utilities

Chad Shurtz edited this page Aug 30, 2016 · 1 revision

A set of utility functions are provided at notebookUtils.ts to allow the application developer to traverse notebooks.

These utilities are a WIP, and more will be added in the future.

Checking if a section exists in a list of notebooks

OneNoteApi.NotebookUtils.sectionExistsInNotebooks(notebooks /* Notebook[] */, sectionId /* string */); // true/false

Checking if a section exists in a given notebook or section group

OneNoteApi.NotebookUtils.sectionExistsInParent(parent /* Notebook | SectionGroup */, sectionId /* string */); // true/false

Determining the path from a list of notebooks to a specified section

// Returns section path (e.g., [Notebook, SectionGroup, ..., Section]
OneNoteApi.NotebookUtils.getPathFromNotebooksToSection(notebooks /* Notebook[] */, function(section) {
    return section.name === "The section I want";
});

Determining the path from the given notebook or section group to a specified section

OneNoteApi.NotebookUtils.getPathFromParentToSection(parent /* Notebook | SectionGroup */, function(section) {
    return section.name === "The section I want"
});

Getting the maximum depth of a list of notebooks

OneNoteApi.NotebookUtils.getDepthOfNotebooks(notebooks /* Notebook[] */); // Number

Getting the maximum depth of a given notebook or section group

OneNoteApi.NotebookUtils.getDepthOfParent(parent /* Notebook | SectionGroup */); // Number