CommentThread
CommentThread:
{}A top-level comment, its flat replies, and the inferred document anchor.
Remarks
Section titled “Remarks”CommentThread is the object you work with after querying or creating
comments. It exposes the top-level comment separately from flat replies so
callers do not need to treat the first item in an array as special.
The mutation methods operate on the underlying document. If you call a
method on a queried or newly created thread, a later
CommentThreadCollection.all call observes the updated state.
Comment thread mutations apply directly, including inside review transactions. They do not create tracked-change revisions. Use document transactions when you need to batch multiple comment operations with other document edits.
Examples
Section titled “Examples”Reply to an open thread and resolve it:
const [thread] = draft.commentThreads().all({ status: 'open' });
if (thread) { thread.reply('Updated the surrounding text.'); thread.resolve();}Edit and then remove a reply:
const [thread] = draft.commentThreads().all();const [reply] = thread?.replies ?? [];
if (reply) { reply.edit('Corrected reply text.'); reply.remove();}Properties
Section titled “Properties”id:
string
Stable identifier for the top-level comment thread.
resolved
Section titled “resolved”resolved:
boolean
Whether the top-level comment thread is resolved.
anchor
Section titled “anchor”anchor:
CommentThreadAnchor
Inferred anchor reconstructed from document content.
comment
Section titled “comment”comment:
CommentThreadComment
Top-level comment for this thread.
replies
Section titled “replies”replies:
CommentThreadReply[]
Flat replies for this thread, ordered deterministically.
Methods
Section titled “Methods”reply()
Section titled “reply()”reply(
body):CommentThreadReply|undefined
Adds a flat reply to this comment thread.
Parameters
Section titled “Parameters”Plain text reply body
Returns
Section titled “Returns”CommentThreadReply | undefined
The created reply, or undefined when no reply can be added
Remarks
Section titled “Remarks”Reply bodies are plain text. The SDK assigns author and timestamp metadata from the current author context and clock.
Replying to a resolved comment thread returns undefined and leaves
the document unchanged.
edit()
Section titled “edit()”edit(
body):void
Replaces the top-level comment body’s plain text.
Parameters
Section titled “Parameters”New plain text body for the top-level comment
Returns
Section titled “Returns”Remarks
Section titled “Remarks”Editing keeps the original creation timestamp metadata. The public API does not expose edit timestamps.
resolve()
Section titled “resolve()”resolve():
void
Marks this comment thread as resolved.
Returns
Section titled “Returns”Remarks
Section titled “Remarks”Resolution is explicit and idempotent. Calling resolve() on an already
resolved thread leaves it resolved.
unresolve()
Section titled “unresolve()”unresolve():
void
Marks this comment thread as open.
Returns
Section titled “Returns”Remarks
Section titled “Remarks”Resolution is explicit and idempotent. Calling unresolve() on an
already open thread leaves it open.
remove()
Section titled “remove()”remove():
void
Removes the whole comment thread.
Returns
Section titled “Returns”Remarks
Section titled “Remarks”Removing a thread removes its top-level comment, all flat replies, and
every text anchor reference for that thread. The removed thread no
longer appears in CommentThreadCollection.all results.