Skip to content

Commit

Permalink
fix(core): allow node to be remove before nested root element is unmo…
Browse files Browse the repository at this point in the history
…unted
  • Loading branch information
yf-yang committed Apr 28, 2024
1 parent 5d4cf3b commit 49b419e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/lexical/src/LexicalEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1030,13 +1030,14 @@ export class LexicalEditor {
key: NodeKey,
nextNestedRootElement: null | HTMLElement,
): void {
invariant(
$isNestedRootNode(this._editorState._nodeMap.get(key)),
'Cannot set nested root element for non-nested root node.',
);
const prevNestedRootElement = this._keyToDOMMap.get(key) || null;
if (nextNestedRootElement !== prevNestedRootElement) {
if (nextNestedRootElement !== null) {
invariant(
$isNestedRootNode(this._editorState._nodeMap.get(key)),
'Cannot set nested root element for non-nested root node.',
);

const style = nextNestedRootElement.style;
style.userSelect = 'text';
style.whiteSpace = 'pre-wrap';
Expand Down

0 comments on commit 49b419e

Please sign in to comment.