diff --git a/apps/client/src/widgets/type_widgets/text/lexical/index.tsx b/apps/client/src/widgets/type_widgets/text/lexical/index.tsx index db67195faa..80b9e07d1f 100644 --- a/apps/client/src/widgets/type_widgets/text/lexical/index.tsx +++ b/apps/client/src/widgets/type_widgets/text/lexical/index.tsx @@ -55,11 +55,21 @@ function CustomEditorPersistencePlugin({ note, noteContext }: TypeWidgetProps) { noteType: "text", getData() { return { - content: JSON.stringify(editor.toJSON()) + content: JSON.stringify(editor.toJSON().editorState) }; }, onContentChange(newContent) { + if (!newContent) return; + try { + const editorState = editor.parseEditorState(newContent); + editor.setEditorState(editorState); + editor.getEditorState().read(() => { + // Clear history after loading to prevent undoing to empty state + }); + } catch (err) { + console.error("Error parsing Lexical content", err); + } }, });