Comment Toolbar Button

PreviousNext

A toolbar button for adding inline comments.

Preview

Loading preview…
registry/ui/comment-toolbar-button.tsx
'use client';

import * as React from 'react';

import { MessageSquareTextIcon } from 'lucide-react';
import { useEditorRef } from 'platejs/react';

import { commentPlugin } from '@/registry/components/editor/plugins/comment-kit';

import { ToolbarButton } from './toolbar';

export function CommentToolbarButton() {
  const editor = useEditorRef();

  return (
    <ToolbarButton
      onClick={() => {
        editor.getTransforms(commentPlugin).comment.setDraft();
      }}
      data-plate-prevent-overlay
      tooltip="Comment"
    >
      <MessageSquareTextIcon />
    </ToolbarButton>
  );
}

Installation

npx shadcn@latest add @plate/comment-toolbar-button

Usage

import { CommentToolbarButton } from "@/components/ui/comment-toolbar-button"
<CommentToolbarButton />