import { FormattingToolbarExtension } from "@blocknote/core/extensions"; // Specifically using type here to avoid pulling in the comments extensions into the main bundle import type { CommentsExtension } from "@blocknote/core/comments"; import { useCallback } from "react"; import { RiChat3Line } from "react-icons/ri"; import { useComponentsContext } from "../../../editor/ComponentsContext.js"; import { useBlockNoteEditor } from "../../../hooks/useBlockNoteEditor.js"; import { useExtension } from "../../../hooks/useExtension.js"; import { useDictionary } from "../../../i18n/dictionary.js"; export const AddCommentButtonInner = () => { const dict = useDictionary(); const Components = useComponentsContext()!; const comments = useExtension("comments") as unknown as ReturnType< ReturnType >; const { store } = useExtension(FormattingToolbarExtension); const onClick = useCallback(() => { comments.startPendingComment(); store.setState(false); }, [comments, store]); return ( } onClick={onClick} /> ); }; export const AddCommentButton = () => { const editor = useBlockNoteEditor(); if (!editor.getExtension("comments")) { return null; } return ; };