API Reference

Thread Comment

Packages@univerjs/thread-comment, @univerjs/docs-thread-comment, @univerjs/sheets-thread-comment, @univerjs-pro/bases-thread-comment, @univerjs-pro/boards-thread-comment, @univerjs-pro/slides-thread-comment, @univerjs-pro/shape-thread-comment

A unified Facade for creating, querying, updating, resolving, and deleting thread comments across Univer products. The existing Sheets comment object and builder APIs remain documented below.

Cross-product API

TypeScript
import '@univerjs/thread-comment/facade'const [comment] = univerAPI.getComments({ resolved: false })if (comment) {  await univerAPI.replyCommentAsync({    unitId: comment.unitId,    subUnitId: comment.subUnitId,    threadId: comment.threadId,    content: 'Verified.',  })}
MethodPurpose
createCommentAsyncCreate a root thread on a serialized product anchor
replyCommentAsyncReply to a loaded root thread
updateCommentAsyncUpdate root or reply content and attachments
deleteCommentAsyncDelete one comment or the complete thread tree
resolveCommentAsyncResolve or reopen a thread
getCommentsFilter locally loaded threads
listCommentsAsyncSynchronize known threads, then apply the same filters

Available anchor kinds are SHEET_CELL, SHEET_DRAWING, DOC_TEXT_RANGE, DOC_DRAWING, SLIDE_ELEMENT, SLIDE_POSITION, BOARD_ELEMENT, BOARD_POSITION, and BASE_RECORD through univerAPI.Enum.ThreadCommentAnchorKind.

Product Facade entries provide convenient methods on ranges, text ranges, elements, slides, boards, and Base records. Use the root methods when an application already owns the serialized anchor.

Legacy Sheets comment objects

@univerjs/sheets-thread-comment

MethodDescription
buildBuild the comment
copyCopy the comment
createCreate a new FTheadCommentItem
deleteAsyncDelete the comment and its replies
getCommentDataGet the comment data
getIsRootWhether the comment is a root comment
getRangeGet the range of the comment
getRepliesGet the replies of the comment
getRichTextGet the rich text of the comment
replyAsyncReply to the comment
resolveAsyncResolve the comment
setContentSet the content of the comment
setDateTimeSet the date time of the comment
setIdSet the id of the comment
setPersonIdSet the person id of the comment
setThreadIdSet the thread id of the comment
updateAsyncUpdate the comment content

APIs

Lifecycle & Creation

build

Build the comment

Signature

TypeScript
build(): IThreadComment

Returns

  • IThreadComment — The comment

Examples

TypeScript
const richText = univerAPI.newRichText().insertText('hello univer');const comment = univerAPI.newTheadComment()  .setContent(richText)  .setPersonId('mock-user-id')  .setDateTime(new Date('2025-02-21 14:22:22'))  .setId('mock-comment-id')  .setThreadId('mock-thread-id')  .build();console.log(comment);
Source: @univerjs/sheets-thread-comment

create

Create a new FTheadCommentItem

Signature

TypeScript
static create(comment?: IThreadComment): FTheadCommentItem

Parameters

  • comment IThreadComment (optional)No description

Returns

  • FTheadCommentItem — A new instance of FTheadCommentItem

Examples

TypeScript
const commentBuilder = univerAPI.newTheadComment();console.log(commentBuilder);
Source: @univerjs/sheets-thread-comment

Getters & Queries

getCommentData

Get the comment data

Signature

TypeScript
getCommentData(): IBaseComment

Returns

  • IBaseComment — The comment data

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();const comments = fWorksheet.getComments();comments.forEach((comment) => {  console.log(comment.getCommentData());});
Source: @univerjs/sheets-thread-comment

getIsRoot

Whether the comment is a root comment

Signature

TypeScript
getIsRoot(): boolean

Returns

  • boolean — Whether the comment is a root comment

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();const comments = fWorksheet.getComments();comments.forEach((comment) => {  console.log(comment.getIsRoot());});
Source: @univerjs/sheets-thread-comment

getRange

Get the range of the comment

Signature

TypeScript
getRange(): FRange | null

Returns

  • FRange | null — The range of the comment

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();const comments = fWorksheet.getComments();comments.forEach((comment) => {  const range = comment.getRange();  if (range) {    console.log(range.getA1Notation());  }});
Source: @univerjs/sheets-thread-comment

getReplies

Get the replies of the comment

Signature

TypeScript
getReplies(): FThreadComment[] | undefined

Returns

  • FThreadComment[] — the replies of the comment

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();const comments = fWorksheet.getComments();comments.forEach((comment) => {  if (comment.getIsRoot()) {    const replies = comment.getReplies();    replies?.forEach((reply) => {      console.log(reply.getCommentData());    });  }});
Source: @univerjs/sheets-thread-comment

getRichText

Get the rich text of the comment

Signature

TypeScript
getRichText(): RichTextValue

Returns

  • RichTextValue — The rich text of the comment

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();const comments = fWorksheet.getComments();comments.forEach((comment) => {  console.log(comment.getRichText());});
Source: @univerjs/sheets-thread-comment

Setters & Modifiers

setContent

Set the content of the comment

Signature

TypeScript
setContent(content: IDocumentBody | RichTextValue): FTheadCommentBuilder

Parameters

  • content IDocumentBody | RichTextValueNo description

Returns

  • FTheadCommentBuilder — The comment builder for chaining

Examples

TypeScript
// Create a new commentconst richText = univerAPI.newRichText().insertText('hello univer');const commentBuilder = univerAPI.newTheadComment()  .setContent(richText);console.log(commentBuilder.content);// Add the comment to the cell A1const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();const cell = fWorksheet.getRange('A1');const result = await cell.addCommentAsync(commentBuilder);console.log(result);
Source: @univerjs/sheets-thread-comment

setDateTime

Set the date time of the comment

Signature

TypeScript
setDateTime(date: Date): FTheadCommentBuilder

Parameters

  • date DateNo description

Returns

  • FTheadCommentBuilder — The comment builder for chaining

Examples

TypeScript
// Create a new commentconst richText = univerAPI.newRichText().insertText('hello univer');const commentBuilder = univerAPI.newTheadComment()  .setContent(richText)  .setDateTime(new Date('2025-02-21 14:22:22'));console.log(commentBuilder.dateTime);// Add the comment to the cell A1const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();const cell = fWorksheet.getRange('A1');const result = await cell.addCommentAsync(commentBuilder);console.log(result);
Source: @univerjs/sheets-thread-comment

setId

Set the id of the comment

Signature

TypeScript
setId(id: string): FTheadCommentBuilder

Parameters

  • id stringNo description

Returns

  • FTheadCommentBuilder — The comment builder for chaining

Examples

TypeScript
// Create a new commentconst richText = univerAPI.newRichText().insertText('hello univer');const commentBuilder = univerAPI.newTheadComment()  .setContent(richText)  .setId('mock-comment-id');console.log(commentBuilder.id);// Add the comment to the cell A1const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();const cell = fWorksheet.getRange('A1');const result = await cell.addCommentAsync(commentBuilder);console.log(result);
Source: @univerjs/sheets-thread-comment

setPersonId

Set the person id of the comment

Signature

TypeScript
setPersonId(userId: string): FTheadCommentBuilder

Parameters

  • userId stringNo description

Returns

  • FTheadCommentBuilder — The comment builder for chaining

Examples

TypeScript
// Create a new commentconst richText = univerAPI.newRichText().insertText('hello univer');const commentBuilder = univerAPI.newTheadComment()  .setContent(richText)  .setPersonId('mock-user-id');console.log(commentBuilder.personId);// Add the comment to the cell A1const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();const cell = fWorksheet.getRange('A1');const result = await cell.addCommentAsync(commentBuilder);console.log(result);
Source: @univerjs/sheets-thread-comment

setThreadId

Set the thread id of the comment

Signature

TypeScript
setThreadId(threadId: string): FTheadCommentBuilder

Parameters

  • threadId stringNo description

Returns

  • FTheadCommentBuilder — The comment builder

Examples

TypeScript
// Create a new commentconst richText = univerAPI.newRichText().insertText('hello univer');const commentBuilder = univerAPI.newTheadComment()  .setContent(richText)  .setThreadId('mock-thread-id');console.log(commentBuilder.threadId);// Add the comment to the cell A1const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();const cell = fWorksheet.getRange('A1');const result = await cell.addCommentAsync(commentBuilder);console.log(result);
Source: @univerjs/sheets-thread-comment

updateAsync

Update the comment content

Signature

TypeScript
async updateAsync(content: IDocumentBody | RichTextValue): Promise<boolean>

Parameters

  • content IDocumentBody | RichTextValueNo description

Returns

  • Promise<boolean> — Whether the comment is updated successfully

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();// Create a new commentconst richText = univerAPI.newRichText().insertText('hello univer');const commentBuilder = univerAPI.newTheadComment()  .setContent(richText)  .setId('mock-comment-id');const cell = fWorksheet.getRange('A1');await cell.addCommentAsync(commentBuilder);// Update the comment after 3 secondssetTimeout(async () => {  const comment = fWorksheet.getCommentById('mock-comment-id');  const newRichText = univerAPI.newRichText().insertText('Hello Univer AI');  const result = await comment.updateAsync(newRichText);  console.log(result);}, 3000);
Source: @univerjs/sheets-thread-comment

Actions & Operations

copy

Copy the comment

Signature

TypeScript
copy(): FTheadCommentBuilder

Returns

  • FTheadCommentBuilder — The comment builder

Examples

TypeScript
const commentBuilder = univerAPI.newTheadComment();const newCommentBuilder = commentBuilder.copy();console.log(newCommentBuilder);
Source: @univerjs/sheets-thread-comment

deleteAsync

Delete the comment and its replies

Signature

TypeScript
deleteAsync(): Promise<boolean>

Returns

  • Promise<boolean> — Whether the comment is deleted successfully

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();const comments = fWorksheet.getComments();// Delete the first commentconst result = await comments[0]?.deleteAsync();console.log(result);
Source: @univerjs/sheets-thread-comment

Miscellaneous

replyAsync

Reply to the comment

Signature

TypeScript
replyAsync(comment: FTheadCommentBuilder): Promise<boolean>

Parameters

  • comment FTheadCommentBuilderNo description

Returns

  • Promise<boolean> — Whether the comment is replied successfully

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();// Create a new commentconst richText = univerAPI.newRichText().insertText('hello univer');const commentBuilder = univerAPI.newTheadComment()  .setContent(richText)  .setId('mock-comment-id');const cell = fWorksheet.getRange('A1');await cell.addCommentAsync(commentBuilder);// Reply to the commentconst replyText = univerAPI.newRichText().insertText('Hello Univer AI');const reply = univerAPI.newTheadComment().setContent(replyText);const comment = fWorksheet.getCommentById('mock-comment-id');const result = await comment.replyAsync(reply);console.log(result);
Source: @univerjs/sheets-thread-comment

resolveAsync

Resolve the comment

Signature

TypeScript
resolveAsync(resolved?: boolean): Promise<boolean>

Parameters

  • resolved boolean (optional)No description

Returns

  • Promise<boolean> — Set the comment to resolved or not operation result

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();// Create a new commentconst richText = univerAPI.newRichText().insertText('hello univer');const commentBuilder = univerAPI.newTheadComment()  .setContent(richText)  .setId('mock-comment-id');const cell = fWorksheet.getRange('A1');await cell.addCommentAsync(commentBuilder);// Resolve the comment after 3 secondssetTimeout(async () => {  const comment = fWorksheet.getCommentById('mock-comment-id');  const result = await comment.resolveAsync(true);  console.log(result);}, 3000);
Source: @univerjs/sheets-thread-comment

How is this guide?

© 2026 DreamNum Co., Ltd.