FTheadCommentBuilder
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
build(): IThreadCommentReturns
The comment
Examples
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
readonly content: RichTextValueReturns
The content of the comment
Examples
const commentBuilder = univerAPI.newTheadComment()console.log(commentBuilder.content)Types: RichTextValue
Package: @univerjs/sheets-thread-comment · Type definitions
FTheadCommentBuilder.copy
Copy the comment
copy(): FTheadCommentBuilderReturns
The comment builder
Examples
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
static create(comment?: IThreadComment): FTheadCommentItemParameters
comment— Optional. The comment
Returns
A new instance of FTheadCommentItem
Examples
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
readonly dateTime: stringReturns
The date time of the comment
Examples
const commentBuilder = univerAPI.newTheadComment()console.log(commentBuilder.dateTime)Package: @univerjs/sheets-thread-comment · Type definitions
FTheadCommentBuilder.id
Get the id of the comment
readonly id: stringReturns
The id of the comment
Examples
const commentBuilder = univerAPI.newTheadComment()console.log(commentBuilder.id)Package: @univerjs/sheets-thread-comment · Type definitions
FTheadCommentBuilder.personId
Get the person id of the comment
readonly personId: stringReturns
The person id of the comment
Examples
const commentBuilder = univerAPI.newTheadComment()console.log(commentBuilder.personId)Package: @univerjs/sheets-thread-comment · Type definitions
FTheadCommentBuilder.setContent
Set the content of the comment
setContent(content: IDocumentBody | RichTextValue): FTheadCommentBuilderParameters
content— Required. The content of the comment
Returns
The comment builder for chaining
Examples
// 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
setDateTime(date: Date): FTheadCommentBuilderParameters
date— Required. The date time of the comment
Returns
The comment builder for chaining
Examples
// 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
setId(id: string): FTheadCommentBuilderParameters
id— Required. The id of the comment
Returns
The comment builder for chaining
Examples
// 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
setPersonId(userId: string): FTheadCommentBuilderParameters
userId— Required. The person id of the comment
Returns
The comment builder for chaining
Examples
// 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
setThreadId(threadId: string): FTheadCommentBuilderParameters
threadId— Required. The thread id of the comment
Returns
The comment builder
Examples
// 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
readonly threadId: stringReturns
The thread id of the comment
Examples
const commentBuilder = univerAPI.newTheadComment()console.log(commentBuilder.threadId)Package: @univerjs/sheets-thread-comment · Type definitions
How is this guide?