DS Server

Javascript: HypertextLink.setDescriptiveText Method

Method|Introduced in 34.0

Description

Sets the hyperlink's descriptive text. An empty string or null can be used to delete a previously set text.

Syntax

<void> HypertextLink.setDescriptiveText(<string> value, [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
value

The new property value.

callback

Optional. Is called when the operation completed.

errorCallback

Optional. Is called when the operation failed with an error.

Examples

The following example demonstrates HypertextLink.setDescriptiveText in a practical document-editing workflow. It sets the hyperlink's descriptive text. An empty string or null can be used to delete a previously set text.

function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.textParts.getMainText(function(mainText) {
    const hypertextLinks = mainText.hypertextLinks;
    hypertextLinks.getItem(function(hypertextLink) {
        if (!hypertextLink) {
            console.warn("No hypertext link is available at the current input position.");
            return;
        }
    
        hypertextLink.setDescriptiveText(
            "Quarterly report",
            function() {
                console.log("set descriptive text completed.");
            },
            onTxError
        );
    }, onTxError);
}, onTxError);