From 0baf79dda75657472430ad3f85915c16c3570e44 Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Tue, 7 Feb 2023 16:14:14 +0000 Subject: [PATCH] Fix $restoreEditorState (#3842) --- packages/lexical-utils/src/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/lexical-utils/src/index.ts b/packages/lexical-utils/src/index.ts index 797503bdcee..70d9fb45e89 100644 --- a/packages/lexical-utils/src/index.ts +++ b/packages/lexical-utils/src/index.ts @@ -309,9 +309,14 @@ export function $restoreEditorState( editorState: EditorState, ): void { const FULL_RECONCILE = 2; - const nodeMap = new Map(editorState._nodeMap); + const nodeMap = new Map(); const activeEditorState = editor._pendingEditorState; + for (const [key, node] of editorState._nodeMap) { + // @ts-ignore + nodeMap.set(key, node.constructor.clone(node)); + } + if (activeEditorState) { activeEditorState._nodeMap = nodeMap; }