mirror of
https://github.com/facebook/lexical.git
synced 2025-08-06 08:30:33 +08:00
Fix failing insertNodes when selection is null (#5956)
This commit is contained in:
@ -2681,10 +2681,17 @@ export function $getTextContent(): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function removeTextAndSplitBlock(selection: RangeSelection): number {
|
function removeTextAndSplitBlock(selection: RangeSelection): number {
|
||||||
|
let selection_ = selection;
|
||||||
if (!selection.isCollapsed()) {
|
if (!selection.isCollapsed()) {
|
||||||
selection.removeText();
|
selection_.removeText();
|
||||||
}
|
}
|
||||||
const selection_ = $getSelection();
|
// A new selection can originate as a result of node replacement, in which case is registered via
|
||||||
|
// $setSelection
|
||||||
|
const newSelection = $getSelection();
|
||||||
|
if ($isRangeSelection(newSelection)) {
|
||||||
|
selection_ = newSelection;
|
||||||
|
}
|
||||||
|
|
||||||
invariant(
|
invariant(
|
||||||
$isRangeSelection(selection_),
|
$isRangeSelection(selection_),
|
||||||
'Unexpected dirty selection to be null',
|
'Unexpected dirty selection to be null',
|
||||||
|
@ -159,5 +159,8 @@
|
|||||||
"157": "Expected tableNode to have a parent TableNode",
|
"157": "Expected tableNode to have a parent TableNode",
|
||||||
"158": "Expected gridParent to have a parent",
|
"158": "Expected gridParent to have a parent",
|
||||||
"159": "Expected focusCellParent to have a parent",
|
"159": "Expected focusCellParent to have a parent",
|
||||||
"160": "Expected TableCellNode parent to be a TableRowNode"
|
"160": "Expected TableCellNode parent to be a TableRowNode",
|
||||||
|
"161": "Unexpected dirty selection to be null",
|
||||||
|
"162": "Root element not registered",
|
||||||
|
"163": "node is not a ListNode"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user