# CommentedText Object

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

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Object
- **Introduced:** 30.0
- **Path:** DS Server > Reference > JavaScript API > CommentedText Object
- **1243 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/llms-full.txt

---

### Description

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

### Syntax

```javascript
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.

```javascript
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);
```

---

## In This Section

- [Javascript: CommentedText.getActive Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/getactive-method/llms-full.txt): Gets whether the comment is currently active or not.
- [Javascript: CommentedText.getComment Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/getcomment-method/llms-full.txt): Retrieves the comment text.
- [Javascript: CommentedText.getCreationTime Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/getcreationtime-method/llms-full.txt): Gets the date and time when the comment has been inserted as a Unix timestamp in milliseconds. The time is a Coordinated Universal Time (UTC).
- [Javascript: CommentedText.getHighlightColor Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/gethighlightcolor-method/llms-full.txt): Gets the highlight color for the comment as a CSS color string.
- [Javascript: CommentedText.getHighlightMode Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/gethighlightmode-method/llms-full.txt): Gets a value indicating whether the comment is highlighted.
- [Javascript: CommentedText.getID Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/getid-method/llms-full.txt): Gets an identifier for a comment.
- [Javascript: CommentedText.getLength Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/getlength-method/llms-full.txt): Gets the number of characters which belong to the comment.
- [Javascript: CommentedText.getNumber Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/getnumber-method/llms-full.txt): Gets 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.
- [Javascript: CommentedText.getRepliedComment Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/getrepliedcomment-method/llms-full.txt): Gets the comment for which this comment is a reply. When this comment is not a reply, null is returned.
- [Javascript: CommentedText.getReplies Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/getreplies-method/llms-full.txt): Gets all replies of this comment or null if there are no replies.
- [Javascript: CommentedText.getStart Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/getstart-method/llms-full.txt): Gets the index (one-based) of the first character which belongs to the comment.
- [Javascript: CommentedText.getText Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/gettext-method/llms-full.txt): Gets the comment's text.
- [Javascript: CommentedText.getUserName Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/getusername-method/llms-full.txt): Gets 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.
- [Javascript: CommentedText.scrollTo Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/scrollto-method/llms-full.txt): Sets the current input position to the beginning of a comment and scrolls it into the visible part of the document.
- [Javascript: CommentedText.setActive Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/setactive-method/llms-full.txt): Sets whether the comment is currently active or not.
- [Javascript: CommentedText.setComment Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/setcomment-method/llms-full.txt): Sets the comment text.
- [Javascript: CommentedText.setHighlightColor Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/sethighlightcolor-method/llms-full.txt): Sets the highlight color for the comment. Accepts CSS color strings.
- [Javascript: CommentedText.setHighlightMode Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/sethighlightmode-method/llms-full.txt): Sets a value indicating whether the comment is highlighted.
- [Javascript: CommentedText.setID Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/setid-method/llms-full.txt): Sets an identifier for the comment.

---

## Nearby

- **Previous:** [Javascript: CommentCollection.remove Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentcollection/remove-method/llms-full.txt)
- **Next:** [Javascript: CommentedText.getActive Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/getactive-method/llms-full.txt)
