1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

Lexical: Made a range of selection improvements

Updated up/down handling to create where a selection candidate does not
exist, to apply to a wider scenario via the selectPrevious/Next methods.

Updated DOM selection change handling to identify single selections
within decorated nodes to select them in full, instead of losing
selection due to partial selection of their contents.

Updated table selection handling so that our colgroups are ignored for
internal selection focus handling.
This commit is contained in:
Dan Brown
2025-05-26 14:48:13 +01:00
parent 1243108e0f
commit 2a32475541
6 changed files with 46 additions and 19 deletions

View File

@ -6,7 +6,7 @@ import {
$isTextNode,
ElementNode,
LexicalEditor,
LexicalNode
LexicalNode, RangeSelection
} from "lexical";
import {LexicalNodeMatcher} from "../nodes";
import {$generateNodesFromDOM} from "@lexical/html";
@ -118,6 +118,17 @@ export function $sortNodes(nodes: LexicalNode[]): LexicalNode[] {
return sorted;
}
export function $insertAndSelectNewEmptyAdjacentNode(node: LexicalNode, after: boolean): RangeSelection {
const target = $createParagraphNode();
if (after) {
node.insertAfter(target)
} else {
node.insertBefore(target);
}
return target.select();
}
export function nodeHasAlignment(node: object): node is NodeHasAlignment {
return '__alignment' in node;
}