Javascript: TableOfContentsCollection.add Method
Description
Adds a new table of contents to the document at the current text input position.
Syntax
<void> TableOfContentsCollection.add([<TableOfContentsCollectionAddParams> parameters], [<RequestTableOfContentsCallback> callback], [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| parameters | Optional. Combines the method parameters. |
| callback | Optional. Receives the added table of contents object or null if something went wrong. |
| errorCallback | Optional. Is called when the operation failed with an error. |
Examples
The following example demonstrates TableOfContentsCollection.add in a practical document-editing workflow. It adds a new table of contents to the document at the current text input position.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
function add(tableOfContentss) {
tableOfContentss.add(
{ title: "Contents", hasLinks: true, hasPageNumbers: true, minimumStructureLevel: 1, maximumStructureLevel: 3 },
function(toc) {
if (!toc) {
console.warn("No table of contents was returned.");
return;
}
console.log("add result:", toc);
},
onTxError
);
}