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