Editor API
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 broader management tasks like creating, retrieving, updating, and deleting documents or comments programmatically.
Commands
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',
})
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',
})