@mx-space/cli 0.7.7 → 0.8.0
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/{Lexical.dev-rcxzwpir.mjs → Lexical.dev-By5dOKBN.mjs} +1486 -356
- package/dist/{Lexical.node-BUsI9gWr.mjs → Lexical.node-fXM8Jp7p.mjs} +39 -17
- package/dist/{Lexical.prod-C8HtkSD6.mjs → Lexical.prod-BlCvXPGa.mjs} +2279 -1768
- package/dist/LexicalClipboard.dev--HxGoSkO.mjs +915 -0
- package/dist/{LexicalClipboard.node-CO-MCKx5.mjs → LexicalClipboard.node-C3mRbrmW.mjs} +10 -3
- package/dist/LexicalClipboard.prod-DNJzFMcT.mjs +371 -0
- package/dist/LexicalCodeCore.dev-DjSrd4A4.mjs +1109 -0
- package/dist/LexicalCodeCore.prod-DTDShkR3.mjs +642 -0
- package/dist/{LexicalDragon.dev-gBP8WSRS.mjs → LexicalDragon.dev-DwprRH0z.mjs} +3 -3
- package/dist/{LexicalDragon.node-OG6G55nl.mjs → LexicalDragon.node-BVhw4C7s.mjs} +2 -2
- package/dist/{LexicalDragon.prod-DP-_Q8cv.mjs → LexicalDragon.prod-nh4J-8vn.mjs} +3 -3
- package/dist/{LexicalExtension.dev-DVbjljrm.mjs → LexicalExtension.dev-BPNyvGqe.mjs} +335 -6
- package/dist/{LexicalExtension.node-CF3EAPN7.mjs → LexicalExtension.node-BVlcrgOx.mjs} +15 -8
- package/dist/{LexicalExtension.prod-DklHHErZ.mjs → LexicalExtension.prod-DFKbiNt-.mjs} +375 -265
- package/dist/{LexicalHeadless.dev-DdWLM7Nl.mjs → LexicalHeadless.dev-B-cj7Pr5.mjs} +2 -2
- package/dist/{LexicalHeadless.prod-CoiiTDzR.mjs → LexicalHeadless.prod-Byp1vNzT.mjs} +2 -2
- package/dist/LexicalHtml.dev-prBAwszN.mjs +2424 -0
- package/dist/LexicalHtml.node-BvNF96jZ.mjs +56 -0
- package/dist/LexicalHtml.prod-Sz3CW1ht.mjs +1207 -0
- package/dist/{LexicalLink.dev-BS1Bf-yD.mjs → LexicalLink.dev-NySTYhVR.mjs} +42 -8
- package/dist/{LexicalLink.prod-B_crkoHP.mjs → LexicalLink.prod-BuCM8gts.mjs} +209 -191
- package/dist/{LexicalList.dev-OMqmcnQ-.mjs → LexicalList.dev-DIMOvSFD.mjs} +252 -80
- package/dist/{LexicalList.prod-CpL1s8vS.mjs → LexicalList.prod-MVqfA6Vo.mjs} +364 -278
- package/dist/{LexicalMarkdown.dev-BHSdx_Gr.mjs → LexicalMarkdown.dev-C7aylvCG.mjs} +729 -552
- package/dist/LexicalMarkdown.prod-CfQSM406.mjs +868 -0
- package/dist/{LexicalRichText.dev-Bz9A_WbM.mjs → LexicalRichText.dev-DfICq6lU.mjs} +272 -77
- package/dist/{LexicalRichText.node-DDpwfE-P.mjs → LexicalRichText.node-Bg9jND3Q.mjs} +21 -8
- package/dist/LexicalRichText.prod-GsFzCK-o.mjs +550 -0
- package/dist/{LexicalSelection.dev-CQ380fnD.mjs → LexicalSelection.dev-DGjj12wW.mjs} +50 -38
- package/dist/{LexicalSelection.node-DesBMjIE.mjs → LexicalSelection.node-BU5L4193.mjs} +4 -4
- package/dist/{LexicalSelection.prod-D2jivCDB.mjs → LexicalSelection.prod-D-PwRbyK.mjs} +158 -140
- package/dist/{LexicalTable.dev-Ca7mQ7Jk.mjs → LexicalTable.dev-ChP7cugd.mjs} +215 -53
- package/dist/{LexicalTable.prod-DyPAcC7y.mjs → LexicalTable.prod-Bpr9YRXp.mjs} +668 -573
- package/dist/{LexicalUtils.dev-HxM8F0g6.mjs → LexicalUtils.dev-BiFU3789.mjs} +10 -47
- package/dist/{LexicalUtils.node-lCWjRjoG.mjs → LexicalUtils.node-j3Llm7Y3.mjs} +2 -2
- package/dist/{LexicalUtils.prod-Bti5w4ki.mjs → LexicalUtils.prod-DCvrA78p.mjs} +103 -105
- package/dist/bin/mxs.d.mts +1 -1
- package/dist/bin/mxs.mjs +1 -1
- package/dist/esm-By7trG9K.mjs +2 -0
- package/dist/{esm-CK9m5JKX.mjs → esm-Dg-WhPCe.mjs} +989 -989
- package/dist/index.d.mts +22 -2
- package/dist/index.mjs +1 -1
- package/dist/{mxs-vbxEu09D.mjs → mxs-DT0oYk6U.mjs} +10387 -8278
- package/package.json +18 -17
- package/dist/LexicalClipboard.dev-BpqRwTLP.mjs +0 -494
- package/dist/LexicalClipboard.prod-B_xdeiAC.mjs +0 -291
- package/dist/LexicalCodeCore.dev-7_cexm39.mjs +0 -537
- package/dist/LexicalCodeCore.prod-Bd6WFHcO.mjs +0 -381
- package/dist/LexicalHtml.dev-C3ZSWBFZ.mjs +0 -684
- package/dist/LexicalHtml.node-D0TD152E.mjs +0 -24
- package/dist/LexicalHtml.prod-CX47X0zl.mjs +0 -430
- package/dist/LexicalMarkdown.prod-C-S7Ii6-.mjs +0 -754
- package/dist/LexicalRichText.prod-C8qXACDL.mjs +0 -427
- package/dist/esm-DRbkkY3r.mjs +0 -2
- /package/dist/{mxs-CM8-6uAr.d.mts → mxs-iqJBopvE.d.mts} +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { $
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { f as namedSignals, l as effect, p as signal } from "./LexicalExtension.node-BVlcrgOx.mjs";
|
|
2
|
+
import { $ as $isElementNode, $t as ElementNode, An as KEY_ARROW_UP_COMMAND, Bt as COMMAND_PRIORITY_LOW, Cn as IS_STRIKETHROUGH, Cr as isHTMLTableRowElement, Ct as $setPointFromCaret, Dn as KEY_ARROW_DOWN_COMMAND, En as IS_UNDERLINE, F as $getEditor, H as $getRoot, Ht as CONTROLLED_TEXT_INSERTION_COMMAND, In as KEY_TAB_COMMAND, Jn as SELECT_ALL_COMMAND, Jt as DELETE_WORD_COMMAND, Kn as SELECTION_CHANGE_COMMAND, Kt as DELETE_CHARACTER_COMMAND, L as $getNearestNodeFromDOMNode, Mn as KEY_DELETE_COMMAND, Mr as setDOMStyleFromCSS, Nr as setDOMUnmanaged, On as KEY_ARROW_LEFT_COMMAND, Pn as KEY_ESCAPE_COMMAND, Pt as CLICK_COMMAND, Qn as TEXT_TYPE_TO_FORMAT, R as $getNodeByKey, Rt as COMMAND_PRIORITY_EDITOR, S as $getAdjacentChildCaret, Sr as isHTMLElement, U as $getSelection, V as $getPreviousSelection, W as $getSiblingCaret, Wt as CUT_COMMAND, X as $isChildCaret, _ as $createTextNode, b as $fullReconcile, cn as INSERT_PARAGRAPH_COMMAND, cr as defineExtension, ct as $isRootNode, en as FOCUS_COMMAND, et as $isExtendableTextPointCaret, f as $createParagraphNode, ft as $isTextNode, gr as isCurrentlyReadOnlyMode, gt as $normalizeSelection__EXPERIMENTAL, h as $createRangeSelectionFromDom, hn as IS_BOLD, ht as $normalizeCaret, ir as createCommand, it as $isLineBreakNode, jn as KEY_BACKSPACE_COMMAND, jr as safeCast, k as $getChildCaret, kn as KEY_ARROW_RIGHT_COMMAND, lr as getDOMSelection, lt as $isRootOrShadowRoot, m as $createRangeSelection, n as $applyNodeReplacement, nn as FORMAT_TEXT_COMMAND, ot as $isParagraphNode, p as $createPoint, qn as SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, qt as DELETE_LINE_COMMAND, r as $caretFromPoint, rr as configExtension, st as $isRangeSelection, tn as FORMAT_ELEMENT_COMMAND, tt as $isInlineElementOrDecoratorNode, ut as $isSiblingCaret, v as $extendCaretToRange, vn as IS_FIREFOX, vr as isDOMNode, wt as $setSelection, xn as IS_ITALIC, z as $getNodeByKeyOrThrow, zt as COMMAND_PRIORITY_HIGH } from "./Lexical.node-fXM8Jp7p.mjs";
|
|
3
|
+
import { a as CoreImportExtension, d as ImportTextStyle, f as contextValue, g as sel, o as DOMImportExtension, p as defineImportRule, u as ImportTextFormat } from "./LexicalHtml.node-BvNF96jZ.mjs";
|
|
4
|
+
import { _ as removeClassNamesFromElement, c as $insertNodeToNearestRoot, d as addClassNamesToElement, g as objectKlassEquals, h as mergeRegister, m as isHTMLElement$1, n as $dfs, r as $findMatchingParent, s as $insertFirst$1, t as $descendantsMatching, u as $unwrapAndFilterDescendants } from "./LexicalUtils.node-j3Llm7Y3.mjs";
|
|
5
|
+
import { o as copyToClipboard, t as $getClipboardDataFromSelection } from "./LexicalClipboard.node-C3mRbrmW.mjs";
|
|
6
|
+
//#region ../../node_modules/.pnpm/@lexical+table@0.45.0/node_modules/@lexical/table/dist/LexicalTable.dev.mjs
|
|
6
7
|
/**
|
|
7
8
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8
9
|
*
|
|
@@ -94,7 +95,7 @@ var TableCellNode = class TableCellNode extends ElementNode {
|
|
|
94
95
|
if (this.__colSpan > 1) element.colSpan = this.__colSpan;
|
|
95
96
|
if (this.__rowSpan > 1) element.rowSpan = this.__rowSpan;
|
|
96
97
|
if (this.__backgroundColor !== null) element.style.backgroundColor = this.__backgroundColor;
|
|
97
|
-
if (isValidVerticalAlign(this.__verticalAlign)) element.style.verticalAlign = this.__verticalAlign;
|
|
98
|
+
if (isValidVerticalAlign$1(this.__verticalAlign)) element.style.verticalAlign = this.__verticalAlign;
|
|
98
99
|
addClassNamesToElement(element, config.theme.tableCell, this.hasHeader() && config.theme.tableCellHeader);
|
|
99
100
|
return element;
|
|
100
101
|
}
|
|
@@ -116,7 +117,7 @@ var TableCellNode = class TableCellNode extends ElementNode {
|
|
|
116
117
|
exportJSON() {
|
|
117
118
|
return {
|
|
118
119
|
...super.exportJSON(),
|
|
119
|
-
...isValidVerticalAlign(this.__verticalAlign) && { verticalAlign: this.__verticalAlign },
|
|
120
|
+
...isValidVerticalAlign$1(this.__verticalAlign) && { verticalAlign: this.__verticalAlign },
|
|
120
121
|
backgroundColor: this.getBackgroundColor(),
|
|
121
122
|
colSpan: this.__colSpan,
|
|
122
123
|
headerState: this.__headerState,
|
|
@@ -203,7 +204,7 @@ var TableCellNode = class TableCellNode extends ElementNode {
|
|
|
203
204
|
return false;
|
|
204
205
|
}
|
|
205
206
|
};
|
|
206
|
-
function isValidVerticalAlign(verticalAlign) {
|
|
207
|
+
function isValidVerticalAlign$1(verticalAlign) {
|
|
207
208
|
return verticalAlign === "middle" || verticalAlign === "bottom";
|
|
208
209
|
}
|
|
209
210
|
function $convertTableCellNodeElement(domNode) {
|
|
@@ -230,7 +231,7 @@ function $convertTableCellNodeElement(domNode) {
|
|
|
230
231
|
const backgroundColor = domNode_.style.backgroundColor;
|
|
231
232
|
if (backgroundColor !== "") tableCellNode.__backgroundColor = backgroundColor;
|
|
232
233
|
const verticalAlign = domNode_.style.verticalAlign;
|
|
233
|
-
if (isValidVerticalAlign(verticalAlign)) tableCellNode.__verticalAlign = verticalAlign;
|
|
234
|
+
if (isValidVerticalAlign$1(verticalAlign)) tableCellNode.__verticalAlign = verticalAlign;
|
|
234
235
|
const style = domNode_.style;
|
|
235
236
|
const textDecoration = (style && style.textDecoration || "").split(" ");
|
|
236
237
|
const hasBoldFontWeight = style.fontWeight === "700" || style.fontWeight === "bold";
|
|
@@ -389,24 +390,6 @@ function $createTableRowNode(height) {
|
|
|
389
390
|
function $isTableRowNode(node) {
|
|
390
391
|
return node instanceof TableRowNode;
|
|
391
392
|
}
|
|
392
|
-
/**
|
|
393
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
394
|
-
*
|
|
395
|
-
* This source code is licensed under the MIT license found in the
|
|
396
|
-
* LICENSE file in the root directory of this source tree.
|
|
397
|
-
*
|
|
398
|
-
*/
|
|
399
|
-
const CAN_USE_DOM = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
400
|
-
/**
|
|
401
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
402
|
-
*
|
|
403
|
-
* This source code is licensed under the MIT license found in the
|
|
404
|
-
* LICENSE file in the root directory of this source tree.
|
|
405
|
-
*
|
|
406
|
-
*/
|
|
407
|
-
const documentMode = CAN_USE_DOM && "documentMode" in document ? document.documentMode : null;
|
|
408
|
-
const IS_FIREFOX = CAN_USE_DOM && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
|
|
409
|
-
CAN_USE_DOM && "InputEvent" in window && !documentMode && "getTargetRanges" in new window.InputEvent("input");
|
|
410
393
|
function $createTableNodeWithDimensions(rowCount, columnCount, includeHeaders = true) {
|
|
411
394
|
const tableNode = $createTableNode();
|
|
412
395
|
for (let iRow = 0; iRow < rowCount; iRow++) {
|
|
@@ -1684,28 +1667,30 @@ const DELETE_TEXT_COMMANDS = [
|
|
|
1684
1667
|
];
|
|
1685
1668
|
const DELETE_KEY_COMMANDS = [KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND];
|
|
1686
1669
|
function registerTableWindowHandlers(editor, tableObservers) {
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
const
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1670
|
+
return editor.registerRootListener((rootElement) => {
|
|
1671
|
+
if (rootElement === null) return;
|
|
1672
|
+
const editorWindow = editor._window;
|
|
1673
|
+
if (editorWindow === null) return;
|
|
1674
|
+
const pointerDownCallback = (event) => {
|
|
1675
|
+
const target = event.target;
|
|
1676
|
+
if (event.button !== 0 || !isDOMNode(target) || !rootElement.contains(target)) return;
|
|
1677
|
+
const selectionInfo = getTableObserverFromCellNode(target);
|
|
1678
|
+
editor.update(() => {
|
|
1679
|
+
if ($isTableSelection($getSelection())) {
|
|
1680
|
+
for (const [observer] of tableObservers.observers.values()) observer.$clearHighlight(false);
|
|
1681
|
+
$setSelection(null);
|
|
1682
|
+
editor.dispatchCommand(SELECTION_CHANGE_COMMAND, void 0);
|
|
1683
|
+
}
|
|
1684
|
+
if (!selectionInfo) return;
|
|
1685
|
+
const { tableObserver, tableElement, cellElement } = selectionInfo;
|
|
1686
|
+
$handleTableClick(editor, event, cellElement, tableElement, tableObserver, tableObservers);
|
|
1687
|
+
});
|
|
1688
|
+
};
|
|
1689
|
+
editorWindow.addEventListener("pointerdown", pointerDownCallback);
|
|
1690
|
+
return () => {
|
|
1691
|
+
editorWindow.removeEventListener("pointerdown", pointerDownCallback);
|
|
1692
|
+
};
|
|
1693
|
+
});
|
|
1709
1694
|
}
|
|
1710
1695
|
function $handleTableClick(editor, event, selectedDOMCell, tableElement, tableObserver, tableObservers) {
|
|
1711
1696
|
const editorWindow = editor._window;
|
|
@@ -2533,7 +2518,8 @@ function $handleArrowKey(editor, event, direction, tableNode, tableObserver, tab
|
|
|
2533
2518
|
}
|
|
2534
2519
|
}
|
|
2535
2520
|
} else if ($isTableSelection(selection)) {
|
|
2536
|
-
const { anchor, focus } = selection;
|
|
2521
|
+
const { anchor, focus, tableKey } = selection;
|
|
2522
|
+
if (tableKey !== tableNode.getKey()) return false;
|
|
2537
2523
|
const anchorCellNode = $findMatchingParent(anchor.getNode(), $isTableCellNode);
|
|
2538
2524
|
const focusCellNode = $findMatchingParent(focus.getNode(), $isTableCellNode);
|
|
2539
2525
|
const [tableNodeFromSelection] = selection.getNodes();
|
|
@@ -2602,6 +2588,7 @@ function $getObserverCellFromCellNodeOrThrow(tableObserver, tableCellNode) {
|
|
|
2602
2588
|
function $getNearestTableCellInTableFromDOMNode(tableNode, startingDOM, editorState) {
|
|
2603
2589
|
return $findParentTableCellNodeInTable(tableNode, $getNearestNodeFromDOMNode(startingDOM, editorState));
|
|
2604
2590
|
}
|
|
2591
|
+
const __DEV__ = true;
|
|
2605
2592
|
function isHTMLDivElement(element) {
|
|
2606
2593
|
return isHTMLElement$1(element) && element.nodeName === "DIV";
|
|
2607
2594
|
}
|
|
@@ -2681,7 +2668,7 @@ var TableNode = class TableNode extends ElementNode {
|
|
|
2681
2668
|
}
|
|
2682
2669
|
setColWidths(colWidths) {
|
|
2683
2670
|
const self = this.getWritable();
|
|
2684
|
-
self.__colWidths = colWidths !== void 0 &&
|
|
2671
|
+
self.__colWidths = colWidths !== void 0 && __DEV__ ? Object.freeze(colWidths) : colWidths;
|
|
2685
2672
|
return self;
|
|
2686
2673
|
}
|
|
2687
2674
|
static clone(node) {
|
|
@@ -3249,12 +3236,187 @@ const TableExtension = defineExtension({
|
|
|
3249
3236
|
const hasHorizontalScroll = stores.hasHorizontalScroll.value;
|
|
3250
3237
|
if ($isScrollableTablesActive(editor) !== hasHorizontalScroll) {
|
|
3251
3238
|
setScrollableTablesActive(editor, hasHorizontalScroll);
|
|
3252
|
-
editor.
|
|
3239
|
+
editor.update($fullReconcile);
|
|
3253
3240
|
}
|
|
3254
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) => {
|
|
3255
3242
|
if (node.getBackgroundColor() !== null) node.setBackgroundColor(null);
|
|
3256
3243
|
})));
|
|
3257
3244
|
}
|
|
3258
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
|
+
function isValidVerticalAlign(verticalAlign) {
|
|
3254
|
+
return verticalAlign === "middle" || verticalAlign === "bottom";
|
|
3255
|
+
}
|
|
3256
|
+
/**
|
|
3257
|
+
* Bitmask of TextNode format bits implied by a `<th>` / `<td>`'s
|
|
3258
|
+
* inline styles (`font-weight: bold`, `font-style: italic`, and
|
|
3259
|
+
* `underline` / `line-through` in `text-decoration`).
|
|
3260
|
+
*/
|
|
3261
|
+
function cellTextFormatMask(style) {
|
|
3262
|
+
let mask = 0;
|
|
3263
|
+
const fontWeight = style.fontWeight;
|
|
3264
|
+
if (fontWeight === "700" || fontWeight === "bold") mask |= IS_BOLD;
|
|
3265
|
+
if (style.fontStyle === "italic") mask |= IS_ITALIC;
|
|
3266
|
+
const decoration = (style.textDecoration || "").split(" ");
|
|
3267
|
+
if (decoration.includes("underline")) mask |= IS_UNDERLINE;
|
|
3268
|
+
if (decoration.includes("line-through")) mask |= IS_STRIKETHROUGH;
|
|
3269
|
+
return mask;
|
|
3270
|
+
}
|
|
3271
|
+
/**
|
|
3272
|
+
* Coalesce inline + line-break runs in a cell into paragraphs. Mirrors
|
|
3273
|
+
* the legacy `removeSingleLineBreakNode` cleanup so a sole `<br>` doesn't
|
|
3274
|
+
* survive as a paragraph's only child.
|
|
3275
|
+
*/
|
|
3276
|
+
function $packageCellChildren(children) {
|
|
3277
|
+
const result = [];
|
|
3278
|
+
let paragraph = null;
|
|
3279
|
+
const flushSingleLineBreak = () => {
|
|
3280
|
+
if (paragraph !== null) {
|
|
3281
|
+
const first = paragraph.getFirstChild();
|
|
3282
|
+
if ($isLineBreakNode(first) && paragraph.getChildrenSize() === 1) first.remove();
|
|
3283
|
+
}
|
|
3284
|
+
};
|
|
3285
|
+
for (const child of children) if ($isInlineElementOrDecoratorNode(child) || $isTextNode(child) || $isLineBreakNode(child)) if (paragraph !== null) paragraph.append(child);
|
|
3286
|
+
else {
|
|
3287
|
+
paragraph = $createParagraphNode().append(child);
|
|
3288
|
+
result.push(paragraph);
|
|
3289
|
+
}
|
|
3290
|
+
else {
|
|
3291
|
+
flushSingleLineBreak();
|
|
3292
|
+
result.push(child);
|
|
3293
|
+
paragraph = null;
|
|
3294
|
+
}
|
|
3295
|
+
flushSingleLineBreak();
|
|
3296
|
+
if (result.length === 0) result.push($createParagraphNode());
|
|
3297
|
+
return result;
|
|
3298
|
+
}
|
|
3299
|
+
const TableRule = defineImportRule({
|
|
3300
|
+
$import: (ctx, el) => {
|
|
3301
|
+
const node = $createTableNode();
|
|
3302
|
+
if (el.hasAttribute("data-lexical-row-striping")) node.setRowStriping(true);
|
|
3303
|
+
if (el.hasAttribute("data-lexical-frozen-column")) node.setFrozenColumns(1);
|
|
3304
|
+
if (el.hasAttribute("data-lexical-frozen-row")) node.setFrozenRows(1);
|
|
3305
|
+
const colGroup = el.querySelector(":scope > colgroup");
|
|
3306
|
+
if (colGroup) {
|
|
3307
|
+
let columns = [];
|
|
3308
|
+
for (const col of colGroup.querySelectorAll(":scope > col")) {
|
|
3309
|
+
let width = col.style.width || "";
|
|
3310
|
+
if (!PIXEL_VALUE_REG_EXP.test(width)) {
|
|
3311
|
+
width = col.getAttribute("width") || "";
|
|
3312
|
+
if (!/^\d+$/.test(width)) {
|
|
3313
|
+
columns = void 0;
|
|
3314
|
+
break;
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
columns.push(parseFloat(width));
|
|
3318
|
+
}
|
|
3319
|
+
if (columns) node.setColWidths(columns);
|
|
3320
|
+
}
|
|
3321
|
+
return [node.splice(0, 0, $descendantsMatching(ctx.$importChildren(el), $isTableRowNode))];
|
|
3322
|
+
},
|
|
3323
|
+
match: sel.tag("table"),
|
|
3324
|
+
name: "@lexical/table/table"
|
|
3325
|
+
});
|
|
3326
|
+
const TableRowRule = defineImportRule({
|
|
3327
|
+
$import: (ctx, el) => {
|
|
3328
|
+
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
|
+
},
|
|
3330
|
+
match: sel.tag("tr"),
|
|
3331
|
+
name: "@lexical/table/tr"
|
|
3332
|
+
});
|
|
3333
|
+
const TableCellRule = defineImportRule({
|
|
3334
|
+
$import: (ctx, el) => {
|
|
3335
|
+
const isHeader = el.nodeName === "TH";
|
|
3336
|
+
const width = PIXEL_VALUE_REG_EXP.test(el.style.width) ? parseFloat(el.style.width) : void 0;
|
|
3337
|
+
let headerState = TableCellHeaderStates.NO_STATUS;
|
|
3338
|
+
if (isHeader) {
|
|
3339
|
+
const scope = el.getAttribute("scope");
|
|
3340
|
+
if (scope === "col") headerState = TableCellHeaderStates.COLUMN;
|
|
3341
|
+
else if (scope === "row") headerState = TableCellHeaderStates.ROW;
|
|
3342
|
+
else {
|
|
3343
|
+
const parentRow = el.parentElement;
|
|
3344
|
+
const isInHeaderRow = isHTMLTableRowElement(parentRow) && (parentRow.parentElement && parentRow.parentElement.nodeName === "THEAD" || parentRow.rowIndex === 0);
|
|
3345
|
+
const isFirstColumn = el.cellIndex === 0;
|
|
3346
|
+
if (isInHeaderRow) headerState |= TableCellHeaderStates.ROW;
|
|
3347
|
+
if (isFirstColumn) headerState |= TableCellHeaderStates.COLUMN;
|
|
3348
|
+
if (headerState === TableCellHeaderStates.NO_STATUS) headerState = TableCellHeaderStates.ROW;
|
|
3349
|
+
}
|
|
3350
|
+
}
|
|
3351
|
+
const cell = $createTableCellNode(headerState, el.colSpan, width);
|
|
3352
|
+
cell.__rowSpan = el.rowSpan;
|
|
3353
|
+
const backgroundColor = el.style.backgroundColor;
|
|
3354
|
+
if (backgroundColor !== "") cell.__backgroundColor = backgroundColor;
|
|
3355
|
+
const verticalAlign = el.style.verticalAlign;
|
|
3356
|
+
if (isValidVerticalAlign(verticalAlign)) cell.__verticalAlign = verticalAlign;
|
|
3357
|
+
const inheritedFormat = ctx.get(ImportTextFormat);
|
|
3358
|
+
const cellFormat = inheritedFormat | cellTextFormatMask(el.style);
|
|
3359
|
+
const inheritedStyle = ctx.get(ImportTextStyle);
|
|
3360
|
+
const color = el.style.color;
|
|
3361
|
+
const cellStyle = color ? {
|
|
3362
|
+
...inheritedStyle,
|
|
3363
|
+
color
|
|
3364
|
+
} : inheritedStyle;
|
|
3365
|
+
const branchContext = [];
|
|
3366
|
+
if (cellFormat !== inheritedFormat) branchContext.push(contextValue(ImportTextFormat, cellFormat));
|
|
3367
|
+
if (cellStyle !== inheritedStyle) branchContext.push(contextValue(ImportTextStyle, cellStyle));
|
|
3368
|
+
return [cell.splice(0, 0, $packageCellChildren(ctx.$importChildren(el, { context: branchContext })))];
|
|
3369
|
+
},
|
|
3370
|
+
match: sel.tag("td", "th"),
|
|
3371
|
+
name: "@lexical/table/cell"
|
|
3372
|
+
});
|
|
3373
|
+
/**
|
|
3374
|
+
* A {@link ChildSchema} that enforces TableNode invariants: only
|
|
3375
|
+
* `TableRowNode` children are accepted; orphan `TableCellNode` runs are
|
|
3376
|
+
* wrapped in a synthesized row.
|
|
3377
|
+
*
|
|
3378
|
+
* @experimental
|
|
3379
|
+
*/
|
|
3380
|
+
const TableSchema = {
|
|
3381
|
+
$accepts: $isTableRowNode,
|
|
3382
|
+
$packageRun: (run) => run.every($isTableCellNode) ? [$createTableRowNode().splice(0, 0, run)] : [],
|
|
3383
|
+
name: "TableSchema"
|
|
3384
|
+
};
|
|
3385
|
+
/**
|
|
3386
|
+
* A {@link ChildSchema} that enforces TableRowNode invariants: only
|
|
3387
|
+
* `TableCellNode` children are accepted; non-cell children are dropped
|
|
3388
|
+
* (the legacy converter does the same via `$descendantsMatching`).
|
|
3389
|
+
*
|
|
3390
|
+
* @experimental
|
|
3391
|
+
*/
|
|
3392
|
+
const TableRowSchema = {
|
|
3393
|
+
$accepts: $isTableCellNode,
|
|
3394
|
+
name: "TableRowSchema"
|
|
3395
|
+
};
|
|
3396
|
+
/**
|
|
3397
|
+
* Import rules for {@link TableNode}, {@link TableRowNode}, and
|
|
3398
|
+
* {@link TableCellNode}.
|
|
3399
|
+
*
|
|
3400
|
+
* @experimental
|
|
3401
|
+
*/
|
|
3402
|
+
const TableImportRules = [
|
|
3403
|
+
TableRule,
|
|
3404
|
+
TableRowRule,
|
|
3405
|
+
TableCellRule
|
|
3406
|
+
];
|
|
3407
|
+
/**
|
|
3408
|
+
* Bundles {@link TableImportRules} (plus {@link CoreImportExtension})
|
|
3409
|
+
* into a single dependency.
|
|
3410
|
+
*
|
|
3411
|
+
* @experimental
|
|
3412
|
+
*/
|
|
3413
|
+
const TableImportExtension = defineExtension({
|
|
3414
|
+
dependencies: [
|
|
3415
|
+
CoreImportExtension,
|
|
3416
|
+
TableExtension,
|
|
3417
|
+
configExtension(DOMImportExtension, { rules: TableImportRules })
|
|
3418
|
+
],
|
|
3419
|
+
name: "@lexical/table/Import"
|
|
3420
|
+
});
|
|
3259
3421
|
//#endregion
|
|
3260
|
-
export { $computeTableMap, $computeTableMapSkipCellCheck, $createTableCellNode, $createTableNode, $createTableNodeWithDimensions, $createTableRowNode, $createTableSelection, $createTableSelectionFrom, $deleteTableColumn, $deleteTableColumnAtSelection, $deleteTableColumn__EXPERIMENTAL, $deleteTableRowAtSelection, $deleteTableRow__EXPERIMENTAL, $findCellNode, $findTableNode, $getElementForTableNode, $getNodeTriplet, $getTableAndElementByKey, $getTableCellNodeFromLexicalNode, $getTableCellNodeRect, $getTableColumnIndexFromTableCellNode, $getTableNodeFromLexicalNodeOrThrow, $getTableRowIndexFromTableCellNode, $getTableRowNodeFromTableCellNodeOrThrow, $insertTableColumn, $insertTableColumnAtSelection, $insertTableColumn__EXPERIMENTAL, $insertTableRow, $insertTableRowAtSelection, $insertTableRow__EXPERIMENTAL, $isScrollableTablesActive, $isSimpleTable, $isTableCellNode, $isTableNode, $isTableRowNode, $isTableSelection, $mergeCells, $moveTableColumn, $removeTableRowAtIndex, $unmergeCell, INSERT_TABLE_COMMAND, TableCellHeaderStates, TableCellNode, TableExtension, TableNode, TableObserver, TableRowNode, applyTableHandlers, getDOMCellFromTarget, getTableElement, getTableObserverFromTableElement, registerTableCellUnmergeTransform, registerTablePlugin, registerTableSelectionObserver, setScrollableTablesActive };
|
|
3422
|
+
export { $computeTableMap, $computeTableMapSkipCellCheck, $createTableCellNode, $createTableNode, $createTableNodeWithDimensions, $createTableRowNode, $createTableSelection, $createTableSelectionFrom, $deleteTableColumn, $deleteTableColumnAtSelection, $deleteTableColumn__EXPERIMENTAL, $deleteTableRowAtSelection, $deleteTableRow__EXPERIMENTAL, $findCellNode, $findTableNode, $getElementForTableNode, $getNodeTriplet, $getTableAndElementByKey, $getTableCellNodeFromLexicalNode, $getTableCellNodeRect, $getTableColumnIndexFromTableCellNode, $getTableNodeFromLexicalNodeOrThrow, $getTableRowIndexFromTableCellNode, $getTableRowNodeFromTableCellNodeOrThrow, $insertTableColumn, $insertTableColumnAtSelection, $insertTableColumn__EXPERIMENTAL, $insertTableRow, $insertTableRowAtSelection, $insertTableRow__EXPERIMENTAL, $isScrollableTablesActive, $isSimpleTable, $isTableCellNode, $isTableNode, $isTableRowNode, $isTableSelection, $mergeCells, $moveTableColumn, $removeTableRowAtIndex, $unmergeCell, INSERT_TABLE_COMMAND, TableCellHeaderStates, TableCellNode, TableExtension, TableImportExtension, TableImportRules, TableNode, TableObserver, TableRowNode, TableRowSchema, TableSchema, applyTableHandlers, getDOMCellFromTarget, getTableElement, getTableObserverFromTableElement, registerTableCellUnmergeTransform, registerTablePlugin, registerTableSelectionObserver, setScrollableTablesActive };
|