mirror of
https://github.com/facebook/lexical.git
synced 2025-05-17 23:26:16 +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 {
|
||||
let selection_ = selection;
|
||||
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(
|
||||
$isRangeSelection(selection_),
|
||||
'Unexpected dirty selection to be null',
|
||||
|
@ -159,5 +159,8 @@
|
||||
"157": "Expected tableNode to have a parent TableNode",
|
||||
"158": "Expected gridParent 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