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

Lexical: Changed table esacpe handling

Avoids misuse of selectPrevious/Next as per prior commit which was then
causing problems elsewhere, and is probably best to avoid creation in
those select methods anyway.
This commit is contained in:
Dan Brown
2025-05-26 18:47:51 +01:00
parent a43a1832f5
commit 2e718c12e1
4 changed files with 19 additions and 19 deletions

View File

@ -118,15 +118,20 @@ 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);
export function $selectOrCreateAdjacent(node: LexicalNode, after: boolean): RangeSelection {
const nearestBlock = $getNearestNodeBlockParent(node) || node;
let target = after ? nearestBlock.getNextSibling() : nearestBlock.getPreviousSibling()
if (!target) {
target = $createParagraphNode();
if (after) {
node.insertAfter(target)
} else {
node.insertBefore(target);
}
}
return target.select();
return after ? target.selectStart() : target.selectEnd();
}
export function nodeHasAlignment(node: object): node is NodeHasAlignment {