diff --git a/src/components/RichTextEditor.tsx b/src/components/RichTextEditor.tsx index 4d267a5..0fac697 100644 --- a/src/components/RichTextEditor.tsx +++ b/src/components/RichTextEditor.tsx @@ -19,6 +19,7 @@ import { IconH3, IconClearFormatting, } from '@tabler/icons-react'; +import { useEffect } from 'react'; interface RichTextEditorProps { content: string; @@ -40,7 +41,18 @@ export function RichTextEditor({ content, onChange }: RichTextEditorProps) { onUpdate: ({ editor }: { editor: Editor }) => { onChange(editor.getHTML()); }, + editorProps: { + attributes: { + class: 'rich-text-editor', + }, + }, }); + + useEffect(() => { + if (editor && content !== editor.getHTML()) { + editor.commands.setContent(content); + } + }, [editor, content]); if (!editor) { return null;