-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.tsx
43 lines (39 loc) · 1.01 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'use client';
import { EditorContent, useEditor } from '@tiptap/react';
import Toolbar from './Toolbar';
import { getTipTapExtention } from './extensions';
import { TiptapEditorProps } from './props';
export function TipTapEditor({
value,
onChange,
onBlur,
placeholder,
}: {
value: string;
onChange: (value: string) => void;
onBlur?: () => void;
placeholder?: string;
}) {
const editor = useEditor({
extensions: getTipTapExtention({ placeholder }),
editorProps: TiptapEditorProps,
onUpdate: (e) => {
onChange(e.editor.getHTML());
},
autofocus: 'end',
content: value,
onBlur,
});
return (
<div
onClick={() => {
editor?.chain().focus().run();
}}
className="relative min-h-[500px] w-full max-w-screen-lg border p-12 px-8 sm:mb-[calc(20vh)] sm:rounded-lg sm:border sm:px-12 sm:shadow-lg"
>
{/* {editor && <EditorBubbleMenu editor={editor} />} */}
<Toolbar editor={editor} />
<EditorContent editor={editor} />
</div>
);
}