]> BookStack Code Mirror - bookstack/blobdiff - resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts
Lexical: Changed table esacpe handling
[bookstack] / resources / js / wysiwyg / lexical / table / LexicalTableSelectionHelpers.ts
index e098a21e498a64988efaa5960c1ab8842e4662a3..44801966996cb1e14c4dc81a8183e6213b3c3dd9 100644 (file)
@@ -71,6 +71,7 @@ import {TableDOMTable, TableObserver} from './LexicalTableObserver';
 import {$isTableRowNode} from './LexicalTableRowNode';
 import {$isTableSelection} from './LexicalTableSelection';
 import {$computeTableMap, $getNodeTriplet} from './LexicalTableUtils';
+import {$selectOrCreateAdjacent} from "../../utils/nodes";
 
 const LEXICAL_ELEMENT_KEY = '__lexicalTableSelection';
 
@@ -917,6 +918,11 @@ export function getTable(tableElement: HTMLElement): TableDOMTable {
   while (currentNode != null) {
     const nodeMame = currentNode.nodeName;
 
+    if (nodeMame === 'COLGROUP') {
+      currentNode = currentNode.nextSibling;
+      continue;
+    }
+
     if (nodeMame === 'TD' || nodeMame === 'TH') {
       const elem = currentNode as HTMLElement;
       const cell = {
@@ -1108,7 +1114,7 @@ const selectTableNodeInDirection = (
           false,
         );
       } else {
-        tableNode.selectPrevious();
+        $selectOrCreateAdjacent(tableNode, false);
       }
 
       return true;
@@ -1120,7 +1126,7 @@ const selectTableNodeInDirection = (
           true,
         );
       } else {
-        tableNode.selectNext();
+        $selectOrCreateAdjacent(tableNode, true);
       }
 
       return true;