Javascript: CommentCollection.getItem Method
Description
Gets the Comment containing the current text input position from the collection.
Syntax
<void> CommentCollection.getItem(<RequestCommentCallback> callback, [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| callback | Receives the comment at the current text input position. |
| errorCallback | Optional. Is called when the operation failed with an error. |
Examples
The following example demonstrates CommentCollection.getItem in a practical document-editing workflow. It gets the Comment containing the current text input position from the collection.
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);