DS Server

Javascript: CommentCollection.getPreviousItem Method

Method|Introduced in 30.0

Description

Gets the previous comment in the text flow.

Syntax

<void> CommentCollection.getPreviousItem(<RequestCommentCallback> callback, [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
callback

Receives the comment.

errorCallback

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

Examples

The following example demonstrates CommentCollection.getPreviousItem in a practical document-editing workflow. It gets the previous comment in the text flow.

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

TXTextControl.textParts.getMainText(function(mainText) {
    const comments = mainText.comments;
    comments.getPreviousItem(
        function(comment) {
            if (!comment) {
                console.warn("No commented text was returned.");
                return;
            }
            
            console.log("get previous item result:", comment);
        },
        onTxError
    );
}, onTxError);