---
title: "Comments editor commands"
description: "Use editor commands to integrate comments and threads into your Tiptap Editor. Learn more in the docs!"
---

> This page is for Tiptap 2.x. [See the latest version of this page.](https://tiptap.dev/docs/comments/integrate/editor-commands.md)

# Comments editor commands

Use editor commands to integrate comments and threads into your Tiptap Editor. Learn more in the docs!

The Comments Editor API focuses on the client-side interactions for managing comments within the editor, enabling direct manipulation and customization of comment threads.

For server-side operations, use the [Comments REST API](https://tiptap.dev/docs/v2/comments/integrate/rest-api.md) to manage thread and comments outside the editor.

## All editor commands for comments

| Command           | Description                                                            |
| ----------------- | ---------------------------------------------------------------------- |
| `setThread`       | Creates a new thread with optional user and content data               |
| `removeThread`    | Deletes a specified thread, with an option to remove it from the Yjs document |
| `updateThread`    | Updates specific thread properties like 'seen' status                  |
| `selectThread`    | Focuses the editor on a specified thread                               |
| `unselectThread`  | Removes focus from the selected thread                                   |
| `resolveThread`   | Marks a thread as resolved                                             |
| `unresolveThread` | Reverts a thread from resolved status                                  |
| `createComment`   | Adds a new comment to a thread with details like content and user data |
| `updateComment`   | Modifies an existing comment's content and metadata                    |
| `removeComment`   | Deletes a specified comment from a thread                              |

## Interact with threads

### setThread( content, data, commentData )

Creates a new thread at your current selection.

```js
editor.commands.setThread({
  content: 'This is a new thread',
  data: { authorId: '123' },
  commentData: { authorId: '123' },
})
```

### removeThread( id, deleteThread )

Deletes a thread with the given ID. If no ID is provided, the thread at the current selection will be deleted. If `deleteThread` is set to `true`, the thread will also be deleted from the Yjs document.

```js
editor.commands.removeThread({
  id: '101',
  deleteThread: true,
})
```

### updateThread( id, data )

Updates the properties of a thread with the specified ID.

```js
editor.commands.updateThread({
  id: '101',
  data: { seen: true },
})
```

### selectThread( id, selectAround )

Selects a thread with the specified ID. If `selectAround` is set to `true`, the editor will create a selection range spanning the entire thread.

```js
editor.commands.selectThread({
  id: '101',
  selectAround: true,
})
```

### unselectThread()

Deselects the currently selected thread.

```js
editor.commands.unselectThread()
```

### resolveThread( id )

Marks the thread with the specified ID as resolved.

```js
editor.commands.resolveThread({
  id: '101',
})
```

### unresolveThread( id )

Reverts the thread with the specified ID to unresolved status.

```js
editor.commands.unresolveThread({
  id: '101',
})
```

## Handle comments

### createComment( threadId, content, data )

Creates a new comment on the thread with the specified thread ID.

```js
editor.commands.createComment({
  threadId: '101',
  content: 'This is a new comment',
  data: { authorId: '123' },
})
```

### updateComment( threadId, id, content, data )

Updates a comment with the specified ID on the thread identified by a given thread ID.

```js
editor.commands.updateComment({
  threadId: '101',
  id: '456',
  content: 'Now this is the new content',
  data: { edited: true },
})
```

### removeComment( threadId, id )

Deletes a comment with the specified ID from the thread identified by a given thread ID.

```js
editor.commands.removeComment({
  threadId: '101',
  id: '456',
})
```
