DS Server

Javascript: EditableRegionCollection.remove Method

Method|Introduced in 28.0

Description

Removes an editable region from the collection. The region's text is not removed.

Syntax

<void> EditableRegionCollection.remove(<EditableRegion> editableRegion, [<boolean> selectedPart], [<RequestBooleanCallback> callback], [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
editableRegion

Specifies the editable region to remove.

selectedPart

Optional. When this parameter is true, only the selected part of the editable region is removed. If the selection is in the middle od the region, it is split into two parts with the same parameters.

callback

Optional. Receives whether the removal was successful.

errorCallback

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

Examples

The following example demonstrates EditableRegionCollection.remove in a practical document-editing workflow. It removes an editable region from the collection. The region's text is not removed.

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

function remove(editableRegion) {
    TXTextControl.textParts.getMainText(function(mainText) {
        const editableRegions = mainText.editableRegions;
        editableRegions.remove(
            editableRegion,
            true,
            function(result) {
                if (result) {
                    console.log("remove is available.");
                } else {
                    console.warn("remove is not available in the current document state.");
                }
            },
            onTxError
        );
    }, onTxError);
}