FTheadCommentBuilder
| packages | @univerjs/sheets-thread-comment |
|---|
A builder for thread comment. use FUniver univerAPI.newTheadComment() to create a new builder.
APIs
build
Build the comment
Signature
build(): IThreadCommentReturns
- (
IThreadComment) — 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)create
Signature
static create(comment?: IThreadComment): FTheadCommentBuildersetContent
Set the content of the comment
Signature
setContent(content: IDocumentBody | RichTextValue): FTheadCommentBuilderParameters
content(IDocumentBody | RichTextValue) — The content of the comment
Returns
- (
FTheadCommentBuilder) — The comment builder for chaining
Examples
// Create a new comment
const richText = univerAPI.newRichText().insertText('hello univer')
const commentBuilder = univerAPI.newTheadComment()
.setContent(richText)
console.log(commentBuilder.content)
// Add the comment to the cell A1
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getActiveSheet()
const cell = fWorksheet.getRange('A1')
const result = await cell.addCommentAsync(commentBuilder)
console.log(result)setDateTime
Set the date time of the comment
Signature
setDateTime(date: Date): FTheadCommentBuilderParameters
date(Date) — The date time of the comment
Returns
- (
FTheadCommentBuilder) — The comment builder for chaining
Examples
// Create a new comment
const 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 A1
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getActiveSheet()
const cell = fWorksheet.getRange('A1')
const result = await cell.addCommentAsync(commentBuilder)
console.log(result)setId
Set the id of the comment
Signature
setId(id: string): FTheadCommentBuilderParameters
id(string) — The id of the comment
Returns
- (
FTheadCommentBuilder) — The comment builder for chaining
Examples
// Create a new comment
const 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 A1
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getActiveSheet()
const cell = fWorksheet.getRange('A1')
const result = await cell.addCommentAsync(commentBuilder)
console.log(result)setPersonId
Set the person id of the comment
Signature
setPersonId(userId: string): FTheadCommentBuilderParameters
userId(string) — The person id of the comment
Returns
- (
FTheadCommentBuilder) — The comment builder for chaining
Examples
// Create a new comment
const 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 A1
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getActiveSheet()
const cell = fWorksheet.getRange('A1')
const result = await cell.addCommentAsync(commentBuilder)
console.log(result)setThreadId
Set the thread id of the comment
Signature
setThreadId(threadId: string): FTheadCommentBuilderParameters
threadId(string) — The thread id of the comment
Returns
- (
FTheadCommentBuilder) — The comment builder
Examples
// Create a new comment
const 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 A1
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getActiveSheet()
const cell = fWorksheet.getRange('A1')
const result = await cell.addCommentAsync(commentBuilder)
console.log(result)