various improvements
This commit is contained in:
40
src/components/rich-text-editor.tsx
Normal file
40
src/components/rich-text-editor.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import { useEditor } from '@tiptap/react';
|
||||
import StarterKit from '@tiptap/starter-kit';
|
||||
import { RichTextEditor as MantineRichTextEditor } from '@mantine/tiptap';
|
||||
|
||||
interface RichTextEditorProps {
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
}
|
||||
|
||||
export function RichTextEditor({
|
||||
value,
|
||||
onChange,
|
||||
}: RichTextEditorProps) {
|
||||
const editor = useEditor({
|
||||
extensions: [StarterKit],
|
||||
content: value,
|
||||
onUpdate: ({ editor }) => {
|
||||
onChange(editor.getHTML());
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<MantineRichTextEditor editor={editor}>
|
||||
<MantineRichTextEditor.Toolbar>
|
||||
<MantineRichTextEditor.ControlsGroup>
|
||||
<MantineRichTextEditor.Bold />
|
||||
<MantineRichTextEditor.Italic />
|
||||
</MantineRichTextEditor.ControlsGroup>
|
||||
<MantineRichTextEditor.ControlsGroup>
|
||||
<MantineRichTextEditor.Blockquote />
|
||||
<MantineRichTextEditor.Hr />
|
||||
<MantineRichTextEditor.BulletList />
|
||||
<MantineRichTextEditor.OrderedList />
|
||||
</MantineRichTextEditor.ControlsGroup>
|
||||
</MantineRichTextEditor.Toolbar>
|
||||
|
||||
<MantineRichTextEditor.Content />
|
||||
</MantineRichTextEditor>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user