Javascript: InlineStyleCollection.add Method
Description
Adds a new style to the current document.
Syntax
<void> InlineStyleCollection.add(<String> styleName, [<RequestInlineStyleCallback> callback], [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| styleName | Specifies the style's name. |
| callback | Optional. Receives the added style if the style is succesfully added. Otherwise null. |
| errorCallback | Optional. Is called when the operation failed with an error. |
Examples
The following example demonstrates InlineStyleCollection.add in a practical document-editing workflow. It adds a new style to the current document.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
TXTextControl.inlineStyles.add(
"Heading 1",
function(style) {
if (!style) {
console.warn("No inline style was returned.");
return;
}
console.log("add result:", style);
},
onTxError
);