DS Server

CommentedText Object

Object|Introduced in 30.0

Description

A CommentedText object represents a commented piece of text. A comment can be inserted through the context menu or programmatically.

Syntax

CommentedText

Examples

The following example demonstrates CommentedText in a practical document-editing workflow. A CommentedText object represents a commented piece of text. A comment can be inserted through the context menu or programmatically.

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

TXTextControl.textParts.getMainText(function(mainText) {
    const comments = mainText.comments;
    comments.getItem(function(commentedText) {
        if (!commentedText) {
            console.warn("No commented text is available at the current input position.");
            return;
        }
    
        commentedText.getID(
            function(result) {
                console.log("get id result:", result);
            },
            onTxError
        );
    }, onTxError);
}, onTxError);

Members

Methods

MethodDescription
getActiveGets whether the comment is currently active or not.
getCommentRetrieves the comment text.
getCreationTimeGets the date and time when the comment has been inserted as a Unix timestamp in milliseconds. The time is a Coordinated Universal Time (UTC).
getHighlightColorGets the highlight color for the comment as a CSS color string.
getHighlightModeGets a value indicating whether the comment is highlighted.
getIDGets an identifier for a comment.
getLengthGets the number of characters which belong to the comment.
getNumberGets the comment's number. The first comment in the document has the number 1. The number is defined through the textflow. Commented text with a smaller start position has a smaller comment number.
getRepliedCommentGets the comment for which this comment is a reply. When this comment is not a reply, null is returned.
getRepliesGets all replies of this comment or null if there are no replies.
getStartGets the index (one-based) of the first character which belongs to the comment.
getTextGets the comment's text.
getUserNameGets the name of the user who has commented the document. This parameter can be null or an empty string to indicate that an unknown user has made the comment.
scrollToSets the current input position to the beginning of a comment and scrolls it into the visible part of the document.
setActiveSets whether the comment is currently active or not.
setCommentSets the comment text.
setHighlightColorSets the highlight color for the comment. Accepts CSS color strings.
setHighlightModeSets a value indicating whether the comment is highlighted.
setIDSets an identifier for the comment.