mirror of
https://github.com/priyanshujain/margin.git
synced 2026-10-03 19:47:03 +00:00
feat(editor): add floating formatting toolbar
This commit is contained in:
1 parent
50bde45d65
commit
6dc1aeb99b
3 files changed
+72
-2
No files matched your search
@@ -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" />;
|
||||
}
|
||||
Reference in new issue
Block a user