API 参考

FTheadCommentBuilder

本 API 页面目前提供英文正文。代码签名与标识符不随界面语言变化。

A builder for thread comment. use FUniver univerAPI.newTheadComment() to create a new builder.

Setup

Register @univerjs/sheets-thread-comment or a preset that includes it. In plugin mode, import @univerjs/sheets-thread-comment/facade. Additional methods below require their listed plugin packages. See Facade setup.

@univerjs/sheets-thread-comment

FTheadCommentBuilder.build

Build the comment

TypeScript
build(): IThreadComment

Returns

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)

Types: IThreadComment

Package: @univerjs/sheets-thread-comment · Type definitions

FTheadCommentBuilder.content

Get the content of the comment

TypeScript
readonly content: RichTextValue

Returns

The content of the comment

Examples

TypeScript
const commentBuilder = univerAPI.newTheadComment()console.log(commentBuilder.content)

Types: RichTextValue

Package: @univerjs/sheets-thread-comment · Type definitions

FTheadCommentBuilder.copy

Copy the comment

TypeScript
copy(): FTheadCommentBuilder

Returns

The comment builder

Examples

TypeScript
const commentBuilder = univerAPI.newTheadComment()const newCommentBuilder = commentBuilder.copy()console.log(newCommentBuilder)

Types: FTheadCommentBuilder

Package: @univerjs/sheets-thread-comment · Type definitions

FTheadCommentBuilder.create

Create a new FTheadCommentItem

TypeScript
static create(comment?: IThreadComment): FTheadCommentItem

Parameters

  • comment — Optional. The comment

Returns

A new instance of FTheadCommentItem

Examples

TypeScript
const commentBuilder = univerAPI.newTheadComment()console.log(commentBuilder)

Types: FTheadCommentItem · IThreadComment

Package: @univerjs/sheets-thread-comment · Type definitions

FTheadCommentBuilder.dateTime

Get the date time of the comment

TypeScript
readonly dateTime: string

Returns

The date time of the comment

Examples

TypeScript
const commentBuilder = univerAPI.newTheadComment()console.log(commentBuilder.dateTime)

Package: @univerjs/sheets-thread-comment · Type definitions

FTheadCommentBuilder.id

Get the id of the comment

TypeScript
readonly id: string

Returns

The id of the comment

Examples

TypeScript
const commentBuilder = univerAPI.newTheadComment()console.log(commentBuilder.id)

Package: @univerjs/sheets-thread-comment · Type definitions

FTheadCommentBuilder.personId

Get the person id of the comment

TypeScript
readonly personId: string

Returns

The person id of the comment

Examples

TypeScript
const commentBuilder = univerAPI.newTheadComment()console.log(commentBuilder.personId)

Package: @univerjs/sheets-thread-comment · Type definitions

FTheadCommentBuilder.setContent

Set the content of the comment

TypeScript
setContent(content: IDocumentBody | RichTextValue): FTheadCommentBuilder

Parameters

  • content — Required. The content of the comment

Returns

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.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')const cell = fWorksheet.getRange('A1')const result = await cell.addCommentAsync(commentBuilder)console.log(result)

Types: FTheadCommentBuilder · IDocumentBody · RichTextValue

Package: @univerjs/sheets-thread-comment · Type definitions

FTheadCommentBuilder.setDateTime

Set the date time of the comment

TypeScript
setDateTime(date: Date): FTheadCommentBuilder

Parameters

  • date — Required. The date time of the comment

Returns

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.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')const cell = fWorksheet.getRange('A1')const result = await cell.addCommentAsync(commentBuilder)console.log(result)

Types: FTheadCommentBuilder · Date

Package: @univerjs/sheets-thread-comment · Type definitions

FTheadCommentBuilder.setId

Set the id of the comment

TypeScript
setId(id: string): FTheadCommentBuilder

Parameters

  • id — Required. The id of the comment

Returns

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.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')const cell = fWorksheet.getRange('A1')const result = await cell.addCommentAsync(commentBuilder)console.log(result)

Types: FTheadCommentBuilder

Package: @univerjs/sheets-thread-comment · Type definitions

FTheadCommentBuilder.setPersonId

Set the person id of the comment

TypeScript
setPersonId(userId: string): FTheadCommentBuilder

Parameters

  • userId — Required. The person id of the comment

Returns

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.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')const cell = fWorksheet.getRange('A1')const result = await cell.addCommentAsync(commentBuilder)console.log(result)

Types: FTheadCommentBuilder

Package: @univerjs/sheets-thread-comment · Type definitions

FTheadCommentBuilder.setThreadId

Set the thread id of the comment

TypeScript
setThreadId(threadId: string): FTheadCommentBuilder

Parameters

  • threadId — Required. The thread id of the comment

Returns

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.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')const cell = fWorksheet.getRange('A1')const result = await cell.addCommentAsync(commentBuilder)console.log(result)

Types: FTheadCommentBuilder

Package: @univerjs/sheets-thread-comment · Type definitions

FTheadCommentBuilder.threadId

Get the thread id of the comment

TypeScript
readonly threadId: string

Returns

The thread id of the comment

Examples

TypeScript
const commentBuilder = univerAPI.newTheadComment()console.log(commentBuilder.threadId)

Package: @univerjs/sheets-thread-comment · Type definitions

你觉得这篇文档如何?

© 2026 DreamNum Co., Ltd.