DS Server

Javascript: SubTextPartCollection.clear Method

Method|Introduced in 28.0

Description

Removes all subtextparts from a Text Control document.

Syntax

<void> SubTextPartCollection.clear([<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
callback

Optional. Is called when the operation completed.

errorCallback

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

Examples

The following example demonstrates SubTextPartCollection.clear in a practical document-editing workflow. It removes all subtextparts from a Text Control document.

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

TXTextControl.textParts.getMainText(function(mainText) {
    const subTextParts = mainText.subTextParts;
    subTextParts.clear(
        function() {
            console.log("clear completed.");
        },
        onTxError
    );
}, onTxError);