DS Server

Javascript: DocumentTargetCollection.getCanAdd Method

Method|Introduced in 28.0

Description

Gets a value indicating whether a new document target can be inserted at the current input position.

Syntax

<void> DocumentTargetCollection.getCanAdd(<RequestBooleanCallback> callback, [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
callback

The callback function that receives the requested value.

errorCallback

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

Examples

The following example demonstrates DocumentTargetCollection.getCanAdd in a practical document-editing workflow. It gets a value indicating whether a new document target can be inserted at the current input position.

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

TXTextControl.textParts.getMainText(function(mainText) {
    const documentTargets = mainText.documentTargets;
    documentTargets.getCanAdd(
        function(result) {
            if (result) {
                console.log("get can add is available.");
            } else {
                console.warn("get can add is not available in the current document state.");
            }
        },
        onTxError
    );
}, onTxError);