Comments
Add comments to text as marks.
Installation
pnpm add @udecode/plate-comments
Usage
import { CommentsPlugin } from '@udecode/plate-comments/react';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
commentsPlugin.configure({
render: { aboveNodes: BlockDiscussion as any },
}),
],
});
Keyboard Shortcuts
Key | Description |
---|---|
Cmd + Shift + M | Add a comment on the selected text. |
Examples
Plate UI
Refer to the preview above.
Plate Plus
Plugins
CommentsPlugin
API
editor.tf.comment.removeMark
Removes the comment mark from the editor.
editor.tf.comment.setDraft
Sets a draft comment mark at the current selection.
editor.tf.comment.unsetMark
Unsets comment nodes with the specified ID from the editor.
editor.api.comment.has
Checks if a comment with the given ID exists.
editor.api.comment.node
Gets a comment node entry.
editor.api.comment.nodeId
Gets the ID of a comment from a leaf node.
editor.api.comment.nodes
Gets all comment node entries matching the options.
getCommentCount
Gets the count of non-draft comments in a comment node.
getCommentKey
Generates a comment key based on the provided ID.
getCommentKeyId
Extracts the comment ID from a comment key.
getCommentKeys
Returns an array of comment keys present in the given node.
getDraftCommentKey
Gets the key used for draft comments.
isCommentKey
Checks if a given key is a comment key.
isCommentNodeById
Checks if a given node is a comment with the specified ID.
Types
TCommentText
Interface for text nodes that can contain comments.