mirror of
https://github.com/facebook/lexical.git
synced 2025-08-06 08:30:33 +08:00
Fix undo selection bug (#517)
This commit is contained in:

committed by
acywatson

parent
ed75ebc44b
commit
0cf9ac6b49
@ -31,8 +31,13 @@ function getMergeAction(
|
|||||||
if (prevViewModel === null) {
|
if (prevViewModel === null) {
|
||||||
return NO_MERGE;
|
return NO_MERGE;
|
||||||
}
|
}
|
||||||
|
const selection = nextViewModel._selection;
|
||||||
|
const prevSelection = prevViewModel._selection;
|
||||||
const hasDirtyNodes = nextViewModel.hasDirtyNodes();
|
const hasDirtyNodes = nextViewModel.hasDirtyNodes();
|
||||||
if (!hasDirtyNodes) {
|
if (!hasDirtyNodes) {
|
||||||
|
if (prevSelection === null && selection !== null) {
|
||||||
|
return MERGE;
|
||||||
|
}
|
||||||
return DISCARD;
|
return DISCARD;
|
||||||
}
|
}
|
||||||
const dirtyNodes = nextViewModel.getDirtyNodes();
|
const dirtyNodes = nextViewModel.getDirtyNodes();
|
||||||
@ -59,8 +64,6 @@ function getMergeAction(
|
|||||||
// Only merge if we're adding/removing a single character
|
// Only merge if we're adding/removing a single character
|
||||||
// or if there is not change at all.
|
// or if there is not change at all.
|
||||||
if (textDiff === -1 || textDiff === 1) {
|
if (textDiff === -1 || textDiff === 1) {
|
||||||
const selection = nextViewModel._selection;
|
|
||||||
const prevSelection = prevViewModel._selection;
|
|
||||||
if (selection == null || prevSelection === null) {
|
if (selection == null || prevSelection === null) {
|
||||||
return MERGE;
|
return MERGE;
|
||||||
}
|
}
|
||||||
|
@ -44,5 +44,7 @@
|
|||||||
"42": "Reconciliation: could not find DOM element for node key \"${key}\"",
|
"42": "Reconciliation: could not find DOM element for node key \"${key}\"",
|
||||||
"43": "resolveNonLineBreakOrInertNode: resolved node not a text node",
|
"43": "resolveNonLineBreakOrInertNode: resolved node not a text node",
|
||||||
"44": "Extraneous keys in serialized node data: %s",
|
"44": "Extraneous keys in serialized node data: %s",
|
||||||
"45": "OutlineNode: Node type %s does not implement deserialize()."
|
"45": "OutlineNode: Node type %s does not implement deserialize().",
|
||||||
|
"46": "getAnchorNode: anchorNode not a valid anchor node",
|
||||||
|
"47": "getFocusNode: focusNode not a valid focus node"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user