fix: resolve TipTap v3 type errors in RichEditor
- Cast editor.storage to any for tiptap-markdown's getMarkdown (untyped extension storage)
- Replace setContent(value, false) with setContent(value, { emitUpdate: false }) for TipTap v3 API
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -28,7 +28,8 @@ export function RichEditor({ value, onChange, placeholder, className }: Props) {
|
||||
content: value,
|
||||
immediatelyRender: false,
|
||||
onUpdate({ editor: e }) {
|
||||
const md = e.storage.markdown?.getMarkdown?.() ?? e.getText();
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const md = (e.storage as any).markdown?.getMarkdown?.() ?? e.getText();
|
||||
onChange(md);
|
||||
},
|
||||
});
|
||||
@@ -36,9 +37,10 @@ export function RichEditor({ value, onChange, placeholder, className }: Props) {
|
||||
// Sync external value changes (e.g. when a new lesson is loaded).
|
||||
useEffect(() => {
|
||||
if (!editor) return;
|
||||
const current = editor.storage.markdown?.getMarkdown?.() ?? editor.getText();
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const current = (editor.storage as any).markdown?.getMarkdown?.() ?? editor.getText();
|
||||
if (current !== value) {
|
||||
editor.commands.setContent(value, false);
|
||||
editor.commands.setContent(value, { emitUpdate: false });
|
||||
}
|
||||
}, [value, editor]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user