feat(editor): add floating formatting toolbar

This commit is contained in:
pj committed 2026-06-20 12:46:18 -04:00
1 parent 50bde45d65
commit 6dc1aeb99b
3 files changed
+72 -2

No files matched your search

+8 -2
View File
@@ -1,4 +1,5 @@
import { EditorContent, useEditor } from "@tiptap/react";
import { useEffect } from "react";
import { EditorContent, useEditor, type Editor as TiptapEditor } from "@tiptap/react";
import type { JSONContent } from "@tiptap/core";
import { editorExtensions } from "./extensions";
@@ -6,9 +7,10 @@ interface EditorProps {
chapterId: string;
content: JSONContent;
onChange: (content: JSONContent) => void;
onReady: (editor: TiptapEditor | null) => void;
}
export function Editor({ chapterId, content, onChange }: EditorProps) {
export function Editor({ chapterId, content, onChange, onReady }: EditorProps) {
const editor = useEditor(
{
extensions: editorExtensions,
@@ -20,5 +22,9 @@ export function Editor({ chapterId, content, onChange }: EditorProps) {
[chapterId]
);
useEffect(() => {
onReady(editor);
}, [editor, onReady]);
return <EditorContent editor={editor} className="editor-host" />;
}