Loading...
功能特性
- 以文本标记形式添加评论
- 支持重叠评论
- 支持撤销/恢复解决和删除操作
安装
pnpm add @platejs/comment
使用方法
import { commentPlugin } from '@/components/editor/plugins/comment-plugin';
import { discussionPlugin } from '@/components/editor/plugins/discussion-plugin';
const editor = createPlateEditor({
plugins: [
// ...其他插件
discussionPlugin,
commentPlugin,
],
});
评论插件需与讨论插件配合使用以提供完整的讨论系统。讨论插件负责管理讨论界面和用户交互层。示例中提供了两个插件的完整源码。
快捷键
Key | Description |
---|---|
Cmd + Shift + M | 为选中文本添加评论 |
示例
Plate UI
参考上方预览组件。
Plate Plus
Get the code
插件
CommentPlugin
API接口
tf.comment.removeMark
从编辑器中移除评论标记。
tf.comment.setDraft
在当前选区设置草稿评论标记。
tf.comment.unsetMark
从编辑器中移除指定ID的评论节点。
api.comment.has
检查指定ID的评论是否存在。
api.comment.node
获取评论节点entry。
api.comment.nodeId
从leaf节点获取评论ID。
api.comment.nodes
获取所有匹配条件的评论节点entry。
getCommentCount
获取评论节点中的非草稿评论数量。
getCommentKey
根据ID生成评论key。
getCommentKeyId
从评论key中提取评论ID。
getCommentKeys
返回节点中存在的所有评论key数组。
getDraftCommentKey
获取草稿评论使用的key。
isCommentKey
检查给定key是否为评论key。
isCommentNodeById
检查给定节点是否为指定ID的评论。
类型定义
TCommentText
可包含评论的文本节点接口。
On This Page
功能特性安装使用方法快捷键示例Plate UIPlate Plus插件CommentPlugin
API接口tf.comment.removeMark
tf.comment.setDraft
tf.comment.unsetMark
api.comment.has
api.comment.node
api.comment.nodeId
api.comment.nodes
getCommentCount
getCommentKey
getCommentKeyId
getCommentKeys
getDraftCommentKey
isCommentKey
isCommentNodeById
类型定义TCommentText