# FTheadCommentBuilder

> Language fallback: requested `zh-CN`; content is `en-US`.

- Human documentation: [https://docs.univer.ai/zh-CN/reference/facade/thead-comment-builder](https://docs.univer.ai/zh-CN/reference/facade/thead-comment-builder)

- Agent Markdown: [https://docs.univer.ai/zh-CN/reference/facade/thead-comment-builder.md](https://docs.univer.ai/zh-CN/reference/facade/thead-comment-builder.md)

- Requested language: `zh-CN`

- Content language: `en-US`

- Documentation version: `1.0.0-rc.0`

- Source: [facade/thead-comment-builder.mdx](https://github.com/dream-num/documentation/blob/dev/content/reference/facade/thead-comment-builder.mdx)

---

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

## Setup

Register [`@univerjs/sheets-thread-comment`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-thread-comment.md) 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](https://docs.univer.ai/zh-CN/guides/sheets/getting-started/facade.md).

## `@univerjs/sheets-thread-comment`

### `FTheadCommentBuilder.build`

Build the comment

```typescript
build(): IThreadComment
```

**Returns**

The comment

**Examples**

```ts
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`](https://unpkg.com/@univerjs/thread-comment@1.0.0-rc.0/lib/types/types/interfaces/i-thread-comment.d.ts)

**Package:** [`@univerjs/sheets-thread-comment`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-thread-comment.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-thread-comment@1.0.0-rc.0/lib/types/facade/f-thread-comment.d.ts)

### `FTheadCommentBuilder.content`

Get the content of the comment

```typescript
readonly content: RichTextValue
```

**Returns**

The content of the comment

**Examples**

```ts
const commentBuilder = univerAPI.newTheadComment()
console.log(commentBuilder.content)
```

**Types:** [`RichTextValue`](https://unpkg.com/@univerjs/core@1.0.0-rc.0/lib/types/docs/data-model/rich-text-builder.d.ts)

**Package:** [`@univerjs/sheets-thread-comment`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-thread-comment.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-thread-comment@1.0.0-rc.0/lib/types/facade/f-thread-comment.d.ts)

### `FTheadCommentBuilder.copy`

Copy the comment

```typescript
copy(): FTheadCommentBuilder
```

**Returns**

The comment builder

**Examples**

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

**Types:** [`FTheadCommentBuilder`](https://docs.univer.ai/zh-CN/reference/facade/thead-comment-builder.md)

**Package:** [`@univerjs/sheets-thread-comment`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-thread-comment.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-thread-comment@1.0.0-rc.0/lib/types/facade/f-thread-comment.d.ts)

### `FTheadCommentBuilder.create`

Create a new FTheadCommentItem

```typescript
static create(comment?: IThreadComment): FTheadCommentItem
```

**Parameters**

* `comment` — Optional. The comment

**Returns**

A new instance of FTheadCommentItem

**Examples**

```ts
const commentBuilder = univerAPI.newTheadComment()
console.log(commentBuilder)
```

**Types:** [`FTheadCommentItem`](https://unpkg.com/@univerjs/sheets-thread-comment@1.0.0-rc.0/lib/types/facade/f-thread-comment.d.ts) · [`IThreadComment`](https://unpkg.com/@univerjs/thread-comment@1.0.0-rc.0/lib/types/types/interfaces/i-thread-comment.d.ts)

**Package:** [`@univerjs/sheets-thread-comment`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-thread-comment.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-thread-comment@1.0.0-rc.0/lib/types/facade/f-thread-comment.d.ts)

### `FTheadCommentBuilder.dateTime`

Get the date time of the comment

```typescript
readonly dateTime: string
```

**Returns**

The date time of the comment

**Examples**

```ts
const commentBuilder = univerAPI.newTheadComment()
console.log(commentBuilder.dateTime)
```

**Package:** [`@univerjs/sheets-thread-comment`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-thread-comment.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-thread-comment@1.0.0-rc.0/lib/types/facade/f-thread-comment.d.ts)

### `FTheadCommentBuilder.id`

Get the id of the comment

```typescript
readonly id: string
```

**Returns**

The id of the comment

**Examples**

```ts
const commentBuilder = univerAPI.newTheadComment()
console.log(commentBuilder.id)
```

**Package:** [`@univerjs/sheets-thread-comment`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-thread-comment.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-thread-comment@1.0.0-rc.0/lib/types/facade/f-thread-comment.d.ts)

### `FTheadCommentBuilder.personId`

Get the person id of the comment

```typescript
readonly personId: string
```

**Returns**

The person id of the comment

**Examples**

```ts
const commentBuilder = univerAPI.newTheadComment()
console.log(commentBuilder.personId)
```

**Package:** [`@univerjs/sheets-thread-comment`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-thread-comment.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-thread-comment@1.0.0-rc.0/lib/types/facade/f-thread-comment.d.ts)

### `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**

```ts
// 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.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`](https://docs.univer.ai/zh-CN/reference/facade/thead-comment-builder.md) · [`IDocumentBody`](https://docs.univer.ai/zh-CN/reference/types/document-body.md) · [`RichTextValue`](https://unpkg.com/@univerjs/core@1.0.0-rc.0/lib/types/docs/data-model/rich-text-builder.d.ts)

**Package:** [`@univerjs/sheets-thread-comment`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-thread-comment.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-thread-comment@1.0.0-rc.0/lib/types/facade/f-thread-comment.d.ts)

### `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**

```ts
// 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.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`](https://docs.univer.ai/zh-CN/reference/facade/thead-comment-builder.md) · [`Date`](https://unpkg.com/@typescript/typescript-darwin-arm64@7.0.2/lib/lib.es5.d.ts)

**Package:** [`@univerjs/sheets-thread-comment`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-thread-comment.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-thread-comment@1.0.0-rc.0/lib/types/facade/f-thread-comment.d.ts)

### `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**

```ts
// 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.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`](https://docs.univer.ai/zh-CN/reference/facade/thead-comment-builder.md)

**Package:** [`@univerjs/sheets-thread-comment`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-thread-comment.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-thread-comment@1.0.0-rc.0/lib/types/facade/f-thread-comment.d.ts)

### `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**

```ts
// 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.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`](https://docs.univer.ai/zh-CN/reference/facade/thead-comment-builder.md)

**Package:** [`@univerjs/sheets-thread-comment`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-thread-comment.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-thread-comment@1.0.0-rc.0/lib/types/facade/f-thread-comment.d.ts)

### `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**

```ts
// 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.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`](https://docs.univer.ai/zh-CN/reference/facade/thead-comment-builder.md)

**Package:** [`@univerjs/sheets-thread-comment`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-thread-comment.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-thread-comment@1.0.0-rc.0/lib/types/facade/f-thread-comment.d.ts)

### `FTheadCommentBuilder.threadId`

Get the thread id of the comment

```typescript
readonly threadId: string
```

**Returns**

The thread id of the comment

**Examples**

```ts
const commentBuilder = univerAPI.newTheadComment()
console.log(commentBuilder.threadId)
```

**Package:** [`@univerjs/sheets-thread-comment`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-thread-comment.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-thread-comment@1.0.0-rc.0/lib/types/facade/f-thread-comment.d.ts)
