comment-kit
plate/comment-kitFreeComponent
plate publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by plate on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://platejs.org/r/comment-kit.jsonSource
1'use client';23import type { ExtendConfig, Path } from 'platejs';45import {6 type BaseCommentConfig,7 BaseCommentPlugin,8 getDraftCommentKey,9} from '@platejs/comment';10import { toTPlatePlugin } from 'platejs/react';1112import { CommentLeaf } from '@/registry/ui/comment-node';13import { getDiscussionClickTarget } from './discussion-kit';1415type CommentConfig = ExtendConfig<16 BaseCommentConfig,17 {18 activeId: string | null;19 commentingBlock: Path | null;20 hoverId: string | null;21 }22>;2324export const commentPlugin = toTPlatePlugin<CommentConfig>(BaseCommentPlugin, {25 handlers: {26 onClick: ({ api, event, setOption, type }) => {27 const activeTarget = getDiscussionClickTarget({28 selector: `.slate-${type}`,29 target: event.target,30 });3132 if (!activeTarget) {33 setOption('activeId', null);34 return;35 }3637 const commentEntry = api.comment?.node();3839 setOption(40 'activeId',41 commentEntry ? (api.comment?.nodeId(commentEntry[0]) ?? null) : null42 );43 },44 },45 options: {46 activeId: null,47 commentingBlock: null,48 hoverId: null,49 },50})51 .extendTransforms(52 ({53 editor,54 setOption,55 tf: {56 comment: { setDraft },57 },58 }) => ({59 setDraft: () => {60 if (editor.api.isCollapsed()) {61 editor.tf.select(editor.api.block()![1]);62 }6364 setDraft();6566 editor.tf.collapse();67 setOption('activeId', getDraftCommentKey());68 setOption('commentingBlock', editor.selection!.focus.path.slice(0, 1));69 },70 })71 )72 .configure({73 node: { component: CommentLeaf },74 shortcuts: {75 setDraft: { keys: 'mod+shift+m' },76 },77 });7879export const CommentKit = [commentPlugin];
What it pulls in
npm packages
Other registry items
Files it writes
More from plate
All 324 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| ai-kitai-kit | plate | Components | Free | 1 dep | |
| AI Menuai-menu | plate | Components | Free | 5 deps · 2 files | |
| AI Leafai-node | plate | Components | Free | no deps | |
| AI Toolbar Buttonai-toolbar-button | plate | Components | Free | 1 dep | |
| align-base-kitalign-base-kit | plate | Components | Free | 1 dep | |
| align-kitalign-kit | plate | Components | Free | 1 dep | |
| Align Toolbar Buttonalign-toolbar-button | plate | Components | Free | 1 dep | |
| autoformat-classic-kitautoformat-classic-kit | plate | Components | Free | 2 deps |
