Skip to content
Document Authoring DA  API Docs v1.14.1
npmGitHub

CommentThread

CommentThread:

A top-level comment, its flat replies, and the inferred document anchor.

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.

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();
}

id: string

Stable identifier for the top-level comment thread.


resolved: boolean

Whether the top-level comment thread is resolved.


anchor: CommentThreadAnchor

Inferred anchor reconstructed from document content.


comment: CommentThreadComment

Top-level comment for this thread.


replies: CommentThreadReply[]

Flat replies for this thread, ordered deterministically.

reply(body): CommentThreadReply | undefined

Adds a flat reply to this comment thread.

string

Plain text reply body

CommentThreadReply | undefined

The created reply, or undefined when no reply can be added

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(body): void

Replaces the top-level comment body’s plain text.

string

New plain text body for the top-level comment

void

Editing keeps the original creation timestamp metadata. The public API does not expose edit timestamps.


resolve(): void

Marks this comment thread as resolved.

void

Resolution is explicit and idempotent. Calling resolve() on an already resolved thread leaves it resolved.


unresolve(): void

Marks this comment thread as open.

void

Resolution is explicit and idempotent. Calling unresolve() on an already open thread leaves it open.


remove(): void

Removes the whole comment thread.

void

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.