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:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user