Skip to content

Commit

Permalink
webapp: fix richtext not loading note until swapping to another mode
Browse files Browse the repository at this point in the history
  • Loading branch information
0xGingi committed Nov 15, 2024
1 parent 526ffc6 commit 8c960c6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/components/RichTextEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
IconH3,
IconClearFormatting,
} from '@tabler/icons-react';
import { useEffect } from 'react';

interface RichTextEditorProps {
content: string;
Expand All @@ -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;
Expand Down

0 comments on commit 8c960c6

Please sign in to comment.