@examind/block-editor 0.1.33 → 0.1.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -950,27 +950,65 @@ function AlignCellsAction() {
950
950
  return /* @__PURE__ */ jsx15(Fragment2, {});
951
951
  }
952
952
 
953
+ // src/utils/$selectAdjacentCell.ts
954
+ import {
955
+ $isTableNode as $isTableNode2,
956
+ $isTableRowNode
957
+ } from "@lexical/table";
958
+ import { $findMatchingParent } from "@lexical/utils";
959
+ import { $isElementNode } from "lexical";
960
+ function $selectAdjacentCell(tableCellNode, direction) {
961
+ const siblingMethod = direction === "next" ? "getNextSibling" : "getPreviousSibling";
962
+ const childMethod = direction === "next" ? "getFirstChild" : "getLastChild";
963
+ const sibling = tableCellNode[siblingMethod]();
964
+ if ($isElementNode(sibling)) {
965
+ return sibling.selectEnd();
966
+ }
967
+ const parentRow = $findMatchingParent(
968
+ tableCellNode,
969
+ $isTableRowNode
970
+ );
971
+ if (!parentRow) {
972
+ throw Error("selectAdjacentCell: Cell not in table row");
973
+ }
974
+ for (let nextRow = parentRow[siblingMethod](); $isTableRowNode(nextRow); nextRow = nextRow[siblingMethod]()) {
975
+ const child = nextRow[childMethod]();
976
+ if ($isElementNode(child)) {
977
+ return child.selectEnd();
978
+ }
979
+ }
980
+ const parentTable = $findMatchingParent(parentRow, $isTableNode2);
981
+ if (!parentTable) {
982
+ throw Error("selectAdjacentCell: Row not in table");
983
+ }
984
+ return direction === "next" ? parentTable.selectNext() : parentTable.selectPrevious();
985
+ }
986
+
953
987
  // src/plugins/SmartTablePlugin/SmartTablePlugin.tsx
954
988
  import { useLexicalComposerContext as useLexicalComposerContext15 } from "@lexical/react/LexicalComposerContext";
955
989
  import {
990
+ $findCellNode,
956
991
  $isTableCellNode as $isTableCellNode3,
957
992
  $isTableSelection as $isTableSelection3,
958
- TableNode as TableNode2
993
+ TableNode as TableNode3
959
994
  } from "@lexical/table";
960
995
  import { mergeRegister as mergeRegister2 } from "@lexical/utils";
961
996
  import {
962
997
  $createParagraphNode as $createParagraphNode3,
963
998
  $getNodeByKey as $getNodeByKey13,
964
999
  $getSelection as $getSelection3,
1000
+ $isRangeSelection,
1001
+ COMMAND_PRIORITY_CRITICAL,
965
1002
  COMMAND_PRIORITY_EDITOR as COMMAND_PRIORITY_EDITOR2,
966
1003
  createCommand as createCommand3,
1004
+ KEY_TAB_COMMAND,
967
1005
  SELECTION_CHANGE_COMMAND
968
1006
  } from "lexical";
969
1007
  import { useEffect as useEffect22, useRef as useRef13, useState as useState3 } from "react";
970
1008
 
971
1009
  // src/plugins/SmartTablePlugin/AddNewColumnAction.tsx
972
1010
  import { useLexicalComposerContext as useLexicalComposerContext6 } from "@lexical/react/LexicalComposerContext";
973
- import { $isTableNode as $isTableNode2 } from "@lexical/table";
1011
+ import { $isTableNode as $isTableNode3 } from "@lexical/table";
974
1012
  import { $getNodeByKey as $getNodeByKey4 } from "lexical";
975
1013
  import { useEffect as useEffect11 } from "react";
976
1014
 
@@ -1269,7 +1307,7 @@ function AddNewColumnAction() {
1269
1307
  if (nodeKey) {
1270
1308
  editor.update(() => {
1271
1309
  const targetNode = $getNodeByKey4(nodeKey);
1272
- if ($isTableNode2(targetNode)) {
1310
+ if ($isTableNode3(targetNode)) {
1273
1311
  let columnIndex = -2;
1274
1312
  if (addDirection === "before") {
1275
1313
  columnIndex = currentColumnIndex - 1;
@@ -1305,7 +1343,7 @@ function AddNewColumnAction() {
1305
1343
  // src/plugins/SmartTablePlugin/AddNewRowAction.tsx
1306
1344
  import { useLexicalComposerContext as useLexicalComposerContext7 } from "@lexical/react/LexicalComposerContext";
1307
1345
  import {
1308
- $isTableNode as $isTableNode3
1346
+ $isTableNode as $isTableNode4
1309
1347
  } from "@lexical/table";
1310
1348
  import { $getNodeByKey as $getNodeByKey5 } from "lexical";
1311
1349
  import { useEffect as useEffect12 } from "react";
@@ -1318,32 +1356,46 @@ function AddNewRowAction() {
1318
1356
  detail: { nodeKey, currentRowIndex, addDirection }
1319
1357
  } = e;
1320
1358
  if (nodeKey) {
1321
- editor.update(() => {
1322
- const targetNode = $getNodeByKey5(nodeKey);
1323
- if ($isTableNode3(targetNode)) {
1324
- let rowIndex = -2;
1325
- if (addDirection === "before") {
1326
- rowIndex = currentRowIndex - 1;
1327
- } else if (addDirection === "after") {
1328
- rowIndex = currentRowIndex;
1329
- }
1330
- const newTableNode = $addNewRowToTable(
1331
- targetNode,
1332
- rowIndex
1333
- );
1334
- newTableNode.setRowStriping(targetNode.getRowStriping());
1335
- targetNode.replace(newTableNode);
1336
- const tableRowNodes = newTableNode.getChildren();
1337
- if (tableRowNodes.length > currentRowIndex) {
1338
- const tableCellNodes = tableRowNodes[currentRowIndex].getChildren();
1339
- if (tableCellNodes.length > 0) {
1340
- tableCellNodes[0].selectStart();
1359
+ let newTableNode = void 0;
1360
+ editor.update(
1361
+ () => {
1362
+ const targetNode = $getNodeByKey5(nodeKey);
1363
+ if ($isTableNode4(targetNode)) {
1364
+ let rowIndex = -2;
1365
+ if (addDirection === "before") {
1366
+ rowIndex = currentRowIndex - 1;
1367
+ } else if (addDirection === "after") {
1368
+ rowIndex = currentRowIndex;
1341
1369
  }
1342
- } else {
1343
- newTableNode.selectStart();
1370
+ newTableNode = $addNewRowToTable(targetNode, rowIndex);
1371
+ newTableNode.setRowStriping(targetNode.getRowStriping());
1372
+ targetNode.replace(newTableNode);
1373
+ }
1374
+ },
1375
+ {
1376
+ onUpdate: () => {
1377
+ editor.update(() => {
1378
+ if (newTableNode) {
1379
+ const tableRowNodes = newTableNode.getChildren();
1380
+ if (tableRowNodes.length > currentRowIndex) {
1381
+ let rowIndex = -1;
1382
+ if (addDirection === "before") {
1383
+ rowIndex = currentRowIndex;
1384
+ } else if (addDirection === "after") {
1385
+ rowIndex = currentRowIndex + 1;
1386
+ }
1387
+ const tableCellNodes = tableRowNodes[rowIndex].getChildren();
1388
+ if (tableCellNodes.length > 0) {
1389
+ tableCellNodes[0].selectStart();
1390
+ }
1391
+ } else {
1392
+ newTableNode.selectStart();
1393
+ }
1394
+ }
1395
+ });
1344
1396
  }
1345
1397
  }
1346
- });
1398
+ );
1347
1399
  }
1348
1400
  };
1349
1401
  useEffect12(() => {
@@ -1362,12 +1414,12 @@ function AddNewRowAction() {
1362
1414
  }
1363
1415
 
1364
1416
  // src/utils/$selectLastDescendant.ts
1365
- import { $isElementNode, $isTextNode } from "lexical";
1417
+ import { $isElementNode as $isElementNode2, $isTextNode } from "lexical";
1366
1418
  function $selectLastDescendant(node) {
1367
1419
  const lastDescendant = node.getLastDescendant();
1368
1420
  if ($isTextNode(lastDescendant)) {
1369
1421
  lastDescendant.select();
1370
- } else if ($isElementNode(lastDescendant)) {
1422
+ } else if ($isElementNode2(lastDescendant)) {
1371
1423
  lastDescendant.selectEnd();
1372
1424
  } else if (lastDescendant !== null) {
1373
1425
  lastDescendant.selectNext();
@@ -1378,7 +1430,7 @@ function $selectLastDescendant(node) {
1378
1430
  import { useLexicalComposerContext as useLexicalComposerContext8 } from "@lexical/react/LexicalComposerContext";
1379
1431
  import {
1380
1432
  $isTableCellNode as $isTableCellNode2,
1381
- $isTableNode as $isTableNode4,
1433
+ $isTableNode as $isTableNode5,
1382
1434
  $isTableSelection as $isTableSelection2,
1383
1435
  $mergeCells
1384
1436
  } from "@lexical/table";
@@ -1395,7 +1447,7 @@ function MergeCellsAction() {
1395
1447
  if (nodeKey) {
1396
1448
  editor.update(() => {
1397
1449
  const targetNode = $getNodeByKey6(nodeKey);
1398
- if ($isTableNode4(targetNode)) {
1450
+ if ($isTableNode5(targetNode)) {
1399
1451
  const selection = $getSelection2();
1400
1452
  if ($isTableSelection2(selection)) {
1401
1453
  const nodes = selection.getNodes();
@@ -1428,7 +1480,7 @@ function MergeCellsAction() {
1428
1480
 
1429
1481
  // src/plugins/SmartTablePlugin/MoveColumnAction.tsx
1430
1482
  import { useLexicalComposerContext as useLexicalComposerContext9 } from "@lexical/react/LexicalComposerContext";
1431
- import { $isTableNode as $isTableNode5 } from "@lexical/table";
1483
+ import { $isTableNode as $isTableNode6 } from "@lexical/table";
1432
1484
  import { $getNodeByKey as $getNodeByKey7 } from "lexical";
1433
1485
  import { useEffect as useEffect14 } from "react";
1434
1486
  import { Fragment as Fragment6, jsx as jsx19 } from "react/jsx-runtime";
@@ -1442,7 +1494,7 @@ function MoveColumnAction() {
1442
1494
  if (nodeKey && currentColumnIndex !== newColumnIndex) {
1443
1495
  editor.update(() => {
1444
1496
  const targetNode = $getNodeByKey7(nodeKey);
1445
- if ($isTableNode5(targetNode)) {
1497
+ if ($isTableNode6(targetNode)) {
1446
1498
  const newTableNode = $moveColumnInTable(
1447
1499
  targetNode,
1448
1500
  currentColumnIndex,
@@ -1472,7 +1524,7 @@ function MoveColumnAction() {
1472
1524
 
1473
1525
  // src/plugins/SmartTablePlugin/MoveRowAction.tsx
1474
1526
  import { useLexicalComposerContext as useLexicalComposerContext10 } from "@lexical/react/LexicalComposerContext";
1475
- import { $isTableNode as $isTableNode6 } from "@lexical/table";
1527
+ import { $isTableNode as $isTableNode7 } from "@lexical/table";
1476
1528
  import { $getNodeByKey as $getNodeByKey8 } from "lexical";
1477
1529
  import { useEffect as useEffect15 } from "react";
1478
1530
  import { Fragment as Fragment7, jsx as jsx20 } from "react/jsx-runtime";
@@ -1486,7 +1538,7 @@ function MoveRowAction() {
1486
1538
  if (nodeKey && currentRowIndex !== newRowIndex) {
1487
1539
  editor.update(() => {
1488
1540
  const targetNode = $getNodeByKey8(nodeKey);
1489
- if ($isTableNode6(targetNode)) {
1541
+ if ($isTableNode7(targetNode)) {
1490
1542
  const newTableNode = $moveRowInTable(
1491
1543
  targetNode,
1492
1544
  currentRowIndex,
@@ -1524,7 +1576,7 @@ function useAlert() {
1524
1576
 
1525
1577
  // src/plugins/SmartTablePlugin/RemoveColumnAction.tsx
1526
1578
  import { useLexicalComposerContext as useLexicalComposerContext11 } from "@lexical/react/LexicalComposerContext";
1527
- import { $isTableNode as $isTableNode7 } from "@lexical/table";
1579
+ import { $isTableNode as $isTableNode8 } from "@lexical/table";
1528
1580
  import { $getNodeByKey as $getNodeByKey9 } from "lexical";
1529
1581
  import { useEffect as useEffect17 } from "react";
1530
1582
  import { Fragment as Fragment8, jsx as jsx21 } from "react/jsx-runtime";
@@ -1539,7 +1591,7 @@ function RemoveColumnAction() {
1539
1591
  if (nodeKey) {
1540
1592
  editor.update(() => {
1541
1593
  const targetNode = $getNodeByKey9(nodeKey);
1542
- if ($isTableNode7(targetNode)) {
1594
+ if ($isTableNode8(targetNode)) {
1543
1595
  try {
1544
1596
  const newTableNode = $removeColumnFromTable(
1545
1597
  targetNode,
@@ -1576,7 +1628,7 @@ function RemoveColumnAction() {
1576
1628
 
1577
1629
  // src/plugins/SmartTablePlugin/RemoveRowAction.tsx
1578
1630
  import { useLexicalComposerContext as useLexicalComposerContext12 } from "@lexical/react/LexicalComposerContext";
1579
- import { $isTableNode as $isTableNode8 } from "@lexical/table";
1631
+ import { $isTableNode as $isTableNode9 } from "@lexical/table";
1580
1632
  import { $getNodeByKey as $getNodeByKey10 } from "lexical";
1581
1633
  import { useEffect as useEffect18 } from "react";
1582
1634
  import { Fragment as Fragment9, jsx as jsx22 } from "react/jsx-runtime";
@@ -1591,7 +1643,7 @@ function RemoveRowAction() {
1591
1643
  if (nodeKey) {
1592
1644
  editor.update(() => {
1593
1645
  const targetNode = $getNodeByKey10(nodeKey);
1594
- if ($isTableNode8(targetNode)) {
1646
+ if ($isTableNode9(targetNode)) {
1595
1647
  try {
1596
1648
  const newTableNode = $removeRowFromTable(
1597
1649
  targetNode,
@@ -1628,7 +1680,7 @@ function RemoveRowAction() {
1628
1680
 
1629
1681
  // src/plugins/SmartTablePlugin/ResizeColumnAction.tsx
1630
1682
  import { useLexicalComposerContext as useLexicalComposerContext13 } from "@lexical/react/LexicalComposerContext";
1631
- import { $isTableNode as $isTableNode9 } from "@lexical/table";
1683
+ import { $isTableNode as $isTableNode10 } from "@lexical/table";
1632
1684
  import { $getNodeByKey as $getNodeByKey11 } from "lexical";
1633
1685
  import { useEffect as useEffect19, useRef as useRef8 } from "react";
1634
1686
  import { Fragment as Fragment10, jsx as jsx23 } from "react/jsx-runtime";
@@ -1644,7 +1696,7 @@ function ResizeColumnAction() {
1644
1696
  if (nodeKey) {
1645
1697
  editor.getEditorState().read(() => {
1646
1698
  const targetNode = $getNodeByKey11(nodeKey);
1647
- if ($isTableNode9(targetNode)) {
1699
+ if ($isTableNode10(targetNode)) {
1648
1700
  const indexKey = `${nodeKey}_${currentColumnIndex}`;
1649
1701
  let columnWidths = [...targetNode.getColWidths() || []];
1650
1702
  if (columnWidths.length === 0) {
@@ -1669,7 +1721,7 @@ function ResizeColumnAction() {
1669
1721
  if (nodeKey) {
1670
1722
  editor.update(() => {
1671
1723
  const targetNode = $getNodeByKey11(nodeKey);
1672
- if ($isTableNode9(targetNode)) {
1724
+ if ($isTableNode10(targetNode)) {
1673
1725
  const indexKey = `${nodeKey}_${currentColumnIndex}`;
1674
1726
  const prevWidths = currentlyResizedNodesRef.current[indexKey];
1675
1727
  if (prevWidths) {
@@ -2070,7 +2122,7 @@ import { useMemo as useMemo4 } from "react";
2070
2122
  import { useLexicalComposerContext as useLexicalComposerContext14 } from "@lexical/react/LexicalComposerContext";
2071
2123
  import {
2072
2124
  $createTableSelection,
2073
- $isTableNode as $isTableNode10,
2125
+ $isTableNode as $isTableNode11,
2074
2126
  $unmergeCell
2075
2127
  } from "@lexical/table";
2076
2128
  import { $getNodeByKey as $getNodeByKey12, $setSelection } from "lexical";
@@ -2087,7 +2139,7 @@ function UnmergeCellAction() {
2087
2139
  editor.update(
2088
2140
  () => {
2089
2141
  const targetNode = $getNodeByKey12(nodeKey);
2090
- if ($isTableNode10(targetNode)) {
2142
+ if ($isTableNode11(targetNode)) {
2091
2143
  const rows = targetNode.getChildren();
2092
2144
  if (rows.length > rowIndex) {
2093
2145
  const foundRow = rows[rowIndex];
@@ -2110,7 +2162,7 @@ function UnmergeCellAction() {
2110
2162
  onUpdate: () => {
2111
2163
  editor.update(() => {
2112
2164
  const targetNode = $getNodeByKey12(nodeKey);
2113
- if ($isTableNode10(targetNode)) {
2165
+ if ($isTableNode11(targetNode)) {
2114
2166
  const rows = targetNode.getChildren();
2115
2167
  if (rows.length > rowIndex) {
2116
2168
  const foundRow = rows[rowIndex];
@@ -3250,6 +3302,7 @@ function SmartTablePlugin() {
3250
3302
  let isHeader = false;
3251
3303
  let rowIndex = 0;
3252
3304
  let rowElementKey;
3305
+ let lastCellElement = null;
3253
3306
  for (const rowElement of foundTableRowElements) {
3254
3307
  rowElementKey = `${nodeKey}:${rowIndex}`;
3255
3308
  let cellElements = rowElement.getElementsByTagName("td");
@@ -3279,6 +3332,8 @@ function SmartTablePlugin() {
3279
3332
  handleColumnMouseLeave
3280
3333
  );
3281
3334
  elementsMapRef.current[cellElementKey] = new WeakRef(cellElement);
3335
+ cellElement.removeAttribute("data-editor-table-last-cell");
3336
+ lastCellElement = cellElement;
3282
3337
  columnIndex++;
3283
3338
  }
3284
3339
  if (rowElement.rowIndex >= (isHeader ? 1 : 0)) {
@@ -3303,6 +3358,12 @@ function SmartTablePlugin() {
3303
3358
  }
3304
3359
  rowIndex++;
3305
3360
  }
3361
+ if (lastCellElement) {
3362
+ lastCellElement.setAttribute(
3363
+ "data-editor-table-last-cell",
3364
+ "true"
3365
+ );
3366
+ }
3306
3367
  }
3307
3368
  }
3308
3369
  useEffect22(() => {
@@ -3377,7 +3438,7 @@ function SmartTablePlugin() {
3377
3438
  COMMAND_PRIORITY_EDITOR2
3378
3439
  ),
3379
3440
  editor.registerMutationListener(
3380
- TableNode2,
3441
+ TableNode3,
3381
3442
  (mutatedNodes) => {
3382
3443
  for (const [nodeKey, mutation] of mutatedNodes) {
3383
3444
  if (mutation === "updated" || mutation === "created") {
@@ -3394,6 +3455,64 @@ function SmartTablePlugin() {
3394
3455
  tableResizerStickyRef.current?.hideHandle();
3395
3456
  },
3396
3457
  { skipInitialization: false }
3458
+ ),
3459
+ editor.registerCommand(
3460
+ KEY_TAB_COMMAND,
3461
+ (event, _activeEditor) => {
3462
+ const selection = $getSelection3();
3463
+ if (!$isRangeSelection(selection) || !selection.isCollapsed()) {
3464
+ return false;
3465
+ }
3466
+ const tableCellNode = $findCellNode(
3467
+ selection.anchor.getNode()
3468
+ );
3469
+ if (!tableCellNode) {
3470
+ return false;
3471
+ }
3472
+ let isLastCellElement = false;
3473
+ const tableCellElement = editor.getElementByKey(
3474
+ tableCellNode.getKey()
3475
+ );
3476
+ if (tableCellElement && tableCellElement.hasAttribute(
3477
+ "data-editor-table-last-cell"
3478
+ )) {
3479
+ isLastCellElement = true;
3480
+ }
3481
+ event.preventDefault();
3482
+ event.stopImmediatePropagation();
3483
+ event.stopPropagation();
3484
+ if (isLastCellElement) {
3485
+ console.log("Last cell");
3486
+ const tableNodeKey = tableCellElement?.getAttribute(
3487
+ "data-editor-table-key"
3488
+ );
3489
+ const cellColumnKey = tableCellElement?.getAttribute(
3490
+ "data-editor-table-column-key"
3491
+ );
3492
+ if (tableNodeKey && cellColumnKey) {
3493
+ const cellMetaData = cellColumnKey.split(":");
3494
+ window.dispatchEvent(
3495
+ new CustomEvent(
3496
+ SMART_TABLE_ADD_NEW_ROW_EVENT,
3497
+ {
3498
+ detail: {
3499
+ nodeKey: tableNodeKey,
3500
+ currentRowIndex: Number(cellMetaData[1]),
3501
+ addDirection: "after"
3502
+ }
3503
+ }
3504
+ )
3505
+ );
3506
+ }
3507
+ } else {
3508
+ $selectAdjacentCell(
3509
+ tableCellNode,
3510
+ event.shiftKey ? "previous" : "next"
3511
+ );
3512
+ }
3513
+ return true;
3514
+ },
3515
+ COMMAND_PRIORITY_CRITICAL
3397
3516
  )
3398
3517
  );
3399
3518
  });
@@ -3467,7 +3586,7 @@ function Table() {
3467
3586
  {
3468
3587
  hasCellMerge: true,
3469
3588
  hasHorizontalScroll: true,
3470
- hasTabHandler: true,
3589
+ hasTabHandler: false,
3471
3590
  hasCellBackgroundColor: true
3472
3591
  }
3473
3592
  ),
@@ -8993,10 +9112,10 @@ import {
8993
9112
  import { useEffect as useEffect51, useRef as useRef29 } from "react";
8994
9113
 
8995
9114
  // src/utils/extractSelectionNode.ts
8996
- import { $getSelection as $getSelection5, $isRangeSelection } from "lexical";
9115
+ import { $getSelection as $getSelection5, $isRangeSelection as $isRangeSelection2 } from "lexical";
8997
9116
  function $extractSelectionNode() {
8998
9117
  const selection = $getSelection5();
8999
- if (!$isRangeSelection(selection) || selection.isCollapsed()) {
9118
+ if (!$isRangeSelection2(selection) || selection.isCollapsed()) {
9000
9119
  return null;
9001
9120
  }
9002
9121
  const anchor = selection.anchor;
@@ -9037,7 +9156,7 @@ import { mergeRegister as mergeRegister12 } from "@lexical/utils";
9037
9156
  import {
9038
9157
  $createNodeSelection as $createNodeSelection8,
9039
9158
  $getSelection as $getSelection6,
9040
- $isRangeSelection as $isRangeSelection2,
9159
+ $isRangeSelection as $isRangeSelection3,
9041
9160
  $setSelection as $setSelection9,
9042
9161
  CLICK_COMMAND as CLICK_COMMAND8,
9043
9162
  COMMAND_PRIORITY_EDITOR as COMMAND_PRIORITY_EDITOR6,
@@ -9101,7 +9220,7 @@ function FillInTheBlankSpaceComponentPlugin() {
9101
9220
  SELECTION_CHANGE_COMMAND5,
9102
9221
  () => {
9103
9222
  const selection = $getSelection6();
9104
- if ($isRangeSelection2(selection)) {
9223
+ if ($isRangeSelection3(selection)) {
9105
9224
  lastSelectedNodeRef.current = selection.anchor.getNode();
9106
9225
  }
9107
9226
  return false;
@@ -9315,7 +9434,7 @@ function $isFillInTheBlankQuestionNode(node) {
9315
9434
 
9316
9435
  // src/plugins/SettingsPanel/SmartTableSettings.tsx
9317
9436
  import { useLexicalComposerContext as useLexicalComposerContext44 } from "@lexical/react/LexicalComposerContext";
9318
- import { $isTableNode as $isTableNode11 } from "@lexical/table";
9437
+ import { $isTableNode as $isTableNode12 } from "@lexical/table";
9319
9438
  import { $getNodeByKey as $getNodeByKey32 } from "lexical";
9320
9439
  import { useEffect as useEffect52, useRef as useRef30 } from "react";
9321
9440
  import { Fragment as Fragment38, jsx as jsx80, jsxs as jsxs27 } from "react/jsx-runtime";
@@ -9328,7 +9447,7 @@ function SmartTableSettings(props) {
9328
9447
  if (nodeKey) {
9329
9448
  editor.getEditorState().read(() => {
9330
9449
  const targetNode = $getNodeByKey32(nodeKey);
9331
- if ($isTableNode11(targetNode)) {
9450
+ if ($isTableNode12(targetNode)) {
9332
9451
  isHeaderRowInputRef.current?.setChecked(
9333
9452
  $hasTableHeader(targetNode)
9334
9453
  );
@@ -9350,7 +9469,7 @@ function SmartTableSettings(props) {
9350
9469
  onChange: (checked) => {
9351
9470
  editor.update(() => {
9352
9471
  const targetNode = $getNodeByKey32(nodeKey);
9353
- if ($isTableNode11(targetNode)) {
9472
+ if ($isTableNode12(targetNode)) {
9354
9473
  const isRowStriping = targetNode.getRowStriping();
9355
9474
  const updatedTableNode = $updateTableNode(
9356
9475
  checked,
@@ -9379,7 +9498,7 @@ function SmartTableSettings(props) {
9379
9498
  onChange: (checked) => {
9380
9499
  editor.update(() => {
9381
9500
  const targetNode = $getNodeByKey32(nodeKey);
9382
- if ($isTableNode11(targetNode)) {
9501
+ if ($isTableNode12(targetNode)) {
9383
9502
  targetNode.setRowStriping(checked);
9384
9503
  }
9385
9504
  });
@@ -9391,13 +9510,13 @@ function SmartTableSettings(props) {
9391
9510
 
9392
9511
  // src/plugins/SettingsPanel/SettingsPanelPlugin.tsx
9393
9512
  import { useLexicalComposerContext as useLexicalComposerContext45 } from "@lexical/react/LexicalComposerContext";
9394
- import { $isTableNode as $isTableNode12, TableNode as TableNode3 } from "@lexical/table";
9513
+ import { $isTableNode as $isTableNode13, TableNode as TableNode4 } from "@lexical/table";
9395
9514
  import { mergeRegister as mergeRegister13 } from "@lexical/utils";
9396
9515
  import {
9397
9516
  $getNodeByKey as $getNodeByKey33,
9398
9517
  $getSelection as $getSelection7,
9399
9518
  $isNodeSelection as $isNodeSelection2,
9400
- $isRangeSelection as $isRangeSelection3,
9519
+ $isRangeSelection as $isRangeSelection4,
9401
9520
  COMMAND_PRIORITY_EDITOR as COMMAND_PRIORITY_EDITOR7,
9402
9521
  createCommand as createCommand11,
9403
9522
  RootNode,
@@ -9488,12 +9607,12 @@ function SettingsPanelPlugin() {
9488
9607
  );
9489
9608
  } else {
9490
9609
  const currentSelection = $getSelection7();
9491
- if ($isRangeSelection3(currentSelection)) {
9610
+ if ($isRangeSelection4(currentSelection)) {
9492
9611
  const selectionNode = currentSelection.anchor.getNode();
9493
9612
  const parentNodes = selectionNode.getParents();
9494
9613
  if (parentNodes.length > 1 && parentNodes[parentNodes.length - 1].__type === RootNode.getType()) {
9495
9614
  const parentNode = parentNodes[parentNodes.length - 2];
9496
- if ($isTableNode12(parentNode)) {
9615
+ if ($isTableNode13(parentNode)) {
9497
9616
  currentFocusedNode.current = parentNode;
9498
9617
  currentFocusedElement.current = activeEditor.getElementByKey(parentNode.getKey());
9499
9618
  }
@@ -9533,7 +9652,7 @@ function SettingsPanelPlugin() {
9533
9652
  currentStickyRef.current?.hide();
9534
9653
  currentStickyRef.current = null;
9535
9654
  if (selectedNode && currentFocusedNode.current?.__type) {
9536
- if (currentFocusedNode.current.__type === TableNode3.getType()) {
9655
+ if (currentFocusedNode.current.__type === TableNode4.getType()) {
9537
9656
  currentStickyRef.current = tableStickyRef.current;
9538
9657
  } else {
9539
9658
  currentStickyRef.current = getSettingsPanel(currentFocusedNode.current.__type) || null;
@@ -9681,7 +9800,7 @@ function SettingsPanelNestedAgentPlugin() {
9681
9800
 
9682
9801
  // src/utils/getLineBreakNodeBeforeCaretOnLastLine.ts
9683
9802
  import {
9684
- $isElementNode as $isElementNode2,
9803
+ $isElementNode as $isElementNode3,
9685
9804
  $isLineBreakNode,
9686
9805
  $isTextNode as $isTextNode2
9687
9806
  } from "lexical";
@@ -9697,7 +9816,7 @@ function getLineBreakNodeBeforeCaretOnLastLine(paragraph, selection) {
9697
9816
  }
9698
9817
  const totalLines = totalBrNodes + 1;
9699
9818
  let lineNumber;
9700
- if ($isElementNode2(focusNode)) {
9819
+ if ($isElementNode3(focusNode)) {
9701
9820
  let brBefore = 0;
9702
9821
  for (let i = 0; i < focusOffset; i++) {
9703
9822
  if ($isLineBreakNode(children[i])) {
@@ -9740,7 +9859,7 @@ import {
9740
9859
  $getRoot as $getRoot11,
9741
9860
  $getSelection as $getSelection9,
9742
9861
  $isParagraphNode as $isParagraphNode2,
9743
- $isRangeSelection as $isRangeSelection4,
9862
+ $isRangeSelection as $isRangeSelection5,
9744
9863
  COMMAND_PRIORITY_LOW as COMMAND_PRIORITY_LOW9,
9745
9864
  KEY_BACKSPACE_COMMAND as KEY_BACKSPACE_COMMAND3,
9746
9865
  KEY_ENTER_COMMAND
@@ -9761,7 +9880,7 @@ function CalloutBoxComponent(props) {
9761
9880
  activeEditor.update(
9762
9881
  () => {
9763
9882
  const currentSelection = $getSelection9();
9764
- if ($isRangeSelection4(currentSelection) && currentSelection.isCollapsed()) {
9883
+ if ($isRangeSelection5(currentSelection) && currentSelection.isCollapsed()) {
9765
9884
  const firstChild = $getRoot11().getFirstChild();
9766
9885
  if (firstChild?.getTextContentSize() === 0) {
9767
9886
  event.stopPropagation();
@@ -9795,7 +9914,7 @@ function CalloutBoxComponent(props) {
9795
9914
  KEY_ENTER_COMMAND,
9796
9915
  (event) => {
9797
9916
  const currentSelection = $getSelection9();
9798
- if ($isRangeSelection4(currentSelection) && currentSelection.isCollapsed()) {
9917
+ if ($isRangeSelection5(currentSelection) && currentSelection.isCollapsed()) {
9799
9918
  const firstChild = $getRoot11().getFirstChild();
9800
9919
  if ($isParagraphNode2(firstChild)) {
9801
9920
  const breakNodes = getLineBreakNodeBeforeCaretOnLastLine(
@@ -10448,7 +10567,7 @@ import {
10448
10567
  import { useEffect as useEffect58, useRef as useRef33 } from "react";
10449
10568
  import { jsx as jsx90, jsxs as jsxs32 } from "react/jsx-runtime";
10450
10569
  function SimulationQuestionComponent(props) {
10451
- const { nodeKey, id, aiSystemMessage, step2Instruction } = props;
10570
+ const { nodeKey, id, aiSystemMessage, commentInstructions } = props;
10452
10571
  const [editor] = useLexicalComposerContext49();
10453
10572
  const rootElementRef = useRef33(null);
10454
10573
  useEffect58(() => {
@@ -10494,7 +10613,7 @@ function SimulationQuestionComponent(props) {
10494
10613
  "data-selectable": "true",
10495
10614
  children: [
10496
10615
  /* @__PURE__ */ jsx90("div", { className: "title", "data-selectable": "true", children: aiSystemMessage }),
10497
- /* @__PURE__ */ jsx90("div", { children: step2Instruction })
10616
+ /* @__PURE__ */ jsx90("div", { children: commentInstructions })
10498
10617
  ]
10499
10618
  }
10500
10619
  )
@@ -10507,13 +10626,14 @@ function SimulationQuestionComponent(props) {
10507
10626
  import { jsx as jsx91 } from "react/jsx-runtime";
10508
10627
  var TYPE_NAME13 = "simulation-question";
10509
10628
  var SimulationQuestionNode = class _SimulationQuestionNode extends DecoratorNode15 {
10510
- constructor(points, aiSystemMessage, aiChatModel, step2Instructions, id, key) {
10629
+ constructor(points, aiSystemMessage, aiChatModel, disableChat, commentInstructions, id, key) {
10511
10630
  super(key);
10512
10631
  this.__id = id || nanoid10();
10513
10632
  this.__points = points < 0 ? 1 : points;
10514
10633
  this.__aiSystemMessage = aiSystemMessage || null;
10515
10634
  this.__aiChatModel = aiChatModel || null;
10516
- this.__step2Instructions = step2Instructions || null;
10635
+ this.__disableChat = disableChat || false;
10636
+ this.__commentInstructions = commentInstructions || null;
10517
10637
  }
10518
10638
  static getType() {
10519
10639
  return TYPE_NAME13;
@@ -10523,7 +10643,8 @@ var SimulationQuestionNode = class _SimulationQuestionNode extends DecoratorNode
10523
10643
  node.__points,
10524
10644
  node.__aiSystemMessage,
10525
10645
  node.__aiChatModel,
10526
- node.__step2Instructions,
10646
+ node.__disableChat,
10647
+ node.__commentInstructions,
10527
10648
  node.__id,
10528
10649
  node.__key
10529
10650
  );
@@ -10551,7 +10672,8 @@ var SimulationQuestionNode = class _SimulationQuestionNode extends DecoratorNode
10551
10672
  serializedNode.points,
10552
10673
  serializedNode.aiSystemMessage,
10553
10674
  serializedNode.aiChatModel,
10554
- serializedNode.step2Instructions,
10675
+ serializedNode.disableChat,
10676
+ serializedNode.commentInstructions,
10555
10677
  serializedNode.id
10556
10678
  );
10557
10679
  }
@@ -10561,7 +10683,8 @@ var SimulationQuestionNode = class _SimulationQuestionNode extends DecoratorNode
10561
10683
  points: this.__points,
10562
10684
  aiSystemMessage: this.__aiSystemMessage,
10563
10685
  aiChatModel: this.__aiChatModel,
10564
- step2Instructions: this.__step2Instructions,
10686
+ disableChat: this.__disableChat,
10687
+ commentInstructions: this.__commentInstructions,
10565
10688
  type: TYPE_NAME13,
10566
10689
  version: 1
10567
10690
  };
@@ -10589,18 +10712,19 @@ var SimulationQuestionNode = class _SimulationQuestionNode extends DecoratorNode
10589
10712
  nodeKey: this.__key,
10590
10713
  id: this.__id,
10591
10714
  aiSystemMessage: this.__aiSystemMessage,
10592
- step2Instruction: this.__step2Instructions
10715
+ commentInstructions: this.__commentInstructions
10593
10716
  }
10594
10717
  );
10595
10718
  }
10596
10719
  };
10597
- function $createSimulationQuestionNode(points, aiSystemMessage, aiChatModel, step2Instructions, id) {
10720
+ function $createSimulationQuestionNode(points, aiSystemMessage, aiChatModel, disableChat, commentInstructions, id) {
10598
10721
  return $applyNodeReplacement15(
10599
10722
  new SimulationQuestionNode(
10600
10723
  points,
10601
10724
  aiSystemMessage,
10602
10725
  aiChatModel,
10603
- step2Instructions,
10726
+ disableChat,
10727
+ commentInstructions,
10604
10728
  id
10605
10729
  )
10606
10730
  );
@@ -10614,8 +10738,8 @@ import { LinkNode } from "@lexical/link";
10614
10738
  import { ListItemNode as ListItemNode2, ListNode } from "@lexical/list";
10615
10739
  import { HeadingNode, QuoteNode } from "@lexical/rich-text";
10616
10740
  import {
10617
- TableCellNode as TableCellNode5,
10618
- TableNode as TableNode4,
10741
+ TableCellNode as TableCellNode6,
10742
+ TableNode as TableNode5,
10619
10743
  TableRowNode as TableRowNode5
10620
10744
  } from "@lexical/table";
10621
10745
  var commonEditorNodes = [
@@ -10628,8 +10752,8 @@ var commonEditorNodes = [
10628
10752
  ListItemNode2,
10629
10753
  CalloutBoxNode,
10630
10754
  ListNode,
10631
- TableCellNode5,
10632
- TableNode4,
10755
+ TableCellNode6,
10756
+ TableNode5,
10633
10757
  TableRowNode5,
10634
10758
  VariableNode,
10635
10759
  MultipleOptionQuestionNode,
@@ -10980,7 +11104,7 @@ var DropdownWrapper = forwardRef11((props, ref) => {
10980
11104
 
10981
11105
  // src/utils/exportNodeToJSON.ts
10982
11106
  import {
10983
- $isElementNode as $isElementNode3
11107
+ $isElementNode as $isElementNode4
10984
11108
  } from "lexical";
10985
11109
  var LEXICAL_NODE_MIME_TYPE = "/application/x-lexical-node/";
10986
11110
  function exportNodeToJSON(node) {
@@ -10991,7 +11115,7 @@ function exportNodeToJSON(node) {
10991
11115
  `LexicalNode: Node ${nodeClass.name} does not match the serialized type. Check if .exportJSON() is implemented and it is returning the correct type.`
10992
11116
  );
10993
11117
  }
10994
- if ($isElementNode3(node)) {
11118
+ if ($isElementNode4(node)) {
10995
11119
  const serializedChildren = serializedNode.children;
10996
11120
  if (!Array.isArray(serializedChildren)) {
10997
11121
  throw Error(
@@ -11011,16 +11135,14 @@ function exportNodeToJSON(node) {
11011
11135
  // src/utils/traverseTableNode.ts
11012
11136
  import {
11013
11137
  $isTableCellNode as $isTableCellNode4,
11014
- $isTableRowNode
11138
+ $isTableRowNode as $isTableRowNode2
11015
11139
  } from "@lexical/table";
11016
11140
  function traverseTableCellNodes(tableNode, cb) {
11017
11141
  const rows = tableNode.getChildren();
11018
- console.log("rows: ", rows);
11019
11142
  if (rows.length > 0) {
11020
11143
  for (const row of rows) {
11021
- if ($isTableRowNode(row)) {
11144
+ if ($isTableRowNode2(row)) {
11022
11145
  const cells = row.getChildren();
11023
- console.log("cells: ", cells);
11024
11146
  if (cells.length > 0) {
11025
11147
  for (const cell of cells) {
11026
11148
  if ($isTableCellNode4(cell)) {
@@ -11035,7 +11157,7 @@ function traverseTableCellNodes(tableNode, cb) {
11035
11157
 
11036
11158
  // src/plugins/FillInTheBlankQuestionPlugin/FillInTheBlankQuestionPlugin.tsx
11037
11159
  import { useLexicalComposerContext as useLexicalComposerContext51 } from "@lexical/react/LexicalComposerContext";
11038
- import { $isTableNode as $isTableNode13 } from "@lexical/table";
11160
+ import { $isTableNode as $isTableNode14 } from "@lexical/table";
11039
11161
  import { mergeRegister as mergeRegister16 } from "@lexical/utils";
11040
11162
  import {
11041
11163
  $createNodeSelection as $createNodeSelection12,
@@ -11161,7 +11283,7 @@ function FillInTheBlankQuestionPlugin() {
11161
11283
  fillInTheBlankNode = $createFillInTheBlankQuestionNode(1);
11162
11284
  if (tableNodeKey) {
11163
11285
  const foundTableNode = $getNodeByKey37(tableNodeKey);
11164
- if ($isTableNode13(foundTableNode)) {
11286
+ if ($isTableNode14(foundTableNode)) {
11165
11287
  nodeSerialized = exportNodeToJSON(foundTableNode);
11166
11288
  serializedData = JSON.stringify(nodeSerialized);
11167
11289
  foundTableNode.replace(fillInTheBlankNode);
@@ -11189,7 +11311,7 @@ function FillInTheBlankQuestionPlugin() {
11189
11311
  const newNode = $parseSerializedNode(nodeSerialized2);
11190
11312
  root.append(newNode);
11191
11313
  const firstChild = root.getFirstChild();
11192
- if ($isTableNode13(firstChild)) {
11314
+ if ($isTableNode14(firstChild)) {
11193
11315
  traverseTableCellNodes(
11194
11316
  firstChild,
11195
11317
  (cell) => {
@@ -14053,7 +14175,7 @@ var useNode = () => {
14053
14175
 
14054
14176
  // src/plugins/AutoBottomParagraphPlugin/AutoBottomParagraphPlugin.tsx
14055
14177
  import { useLexicalComposerContext as useLexicalComposerContext60 } from "@lexical/react/LexicalComposerContext";
14056
- import { TableNode as TableNode6 } from "@lexical/table";
14178
+ import { TableNode as TableNode7 } from "@lexical/table";
14057
14179
  import { mergeRegister as mergeRegister21 } from "@lexical/utils";
14058
14180
  import {
14059
14181
  $createParagraphNode as $createParagraphNode16,
@@ -14086,7 +14208,7 @@ function AutoBottomParagraphPlugin() {
14086
14208
  ImageNode2,
14087
14209
  ImagePlaceholderNode,
14088
14210
  CalloutBoxNode,
14089
- TableNode6,
14211
+ TableNode7,
14090
14212
  MultipleOptionQuestionNode,
14091
14213
  ShortAnswerQuestionNode,
14092
14214
  MatchingQuestionNode,
@@ -14148,7 +14270,7 @@ import { useLexicalComposerContext as useLexicalComposerContext63 } from "@lexic
14148
14270
  import {
14149
14271
  $getRoot as $getRoot20,
14150
14272
  $isDecoratorNode,
14151
- $isElementNode as $isElementNode4,
14273
+ $isElementNode as $isElementNode5,
14152
14274
  $isLineBreakNode as $isLineBreakNode2,
14153
14275
  $isTextNode as $isTextNode4
14154
14276
  } from "lexical";
@@ -14403,7 +14525,7 @@ import {
14403
14525
  $isListNode as $isListNode6
14404
14526
  } from "@lexical/list";
14405
14527
  import { $isQuoteNode as $isQuoteNode2 } from "@lexical/rich-text";
14406
- import { $findMatchingParent } from "@lexical/utils";
14528
+ import { $findMatchingParent as $findMatchingParent2 } from "@lexical/utils";
14407
14529
  import {
14408
14530
  $createLineBreakNode as $createLineBreakNode2,
14409
14531
  $createParagraphNode as $createParagraphNode17,
@@ -14432,7 +14554,7 @@ import {
14432
14554
  $createRangeSelection,
14433
14555
  $getSelection as $getSelection12,
14434
14556
  $isLineBreakNode as $isLineBreakNode3,
14435
- $isRangeSelection as $isRangeSelection5,
14557
+ $isRangeSelection as $isRangeSelection6,
14436
14558
  $isRootOrShadowRoot,
14437
14559
  $isTextNode as $isTextNode5,
14438
14560
  $setSelection as $setSelection18
@@ -14598,7 +14720,7 @@ function $runTextFormatTransformers(anchorNode, anchorOffset, textFormatTransfor
14598
14720
  nextSelection.toggleFormat(format);
14599
14721
  }
14600
14722
  }
14601
- if ($isRangeSelection5(selection)) {
14723
+ if ($isRangeSelection6(selection)) {
14602
14724
  nextSelection.format = selection.format;
14603
14725
  }
14604
14726
  return true;
@@ -14681,7 +14803,7 @@ function registerMarkdownShortcuts(editor, transformers) {
14681
14803
  }
14682
14804
  const selection = editorState.read($getSelection12);
14683
14805
  const prevSelection = prevEditorState.read($getSelection12);
14684
- if (!$isRangeSelection5(prevSelection) || !$isRangeSelection5(selection) || !selection.isCollapsed()) {
14806
+ if (!$isRangeSelection6(prevSelection) || !$isRangeSelection6(selection) || !selection.isCollapsed()) {
14685
14807
  return;
14686
14808
  }
14687
14809
  const anchorKey = selection.anchor.key;
@@ -15086,7 +15208,7 @@ import {
15086
15208
  import { useLexicalComposerContext as useLexicalComposerContext65 } from "@lexical/react/LexicalComposerContext";
15087
15209
  import { HorizontalRuleNode as HorizontalRuleNode3 } from "@lexical/react/LexicalHorizontalRuleNode";
15088
15210
  import { HeadingNode as HeadingNode5 } from "@lexical/rich-text";
15089
- import { $isTableCellNode as $isTableCellNode5, TableNode as TableNode7 } from "@lexical/table";
15211
+ import { $isTableCellNode as $isTableCellNode5, TableNode as TableNode8 } from "@lexical/table";
15090
15212
  import { mergeRegister as mergeRegister22 } from "@lexical/utils";
15091
15213
  import {
15092
15214
  $createParagraphNode as $createParagraphNode18,
@@ -15431,7 +15553,7 @@ function NodeMousePlugin() {
15431
15553
  ListNode5,
15432
15554
  ParagraphNode4,
15433
15555
  CalloutBoxNode,
15434
- TableNode7,
15556
+ TableNode8,
15435
15557
  MultipleOptionQuestionNode,
15436
15558
  ShortAnswerQuestionNode,
15437
15559
  MatchingQuestionNode,
@@ -16531,7 +16653,7 @@ var PopupMenu = forwardRef16(
16531
16653
  import {
16532
16654
  $createNodeSelection as $createNodeSelection17,
16533
16655
  $getSelection as $getSelection14,
16534
- $isRangeSelection as $isRangeSelection6,
16656
+ $isRangeSelection as $isRangeSelection7,
16535
16657
  $setSelection as $setSelection20
16536
16658
  } from "lexical";
16537
16659
  function getFullMatchOffset(documentText, entryText, offset) {
@@ -16545,7 +16667,7 @@ function getFullMatchOffset(documentText, entryText, offset) {
16545
16667
  }
16546
16668
  function $splitNodeContainingQuery(replaceableString, matchingString) {
16547
16669
  const selection = $getSelection14();
16548
- if (!$isRangeSelection6(selection) || !selection.isCollapsed()) {
16670
+ if (!$isRangeSelection7(selection) || !selection.isCollapsed()) {
16549
16671
  return null;
16550
16672
  }
16551
16673
  const anchor = selection.anchor;
@@ -16662,12 +16784,12 @@ function useTypeaheadTriggerMatch(trigger, {
16662
16784
  }
16663
16785
 
16664
16786
  // src/utils/visitVariableNodes.ts
16665
- import { $isElementNode as $isElementNode5 } from "lexical";
16787
+ import { $isElementNode as $isElementNode6 } from "lexical";
16666
16788
  function visitVariableNodes(rootNode, cb) {
16667
16789
  if ($isVariableNode(rootNode)) {
16668
16790
  cb(rootNode);
16669
16791
  }
16670
- if ($isElementNode5(rootNode)) {
16792
+ if ($isElementNode6(rootNode)) {
16671
16793
  const children = rootNode.getChildren();
16672
16794
  for (const childNode of children) {
16673
16795
  visitVariableNodes(childNode, cb);
@@ -16774,7 +16896,7 @@ function getSelectionDOMRangeRect(editor, leadOffset) {
16774
16896
  import {
16775
16897
  $createRangeSelection as $createRangeSelection2,
16776
16898
  $getSelection as $getSelection15,
16777
- $isRangeSelection as $isRangeSelection7,
16899
+ $isRangeSelection as $isRangeSelection8,
16778
16900
  $setSelection as $setSelection21
16779
16901
  } from "lexical";
16780
16902
  function removeText(editorWindow, leadOffset) {
@@ -16803,7 +16925,7 @@ function removeTextInDomSelection(editor, leadOffset, onUpdate) {
16803
16925
  () => {
16804
16926
  const selection = $getSelection15();
16805
16927
  let selectedNode;
16806
- if ($isRangeSelection7(selection)) {
16928
+ if ($isRangeSelection8(selection)) {
16807
16929
  selectedNode = selection.focus.getNode();
16808
16930
  }
16809
16931
  removeText(editorWindow, leadOffset);
@@ -16834,9 +16956,9 @@ import { mergeRegister as mergeRegister25 } from "@lexical/utils";
16834
16956
  import {
16835
16957
  $createNodeSelection as $createNodeSelection18,
16836
16958
  $getSelection as $getSelection16,
16837
- $isRangeSelection as $isRangeSelection8,
16959
+ $isRangeSelection as $isRangeSelection9,
16838
16960
  $setSelection as $setSelection22,
16839
- COMMAND_PRIORITY_CRITICAL,
16961
+ COMMAND_PRIORITY_CRITICAL as COMMAND_PRIORITY_CRITICAL2,
16840
16962
  COMMAND_PRIORITY_HIGH as COMMAND_PRIORITY_HIGH4,
16841
16963
  KEY_ARROW_DOWN_COMMAND,
16842
16964
  KEY_ARROW_UP_COMMAND,
@@ -16861,7 +16983,7 @@ function TypeaheadVariablePlugin() {
16861
16983
  const handleUpdate = () => {
16862
16984
  activeEditorRef.current?.getEditorState().read(() => {
16863
16985
  const selection = $getSelection16();
16864
- if ($isRangeSelection8(selection)) {
16986
+ if ($isRangeSelection9(selection)) {
16865
16987
  if (selection.isCollapsed()) {
16866
16988
  const anchor = selection.anchor;
16867
16989
  const isEmpty = anchor.getNode().getTextContent().trim().length === 0;
@@ -17027,14 +17149,14 @@ function TypeaheadVariablePlugin() {
17027
17149
  handleMenuItemSelect("down"),
17028
17150
  // Highest priority
17029
17151
  // Prevents any events from nested editors
17030
- COMMAND_PRIORITY_CRITICAL
17152
+ COMMAND_PRIORITY_CRITICAL2
17031
17153
  ),
17032
17154
  editor.registerCommand(
17033
17155
  KEY_ARROW_UP_COMMAND,
17034
17156
  handleMenuItemSelect("up"),
17035
17157
  // Highest priority
17036
17158
  // Prevents any events from nested editors
17037
- COMMAND_PRIORITY_CRITICAL
17159
+ COMMAND_PRIORITY_CRITICAL2
17038
17160
  ),
17039
17161
  editor.registerCommand(
17040
17162
  CREATE_VARIABLE_FROM_SELECTION_COMMAND,
@@ -17204,15 +17326,15 @@ import {
17204
17326
  $getSelectionStyleValueForProperty,
17205
17327
  $patchStyleText
17206
17328
  } from "@lexical/selection";
17207
- import { TableNode as TableNode8 } from "@lexical/table";
17208
- import { $findMatchingParent as $findMatchingParent2, mergeRegister as mergeRegister26 } from "@lexical/utils";
17329
+ import { TableNode as TableNode9 } from "@lexical/table";
17330
+ import { $findMatchingParent as $findMatchingParent3, mergeRegister as mergeRegister26 } from "@lexical/utils";
17209
17331
  import {
17210
17332
  $getSelection as $getSelection17,
17211
17333
  $isDecoratorNode as $isDecoratorNode2,
17212
- $isElementNode as $isElementNode6,
17334
+ $isElementNode as $isElementNode7,
17213
17335
  $isNodeSelection as $isNodeSelection5,
17214
17336
  $isParagraphNode as $isParagraphNode8,
17215
- $isRangeSelection as $isRangeSelection9,
17337
+ $isRangeSelection as $isRangeSelection10,
17216
17338
  $isRootOrShadowRoot as $isRootOrShadowRoot2,
17217
17339
  $isTextNode as $isTextNode7,
17218
17340
  $setSelection as $setSelection23,
@@ -17274,7 +17396,7 @@ function TextToolbarPlugin() {
17274
17396
  const formatText = (format) => {
17275
17397
  activeEditorRef.current?.update(() => {
17276
17398
  const selection = $getSelection17();
17277
- if (!$isRangeSelection9(selection)) {
17399
+ if (!$isRangeSelection10(selection)) {
17278
17400
  return false;
17279
17401
  }
17280
17402
  selection.formatText(format);
@@ -17283,14 +17405,14 @@ function TextToolbarPlugin() {
17283
17405
  const formatElement = (format) => {
17284
17406
  activeEditorRef.current?.update(() => {
17285
17407
  const selection = $getSelection17();
17286
- if (!$isRangeSelection9(selection) && !$isNodeSelection5(selection)) {
17408
+ if (!$isRangeSelection10(selection) && !$isNodeSelection5(selection)) {
17287
17409
  return false;
17288
17410
  }
17289
17411
  const nodes = selection.getNodes();
17290
17412
  for (const node of nodes) {
17291
- const element = $findMatchingParent2(
17413
+ const element = $findMatchingParent3(
17292
17414
  node,
17293
- (parentNode) => $isElementNode6(parentNode) && !parentNode.isInline()
17415
+ (parentNode) => $isElementNode7(parentNode) && !parentNode.isInline()
17294
17416
  );
17295
17417
  if (element !== null) {
17296
17418
  element.setFormat(format);
@@ -17360,7 +17482,7 @@ function TextToolbarPlugin() {
17360
17482
  "font-size": null,
17361
17483
  "font-weight": null
17362
17484
  });
17363
- if ($isRangeSelection9(selection)) {
17485
+ if ($isRangeSelection10(selection)) {
17364
17486
  const selectedNodes = selection.getNodes();
17365
17487
  for (const selectedNode of selectedNodes) {
17366
17488
  if ($isTextNode7(selectedNode)) {
@@ -17411,7 +17533,7 @@ function TextToolbarPlugin() {
17411
17533
  activeEditorRef.current?.getEditorState().read(() => {
17412
17534
  const foundParentTableNode = getParentNodeType(
17413
17535
  selectedNode,
17414
- TableNode8
17536
+ TableNode9
17415
17537
  );
17416
17538
  if (foundParentTableNode) {
17417
17539
  activeEditorRef.current?.dispatchCommand(
@@ -17532,7 +17654,7 @@ function TextToolbarPlugin() {
17532
17654
  popupToolbarRef.current?.hideToolbar();
17533
17655
  return false;
17534
17656
  }
17535
- if (!$isRangeSelection9(selection)) {
17657
+ if (!$isRangeSelection10(selection)) {
17536
17658
  popupToolbarRef.current?.hideToolbar();
17537
17659
  return false;
17538
17660
  }
@@ -17554,7 +17676,7 @@ function TextToolbarPlugin() {
17554
17676
  return false;
17555
17677
  }
17556
17678
  const anchorNode = selection.anchor.getNode();
17557
- let element = anchorNode.getKey() === "root" ? anchorNode : $findMatchingParent2(
17679
+ let element = anchorNode.getKey() === "root" ? anchorNode : $findMatchingParent3(
17558
17680
  anchorNode,
17559
17681
  (e) => {
17560
17682
  const parent = e.getParent();
@@ -17617,7 +17739,7 @@ function TextToolbarPlugin() {
17617
17739
  "background-color",
17618
17740
  ""
17619
17741
  );
17620
- if ($isElementNode6(element)) {
17742
+ if ($isElementNode7(element)) {
17621
17743
  newToolbarState.textAlign = element.getFormatType();
17622
17744
  } else {
17623
17745
  newToolbarState.textAlign = "left";
@@ -17935,7 +18057,7 @@ function TextToolbarPlugin() {
17935
18057
  activeEditorRef.current?.getEditorState().read(() => {
17936
18058
  const foundParentTableNode = getParentNodeType(
17937
18059
  selectedNode,
17938
- TableNode8
18060
+ TableNode9
17939
18061
  );
17940
18062
  if (foundParentTableNode) {
17941
18063
  activeEditorRef.current?.dispatchCommand(
@@ -18468,7 +18590,7 @@ function useTypeaheadTriggerMatch2(trigger, {
18468
18590
  // src/plugins/TypeaheadMenuPlugin/TypeaheadMenuPlugin.tsx
18469
18591
  import { useLexicalComposerContext as useLexicalComposerContext70 } from "@lexical/react/LexicalComposerContext";
18470
18592
  import { $isHeadingNode as $isHeadingNode5 } from "@lexical/rich-text";
18471
- import { $isTableCellNode as $isTableCellNode6, TableNode as TableNode9 } from "@lexical/table";
18593
+ import { $isTableCellNode as $isTableCellNode6, TableNode as TableNode10 } from "@lexical/table";
18472
18594
  import { mergeRegister as mergeRegister27 } from "@lexical/utils";
18473
18595
  import {
18474
18596
  $createParagraphNode as $createParagraphNode21,
@@ -18476,7 +18598,7 @@ import {
18476
18598
  $getRoot as $getRoot24,
18477
18599
  $getSelection as $getSelection18,
18478
18600
  $isParagraphNode as $isParagraphNode9,
18479
- $isRangeSelection as $isRangeSelection10,
18601
+ $isRangeSelection as $isRangeSelection11,
18480
18602
  BLUR_COMMAND,
18481
18603
  COMMAND_PRIORITY_HIGH as COMMAND_PRIORITY_HIGH6,
18482
18604
  KEY_ARROW_DOWN_COMMAND as KEY_ARROW_DOWN_COMMAND2,
@@ -18613,7 +18735,7 @@ function TypeaheadMenuPlugin() {
18613
18735
  const handleUpdate = () => {
18614
18736
  activeEditorRef.current?.getEditorState().read(() => {
18615
18737
  const selection = $getSelection18();
18616
- if ($isRangeSelection10(selection)) {
18738
+ if ($isRangeSelection11(selection)) {
18617
18739
  if (selection.isCollapsed()) {
18618
18740
  const node = selection.focus.getNode();
18619
18741
  const nodeKey = node.getKey();
@@ -18627,7 +18749,7 @@ function TypeaheadMenuPlugin() {
18627
18749
  }
18628
18750
  const parentNodes = node.getParents();
18629
18751
  const isTableParent = parentNodes.findIndex(
18630
- (i) => i.getType() === TableNode9.getType()
18752
+ (i) => i.getType() === TableNode10.getType()
18631
18753
  ) >= 0;
18632
18754
  if (dom && !isTableParent) {
18633
18755
  if (isEmpty) {
@@ -19197,6 +19319,8 @@ var themeLight = `
19197
19319
  --be-bg-color-green: hsl(122, 100%, 23%, 0.1);
19198
19320
 
19199
19321
  --be-settings-node-selected-border-color: #7B00FF;
19322
+
19323
+ --be-bg-color-table-selection: hsl(221, 100%, 50%, 0.1);
19200
19324
  }
19201
19325
  `;
19202
19326
  var themeDark = `
@@ -19507,6 +19631,8 @@ var themeDark = `
19507
19631
  --be-bg-color-green: hsl(122, 100%, 34%, 0.2);
19508
19632
 
19509
19633
  --be-settings-node-selected-border-color: #7B00FF;
19634
+
19635
+ --be-bg-color-table-selection: hsl(221, 100%, 70%, 0.2);
19510
19636
  }
19511
19637
  `;
19512
19638
 
@@ -19658,7 +19784,7 @@ function BlockEditor(props) {
19658
19784
  [onChange]
19659
19785
  );
19660
19786
  useEffect89(() => {
19661
- if (editorState) {
19787
+ if (editorState && !editorRef.current?._pendingEditorState) {
19662
19788
  const parsedEditorState = editorRef.current?.parseEditorState(editorState);
19663
19789
  if (parsedEditorState) {
19664
19790
  editorRef.current?.setEditorState(parsedEditorState, {
@@ -19931,7 +20057,7 @@ import { mergeRegister as mergeRegister28 } from "@lexical/utils";
19931
20057
  import {
19932
20058
  $createRangeSelection as $createRangeSelection3,
19933
20059
  $getSelection as $getSelection19,
19934
- $isRangeSelection as $isRangeSelection11,
20060
+ $isRangeSelection as $isRangeSelection12,
19935
20061
  $isTextNode as $isTextNode8,
19936
20062
  $setSelection as $setSelection24,
19937
20063
  CLICK_COMMAND as CLICK_COMMAND13,
@@ -19981,7 +20107,7 @@ function LinkToolbarPlugin() {
19981
20107
  return;
19982
20108
  }
19983
20109
  const selection = $getSelection19();
19984
- if (!$isRangeSelection11(selection)) {
20110
+ if (!$isRangeSelection12(selection)) {
19985
20111
  popupToolbarRef.current?.hideToolbar();
19986
20112
  return;
19987
20113
  }
@@ -20915,15 +21041,24 @@ function VariableSettingsPlugin() {
20915
21041
 
20916
21042
  // src/plugins/VariablesPlugin/VariableToolbarPlugin.tsx
20917
21043
  import { useLexicalComposerContext as useLexicalComposerContext77 } from "@lexical/react/LexicalComposerContext";
20918
- import { mergeRegister as mergeRegister31 } from "@lexical/utils";
21044
+ import { $findMatchingParent as $findMatchingParent4, mergeRegister as mergeRegister31 } from "@lexical/utils";
20919
21045
  import {
20920
21046
  $getNodeByKey as $getNodeByKey62,
20921
21047
  $getSelection as $getSelection20,
21048
+ $isElementNode as $isElementNode8,
20922
21049
  $isNodeSelection as $isNodeSelection6,
21050
+ $isRootOrShadowRoot as $isRootOrShadowRoot3,
20923
21051
  COMMAND_PRIORITY_NORMAL as COMMAND_PRIORITY_NORMAL4
20924
21052
  } from "lexical";
20925
21053
  import debounce8 from "lodash-es/debounce";
20926
- import { Bold as Bold2, Italic as Italic2, Underline as Underline2 } from "lucide-react";
21054
+ import {
21055
+ AlignCenter as AlignCenter4,
21056
+ AlignLeft as AlignLeft4,
21057
+ AlignRight as AlignRight4,
21058
+ Bold as Bold2,
21059
+ Italic as Italic2,
21060
+ Underline as Underline2
21061
+ } from "lucide-react";
20927
21062
  import {
20928
21063
  useCallback as useCallback19,
20929
21064
  useEffect as useEffect102,
@@ -20940,8 +21075,25 @@ function VariableToolbarPlugin() {
20940
21075
  const [toolbarState, setToolbarState] = useState25({
20941
21076
  isBold: false,
20942
21077
  isItalic: false,
20943
- isUnderline: false
21078
+ isUnderline: false,
21079
+ textAlign: ""
20944
21080
  });
21081
+ const formatElement = (format) => {
21082
+ activeEditorRef.current?.update(() => {
21083
+ const foundNode = $getNodeByKey62(
21084
+ selectedNodeRef.current?.getKey() || ""
21085
+ );
21086
+ if ($isVariableNode(foundNode)) {
21087
+ const element = $findMatchingParent4(
21088
+ foundNode,
21089
+ (parentNode) => $isElementNode8(parentNode) && !parentNode.isInline()
21090
+ );
21091
+ if (element !== null) {
21092
+ element.setFormat(format);
21093
+ }
21094
+ }
21095
+ });
21096
+ };
20945
21097
  function formatVariable(format) {
20946
21098
  activeEditorRef.current?.update(() => {
20947
21099
  const foundNode = $getNodeByKey62(
@@ -20992,6 +21144,21 @@ function VariableToolbarPlugin() {
20992
21144
  repositionPopupToolbar();
20993
21145
  e.preventDefault();
20994
21146
  e.stopPropagation();
21147
+ } else if (e.shiftKey && (e.key === "l" || e.key === "L")) {
21148
+ formatElement("left");
21149
+ repositionPopupToolbar();
21150
+ e.preventDefault();
21151
+ e.stopPropagation();
21152
+ } else if (e.shiftKey && (e.key === "e" || e.key === "E")) {
21153
+ formatElement("center");
21154
+ repositionPopupToolbar();
21155
+ e.preventDefault();
21156
+ e.stopPropagation();
21157
+ } else if (e.shiftKey && (e.key === "r" || e.key === "R")) {
21158
+ formatElement("right");
21159
+ repositionPopupToolbar();
21160
+ e.preventDefault();
21161
+ e.stopPropagation();
20995
21162
  }
20996
21163
  }
20997
21164
  } else {
@@ -21008,6 +21175,23 @@ function VariableToolbarPlugin() {
21008
21175
  repositionPopupToolbar();
21009
21176
  e.preventDefault();
21010
21177
  e.stopPropagation();
21178
+ } else if (e.ctrlKey && e.altKey) {
21179
+ if (e.key === "l" || e.key === "L") {
21180
+ formatElement("left");
21181
+ repositionPopupToolbar();
21182
+ e.preventDefault();
21183
+ e.stopPropagation();
21184
+ } else if (e.key === "e" || e.key === "E") {
21185
+ formatElement("center");
21186
+ repositionPopupToolbar();
21187
+ e.preventDefault();
21188
+ e.stopPropagation();
21189
+ } else if (e.key === "r" || e.key === "R") {
21190
+ formatElement("right");
21191
+ repositionPopupToolbar();
21192
+ e.preventDefault();
21193
+ e.stopPropagation();
21194
+ }
21011
21195
  }
21012
21196
  }
21013
21197
  }
@@ -21054,11 +21238,19 @@ function VariableToolbarPlugin() {
21054
21238
  const nodes = selection.extract();
21055
21239
  const focusedNode = nodes[0];
21056
21240
  if ($isVariableNode(focusedNode)) {
21241
+ const element = focusedNode.getKey() === "root" ? focusedNode : $findMatchingParent4(
21242
+ focusedNode,
21243
+ (e) => {
21244
+ const parent = e.getParent();
21245
+ return parent !== null && $isRootOrShadowRoot3(parent);
21246
+ }
21247
+ );
21057
21248
  selectedNodeRef.current = focusedNode;
21058
21249
  setToolbarState({
21059
21250
  isBold: !!focusedNode.getBold(),
21060
21251
  isItalic: !!focusedNode.getItalic(),
21061
- isUnderline: !!focusedNode.getUnderline()
21252
+ isUnderline: !!focusedNode.getUnderline(),
21253
+ textAlign: $isElementNode8(element) ? element.getFormatType() : "left"
21062
21254
  });
21063
21255
  }
21064
21256
  }
@@ -21120,6 +21312,44 @@ function VariableToolbarPlugin() {
21120
21312
  onClick: () => {
21121
21313
  formatVariable("underline");
21122
21314
  }
21315
+ },
21316
+ {
21317
+ id: "text-align",
21318
+ label: "",
21319
+ Icon: textAlignToIcon[toolbarState.textAlign] || AlignLeft4,
21320
+ tooltip: "Align Text",
21321
+ subMenu: [
21322
+ {
21323
+ id: "text-left",
21324
+ Icon: AlignLeft4,
21325
+ label: `Align Left ${plt === "macOS" /* macOS */ ? "(\u2318\u21E7L)" : "(Ctrl+Alt+L)"}`,
21326
+ selected: toolbarState.textAlign === "left",
21327
+ onClick: () => {
21328
+ formatElement("left");
21329
+ repositionPopupToolbar();
21330
+ }
21331
+ },
21332
+ {
21333
+ id: "text-center",
21334
+ Icon: AlignCenter4,
21335
+ label: `Align Center ${plt === "macOS" /* macOS */ ? "(\u2318\u21E7E)" : "(Ctrl+Alt+E)"}`,
21336
+ selected: toolbarState.textAlign === "center",
21337
+ onClick: () => {
21338
+ formatElement("center");
21339
+ repositionPopupToolbar();
21340
+ }
21341
+ },
21342
+ {
21343
+ id: "text-right",
21344
+ Icon: AlignRight4,
21345
+ label: `Align Right ${plt === "macOS" /* macOS */ ? "(\u2318\u21E7R)" : "(Ctrl+Alt+R)"}`,
21346
+ selected: toolbarState.textAlign === "right",
21347
+ onClick: () => {
21348
+ formatElement("right");
21349
+ repositionPopupToolbar();
21350
+ }
21351
+ }
21352
+ ]
21123
21353
  }
21124
21354
  ];
21125
21355
  return resultList;