Javascript: SectionCollection.add Method
Description
Adds a new section at the current text input position. The new section ends at the end position of the section containing the input position. If a new section is inserted in a paragraph or table, the paragraph or table is split into two paragraphs or tables.
Syntax
<void> SectionCollection.add(<SectionBreakKind> sectionBreakKind, [<RequestBooleanCallback> callback], [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| sectionBreakKind | Specifies the kind of section's break. |
| callback | Optional. Receives whether the section could be added. |
| errorCallback | Optional. Is called when the operation failed with an error. |
Examples
The following example demonstrates SectionCollection.add in a practical document-editing workflow. It adds a new section at the current text input position. The new section ends at the end position of the section containing the input position. If a new section is inserted in a paragraph or table, the paragraph or table is split into two paragraphs or tables.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
TXTextControl.sections.add(
TXTextControl.SectionBreakKind.BeginAtNewLine,
function(result) {
if (result) {
console.log("add is available.");
} else {
console.warn("add is not available in the current document state.");
}
},
onTxError
);