@mx-space/cli 0.13.0 → 0.13.2
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/README.md +23 -1
- package/dist/{Lexical.dev-By5dOKBN.mjs → Lexical.dev-BsbWMhb3.mjs} +2265 -429
- package/dist/{Lexical.node-fXM8Jp7p.mjs → Lexical.node-DnR_u_Ke.mjs} +47 -10
- package/dist/Lexical.prod-B7L8eVsO.mjs +6816 -0
- package/dist/{LexicalClipboard.dev--HxGoSkO.mjs → LexicalClipboard.dev-BGSFbuTA.mjs} +131 -39
- package/dist/{LexicalClipboard.node-C3mRbrmW.mjs → LexicalClipboard.node-CUD_tpWb.mjs} +2 -2
- package/dist/LexicalClipboard.prod-DQXfRt3h.mjs +429 -0
- package/dist/{LexicalCodeCore.dev-DjSrd4A4.mjs → LexicalCodeCore.dev-B9lK_GSN.mjs} +81 -67
- package/dist/LexicalCodeCore.prod-CNWMPXhg.mjs +651 -0
- package/dist/LexicalDragon.dev-DRm2bGZ1.mjs +186 -0
- package/dist/{LexicalDragon.node-BVhw4C7s.mjs → LexicalDragon.node-d8gPruly.mjs} +3 -2
- package/dist/LexicalDragon.prod-ey3uKDJF.mjs +121 -0
- package/dist/{LexicalExtension.dev-BPNyvGqe.mjs → LexicalExtension.dev-CXtOJb83.mjs} +349 -35
- package/dist/{LexicalExtension.node-BVlcrgOx.mjs → LexicalExtension.node-CMsupJZs.mjs} +9 -4
- package/dist/{LexicalExtension.prod-DFKbiNt-.mjs → LexicalExtension.prod-BCLGhzcg.mjs} +477 -328
- package/dist/{LexicalHeadless.dev-B-cj7Pr5.mjs → LexicalHeadless.dev-yVDOBd64.mjs} +2 -2
- package/dist/{LexicalHeadless.prod-Byp1vNzT.mjs → LexicalHeadless.prod-B8qauuEA.mjs} +2 -2
- package/dist/{LexicalHtml.dev-prBAwszN.mjs → LexicalHtml.dev-3rdckXIU.mjs} +323 -265
- package/dist/{LexicalHtml.node-BvNF96jZ.mjs → LexicalHtml.node-DagZUjQ_.mjs} +6 -4
- package/dist/{LexicalHtml.prod-Sz3CW1ht.mjs → LexicalHtml.prod-B5AQaJDb.mjs} +354 -352
- package/dist/{LexicalLink.dev-NySTYhVR.mjs → LexicalLink.dev-CspSwLNB.mjs} +69 -58
- package/dist/{LexicalLink.prod-BuCM8gts.mjs → LexicalLink.prod-Da-ZW6H5.mjs} +210 -211
- package/dist/{LexicalList.dev-DIMOvSFD.mjs → LexicalList.dev-CNXmV6v8.mjs} +246 -198
- package/dist/LexicalList.prod-DgQzj4v9.mjs +944 -0
- package/dist/{LexicalMarkdown.dev-C7aylvCG.mjs → LexicalMarkdown.dev-0XURdo96.mjs} +129 -37
- package/dist/LexicalMarkdown.prod-qUsIQfJx.mjs +932 -0
- package/dist/{LexicalRichText.dev-DfICq6lU.mjs → LexicalRichText.dev-BqsEA7I9.mjs} +151 -122
- package/dist/{LexicalRichText.node-Bg9jND3Q.mjs → LexicalRichText.node-D73RR0Ck.mjs} +8 -11
- package/dist/LexicalRichText.prod-4Atyd7OR.mjs +538 -0
- package/dist/{LexicalSelection.dev-DGjj12wW.mjs → LexicalSelection.dev-DK5xfxKP.mjs} +10 -9
- package/dist/{LexicalSelection.node-BU5L4193.mjs → LexicalSelection.node-pyZyrANz.mjs} +4 -4
- package/dist/{LexicalSelection.prod-D-PwRbyK.mjs → LexicalSelection.prod-C5GrCbDC.mjs} +144 -146
- package/dist/{LexicalTable.dev-ChP7cugd.mjs → LexicalTable.dev-DiR_4rdI.mjs} +184 -119
- package/dist/LexicalTable.prod-Cbc5EasT.mjs +2336 -0
- package/dist/{LexicalUtils.dev-BiFU3789.mjs → LexicalUtils.dev-jhPjn1vQ.mjs} +375 -35
- package/dist/{LexicalUtils.node-j3Llm7Y3.mjs → LexicalUtils.node-Ck74ludK.mjs} +24 -12
- package/dist/LexicalUtils.prod-nuTBxnk_.mjs +504 -0
- package/dist/bin/mxs.mjs +1 -1
- package/dist/esm-BumPuCXw.mjs +2 -0
- package/dist/{esm-lpolVSUJ.mjs → esm-DupC6TTP.mjs} +172 -172
- package/dist/index.d.mts +16 -16
- package/dist/index.mjs +1 -1
- package/dist/{mxs-PFV8OJ-M.mjs → mxs-BgAyMQdq.mjs} +1595 -314
- package/package.json +17 -17
- package/dist/Lexical.prod-BlCvXPGa.mjs +0 -6088
- package/dist/LexicalClipboard.prod-DNJzFMcT.mjs +0 -371
- package/dist/LexicalCodeCore.prod-DTDShkR3.mjs +0 -642
- package/dist/LexicalDragon.dev-DwprRH0z.mjs +0 -88
- package/dist/LexicalDragon.prod-nh4J-8vn.mjs +0 -59
- package/dist/LexicalList.prod-MVqfA6Vo.mjs +0 -925
- package/dist/LexicalMarkdown.prod-CfQSM406.mjs +0 -868
- package/dist/LexicalRichText.prod-GsFzCK-o.mjs +0 -550
- package/dist/LexicalTable.prod-Bpr9YRXp.mjs +0 -2311
- package/dist/LexicalUtils.prod-DCvrA78p.mjs +0 -373
- package/dist/esm-DGvoYR6n.mjs +0 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { f as namedSignals, l as effect, p as signal } from "./LexicalExtension.node-
|
|
2
|
-
import { $ as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { o as copyToClipboard, t as $getClipboardDataFromSelection } from "./LexicalClipboard.node-
|
|
6
|
-
//#region ../../node_modules/.pnpm/@lexical+table@0.
|
|
1
|
+
import { f as namedSignals, l as effect, p as signal } from "./LexicalExtension.node-CMsupJZs.mjs";
|
|
2
|
+
import { $t as CONTROLLED_TEXT_INSERTION_COMMAND, A as $getChildCaret, An as IS_FIREFOX, B as $getNodeByKeyOrThrow, Bn as KEY_ARROW_LEFT_COMMAND, Br as isDOMDocumentNode, C as $getAdjacentChildCaret, Ct as $normalizeCaret, Dn as IS_BOLD, Dr as getDOMSelectionRange, Er as getDOMSelectionPoints, Fn as IS_STRIKETHROUGH, G as $getSiblingCaret, H as $getPreviousSelection, Hn as KEY_ARROW_UP_COMMAND, Hr as isDOMShadowRoot, Ht as CLICK_COMMAND, I as $getEditor, Jn as KEY_TAB_COMMAND, Jr as isHTMLTableRowElement, Jt as COMMAND_PRIORITY_HIGH, Kn as KEY_ESCAPE_COMMAND, Mt as $setSelection, Nn as IS_ITALIC, R as $getNearestNodeFromDOMNode, Rn as IS_UNDERLINE, Tr as getDOMSelection, U as $getRoot, Un as KEY_BACKSPACE_COMMAND, Vn as KEY_ARROW_RIGHT_COMMAND, Vr as isDOMNode, W as $getSelection, Wn as KEY_DELETE_COMMAND, Yt as COMMAND_PRIORITY_LOW, _t as $isSiblingCaret, ai as safeCast, an as DELETE_LINE_COMMAND, ar as SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, at as $isElementNode, b as $findMatchingParent, bn as INSERT_PARAGRAPH_COMMAND, br as defineExtension, bt as $isTextNode, dn as ElementNode, fn as FOCUS_COMMAND, ft as $isParagraphNode, g as $createRangeSelectionFromDom, gr as createCommand, h as $createRangeSelection, hr as configExtension, ht as $isRootOrShadowRoot, i as $caretFromPoint, ii as removeClassNamesFromElement, in as DELETE_CHARACTER_COMMAND, ir as SELECTION_CHANGE_COMMAND, jt as $setPointFromCaret, m as $createPoint, mn as FORMAT_TEXT_COMMAND, mt as $isRootNode, n as $applyNodeReplacement, ni as mergeRegister, nt as $isChildCaret, oi as setDOMStyleFromCSS, on as DELETE_WORD_COMMAND, or as SELECT_ALL_COMMAND, ot as $isExtendableTextPointCaret, p as $createParagraphNode, pn as FORMAT_ELEMENT_COMMAND, pr as addClassNamesToElement, pt as $isRangeSelection, qr as isHTMLElement, qt as COMMAND_PRIORITY_EDITOR, si as setDOMUnmanaged, st as $isInlineElementOrDecoratorNode, tn as CUT_COMMAND, ur as TEXT_TYPE_TO_FORMAT, ut as $isLineBreakNode, v as $createTextNode, wr as getComposedEventTarget, wt as $normalizeSelection__EXPERIMENTAL, x as $fullReconcile, y as $extendCaretToRange, z as $getNodeByKey, zn as KEY_ARROW_DOWN_COMMAND, zr as isCurrentlyReadOnlyMode } from "./Lexical.node-DnR_u_Ke.mjs";
|
|
3
|
+
import { c as DOMImportExtension, f as ImportTextFormat, h as defineImportRule, m as contextValue, o as $propagateTextAlignToBlockChildren, p as ImportTextStyle, s as CoreImportExtension, v as sel } from "./LexicalHtml.node-DagZUjQ_.mjs";
|
|
4
|
+
import { d as $unwrapAndFilterDescendants, h as objectKlassEquals, n as $dfsWithSlots, o as $insertFirst$1, s as $insertNodeToNearestRoot, t as $descendantsMatching } from "./LexicalUtils.node-Ck74ludK.mjs";
|
|
5
|
+
import { o as copyToClipboard, t as $getClipboardDataFromSelection } from "./LexicalClipboard.node-CUD_tpWb.mjs";
|
|
6
|
+
//#region ../../node_modules/.pnpm/@lexical+table@0.46.0_typescript@6.0.3/node_modules/@lexical/table/dist/LexicalTable.dev.mjs
|
|
7
7
|
/**
|
|
8
8
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
9
9
|
*
|
|
@@ -290,7 +290,7 @@ function $isTableCellNode(node) {
|
|
|
290
290
|
* LICENSE file in the root directory of this source tree.
|
|
291
291
|
*
|
|
292
292
|
*/
|
|
293
|
-
const INSERT_TABLE_COMMAND = createCommand("INSERT_TABLE_COMMAND");
|
|
293
|
+
const INSERT_TABLE_COMMAND = /* @__PURE__ */ createCommand("INSERT_TABLE_COMMAND");
|
|
294
294
|
/**
|
|
295
295
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
296
296
|
*
|
|
@@ -709,7 +709,7 @@ function $deleteTableRowAtSelection() {
|
|
|
709
709
|
cell.setRowSpan(cell.__rowSpan - overflowRowsCount);
|
|
710
710
|
}
|
|
711
711
|
if (cellStartRow >= anchorStartRow && cellStartRow + cell.__rowSpan - 1 > focusEndRow && row === focusEndRow) {
|
|
712
|
-
if (
|
|
712
|
+
if (!$isTableRowNode(nextRowNode)) formatDevErrorMessage(`Expected a TableRowNode`);
|
|
713
713
|
let insertAfterCell = null;
|
|
714
714
|
for (let columnIndex = 0; columnIndex < column; columnIndex++) {
|
|
715
715
|
const currentCellMap = nextRow[columnIndex];
|
|
@@ -1079,13 +1079,13 @@ function $moveTableColumn(tableNode, originColumn, targetColumn) {
|
|
|
1079
1079
|
}
|
|
1080
1080
|
function $getTableCellNodeRect(tableCellNode) {
|
|
1081
1081
|
const [cellNode, , gridNode] = $getNodeTriplet(tableCellNode);
|
|
1082
|
-
const rows = gridNode.getChildren();
|
|
1082
|
+
const rows = gridNode.getChildren().filter($isTableRowNode);
|
|
1083
1083
|
const rowCount = rows.length;
|
|
1084
1084
|
const columnCount = rows[0].getChildren().length;
|
|
1085
1085
|
const cellMatrix = new Array(rowCount);
|
|
1086
1086
|
for (let i = 0; i < rowCount; i++) cellMatrix[i] = new Array(columnCount);
|
|
1087
1087
|
for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
1088
|
-
const cells = rows[rowIndex].getChildren();
|
|
1088
|
+
const cells = rows[rowIndex].getChildren().filter($isTableCellNode);
|
|
1089
1089
|
let columnIndex = 0;
|
|
1090
1090
|
for (let cellIndex = 0; cellIndex < cells.length; cellIndex++) {
|
|
1091
1091
|
while (cellMatrix[rowIndex][columnIndex]) columnIndex++;
|
|
@@ -1379,6 +1379,50 @@ var TableObservers = class {
|
|
|
1379
1379
|
}
|
|
1380
1380
|
return null;
|
|
1381
1381
|
}
|
|
1382
|
+
/**
|
|
1383
|
+
* @internal
|
|
1384
|
+
* Remove the observer for tableKey from the registry and unregister all
|
|
1385
|
+
* of its listeners, e.g. because the table was removed from the document
|
|
1386
|
+
* or its DOM was recreated.
|
|
1387
|
+
*
|
|
1388
|
+
* @returns true if an observer was registered for tableKey
|
|
1389
|
+
*/
|
|
1390
|
+
removeObserver(tableKey) {
|
|
1391
|
+
const observerAndElement = this.observers.get(tableKey);
|
|
1392
|
+
if (observerAndElement === void 0) return false;
|
|
1393
|
+
observerAndElement[0].removeListeners();
|
|
1394
|
+
this.observers.delete(tableKey);
|
|
1395
|
+
return true;
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* @internal
|
|
1399
|
+
* Remove all observers from the registry and unregister their listeners,
|
|
1400
|
+
* e.g. because the table selection observer is being unregistered.
|
|
1401
|
+
*/
|
|
1402
|
+
removeAllObservers() {
|
|
1403
|
+
for (const tableKey of Array.from(this.observers.keys())) this.removeObserver(tableKey);
|
|
1404
|
+
}
|
|
1405
|
+
/**
|
|
1406
|
+
* @internal
|
|
1407
|
+
* Get a snapshot of the registry as [TableNode, TableObserver] pairs for
|
|
1408
|
+
* the current editor state. A table's destroyed mutation can be missed
|
|
1409
|
+
* entirely (e.g. when it is removed during an update while the editor's
|
|
1410
|
+
* root element is detached), so any entry whose table no longer exists
|
|
1411
|
+
* is removed from the registry instead of being returned, otherwise such
|
|
1412
|
+
* an entry would poison the registry and break every subsequent
|
|
1413
|
+
* selection change.
|
|
1414
|
+
*
|
|
1415
|
+
* Must be called within an editor read or update.
|
|
1416
|
+
*/
|
|
1417
|
+
$getTableNodesAndObservers() {
|
|
1418
|
+
const tableNodesAndObservers = [];
|
|
1419
|
+
for (const [tableKey, [tableObserver]] of Array.from(this.observers.entries())) {
|
|
1420
|
+
const tableNode = $getNodeByKey(tableKey);
|
|
1421
|
+
if ($isTableNode(tableNode)) tableNodesAndObservers.push([tableNode, tableObserver]);
|
|
1422
|
+
else this.removeObserver(tableKey);
|
|
1423
|
+
}
|
|
1424
|
+
return tableNodesAndObservers;
|
|
1425
|
+
}
|
|
1382
1426
|
};
|
|
1383
1427
|
var TableObserver = class {
|
|
1384
1428
|
focusX;
|
|
@@ -1439,7 +1483,7 @@ var TableObserver = class {
|
|
|
1439
1483
|
}
|
|
1440
1484
|
trackTable() {
|
|
1441
1485
|
const observer = new MutationObserver((records) => {
|
|
1442
|
-
this.editor.
|
|
1486
|
+
this.editor.read("latest", () => {
|
|
1443
1487
|
let gridNeedsRedraw = false;
|
|
1444
1488
|
for (let i = 0; i < records.length; i++) {
|
|
1445
1489
|
const nodeName = records[i].target.nodeName;
|
|
@@ -1451,9 +1495,9 @@ var TableObserver = class {
|
|
|
1451
1495
|
if (!gridNeedsRedraw) return;
|
|
1452
1496
|
const { tableNode, tableElement } = this.$lookup();
|
|
1453
1497
|
this.table = getTable(tableNode, tableElement);
|
|
1454
|
-
}
|
|
1498
|
+
});
|
|
1455
1499
|
});
|
|
1456
|
-
this.editor.
|
|
1500
|
+
this.editor.read("latest", () => {
|
|
1457
1501
|
const { tableNode, tableElement } = this.$lookup();
|
|
1458
1502
|
this.table = getTable(tableNode, tableElement);
|
|
1459
1503
|
observer.observe(tableElement, {
|
|
@@ -1461,7 +1505,7 @@ var TableObserver = class {
|
|
|
1461
1505
|
childList: true,
|
|
1462
1506
|
subtree: true
|
|
1463
1507
|
});
|
|
1464
|
-
}
|
|
1508
|
+
});
|
|
1465
1509
|
}
|
|
1466
1510
|
$clearHighlight(setEmptySelection = true) {
|
|
1467
1511
|
const editor = this.editor;
|
|
@@ -1548,7 +1592,8 @@ var TableObserver = class {
|
|
|
1548
1592
|
return false;
|
|
1549
1593
|
}
|
|
1550
1594
|
$getAnchorTableCell() {
|
|
1551
|
-
|
|
1595
|
+
const node = this.anchorCellNodeKey ? $getNodeByKey(this.anchorCellNodeKey) : null;
|
|
1596
|
+
return $isTableCellNode(node) ? node : null;
|
|
1552
1597
|
}
|
|
1553
1598
|
$getAnchorTableCellOrThrow() {
|
|
1554
1599
|
const anchorTableCell = this.$getAnchorTableCell();
|
|
@@ -1556,7 +1601,8 @@ var TableObserver = class {
|
|
|
1556
1601
|
return anchorTableCell;
|
|
1557
1602
|
}
|
|
1558
1603
|
$getFocusTableCell() {
|
|
1559
|
-
|
|
1604
|
+
const node = this.focusCellNodeKey ? $getNodeByKey(this.focusCellNodeKey) : null;
|
|
1605
|
+
return $isTableCellNode(node) ? node : null;
|
|
1560
1606
|
}
|
|
1561
1607
|
$getFocusTableCellOrThrow() {
|
|
1562
1608
|
const focusTableCell = this.$getFocusTableCell();
|
|
@@ -1634,6 +1680,11 @@ var TableObserver = class {
|
|
|
1634
1680
|
}
|
|
1635
1681
|
};
|
|
1636
1682
|
const LEXICAL_ELEMENT_KEY = "__lexicalTableSelection";
|
|
1683
|
+
function $getTableNodeByKeyOrThrow(key) {
|
|
1684
|
+
const tableNode = $getNodeByKeyOrThrow(key);
|
|
1685
|
+
if (!$isTableNode(tableNode)) formatDevErrorMessage(`Expected TableNode for key ${key}`);
|
|
1686
|
+
return tableNode;
|
|
1687
|
+
}
|
|
1637
1688
|
const isPointerDownOnEvent = (event) => {
|
|
1638
1689
|
return (event.buttons & 1) === 1;
|
|
1639
1690
|
};
|
|
@@ -1672,7 +1723,7 @@ function registerTableWindowHandlers(editor, tableObservers) {
|
|
|
1672
1723
|
const editorWindow = editor._window;
|
|
1673
1724
|
if (editorWindow === null) return;
|
|
1674
1725
|
const pointerDownCallback = (event) => {
|
|
1675
|
-
const target = event
|
|
1726
|
+
const target = getComposedEventTarget(event);
|
|
1676
1727
|
if (event.button !== 0 || !isDOMNode(target) || !rootElement.contains(target)) return;
|
|
1677
1728
|
const selectionInfo = getTableObserverFromCellNode(target);
|
|
1678
1729
|
editor.update(() => {
|
|
@@ -1713,13 +1764,18 @@ function $handleTableClick(editor, event, selectedDOMCell, tableElement, tableOb
|
|
|
1713
1764
|
editorWindow.removeEventListener("pointermove", onPointerMove);
|
|
1714
1765
|
return;
|
|
1715
1766
|
}
|
|
1716
|
-
|
|
1767
|
+
const moveTarget = getComposedEventTarget(moveEvent);
|
|
1768
|
+
if (!isDOMNode(moveTarget)) return;
|
|
1717
1769
|
let focusCell = null;
|
|
1718
|
-
const override = !(IS_FIREFOX || tableElement.contains(
|
|
1719
|
-
if (override) focusCell = getDOMCellInTableFromTarget(tableElement,
|
|
1720
|
-
else
|
|
1721
|
-
|
|
1722
|
-
if (
|
|
1770
|
+
const override = !(IS_FIREFOX || tableElement.contains(moveTarget));
|
|
1771
|
+
if (override) focusCell = getDOMCellInTableFromTarget(tableElement, moveTarget);
|
|
1772
|
+
else {
|
|
1773
|
+
const tableRoot = tableElement.getRootNode();
|
|
1774
|
+
if (!isDOMDocumentNode(tableRoot) && !isDOMShadowRoot(tableRoot)) return;
|
|
1775
|
+
for (const el of tableRoot.elementsFromPoint(moveEvent.clientX, moveEvent.clientY)) {
|
|
1776
|
+
focusCell = getDOMCellInTableFromTarget(tableElement, el);
|
|
1777
|
+
if (focusCell) break;
|
|
1778
|
+
}
|
|
1723
1779
|
}
|
|
1724
1780
|
if (focusCell) {
|
|
1725
1781
|
const anchorCell = focusCell;
|
|
@@ -1740,7 +1796,7 @@ function $handleTableClick(editor, event, selectedDOMCell, tableElement, tableOb
|
|
|
1740
1796
|
editorWindow.addEventListener("pointermove", onPointerMove, tableObserver.listenerOptions);
|
|
1741
1797
|
};
|
|
1742
1798
|
tableObserver.pointerType = event.pointerType;
|
|
1743
|
-
const tableNode = $
|
|
1799
|
+
const tableNode = $getTableNodeByKeyOrThrow(tableObserver.tableNodeKey);
|
|
1744
1800
|
const prevSelection = $getPreviousSelection();
|
|
1745
1801
|
if (IS_FIREFOX && event.shiftKey && $isSelectionInTable(prevSelection, tableNode) && ($isRangeSelection(prevSelection) || $isTableSelection(prevSelection))) {
|
|
1746
1802
|
const prevAnchorNode = prevSelection.anchor.getNode();
|
|
@@ -1762,8 +1818,9 @@ function applyTableHandlers(tableNode, element, editor, hasTabHandler, tableObse
|
|
|
1762
1818
|
attachTableObserverToTableElement(tableElement, tableObserver);
|
|
1763
1819
|
tableObserver.listenersToRemove.add(() => detachTableObserverFromTableElement(tableElement, tableObserver));
|
|
1764
1820
|
const onTripleClick = (event) => {
|
|
1765
|
-
|
|
1766
|
-
|
|
1821
|
+
const target = getComposedEventTarget(event);
|
|
1822
|
+
if (event.detail >= 3 && isDOMNode(target)) {
|
|
1823
|
+
if (getDOMCellFromTarget(target) !== null) event.preventDefault();
|
|
1767
1824
|
}
|
|
1768
1825
|
};
|
|
1769
1826
|
tableElement.addEventListener("mousedown", onTripleClick, tableObserver.listenerOptions);
|
|
@@ -1948,25 +2005,23 @@ function $handleTableSelectionChangeCommand(tableObservers, editor) {
|
|
|
1948
2005
|
}
|
|
1949
2006
|
const shouldCheckSelectionForTable = tableObservers.getAndClearShouldCheckSelectionForTable();
|
|
1950
2007
|
if (!!shouldCheckSelectionForTable && $isRangeSelection(prevSelection) && $isRangeSelection(selection) && selection.isCollapsed()) {
|
|
1951
|
-
const tableNode = $
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
firstCell.
|
|
1959
|
-
|
|
2008
|
+
const tableNode = $getNodeByKey(shouldCheckSelectionForTable);
|
|
2009
|
+
if ($isTableNode(tableNode)) {
|
|
2010
|
+
const anchor = selection.anchor.getNode();
|
|
2011
|
+
const firstRow = tableNode.getFirstChild();
|
|
2012
|
+
const anchorCell = $findCellNode(anchor);
|
|
2013
|
+
if (anchorCell !== null && $isTableRowNode(firstRow)) {
|
|
2014
|
+
const firstCell = firstRow.getFirstChild();
|
|
2015
|
+
if ($isTableCellNode(firstCell) && tableNode.is($findMatchingParent(anchorCell, (node) => node.is(tableNode) || node.is(firstCell)))) {
|
|
2016
|
+
firstCell.selectStart();
|
|
2017
|
+
return true;
|
|
2018
|
+
}
|
|
1960
2019
|
}
|
|
1961
2020
|
}
|
|
1962
2021
|
}
|
|
1963
2022
|
if ($isTableSelection(selection)) $fixTableSelectionForSelectedTable(editor, selection);
|
|
1964
2023
|
if ($isRangeSelection(selection)) $fixRangeSelectionForSelectedTable(selection, tableObservers);
|
|
1965
|
-
const
|
|
1966
|
-
tableNode: $getNodeByKeyOrThrow(tableKey),
|
|
1967
|
-
tableObserver
|
|
1968
|
-
}));
|
|
1969
|
-
for (const { tableNode, tableObserver } of tableNodesAndObservers) $syncTableSelectionState(editor, tableNode, tableObserver);
|
|
2024
|
+
for (const [tableNode, tableObserver] of tableObservers.$getTableNodesAndObservers()) $syncTableSelectionState(editor, tableNode, tableObserver);
|
|
1970
2025
|
return false;
|
|
1971
2026
|
}
|
|
1972
2027
|
/**
|
|
@@ -2024,12 +2079,13 @@ function $fixTableSelectionForSelectedTable(editor, selection) {
|
|
|
2024
2079
|
const editorWindow = getEditorWindow(editor);
|
|
2025
2080
|
const prevSelection = $getPreviousSelection();
|
|
2026
2081
|
if (!selection.is(prevSelection)) return;
|
|
2027
|
-
const tableNode = $
|
|
2082
|
+
const tableNode = $getTableNodeByKeyOrThrow(selection.tableKey);
|
|
2028
2083
|
const domSelection = getDOMSelection(editorWindow);
|
|
2029
|
-
|
|
2030
|
-
|
|
2084
|
+
const points = domSelection && getDOMSelectionPoints(domSelection, editor.getRootElement());
|
|
2085
|
+
if (domSelection && points && points.anchorNode && points.focusNode) {
|
|
2086
|
+
const focusNode = $getNearestNodeFromDOMNode(points.focusNode);
|
|
2031
2087
|
const isFocusOutside = focusNode && !tableNode.isParentOf(focusNode);
|
|
2032
|
-
const anchorNode = $getNearestNodeFromDOMNode(
|
|
2088
|
+
const anchorNode = $getNearestNodeFromDOMNode(points.anchorNode);
|
|
2033
2089
|
const isAnchorInside = anchorNode && tableNode.isParentOf(anchorNode);
|
|
2034
2090
|
if (isFocusOutside && isAnchorInside && domSelection.rangeCount > 0) {
|
|
2035
2091
|
const newSelection = $createRangeSelectionFromDom(domSelection, editor);
|
|
@@ -2499,7 +2555,9 @@ function $handleArrowKey(editor, event, direction, tableNode, tableObserver, tab
|
|
|
2499
2555
|
else {
|
|
2500
2556
|
const domSelection = getDOMSelection(getEditorWindow(editor));
|
|
2501
2557
|
if (domSelection === null || domSelection.rangeCount === 0) return false;
|
|
2502
|
-
|
|
2558
|
+
const range = getDOMSelectionRange(domSelection, editor.getRootElement());
|
|
2559
|
+
if (range === null) return false;
|
|
2560
|
+
edgeSelectionRect = range.getBoundingClientRect();
|
|
2503
2561
|
}
|
|
2504
2562
|
const edgeChild = direction === "up" ? anchorCellNode.getFirstChild() : anchorCellNode.getLastChild();
|
|
2505
2563
|
if (edgeChild == null) return false;
|
|
@@ -2562,7 +2620,7 @@ function $getTableEdgeCursorPosition(editor, selection, tableNode) {
|
|
|
2562
2620
|
if (!tableNodeParent) return;
|
|
2563
2621
|
const domSelection = getDOMSelection(getEditorWindow(editor));
|
|
2564
2622
|
if (!domSelection) return;
|
|
2565
|
-
const domAnchorNode = domSelection.anchorNode;
|
|
2623
|
+
const domAnchorNode = getDOMSelectionPoints(domSelection, editor.getRootElement()).anchorNode;
|
|
2566
2624
|
const tableNodeParentDOM = editor.getElementByKey(tableNodeParent.getKey());
|
|
2567
2625
|
const tableElement = getTableElement(tableNode, editor.getElementByKey(tableNode.getKey()));
|
|
2568
2626
|
if (!domAnchorNode || !tableNodeParentDOM || !tableElement || !tableNodeParentDOM.contains(domAnchorNode) || tableElement.contains(domAnchorNode)) return;
|
|
@@ -2590,7 +2648,7 @@ function $getNearestTableCellInTableFromDOMNode(tableNode, startingDOM, editorSt
|
|
|
2590
2648
|
}
|
|
2591
2649
|
const __DEV__ = true;
|
|
2592
2650
|
function isHTMLDivElement(element) {
|
|
2593
|
-
return isHTMLElement
|
|
2651
|
+
return isHTMLElement(element) && element.nodeName === "DIV";
|
|
2594
2652
|
}
|
|
2595
2653
|
function updateColgroup(dom, colCount, colWidths) {
|
|
2596
2654
|
const colGroup = dom.querySelector("colgroup");
|
|
@@ -2766,7 +2824,7 @@ var TableNode = class TableNode extends ElementNode {
|
|
|
2766
2824
|
return {
|
|
2767
2825
|
after: (tableElement) => {
|
|
2768
2826
|
if (superExport.after) tableElement = superExport.after(tableElement);
|
|
2769
|
-
if (!isHTMLTableElement(tableElement) && isHTMLElement
|
|
2827
|
+
if (!isHTMLTableElement(tableElement) && isHTMLElement(tableElement)) tableElement = tableElement.querySelector("table");
|
|
2770
2828
|
if (!isHTMLTableElement(tableElement)) return null;
|
|
2771
2829
|
alignTableElement(tableElement, editor._config, this.getFormatType());
|
|
2772
2830
|
const [tableMap] = $computeTableMapSkipCellCheck(this, null, null);
|
|
@@ -2803,7 +2861,7 @@ var TableNode = class TableNode extends ElementNode {
|
|
|
2803
2861
|
}
|
|
2804
2862
|
return tableElement;
|
|
2805
2863
|
},
|
|
2806
|
-
element: !isHTMLTableElement(element) && isHTMLElement
|
|
2864
|
+
element: !isHTMLTableElement(element) && isHTMLElement(element) ? element.querySelector("table") : element
|
|
2807
2865
|
};
|
|
2808
2866
|
}
|
|
2809
2867
|
canBeEmpty() {
|
|
@@ -2887,7 +2945,7 @@ var TableNode = class TableNode extends ElementNode {
|
|
|
2887
2945
|
}
|
|
2888
2946
|
getColumnCount() {
|
|
2889
2947
|
const firstRow = this.getFirstChild();
|
|
2890
|
-
if (
|
|
2948
|
+
if (!$isTableRowNode(firstRow)) return 0;
|
|
2891
2949
|
let columnCount = 0;
|
|
2892
2950
|
firstRow.getChildren().forEach((cell) => {
|
|
2893
2951
|
if ($isTableCellNode(cell)) columnCount += cell.getColSpan();
|
|
@@ -3062,27 +3120,21 @@ function registerTableSelectionObserver(editor, hasTabHandler = true) {
|
|
|
3062
3120
|
return mergeRegister(registerTableWindowHandlers(editor, tableObservers), editor.registerCommand(SELECTION_CHANGE_COMMAND, () => {
|
|
3063
3121
|
return $handleTableSelectionChangeCommand(tableObservers, editor);
|
|
3064
3122
|
}, COMMAND_PRIORITY_HIGH), editor.registerMutationListener(TableNode, (nodeMutations) => {
|
|
3065
|
-
editor.
|
|
3123
|
+
editor.read("latest", () => {
|
|
3066
3124
|
for (const [nodeKey, mutation] of nodeMutations) {
|
|
3067
3125
|
const tableSelection = tableObservers.observers.get(nodeKey);
|
|
3068
3126
|
if (mutation === "created" || mutation === "updated") {
|
|
3069
3127
|
const { tableNode, tableElement } = $getTableAndElementByKey(nodeKey);
|
|
3070
3128
|
if (tableSelection === void 0) initializeTableNode(tableNode, nodeKey, tableElement);
|
|
3071
3129
|
else if (tableElement !== tableSelection[1]) {
|
|
3072
|
-
|
|
3073
|
-
tableObservers.observers.delete(nodeKey);
|
|
3130
|
+
tableObservers.removeObserver(nodeKey);
|
|
3074
3131
|
initializeTableNode(tableNode, nodeKey, tableElement);
|
|
3075
3132
|
}
|
|
3076
|
-
} else if (mutation === "destroyed")
|
|
3077
|
-
if (tableSelection !== void 0) {
|
|
3078
|
-
tableSelection[0].removeListeners();
|
|
3079
|
-
tableObservers.observers.delete(nodeKey);
|
|
3080
|
-
}
|
|
3081
|
-
}
|
|
3133
|
+
} else if (mutation === "destroyed") tableObservers.removeObserver(nodeKey);
|
|
3082
3134
|
}
|
|
3083
|
-
}
|
|
3135
|
+
});
|
|
3084
3136
|
}, { skipInitialization: false }), () => {
|
|
3085
|
-
|
|
3137
|
+
tableObservers.removeAllObservers();
|
|
3086
3138
|
});
|
|
3087
3139
|
}
|
|
3088
3140
|
/**
|
|
@@ -3105,7 +3157,7 @@ function registerTablePlugin(editor, options) {
|
|
|
3105
3157
|
}
|
|
3106
3158
|
function $tableSelectionInsertClipboardNodesCommand(selectionPayload, hasNestedTables) {
|
|
3107
3159
|
const { nodes, selection } = selectionPayload;
|
|
3108
|
-
if (!nodes.some((n) => $isTableNode(n) || $
|
|
3160
|
+
if (!nodes.some((n) => $isTableNode(n) || $dfsWithSlots(n).some((d) => $isTableNode(d.node)))) return false;
|
|
3109
3161
|
const isTableSelection = $isTableSelection(selection);
|
|
3110
3162
|
const isRangeSelection = $isRangeSelection(selection);
|
|
3111
3163
|
if (!(isRangeSelection && $findMatchingParent(selection.anchor.getNode(), (n) => $isTableCellNode(n)) !== null && $findMatchingParent(selection.focus.getNode(), (n) => $isTableCellNode(n)) !== null || isTableSelection)) return false;
|
|
@@ -3209,47 +3261,6 @@ function $isMultiCellTableSelection(selection) {
|
|
|
3209
3261
|
* LICENSE file in the root directory of this source tree.
|
|
3210
3262
|
*
|
|
3211
3263
|
*/
|
|
3212
|
-
/**
|
|
3213
|
-
* Configures {@link TableNode}, {@link TableRowNode}, {@link TableCellNode} and
|
|
3214
|
-
* registers table behaviors (see {@link TableConfig})
|
|
3215
|
-
*/
|
|
3216
|
-
const TableExtension = defineExtension({
|
|
3217
|
-
build(editor, config, state) {
|
|
3218
|
-
return namedSignals(config);
|
|
3219
|
-
},
|
|
3220
|
-
config: safeCast({
|
|
3221
|
-
hasCellBackgroundColor: true,
|
|
3222
|
-
hasCellMerge: true,
|
|
3223
|
-
hasHorizontalScroll: true,
|
|
3224
|
-
hasNestedTables: false,
|
|
3225
|
-
hasTabHandler: true
|
|
3226
|
-
}),
|
|
3227
|
-
name: "@lexical/table/Table",
|
|
3228
|
-
nodes: () => [
|
|
3229
|
-
TableNode,
|
|
3230
|
-
TableRowNode,
|
|
3231
|
-
TableCellNode
|
|
3232
|
-
],
|
|
3233
|
-
register(editor, config, state) {
|
|
3234
|
-
const stores = state.getOutput();
|
|
3235
|
-
return mergeRegister(effect(() => {
|
|
3236
|
-
const hasHorizontalScroll = stores.hasHorizontalScroll.value;
|
|
3237
|
-
if ($isScrollableTablesActive(editor) !== hasHorizontalScroll) {
|
|
3238
|
-
setScrollableTablesActive(editor, hasHorizontalScroll);
|
|
3239
|
-
editor.update($fullReconcile);
|
|
3240
|
-
}
|
|
3241
|
-
}), registerTablePlugin(editor, stores), effect(() => registerTableSelectionObserver(editor, stores.hasTabHandler.value)), effect(() => stores.hasCellMerge.value ? void 0 : registerTableCellUnmergeTransform(editor)), effect(() => stores.hasCellBackgroundColor.value ? void 0 : editor.registerNodeTransform(TableCellNode, (node) => {
|
|
3242
|
-
if (node.getBackgroundColor() !== null) node.setBackgroundColor(null);
|
|
3243
|
-
})));
|
|
3244
|
-
}
|
|
3245
|
-
});
|
|
3246
|
-
/**
|
|
3247
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3248
|
-
*
|
|
3249
|
-
* This source code is licensed under the MIT license found in the
|
|
3250
|
-
* LICENSE file in the root directory of this source tree.
|
|
3251
|
-
*
|
|
3252
|
-
*/
|
|
3253
3264
|
function isValidVerticalAlign(verticalAlign) {
|
|
3254
3265
|
return verticalAlign === "middle" || verticalAlign === "bottom";
|
|
3255
3266
|
}
|
|
@@ -3269,9 +3280,15 @@ function cellTextFormatMask(style) {
|
|
|
3269
3280
|
return mask;
|
|
3270
3281
|
}
|
|
3271
3282
|
/**
|
|
3272
|
-
* Coalesce inline + line-break runs
|
|
3273
|
-
*
|
|
3274
|
-
*
|
|
3283
|
+
* Coalesce inline + line-break runs inside a `<td>`/`<th>` into their own
|
|
3284
|
+
* `ParagraphNode`s, leaving any pre-existing `ParagraphNode` children
|
|
3285
|
+
* (real `<p>` elements, or the `ParagraphNode` stand-ins that
|
|
3286
|
+
* {@link TransparentBlockRule} lowers `<div>`/`<section>`/… to) in
|
|
3287
|
+
* place as their own paragraph siblings. Mirrors the legacy `<td>`
|
|
3288
|
+
* importer where a bare `<td>789<div>000</div></td>` ended up as two
|
|
3289
|
+
* paragraphs (`<p>789</p><p>000</p>`), and also drops a sole leading
|
|
3290
|
+
* `<br>` that the legacy `removeSingleLineBreakNode` cleanup would have
|
|
3291
|
+
* removed.
|
|
3275
3292
|
*/
|
|
3276
3293
|
function $packageCellChildren(children) {
|
|
3277
3294
|
const result = [];
|
|
@@ -3289,14 +3306,14 @@ function $packageCellChildren(children) {
|
|
|
3289
3306
|
}
|
|
3290
3307
|
else {
|
|
3291
3308
|
flushSingleLineBreak();
|
|
3292
|
-
result.push(child);
|
|
3293
3309
|
paragraph = null;
|
|
3310
|
+
result.push(child);
|
|
3294
3311
|
}
|
|
3295
3312
|
flushSingleLineBreak();
|
|
3296
3313
|
if (result.length === 0) result.push($createParagraphNode());
|
|
3297
3314
|
return result;
|
|
3298
3315
|
}
|
|
3299
|
-
const TableRule = defineImportRule({
|
|
3316
|
+
const TableRule = /* @__PURE__ */ defineImportRule({
|
|
3300
3317
|
$import: (ctx, el) => {
|
|
3301
3318
|
const node = $createTableNode();
|
|
3302
3319
|
if (el.hasAttribute("data-lexical-row-striping")) node.setRowStriping(true);
|
|
@@ -3323,14 +3340,14 @@ const TableRule = defineImportRule({
|
|
|
3323
3340
|
match: sel.tag("table"),
|
|
3324
3341
|
name: "@lexical/table/table"
|
|
3325
3342
|
});
|
|
3326
|
-
const TableRowRule = defineImportRule({
|
|
3343
|
+
const TableRowRule = /* @__PURE__ */ defineImportRule({
|
|
3327
3344
|
$import: (ctx, el) => {
|
|
3328
3345
|
return [$createTableRowNode(PIXEL_VALUE_REG_EXP.test(el.style.height) ? parseFloat(el.style.height) : void 0).splice(0, 0, $descendantsMatching(ctx.$importChildren(el), $isTableCellNode))];
|
|
3329
3346
|
},
|
|
3330
3347
|
match: sel.tag("tr"),
|
|
3331
3348
|
name: "@lexical/table/tr"
|
|
3332
3349
|
});
|
|
3333
|
-
const TableCellRule = defineImportRule({
|
|
3350
|
+
const TableCellRule = /* @__PURE__ */ defineImportRule({
|
|
3334
3351
|
$import: (ctx, el) => {
|
|
3335
3352
|
const isHeader = el.nodeName === "TH";
|
|
3336
3353
|
const width = PIXEL_VALUE_REG_EXP.test(el.style.width) ? parseFloat(el.style.width) : void 0;
|
|
@@ -3365,7 +3382,9 @@ const TableCellRule = defineImportRule({
|
|
|
3365
3382
|
const branchContext = [];
|
|
3366
3383
|
if (cellFormat !== inheritedFormat) branchContext.push(contextValue(ImportTextFormat, cellFormat));
|
|
3367
3384
|
if (cellStyle !== inheritedStyle) branchContext.push(contextValue(ImportTextStyle, cellStyle));
|
|
3368
|
-
|
|
3385
|
+
const packaged = $packageCellChildren(ctx.$importChildren(el, { context: branchContext }));
|
|
3386
|
+
const children = isHeader ? packaged : $propagateTextAlignToBlockChildren(packaged, el);
|
|
3387
|
+
return [cell.splice(0, 0, children)];
|
|
3369
3388
|
},
|
|
3370
3389
|
match: sel.tag("td", "th"),
|
|
3371
3390
|
name: "@lexical/table/cell"
|
|
@@ -3397,6 +3416,11 @@ const TableRowSchema = {
|
|
|
3397
3416
|
* Import rules for {@link TableNode}, {@link TableRowNode}, and
|
|
3398
3417
|
* {@link TableCellNode}.
|
|
3399
3418
|
*
|
|
3419
|
+
* Registered by {@link TableExtension} itself (together with
|
|
3420
|
+
* `CoreImportExtension`), so any editor that uses the table extension can
|
|
3421
|
+
* import these tags through the `DOMImportExtension` pipeline without
|
|
3422
|
+
* further configuration.
|
|
3423
|
+
*
|
|
3400
3424
|
* @experimental
|
|
3401
3425
|
*/
|
|
3402
3426
|
const TableImportRules = [
|
|
@@ -3405,17 +3429,58 @@ const TableImportRules = [
|
|
|
3405
3429
|
TableCellRule
|
|
3406
3430
|
];
|
|
3407
3431
|
/**
|
|
3408
|
-
*
|
|
3409
|
-
* into a single dependency.
|
|
3432
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3410
3433
|
*
|
|
3411
|
-
*
|
|
3434
|
+
* This source code is licensed under the MIT license found in the
|
|
3435
|
+
* LICENSE file in the root directory of this source tree.
|
|
3436
|
+
*
|
|
3437
|
+
*/
|
|
3438
|
+
/**
|
|
3439
|
+
* Configures {@link TableNode}, {@link TableRowNode}, {@link TableCellNode} and
|
|
3440
|
+
* registers table behaviors (see {@link TableConfig})
|
|
3412
3441
|
*/
|
|
3413
|
-
const
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3442
|
+
const TableExtension = /* @__PURE__ */ defineExtension({
|
|
3443
|
+
build(editor, config, state) {
|
|
3444
|
+
return namedSignals(config);
|
|
3445
|
+
},
|
|
3446
|
+
config: /* @__PURE__ */ safeCast({
|
|
3447
|
+
hasCellBackgroundColor: true,
|
|
3448
|
+
hasCellMerge: true,
|
|
3449
|
+
hasHorizontalScroll: true,
|
|
3450
|
+
hasNestedTables: false,
|
|
3451
|
+
hasTabHandler: true
|
|
3452
|
+
}),
|
|
3453
|
+
dependencies: [CoreImportExtension, /* @__PURE__ */ configExtension(DOMImportExtension, { rules: TableImportRules })],
|
|
3454
|
+
name: "@lexical/table/Table",
|
|
3455
|
+
nodes: () => [
|
|
3456
|
+
TableNode,
|
|
3457
|
+
TableRowNode,
|
|
3458
|
+
TableCellNode
|
|
3418
3459
|
],
|
|
3460
|
+
register(editor, config, state) {
|
|
3461
|
+
const stores = state.getOutput();
|
|
3462
|
+
return mergeRegister(effect(() => {
|
|
3463
|
+
const hasHorizontalScroll = stores.hasHorizontalScroll.value;
|
|
3464
|
+
if ($isScrollableTablesActive(editor) !== hasHorizontalScroll) {
|
|
3465
|
+
setScrollableTablesActive(editor, hasHorizontalScroll);
|
|
3466
|
+
editor.update($fullReconcile);
|
|
3467
|
+
}
|
|
3468
|
+
}), registerTablePlugin(editor, stores), effect(() => registerTableSelectionObserver(editor, stores.hasTabHandler.value)), effect(() => stores.hasCellMerge.value ? void 0 : registerTableCellUnmergeTransform(editor)), effect(() => stores.hasCellBackgroundColor.value ? void 0 : editor.registerNodeTransform(TableCellNode, (node) => {
|
|
3469
|
+
if (node.getBackgroundColor() !== null) node.setBackgroundColor(null);
|
|
3470
|
+
})));
|
|
3471
|
+
}
|
|
3472
|
+
});
|
|
3473
|
+
/**
|
|
3474
|
+
* Bundles {@link TableImportRules} together with the runtime
|
|
3475
|
+
* {@link TableExtension}.
|
|
3476
|
+
*
|
|
3477
|
+
* @experimental
|
|
3478
|
+
* @deprecated {@link TableExtension} now registers
|
|
3479
|
+
* {@link TableImportRules} (and `CoreImportExtension`) itself — depend on
|
|
3480
|
+
* it directly instead.
|
|
3481
|
+
*/
|
|
3482
|
+
const TableImportExtension = /* @__PURE__ */ defineExtension({
|
|
3483
|
+
dependencies: [TableExtension],
|
|
3419
3484
|
name: "@lexical/table/Import"
|
|
3420
3485
|
});
|
|
3421
3486
|
//#endregion
|