Javascript: HypertextLinkCollection.remove Method
Description
Removes a hypertext link from a Text Control document.
Syntax
<void> HypertextLinkCollection.remove(<HypertextLink> HypertextLink, <boolean> keepText, [<RequestBooleanCallback> callback], [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| HypertextLink | Specifies the hypertext link to remove. |
| keepText | If this parameter is set to true, the hypertext link is removed without deleting its text. Otherwise, the link's text is also deleted. |
| callback | Optional. Receives whether the remove was succesful. |
| errorCallback | Optional. Is called when the operation failed with an error. |
Examples
The following example demonstrates HypertextLinkCollection.remove in a practical document-editing workflow. It removes a hypertext link from a Text Control document.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
function remove(HypertextLink) {
TXTextControl.textParts.getMainText(function(mainText) {
const hypertextLinks = mainText.hypertextLinks;
hypertextLinks.remove(
HypertextLink,
true,
function(result) {
if (result) {
console.log("remove is available.");
} else {
console.warn("remove is not available in the current document state.");
}
},
onTxError
);
}, onTxError);
}