CommentCollection Object
Description
Contains all comments in the main text or another part of a document. All comments are associated with a certain piece of text of the document. The collection consists of CommentedText objects, describing the position and length of the commented text and the comment string itself. A collection object can be obtained with the FormattedText.comments property.
Syntax
CommentCollectionExamples
The following example demonstrates CommentCollection in a practical document-editing workflow. It contains all comments in the main text or another part of a document. All comments are associated with a certain piece of text of the document. The collection consists of CommentedText objects, describing the position and length of the commented text and the comment string itself. A collection object can be obtained with the FormattedText.comments property.
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(comment) {
if (!comment) {
console.warn("No commented text was returned.");
return;
}
console.log("get item result:", comment);
},
onTxError
);
}, onTxError);Members
Methods
| Method | Description |
|---|---|
| add | Creates a comment with the specified comment string. The current text selection defines the commented text. |
| addAtPosition | Creates a comment with the specified comment string, start position and length. |
| addReply | Creates a reply to an existing comment using the specified comment string. |
| elementAt | Returns the element at a specified index in the collection. (Inherited from Collection.) |
| forEach | Executes a callback function for each element. (Inherited from Collection.) |
| getCount | Gets the number of elements contained in the collection. (Inherited from Collection.) |
| getItem | Gets the Comment containing the current text input position from the collection. |
| getNextItem | Gets the next comment in the text flow. |
| getPreviousItem | Gets the previous comment in the text flow. |
| remove | Removes a comment from the collection. |