@examind/block-editor 0.1.35 → 0.1.37
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.css +2 -2
- package/dist/index.js +1057 -848
- package/dist/index.mjs +349 -124
- package/package.json +2 -2
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
|
|
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 $
|
|
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 ($
|
|
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 $
|
|
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
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
if (
|
|
1326
|
-
rowIndex =
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
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
|
-
|
|
1343
|
-
newTableNode.
|
|
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 ($
|
|
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 $
|
|
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 ($
|
|
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 $
|
|
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 ($
|
|
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 $
|
|
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 ($
|
|
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 $
|
|
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 ($
|
|
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 $
|
|
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 ($
|
|
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 $
|
|
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 ($
|
|
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 ($
|
|
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 $
|
|
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 ($
|
|
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 ($
|
|
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
|
-
|
|
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:
|
|
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 (!$
|
|
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 $
|
|
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 ($
|
|
9223
|
+
if ($isRangeSelection3(selection)) {
|
|
9105
9224
|
lastSelectedNodeRef.current = selection.anchor.getNode();
|
|
9106
9225
|
}
|
|
9107
9226
|
return false;
|
|
@@ -9291,7 +9410,7 @@ var FillInTheBlankQuestionNode = class _FillInTheBlankQuestionNode extends Decor
|
|
|
9291
9410
|
}
|
|
9292
9411
|
setPointsPerSpace(points) {
|
|
9293
9412
|
const writable = this.getWritable();
|
|
9294
|
-
writable.__pointsPerSpace = points
|
|
9413
|
+
writable.__pointsPerSpace = points < 0 ? 1 : points;
|
|
9295
9414
|
}
|
|
9296
9415
|
decorate() {
|
|
9297
9416
|
return /* @__PURE__ */ jsx79(
|
|
@@ -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 $
|
|
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 ($
|
|
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 ($
|
|
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 ($
|
|
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 $
|
|
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 $
|
|
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 ($
|
|
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 ($
|
|
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 ===
|
|
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 $
|
|
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 ($
|
|
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 $
|
|
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 ($
|
|
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 ($
|
|
9917
|
+
if ($isRangeSelection5(currentSelection) && currentSelection.isCollapsed()) {
|
|
9799
9918
|
const firstChild = $getRoot11().getFirstChild();
|
|
9800
9919
|
if ($isParagraphNode2(firstChild)) {
|
|
9801
9920
|
const breakNodes = getLineBreakNodeBeforeCaretOnLastLine(
|
|
@@ -10619,8 +10738,8 @@ import { LinkNode } from "@lexical/link";
|
|
|
10619
10738
|
import { ListItemNode as ListItemNode2, ListNode } from "@lexical/list";
|
|
10620
10739
|
import { HeadingNode, QuoteNode } from "@lexical/rich-text";
|
|
10621
10740
|
import {
|
|
10622
|
-
TableCellNode as
|
|
10623
|
-
TableNode as
|
|
10741
|
+
TableCellNode as TableCellNode6,
|
|
10742
|
+
TableNode as TableNode5,
|
|
10624
10743
|
TableRowNode as TableRowNode5
|
|
10625
10744
|
} from "@lexical/table";
|
|
10626
10745
|
var commonEditorNodes = [
|
|
@@ -10633,8 +10752,8 @@ var commonEditorNodes = [
|
|
|
10633
10752
|
ListItemNode2,
|
|
10634
10753
|
CalloutBoxNode,
|
|
10635
10754
|
ListNode,
|
|
10636
|
-
|
|
10637
|
-
|
|
10755
|
+
TableCellNode6,
|
|
10756
|
+
TableNode5,
|
|
10638
10757
|
TableRowNode5,
|
|
10639
10758
|
VariableNode,
|
|
10640
10759
|
MultipleOptionQuestionNode,
|
|
@@ -10985,7 +11104,7 @@ var DropdownWrapper = forwardRef11((props, ref) => {
|
|
|
10985
11104
|
|
|
10986
11105
|
// src/utils/exportNodeToJSON.ts
|
|
10987
11106
|
import {
|
|
10988
|
-
$isElementNode as $
|
|
11107
|
+
$isElementNode as $isElementNode4
|
|
10989
11108
|
} from "lexical";
|
|
10990
11109
|
var LEXICAL_NODE_MIME_TYPE = "/application/x-lexical-node/";
|
|
10991
11110
|
function exportNodeToJSON(node) {
|
|
@@ -10996,7 +11115,7 @@ function exportNodeToJSON(node) {
|
|
|
10996
11115
|
`LexicalNode: Node ${nodeClass.name} does not match the serialized type. Check if .exportJSON() is implemented and it is returning the correct type.`
|
|
10997
11116
|
);
|
|
10998
11117
|
}
|
|
10999
|
-
if ($
|
|
11118
|
+
if ($isElementNode4(node)) {
|
|
11000
11119
|
const serializedChildren = serializedNode.children;
|
|
11001
11120
|
if (!Array.isArray(serializedChildren)) {
|
|
11002
11121
|
throw Error(
|
|
@@ -11016,16 +11135,14 @@ function exportNodeToJSON(node) {
|
|
|
11016
11135
|
// src/utils/traverseTableNode.ts
|
|
11017
11136
|
import {
|
|
11018
11137
|
$isTableCellNode as $isTableCellNode4,
|
|
11019
|
-
$isTableRowNode
|
|
11138
|
+
$isTableRowNode as $isTableRowNode2
|
|
11020
11139
|
} from "@lexical/table";
|
|
11021
11140
|
function traverseTableCellNodes(tableNode, cb) {
|
|
11022
11141
|
const rows = tableNode.getChildren();
|
|
11023
|
-
console.log("rows: ", rows);
|
|
11024
11142
|
if (rows.length > 0) {
|
|
11025
11143
|
for (const row of rows) {
|
|
11026
|
-
if ($
|
|
11144
|
+
if ($isTableRowNode2(row)) {
|
|
11027
11145
|
const cells = row.getChildren();
|
|
11028
|
-
console.log("cells: ", cells);
|
|
11029
11146
|
if (cells.length > 0) {
|
|
11030
11147
|
for (const cell of cells) {
|
|
11031
11148
|
if ($isTableCellNode4(cell)) {
|
|
@@ -11040,7 +11157,7 @@ function traverseTableCellNodes(tableNode, cb) {
|
|
|
11040
11157
|
|
|
11041
11158
|
// src/plugins/FillInTheBlankQuestionPlugin/FillInTheBlankQuestionPlugin.tsx
|
|
11042
11159
|
import { useLexicalComposerContext as useLexicalComposerContext51 } from "@lexical/react/LexicalComposerContext";
|
|
11043
|
-
import { $isTableNode as $
|
|
11160
|
+
import { $isTableNode as $isTableNode14 } from "@lexical/table";
|
|
11044
11161
|
import { mergeRegister as mergeRegister16 } from "@lexical/utils";
|
|
11045
11162
|
import {
|
|
11046
11163
|
$createNodeSelection as $createNodeSelection12,
|
|
@@ -11166,7 +11283,7 @@ function FillInTheBlankQuestionPlugin() {
|
|
|
11166
11283
|
fillInTheBlankNode = $createFillInTheBlankQuestionNode(1);
|
|
11167
11284
|
if (tableNodeKey) {
|
|
11168
11285
|
const foundTableNode = $getNodeByKey37(tableNodeKey);
|
|
11169
|
-
if ($
|
|
11286
|
+
if ($isTableNode14(foundTableNode)) {
|
|
11170
11287
|
nodeSerialized = exportNodeToJSON(foundTableNode);
|
|
11171
11288
|
serializedData = JSON.stringify(nodeSerialized);
|
|
11172
11289
|
foundTableNode.replace(fillInTheBlankNode);
|
|
@@ -11194,7 +11311,7 @@ function FillInTheBlankQuestionPlugin() {
|
|
|
11194
11311
|
const newNode = $parseSerializedNode(nodeSerialized2);
|
|
11195
11312
|
root.append(newNode);
|
|
11196
11313
|
const firstChild = root.getFirstChild();
|
|
11197
|
-
if ($
|
|
11314
|
+
if ($isTableNode14(firstChild)) {
|
|
11198
11315
|
traverseTableCellNodes(
|
|
11199
11316
|
firstChild,
|
|
11200
11317
|
(cell) => {
|
|
@@ -14058,7 +14175,7 @@ var useNode = () => {
|
|
|
14058
14175
|
|
|
14059
14176
|
// src/plugins/AutoBottomParagraphPlugin/AutoBottomParagraphPlugin.tsx
|
|
14060
14177
|
import { useLexicalComposerContext as useLexicalComposerContext60 } from "@lexical/react/LexicalComposerContext";
|
|
14061
|
-
import { TableNode as
|
|
14178
|
+
import { TableNode as TableNode7 } from "@lexical/table";
|
|
14062
14179
|
import { mergeRegister as mergeRegister21 } from "@lexical/utils";
|
|
14063
14180
|
import {
|
|
14064
14181
|
$createParagraphNode as $createParagraphNode16,
|
|
@@ -14091,7 +14208,7 @@ function AutoBottomParagraphPlugin() {
|
|
|
14091
14208
|
ImageNode2,
|
|
14092
14209
|
ImagePlaceholderNode,
|
|
14093
14210
|
CalloutBoxNode,
|
|
14094
|
-
|
|
14211
|
+
TableNode7,
|
|
14095
14212
|
MultipleOptionQuestionNode,
|
|
14096
14213
|
ShortAnswerQuestionNode,
|
|
14097
14214
|
MatchingQuestionNode,
|
|
@@ -14153,7 +14270,7 @@ import { useLexicalComposerContext as useLexicalComposerContext63 } from "@lexic
|
|
|
14153
14270
|
import {
|
|
14154
14271
|
$getRoot as $getRoot20,
|
|
14155
14272
|
$isDecoratorNode,
|
|
14156
|
-
$isElementNode as $
|
|
14273
|
+
$isElementNode as $isElementNode5,
|
|
14157
14274
|
$isLineBreakNode as $isLineBreakNode2,
|
|
14158
14275
|
$isTextNode as $isTextNode4
|
|
14159
14276
|
} from "lexical";
|
|
@@ -14408,7 +14525,7 @@ import {
|
|
|
14408
14525
|
$isListNode as $isListNode6
|
|
14409
14526
|
} from "@lexical/list";
|
|
14410
14527
|
import { $isQuoteNode as $isQuoteNode2 } from "@lexical/rich-text";
|
|
14411
|
-
import { $findMatchingParent } from "@lexical/utils";
|
|
14528
|
+
import { $findMatchingParent as $findMatchingParent2 } from "@lexical/utils";
|
|
14412
14529
|
import {
|
|
14413
14530
|
$createLineBreakNode as $createLineBreakNode2,
|
|
14414
14531
|
$createParagraphNode as $createParagraphNode17,
|
|
@@ -14437,7 +14554,7 @@ import {
|
|
|
14437
14554
|
$createRangeSelection,
|
|
14438
14555
|
$getSelection as $getSelection12,
|
|
14439
14556
|
$isLineBreakNode as $isLineBreakNode3,
|
|
14440
|
-
$isRangeSelection as $
|
|
14557
|
+
$isRangeSelection as $isRangeSelection6,
|
|
14441
14558
|
$isRootOrShadowRoot,
|
|
14442
14559
|
$isTextNode as $isTextNode5,
|
|
14443
14560
|
$setSelection as $setSelection18
|
|
@@ -14603,7 +14720,7 @@ function $runTextFormatTransformers(anchorNode, anchorOffset, textFormatTransfor
|
|
|
14603
14720
|
nextSelection.toggleFormat(format);
|
|
14604
14721
|
}
|
|
14605
14722
|
}
|
|
14606
|
-
if ($
|
|
14723
|
+
if ($isRangeSelection6(selection)) {
|
|
14607
14724
|
nextSelection.format = selection.format;
|
|
14608
14725
|
}
|
|
14609
14726
|
return true;
|
|
@@ -14686,7 +14803,7 @@ function registerMarkdownShortcuts(editor, transformers) {
|
|
|
14686
14803
|
}
|
|
14687
14804
|
const selection = editorState.read($getSelection12);
|
|
14688
14805
|
const prevSelection = prevEditorState.read($getSelection12);
|
|
14689
|
-
if (!$
|
|
14806
|
+
if (!$isRangeSelection6(prevSelection) || !$isRangeSelection6(selection) || !selection.isCollapsed()) {
|
|
14690
14807
|
return;
|
|
14691
14808
|
}
|
|
14692
14809
|
const anchorKey = selection.anchor.key;
|
|
@@ -15091,7 +15208,7 @@ import {
|
|
|
15091
15208
|
import { useLexicalComposerContext as useLexicalComposerContext65 } from "@lexical/react/LexicalComposerContext";
|
|
15092
15209
|
import { HorizontalRuleNode as HorizontalRuleNode3 } from "@lexical/react/LexicalHorizontalRuleNode";
|
|
15093
15210
|
import { HeadingNode as HeadingNode5 } from "@lexical/rich-text";
|
|
15094
|
-
import { $isTableCellNode as $isTableCellNode5, TableNode as
|
|
15211
|
+
import { $isTableCellNode as $isTableCellNode5, TableNode as TableNode8 } from "@lexical/table";
|
|
15095
15212
|
import { mergeRegister as mergeRegister22 } from "@lexical/utils";
|
|
15096
15213
|
import {
|
|
15097
15214
|
$createParagraphNode as $createParagraphNode18,
|
|
@@ -15436,7 +15553,7 @@ function NodeMousePlugin() {
|
|
|
15436
15553
|
ListNode5,
|
|
15437
15554
|
ParagraphNode4,
|
|
15438
15555
|
CalloutBoxNode,
|
|
15439
|
-
|
|
15556
|
+
TableNode8,
|
|
15440
15557
|
MultipleOptionQuestionNode,
|
|
15441
15558
|
ShortAnswerQuestionNode,
|
|
15442
15559
|
MatchingQuestionNode,
|
|
@@ -16536,7 +16653,7 @@ var PopupMenu = forwardRef16(
|
|
|
16536
16653
|
import {
|
|
16537
16654
|
$createNodeSelection as $createNodeSelection17,
|
|
16538
16655
|
$getSelection as $getSelection14,
|
|
16539
|
-
$isRangeSelection as $
|
|
16656
|
+
$isRangeSelection as $isRangeSelection7,
|
|
16540
16657
|
$setSelection as $setSelection20
|
|
16541
16658
|
} from "lexical";
|
|
16542
16659
|
function getFullMatchOffset(documentText, entryText, offset) {
|
|
@@ -16550,7 +16667,7 @@ function getFullMatchOffset(documentText, entryText, offset) {
|
|
|
16550
16667
|
}
|
|
16551
16668
|
function $splitNodeContainingQuery(replaceableString, matchingString) {
|
|
16552
16669
|
const selection = $getSelection14();
|
|
16553
|
-
if (!$
|
|
16670
|
+
if (!$isRangeSelection7(selection) || !selection.isCollapsed()) {
|
|
16554
16671
|
return null;
|
|
16555
16672
|
}
|
|
16556
16673
|
const anchor = selection.anchor;
|
|
@@ -16667,12 +16784,12 @@ function useTypeaheadTriggerMatch(trigger, {
|
|
|
16667
16784
|
}
|
|
16668
16785
|
|
|
16669
16786
|
// src/utils/visitVariableNodes.ts
|
|
16670
|
-
import { $isElementNode as $
|
|
16787
|
+
import { $isElementNode as $isElementNode6 } from "lexical";
|
|
16671
16788
|
function visitVariableNodes(rootNode, cb) {
|
|
16672
16789
|
if ($isVariableNode(rootNode)) {
|
|
16673
16790
|
cb(rootNode);
|
|
16674
16791
|
}
|
|
16675
|
-
if ($
|
|
16792
|
+
if ($isElementNode6(rootNode)) {
|
|
16676
16793
|
const children = rootNode.getChildren();
|
|
16677
16794
|
for (const childNode of children) {
|
|
16678
16795
|
visitVariableNodes(childNode, cb);
|
|
@@ -16779,7 +16896,7 @@ function getSelectionDOMRangeRect(editor, leadOffset) {
|
|
|
16779
16896
|
import {
|
|
16780
16897
|
$createRangeSelection as $createRangeSelection2,
|
|
16781
16898
|
$getSelection as $getSelection15,
|
|
16782
|
-
$isRangeSelection as $
|
|
16899
|
+
$isRangeSelection as $isRangeSelection8,
|
|
16783
16900
|
$setSelection as $setSelection21
|
|
16784
16901
|
} from "lexical";
|
|
16785
16902
|
function removeText(editorWindow, leadOffset) {
|
|
@@ -16808,7 +16925,7 @@ function removeTextInDomSelection(editor, leadOffset, onUpdate) {
|
|
|
16808
16925
|
() => {
|
|
16809
16926
|
const selection = $getSelection15();
|
|
16810
16927
|
let selectedNode;
|
|
16811
|
-
if ($
|
|
16928
|
+
if ($isRangeSelection8(selection)) {
|
|
16812
16929
|
selectedNode = selection.focus.getNode();
|
|
16813
16930
|
}
|
|
16814
16931
|
removeText(editorWindow, leadOffset);
|
|
@@ -16839,9 +16956,9 @@ import { mergeRegister as mergeRegister25 } from "@lexical/utils";
|
|
|
16839
16956
|
import {
|
|
16840
16957
|
$createNodeSelection as $createNodeSelection18,
|
|
16841
16958
|
$getSelection as $getSelection16,
|
|
16842
|
-
$isRangeSelection as $
|
|
16959
|
+
$isRangeSelection as $isRangeSelection9,
|
|
16843
16960
|
$setSelection as $setSelection22,
|
|
16844
|
-
COMMAND_PRIORITY_CRITICAL,
|
|
16961
|
+
COMMAND_PRIORITY_CRITICAL as COMMAND_PRIORITY_CRITICAL2,
|
|
16845
16962
|
COMMAND_PRIORITY_HIGH as COMMAND_PRIORITY_HIGH4,
|
|
16846
16963
|
KEY_ARROW_DOWN_COMMAND,
|
|
16847
16964
|
KEY_ARROW_UP_COMMAND,
|
|
@@ -16866,7 +16983,7 @@ function TypeaheadVariablePlugin() {
|
|
|
16866
16983
|
const handleUpdate = () => {
|
|
16867
16984
|
activeEditorRef.current?.getEditorState().read(() => {
|
|
16868
16985
|
const selection = $getSelection16();
|
|
16869
|
-
if ($
|
|
16986
|
+
if ($isRangeSelection9(selection)) {
|
|
16870
16987
|
if (selection.isCollapsed()) {
|
|
16871
16988
|
const anchor = selection.anchor;
|
|
16872
16989
|
const isEmpty = anchor.getNode().getTextContent().trim().length === 0;
|
|
@@ -17032,14 +17149,14 @@ function TypeaheadVariablePlugin() {
|
|
|
17032
17149
|
handleMenuItemSelect("down"),
|
|
17033
17150
|
// Highest priority
|
|
17034
17151
|
// Prevents any events from nested editors
|
|
17035
|
-
|
|
17152
|
+
COMMAND_PRIORITY_CRITICAL2
|
|
17036
17153
|
),
|
|
17037
17154
|
editor.registerCommand(
|
|
17038
17155
|
KEY_ARROW_UP_COMMAND,
|
|
17039
17156
|
handleMenuItemSelect("up"),
|
|
17040
17157
|
// Highest priority
|
|
17041
17158
|
// Prevents any events from nested editors
|
|
17042
|
-
|
|
17159
|
+
COMMAND_PRIORITY_CRITICAL2
|
|
17043
17160
|
),
|
|
17044
17161
|
editor.registerCommand(
|
|
17045
17162
|
CREATE_VARIABLE_FROM_SELECTION_COMMAND,
|
|
@@ -17209,15 +17326,15 @@ import {
|
|
|
17209
17326
|
$getSelectionStyleValueForProperty,
|
|
17210
17327
|
$patchStyleText
|
|
17211
17328
|
} from "@lexical/selection";
|
|
17212
|
-
import { TableNode as
|
|
17213
|
-
import { $findMatchingParent as $
|
|
17329
|
+
import { TableNode as TableNode9 } from "@lexical/table";
|
|
17330
|
+
import { $findMatchingParent as $findMatchingParent3, mergeRegister as mergeRegister26 } from "@lexical/utils";
|
|
17214
17331
|
import {
|
|
17215
17332
|
$getSelection as $getSelection17,
|
|
17216
17333
|
$isDecoratorNode as $isDecoratorNode2,
|
|
17217
|
-
$isElementNode as $
|
|
17334
|
+
$isElementNode as $isElementNode7,
|
|
17218
17335
|
$isNodeSelection as $isNodeSelection5,
|
|
17219
17336
|
$isParagraphNode as $isParagraphNode8,
|
|
17220
|
-
$isRangeSelection as $
|
|
17337
|
+
$isRangeSelection as $isRangeSelection10,
|
|
17221
17338
|
$isRootOrShadowRoot as $isRootOrShadowRoot2,
|
|
17222
17339
|
$isTextNode as $isTextNode7,
|
|
17223
17340
|
$setSelection as $setSelection23,
|
|
@@ -17279,7 +17396,7 @@ function TextToolbarPlugin() {
|
|
|
17279
17396
|
const formatText = (format) => {
|
|
17280
17397
|
activeEditorRef.current?.update(() => {
|
|
17281
17398
|
const selection = $getSelection17();
|
|
17282
|
-
if (!$
|
|
17399
|
+
if (!$isRangeSelection10(selection)) {
|
|
17283
17400
|
return false;
|
|
17284
17401
|
}
|
|
17285
17402
|
selection.formatText(format);
|
|
@@ -17288,14 +17405,14 @@ function TextToolbarPlugin() {
|
|
|
17288
17405
|
const formatElement = (format) => {
|
|
17289
17406
|
activeEditorRef.current?.update(() => {
|
|
17290
17407
|
const selection = $getSelection17();
|
|
17291
|
-
if (!$
|
|
17408
|
+
if (!$isRangeSelection10(selection) && !$isNodeSelection5(selection)) {
|
|
17292
17409
|
return false;
|
|
17293
17410
|
}
|
|
17294
17411
|
const nodes = selection.getNodes();
|
|
17295
17412
|
for (const node of nodes) {
|
|
17296
|
-
const element = $
|
|
17413
|
+
const element = $findMatchingParent3(
|
|
17297
17414
|
node,
|
|
17298
|
-
(parentNode) => $
|
|
17415
|
+
(parentNode) => $isElementNode7(parentNode) && !parentNode.isInline()
|
|
17299
17416
|
);
|
|
17300
17417
|
if (element !== null) {
|
|
17301
17418
|
element.setFormat(format);
|
|
@@ -17365,7 +17482,7 @@ function TextToolbarPlugin() {
|
|
|
17365
17482
|
"font-size": null,
|
|
17366
17483
|
"font-weight": null
|
|
17367
17484
|
});
|
|
17368
|
-
if ($
|
|
17485
|
+
if ($isRangeSelection10(selection)) {
|
|
17369
17486
|
const selectedNodes = selection.getNodes();
|
|
17370
17487
|
for (const selectedNode of selectedNodes) {
|
|
17371
17488
|
if ($isTextNode7(selectedNode)) {
|
|
@@ -17416,7 +17533,7 @@ function TextToolbarPlugin() {
|
|
|
17416
17533
|
activeEditorRef.current?.getEditorState().read(() => {
|
|
17417
17534
|
const foundParentTableNode = getParentNodeType(
|
|
17418
17535
|
selectedNode,
|
|
17419
|
-
|
|
17536
|
+
TableNode9
|
|
17420
17537
|
);
|
|
17421
17538
|
if (foundParentTableNode) {
|
|
17422
17539
|
activeEditorRef.current?.dispatchCommand(
|
|
@@ -17537,7 +17654,7 @@ function TextToolbarPlugin() {
|
|
|
17537
17654
|
popupToolbarRef.current?.hideToolbar();
|
|
17538
17655
|
return false;
|
|
17539
17656
|
}
|
|
17540
|
-
if (!$
|
|
17657
|
+
if (!$isRangeSelection10(selection)) {
|
|
17541
17658
|
popupToolbarRef.current?.hideToolbar();
|
|
17542
17659
|
return false;
|
|
17543
17660
|
}
|
|
@@ -17559,7 +17676,7 @@ function TextToolbarPlugin() {
|
|
|
17559
17676
|
return false;
|
|
17560
17677
|
}
|
|
17561
17678
|
const anchorNode = selection.anchor.getNode();
|
|
17562
|
-
let element = anchorNode.getKey() === "root" ? anchorNode : $
|
|
17679
|
+
let element = anchorNode.getKey() === "root" ? anchorNode : $findMatchingParent3(
|
|
17563
17680
|
anchorNode,
|
|
17564
17681
|
(e) => {
|
|
17565
17682
|
const parent = e.getParent();
|
|
@@ -17622,7 +17739,7 @@ function TextToolbarPlugin() {
|
|
|
17622
17739
|
"background-color",
|
|
17623
17740
|
""
|
|
17624
17741
|
);
|
|
17625
|
-
if ($
|
|
17742
|
+
if ($isElementNode7(element)) {
|
|
17626
17743
|
newToolbarState.textAlign = element.getFormatType();
|
|
17627
17744
|
} else {
|
|
17628
17745
|
newToolbarState.textAlign = "left";
|
|
@@ -17940,7 +18057,7 @@ function TextToolbarPlugin() {
|
|
|
17940
18057
|
activeEditorRef.current?.getEditorState().read(() => {
|
|
17941
18058
|
const foundParentTableNode = getParentNodeType(
|
|
17942
18059
|
selectedNode,
|
|
17943
|
-
|
|
18060
|
+
TableNode9
|
|
17944
18061
|
);
|
|
17945
18062
|
if (foundParentTableNode) {
|
|
17946
18063
|
activeEditorRef.current?.dispatchCommand(
|
|
@@ -18473,7 +18590,7 @@ function useTypeaheadTriggerMatch2(trigger, {
|
|
|
18473
18590
|
// src/plugins/TypeaheadMenuPlugin/TypeaheadMenuPlugin.tsx
|
|
18474
18591
|
import { useLexicalComposerContext as useLexicalComposerContext70 } from "@lexical/react/LexicalComposerContext";
|
|
18475
18592
|
import { $isHeadingNode as $isHeadingNode5 } from "@lexical/rich-text";
|
|
18476
|
-
import { $isTableCellNode as $isTableCellNode6, TableNode as
|
|
18593
|
+
import { $isTableCellNode as $isTableCellNode6, TableNode as TableNode10 } from "@lexical/table";
|
|
18477
18594
|
import { mergeRegister as mergeRegister27 } from "@lexical/utils";
|
|
18478
18595
|
import {
|
|
18479
18596
|
$createParagraphNode as $createParagraphNode21,
|
|
@@ -18481,7 +18598,7 @@ import {
|
|
|
18481
18598
|
$getRoot as $getRoot24,
|
|
18482
18599
|
$getSelection as $getSelection18,
|
|
18483
18600
|
$isParagraphNode as $isParagraphNode9,
|
|
18484
|
-
$isRangeSelection as $
|
|
18601
|
+
$isRangeSelection as $isRangeSelection11,
|
|
18485
18602
|
BLUR_COMMAND,
|
|
18486
18603
|
COMMAND_PRIORITY_HIGH as COMMAND_PRIORITY_HIGH6,
|
|
18487
18604
|
KEY_ARROW_DOWN_COMMAND as KEY_ARROW_DOWN_COMMAND2,
|
|
@@ -18618,7 +18735,7 @@ function TypeaheadMenuPlugin() {
|
|
|
18618
18735
|
const handleUpdate = () => {
|
|
18619
18736
|
activeEditorRef.current?.getEditorState().read(() => {
|
|
18620
18737
|
const selection = $getSelection18();
|
|
18621
|
-
if ($
|
|
18738
|
+
if ($isRangeSelection11(selection)) {
|
|
18622
18739
|
if (selection.isCollapsed()) {
|
|
18623
18740
|
const node = selection.focus.getNode();
|
|
18624
18741
|
const nodeKey = node.getKey();
|
|
@@ -18632,7 +18749,7 @@ function TypeaheadMenuPlugin() {
|
|
|
18632
18749
|
}
|
|
18633
18750
|
const parentNodes = node.getParents();
|
|
18634
18751
|
const isTableParent = parentNodes.findIndex(
|
|
18635
|
-
(i) => i.getType() ===
|
|
18752
|
+
(i) => i.getType() === TableNode10.getType()
|
|
18636
18753
|
) >= 0;
|
|
18637
18754
|
if (dom && !isTableParent) {
|
|
18638
18755
|
if (isEmpty) {
|
|
@@ -19202,6 +19319,8 @@ var themeLight = `
|
|
|
19202
19319
|
--be-bg-color-green: hsl(122, 100%, 23%, 0.1);
|
|
19203
19320
|
|
|
19204
19321
|
--be-settings-node-selected-border-color: #7B00FF;
|
|
19322
|
+
|
|
19323
|
+
--be-bg-color-table-selection: hsl(221, 100%, 50%, 0.1);
|
|
19205
19324
|
}
|
|
19206
19325
|
`;
|
|
19207
19326
|
var themeDark = `
|
|
@@ -19512,6 +19631,8 @@ var themeDark = `
|
|
|
19512
19631
|
--be-bg-color-green: hsl(122, 100%, 34%, 0.2);
|
|
19513
19632
|
|
|
19514
19633
|
--be-settings-node-selected-border-color: #7B00FF;
|
|
19634
|
+
|
|
19635
|
+
--be-bg-color-table-selection: hsl(221, 100%, 70%, 0.2);
|
|
19515
19636
|
}
|
|
19516
19637
|
`;
|
|
19517
19638
|
|
|
@@ -19663,7 +19784,7 @@ function BlockEditor(props) {
|
|
|
19663
19784
|
[onChange]
|
|
19664
19785
|
);
|
|
19665
19786
|
useEffect89(() => {
|
|
19666
|
-
if (editorState) {
|
|
19787
|
+
if (editorState && !editorRef.current?._pendingEditorState) {
|
|
19667
19788
|
const parsedEditorState = editorRef.current?.parseEditorState(editorState);
|
|
19668
19789
|
if (parsedEditorState) {
|
|
19669
19790
|
editorRef.current?.setEditorState(parsedEditorState, {
|
|
@@ -19936,7 +20057,7 @@ import { mergeRegister as mergeRegister28 } from "@lexical/utils";
|
|
|
19936
20057
|
import {
|
|
19937
20058
|
$createRangeSelection as $createRangeSelection3,
|
|
19938
20059
|
$getSelection as $getSelection19,
|
|
19939
|
-
$isRangeSelection as $
|
|
20060
|
+
$isRangeSelection as $isRangeSelection12,
|
|
19940
20061
|
$isTextNode as $isTextNode8,
|
|
19941
20062
|
$setSelection as $setSelection24,
|
|
19942
20063
|
CLICK_COMMAND as CLICK_COMMAND13,
|
|
@@ -19986,7 +20107,7 @@ function LinkToolbarPlugin() {
|
|
|
19986
20107
|
return;
|
|
19987
20108
|
}
|
|
19988
20109
|
const selection = $getSelection19();
|
|
19989
|
-
if (!$
|
|
20110
|
+
if (!$isRangeSelection12(selection)) {
|
|
19990
20111
|
popupToolbarRef.current?.hideToolbar();
|
|
19991
20112
|
return;
|
|
19992
20113
|
}
|
|
@@ -20920,15 +21041,24 @@ function VariableSettingsPlugin() {
|
|
|
20920
21041
|
|
|
20921
21042
|
// src/plugins/VariablesPlugin/VariableToolbarPlugin.tsx
|
|
20922
21043
|
import { useLexicalComposerContext as useLexicalComposerContext77 } from "@lexical/react/LexicalComposerContext";
|
|
20923
|
-
import { mergeRegister as mergeRegister31 } from "@lexical/utils";
|
|
21044
|
+
import { $findMatchingParent as $findMatchingParent4, mergeRegister as mergeRegister31 } from "@lexical/utils";
|
|
20924
21045
|
import {
|
|
20925
21046
|
$getNodeByKey as $getNodeByKey62,
|
|
20926
21047
|
$getSelection as $getSelection20,
|
|
21048
|
+
$isElementNode as $isElementNode8,
|
|
20927
21049
|
$isNodeSelection as $isNodeSelection6,
|
|
21050
|
+
$isRootOrShadowRoot as $isRootOrShadowRoot3,
|
|
20928
21051
|
COMMAND_PRIORITY_NORMAL as COMMAND_PRIORITY_NORMAL4
|
|
20929
21052
|
} from "lexical";
|
|
20930
21053
|
import debounce8 from "lodash-es/debounce";
|
|
20931
|
-
import {
|
|
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";
|
|
20932
21062
|
import {
|
|
20933
21063
|
useCallback as useCallback19,
|
|
20934
21064
|
useEffect as useEffect102,
|
|
@@ -20945,8 +21075,25 @@ function VariableToolbarPlugin() {
|
|
|
20945
21075
|
const [toolbarState, setToolbarState] = useState25({
|
|
20946
21076
|
isBold: false,
|
|
20947
21077
|
isItalic: false,
|
|
20948
|
-
isUnderline: false
|
|
21078
|
+
isUnderline: false,
|
|
21079
|
+
textAlign: ""
|
|
20949
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
|
+
};
|
|
20950
21097
|
function formatVariable(format) {
|
|
20951
21098
|
activeEditorRef.current?.update(() => {
|
|
20952
21099
|
const foundNode = $getNodeByKey62(
|
|
@@ -20997,6 +21144,21 @@ function VariableToolbarPlugin() {
|
|
|
20997
21144
|
repositionPopupToolbar();
|
|
20998
21145
|
e.preventDefault();
|
|
20999
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();
|
|
21000
21162
|
}
|
|
21001
21163
|
}
|
|
21002
21164
|
} else {
|
|
@@ -21013,6 +21175,23 @@ function VariableToolbarPlugin() {
|
|
|
21013
21175
|
repositionPopupToolbar();
|
|
21014
21176
|
e.preventDefault();
|
|
21015
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
|
+
}
|
|
21016
21195
|
}
|
|
21017
21196
|
}
|
|
21018
21197
|
}
|
|
@@ -21059,11 +21238,19 @@ function VariableToolbarPlugin() {
|
|
|
21059
21238
|
const nodes = selection.extract();
|
|
21060
21239
|
const focusedNode = nodes[0];
|
|
21061
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
|
+
);
|
|
21062
21248
|
selectedNodeRef.current = focusedNode;
|
|
21063
21249
|
setToolbarState({
|
|
21064
21250
|
isBold: !!focusedNode.getBold(),
|
|
21065
21251
|
isItalic: !!focusedNode.getItalic(),
|
|
21066
|
-
isUnderline: !!focusedNode.getUnderline()
|
|
21252
|
+
isUnderline: !!focusedNode.getUnderline(),
|
|
21253
|
+
textAlign: $isElementNode8(element) ? element.getFormatType() : "left"
|
|
21067
21254
|
});
|
|
21068
21255
|
}
|
|
21069
21256
|
}
|
|
@@ -21125,6 +21312,44 @@ function VariableToolbarPlugin() {
|
|
|
21125
21312
|
onClick: () => {
|
|
21126
21313
|
formatVariable("underline");
|
|
21127
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
|
+
]
|
|
21128
21353
|
}
|
|
21129
21354
|
];
|
|
21130
21355
|
return resultList;
|