mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
fix(app): preserve node selection when reconciling composer markdown (#1626)
This commit is contained in:
1 parent
3df84098e6
commit
d0f56c3afd
1 file changed
+16
@@ -19,11 +19,14 @@ import {$isComposerStandardEmojiNode} from '@app/features/lexical/composer/nodes
|
||||
import {$isSlashSlotNode} from '@app/features/lexical/composer/nodes/SlashSlotNode';
|
||||
import {$createSyntaxMarkerNode, $isSyntaxMarkerNode} from '@app/features/lexical/composer/nodes/SyntaxMarkerNode';
|
||||
import {
|
||||
$createNodeSelection,
|
||||
$createTextNode,
|
||||
$getNodeByKey,
|
||||
$getSelection,
|
||||
$isLineBreakNode,
|
||||
$isNodeSelection,
|
||||
$isRangeSelection,
|
||||
$setSelection,
|
||||
type LexicalEditor,
|
||||
type LexicalNode,
|
||||
ParagraphNode,
|
||||
@@ -205,8 +208,21 @@ function $reconcileLine(
|
||||
const selectionKeys = $isRangeSelection(currentSelection)
|
||||
? {anchor: currentSelection.anchor.key, focus: currentSelection.focus.key}
|
||||
: null;
|
||||
const nodeSelectionKeys = $isNodeSelection(currentSelection)
|
||||
? currentSelection.getNodes().map((node) => node.getKey())
|
||||
: null;
|
||||
const selection = $captureSelectionOffsets();
|
||||
$applyDescriptors(line, desired);
|
||||
if (nodeSelectionKeys != null) {
|
||||
if (nodeSelectionKeys.every((key) => $getNodeByKey(key)?.isAttached() === true)) {
|
||||
const restored = $createNodeSelection();
|
||||
for (const key of nodeSelectionKeys) {
|
||||
restored.add(key);
|
||||
}
|
||||
$setSelection(restored);
|
||||
}
|
||||
return;
|
||||
}
|
||||
const anchorNode = selectionKeys == null ? null : $getNodeByKey(selectionKeys.anchor);
|
||||
const focusNode = selectionKeys == null ? null : $getNodeByKey(selectionKeys.focus);
|
||||
const selectionNodesSurvived =
|
||||
|
||||
Reference in new issue
Block a user