]> BookStack Code Mirror - bookstack/blobdiff - resources/js/wysiwyg/lexical/core/LexicalNode.ts
Lexical: Made a range of selection improvements
[bookstack] / resources / js / wysiwyg / lexical / core / LexicalNode.ts
index 7306e6bca2755a578826f4bf87f37d24935ed465..e54cd1066c2050322750dd8a654aefbd5a1fb554 100644 (file)
@@ -48,6 +48,7 @@ import {
   internalMarkNodeAsDirty,
   removeFromParent,
 } from './LexicalUtils';
+import {$insertAndSelectNewEmptyAdjacentNode} from "../../utils/nodes";
 
 export type NodeMap = Map<NodeKey, LexicalNode>;
 
@@ -1130,7 +1131,7 @@ export class LexicalNode {
     const prevSibling = this.getPreviousSibling();
     const parent = this.getParentOrThrow();
     if (prevSibling === null) {
-      return parent.select(0, 0);
+      return $insertAndSelectNewEmptyAdjacentNode(this, false);
     }
     if ($isElementNode(prevSibling)) {
       return prevSibling.select();
@@ -1152,7 +1153,7 @@ export class LexicalNode {
     const nextSibling = this.getNextSibling();
     const parent = this.getParentOrThrow();
     if (nextSibling === null) {
-      return parent.select();
+      return $insertAndSelectNewEmptyAdjacentNode(this, true);
     }
     if ($isElementNode(nextSibling)) {
       return nextSibling.select(0, 0);