TX Text Control .NET Server

Javascript: DocumentLinkCollection.getItem Method

Method|Introduced in 28.0

Description

Gets the document link at the current text input position or the document link with the specified id.

Syntax

<void> DocumentLinkCollection.getItem(<RequestDocumentLinkCallback> callback, [<ErrorCallback> errorCallback], [<number> id])

Parameters

ParameterDescription
callback

The callback function that receives the requested value.

errorCallback

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

id

Optional. Specifies the document link's identifier set with the ID property. The method returns null if a link with the specified identifier does not exist.

Examples

The following example demonstrates DocumentLinkCollection.getItem in a practical document-editing workflow. It gets the document link at the current text input position or the document link with the specified id.

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

TXTextControl.textParts.getMainText(function(mainText) {
    const documentLinks = mainText.documentLinks;
    documentLinks.getItem(
        function(result) {
            if (!result) {
                console.warn("No document link was returned.");
                return;
            }
            
            console.log("get item result:", result);
        },
        onTxError,
        25
    );
}, onTxError);