Class: FTheadCommentBuilder
A builder for thread comment. use FUniver univerAPI.newTheadComment()
to create a new builder.
Extends
FTheadCommentItem
Methods
build()
build(): IThreadComment
Build the comment
Returns
IThreadComment
The comment
Example
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);
setContent()
setContent(content): FTheadCommentBuilder
Set the content of the comment
Parameters
Parameter | Type | Description |
---|---|---|
content | any | The content of the comment |
Returns
The comment builder for chaining
Example
// 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()
setDateTime(date): FTheadCommentBuilder
Set the date time of the comment
Parameters
Parameter | Type | Description |
---|---|---|
date | Date | The date time of the comment |
Returns
The comment builder for chaining
Example
// 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()
setId(id): FTheadCommentBuilder
Set the id of the comment
Parameters
Parameter | Type | Description |
---|---|---|
id | string | The id of the comment |
Returns
The comment builder for chaining
Example
// 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()
setPersonId(userId): FTheadCommentBuilder
Set the person id of the comment
Parameters
Parameter | Type | Description |
---|---|---|
userId | string | The person id of the comment |
Returns
The comment builder for chaining
Example
// 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()
setThreadId(threadId): FTheadCommentBuilder
Set the thread id of the comment
Parameters
Parameter | Type | Description |
---|---|---|
threadId | string | The thread id of the comment |
Returns
The comment builder
Example
// 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);
create()
static create(comment?): FTheadCommentBuilder
Create a new FTheadCommentItem
Parameters
Parameter | Type | Description |
---|---|---|
comment ? | IThreadComment | The comment |
Returns
A new instance of FTheadCommentItem
Example
const commentBuilder = univerAPI.newTheadComment();
console.log(commentBuilder);
Overrides
FTheadCommentItem.create