Comments editor commands
The Comments Editor API focuses on the client-side interactions for managing comments within the editor environment, enabling direct manipulation and customization of comment threads.
In contrast, the Comments REST API is designed for server-side operations, allowing for management outside of your 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 from Yjs document. |
updateThread | Updates specific thread properties like 'seen' status. |
selectThread | Focuses the editor on a specified thread. |
unselectThread | Removes focus from a 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 | Removes a specified comment from a thread. |
Interact with threads
setThread( content, data, commentData )
Creates a new thread at your current selection.
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 now id is given, 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.
editor.commands.removeThread({
id: '123',
deleteThread: true,
})
updateThread( id, data )
Updates a thread with the given id.
editor.commands.updateThread({
id: '123',
data: { seen: true },
})
selectThread( id, selectAround )
Selects a thread with the given id. If selectAround
is set to true
, the editor will create a selection range spanning the whole thread.
editor.commands.selectThread({
id: '123',
selectAround: true,
})
unselectThread()
Unselects the currently selected thread.
editor.commands.unselectThread()
resolveThread( id )
Resolves a thread with the given id.
editor.commands.resolveThread({
id: '123',
})
unresolveThread( id )
Unresolves a thread with the given id.
editor.commands.unresolveThread({
id: '123',
})
Handle comments
createComment( threadId, content, data )
Creates a new comment on the thread with the given id.
editor.commands.createComment({
threadId: '123',
content: 'This is a new comment',
data: { authorId: '123' },
})
updateComment( threadId, id, content, data )
Updates a comment with the given id on the thread with the given id.
editor.commands.updateComment({
threadId: '123',
id: '456',
content: 'Now this is the new content',
data: { edited: true },
})
removeComment( threadId, id )
Deletes a comment with the given id on the thread with the given id.
editor.commands.removeComment({
threadId: '123',
id: '456',
})