Outline Object (JavaScript API for OneNote)
Applies to: OneNote Online
Represents a container for Paragraph objects.
Properties
| Property | Type | Description | Feedback |
|---|---|---|---|
| id | string | Gets the ID of the Outline object. Read-only. | Go |
Relationships
| Relationship | Type | Description | Feedback |
|---|---|---|---|
| pageContent | PageContent | Gets the PageContent object that contains the Outline. This object defines the position of the Outline on the page. Read-only. | Go |
| paragraphs | ParagraphCollection | Gets the collection of Paragraph objects in the Outline. Read-only. | Go |
Methods
| Method | Return Type | Description | Feedback |
|---|---|---|---|
| appendHtml(html: string) | void | Adds the specified HTML to the bottom of the Outline. | Go |
| appendImage(base64EncodedImage: string, width: double, height: double) | Image | Adds the specified image to the bottom of the Outline. | Go |
| appendRichText(paragraphText: string) | RichText | Adds the specified text to the bottom of the Outline. | Go |
| appendTable(rowCount: number, columnCount: number, values: string[][]) | Table | Adds a table with the specified number of rows and columns to the bottom of the outline. | Go |
| load(param: object) | void | Fills the proxy object created in JavaScript layer with property and object values specified in the parameter. | Go |
Method Details
appendHtml(html: string)
Adds the specified HTML to the bottom of the Outline.
Syntax
outlineObject.appendHtml(html);
Parameters
| Parameter | Type | Description |
|---|---|---|
| html | string | The HTML string to append. See supported HTML for the OneNote add-ins JavaScript API. |
Returns
void
Examples
OneNote.run(function (context) {
// Gets the active page.
var activePage = context.application.getActivePage();
// Get pageContents of the activePage.
var 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.
return context.sync()
.then(function() {
if (pageContents.items.length != 0 && pageContents.items[0].type == "Outline")
{
// First item is an outline.
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.
return context.sync();
}
});
})
.catch(function(error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});
appendImage(base64EncodedImage: string, width: double, height: double)
Adds the specified image to the bottom of the Outline.
Syntax
outlineObject.appendImage(base64EncodedImage, width, height);
Parameters
| Parameter | Type | Description |
|---|---|---|
| base64EncodedImage | string | HTML string to append. |
| width | double | Optional. Width in the unit of Points. The default value is null and image width will be respected. |
| height | double | Optional. Height in the unit of Points. The default value is null and image height will be respected. |
Returns
appendRichText(paragraphText: string)
Adds the specified text to the bottom of the Outline.
Syntax
outlineObject.appendRichText(paragraphText);
Parameters
| Parameter | Type | Description |
|---|---|---|
| paragraphText | string | HTML string to append. |
Returns
appendTable(rowCount: number, columnCount: number, values: string[][])
Adds a table with the specified number of rows and columns to the bottom of the outline.
Syntax
outlineObject.appendTable(rowCount, columnCount, values);
Parameters
| Parameter | Type | Description |
|---|---|---|
| rowCount | number | Required. The number of rows in the table. |
| columnCount | number | Required. The number of columns in the table. |
| values | string[][] | Optional. Optional 2D array. Cells are filled if the corresponding strings are specified in the array. |
Returns
Examples
OneNote.run(function (context) {
// Gets the active page.
var activePage = context.application.getActivePage();
// Get pageContents of the activePage.
var 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.
return context.sync()
.then(function() {
if (pageContents.items.length != 0 && pageContents.items[0].type == "Outline") {
// First item is an outline.
var 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.
return context.sync();
}
});
})
.catch(function(error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});
load(param: object)
Fills the proxy object created in JavaScript layer with property and object values specified in the parameter.
Syntax
object.load(param);
Parameters
| Parameter | Type | Description |
|---|---|---|
| param | object | Optional. Accepts parameter and relationship names as delimited string or an array. Or, provide loadOption object. |
Returns
void