TX Text Control .NET Server

Javascript: TrackedChangeCollection.getItem Method

Method|Introduced in 28.0

Description

Gets the change at the current text input position or the next or the previous change in the textflow. The search begins at the current text input position. If there is more than one change at the current input position the innermost change is returned.

Syntax

<void> TrackedChangeCollection.getItem(<RequestTrackedChangeCallback> callback, [<boolean> next], [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
callback

Receives the tracked change as parameter. The result value is null if a change could not be found.

next

Optional. If this parameter is true, the next change in the textflow is returned. If this parameter is false, the previous change in the textflow is returned. The next or the previous change is returned independent whether there is a change at the current text input position.

errorCallback

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

Examples

The following example demonstrates TrackedChangeCollection.getItem in a practical document-editing workflow. It gets the change at the current text input position or the next or the previous change in the textflow. The search begins at the current text input position. If there is more than one change at the current input position the innermost change is returned.

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

TXTextControl.textParts.getMainText(function(mainText) {
    const trackedChanges = mainText.trackedChanges;
    trackedChanges.getItem(
        function(change) {
            if (!change) {
                console.warn("No tracked change was returned.");
                return;
            }
            
            console.log("get item result:", change);
        },
        true,
        onTxError
    );
}, onTxError);

Further Reading