@mx-space/cli 0.7.8 → 0.9.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.
Files changed (68) hide show
  1. package/README.md +30 -0
  2. package/ROADMAP.md +1 -0
  3. package/dist/{Lexical.dev-rcxzwpir.mjs → Lexical.dev-By5dOKBN.mjs} +1486 -356
  4. package/dist/{Lexical.node-BUsI9gWr.mjs → Lexical.node-fXM8Jp7p.mjs} +39 -17
  5. package/dist/{Lexical.prod-C8HtkSD6.mjs → Lexical.prod-BlCvXPGa.mjs} +2279 -1768
  6. package/dist/LexicalClipboard.dev--HxGoSkO.mjs +915 -0
  7. package/dist/{LexicalClipboard.node-CO-MCKx5.mjs → LexicalClipboard.node-C3mRbrmW.mjs} +10 -3
  8. package/dist/LexicalClipboard.prod-DNJzFMcT.mjs +371 -0
  9. package/dist/LexicalCodeCore.dev-DjSrd4A4.mjs +1109 -0
  10. package/dist/LexicalCodeCore.prod-DTDShkR3.mjs +642 -0
  11. package/dist/{LexicalDragon.dev-gBP8WSRS.mjs → LexicalDragon.dev-DwprRH0z.mjs} +3 -3
  12. package/dist/{LexicalDragon.node-OG6G55nl.mjs → LexicalDragon.node-BVhw4C7s.mjs} +2 -2
  13. package/dist/{LexicalDragon.prod-DP-_Q8cv.mjs → LexicalDragon.prod-nh4J-8vn.mjs} +3 -3
  14. package/dist/{LexicalExtension.dev-DVbjljrm.mjs → LexicalExtension.dev-BPNyvGqe.mjs} +335 -6
  15. package/dist/{LexicalExtension.node-CF3EAPN7.mjs → LexicalExtension.node-BVlcrgOx.mjs} +15 -8
  16. package/dist/{LexicalExtension.prod-DklHHErZ.mjs → LexicalExtension.prod-DFKbiNt-.mjs} +375 -265
  17. package/dist/{LexicalHeadless.dev-DdWLM7Nl.mjs → LexicalHeadless.dev-B-cj7Pr5.mjs} +2 -2
  18. package/dist/{LexicalHeadless.prod-CoiiTDzR.mjs → LexicalHeadless.prod-Byp1vNzT.mjs} +2 -2
  19. package/dist/LexicalHtml.dev-prBAwszN.mjs +2424 -0
  20. package/dist/LexicalHtml.node-BvNF96jZ.mjs +56 -0
  21. package/dist/LexicalHtml.prod-Sz3CW1ht.mjs +1207 -0
  22. package/dist/{LexicalLink.dev-BS1Bf-yD.mjs → LexicalLink.dev-NySTYhVR.mjs} +42 -8
  23. package/dist/{LexicalLink.prod-B_crkoHP.mjs → LexicalLink.prod-BuCM8gts.mjs} +209 -191
  24. package/dist/{LexicalList.dev-OMqmcnQ-.mjs → LexicalList.dev-DIMOvSFD.mjs} +252 -80
  25. package/dist/{LexicalList.prod-CpL1s8vS.mjs → LexicalList.prod-MVqfA6Vo.mjs} +364 -278
  26. package/dist/{LexicalMarkdown.dev-BHSdx_Gr.mjs → LexicalMarkdown.dev-C7aylvCG.mjs} +729 -552
  27. package/dist/LexicalMarkdown.prod-CfQSM406.mjs +868 -0
  28. package/dist/{LexicalRichText.dev-Bz9A_WbM.mjs → LexicalRichText.dev-DfICq6lU.mjs} +272 -77
  29. package/dist/{LexicalRichText.node-DDpwfE-P.mjs → LexicalRichText.node-Bg9jND3Q.mjs} +21 -8
  30. package/dist/LexicalRichText.prod-GsFzCK-o.mjs +550 -0
  31. package/dist/{LexicalSelection.dev-CQ380fnD.mjs → LexicalSelection.dev-DGjj12wW.mjs} +50 -38
  32. package/dist/{LexicalSelection.node-DesBMjIE.mjs → LexicalSelection.node-BU5L4193.mjs} +4 -4
  33. package/dist/{LexicalSelection.prod-D2jivCDB.mjs → LexicalSelection.prod-D-PwRbyK.mjs} +158 -140
  34. package/dist/{LexicalTable.dev-Ca7mQ7Jk.mjs → LexicalTable.dev-ChP7cugd.mjs} +215 -53
  35. package/dist/{LexicalTable.prod-DyPAcC7y.mjs → LexicalTable.prod-Bpr9YRXp.mjs} +668 -573
  36. package/dist/{LexicalUtils.dev-HxM8F0g6.mjs → LexicalUtils.dev-BiFU3789.mjs} +10 -47
  37. package/dist/{LexicalUtils.node-lCWjRjoG.mjs → LexicalUtils.node-j3Llm7Y3.mjs} +2 -2
  38. package/dist/{LexicalUtils.prod-Bti5w4ki.mjs → LexicalUtils.prod-DCvrA78p.mjs} +103 -105
  39. package/dist/bin/mxs.d.mts +1 -1
  40. package/dist/bin/mxs.mjs +1 -1
  41. package/dist/esm-By7trG9K.mjs +2 -0
  42. package/dist/{esm-CK9m5JKX.mjs → esm-Dg-WhPCe.mjs} +989 -989
  43. package/dist/index.d.mts +11 -2
  44. package/dist/index.mjs +1 -1
  45. package/dist/{mxs-BZt1cLW9.mjs → mxs-BR5Y5ash.mjs} +25141 -24672
  46. package/package.json +15 -14
  47. package/skills/commands-auth.md +1 -1
  48. package/skills/commands-category.md +1 -1
  49. package/skills/commands-comment.md +1 -1
  50. package/skills/commands-config.md +1 -1
  51. package/skills/commands-preview.md +1 -1
  52. package/skills/commands-profile.md +1 -1
  53. package/skills/commands-project.md +57 -0
  54. package/skills/commands-topic.md +1 -1
  55. package/skills/output-modes.md +1 -1
  56. package/skills/overview.md +2 -1
  57. package/skills/safety.md +10 -0
  58. package/dist/LexicalClipboard.dev-BpqRwTLP.mjs +0 -494
  59. package/dist/LexicalClipboard.prod-B_xdeiAC.mjs +0 -291
  60. package/dist/LexicalCodeCore.dev-7_cexm39.mjs +0 -537
  61. package/dist/LexicalCodeCore.prod-Bd6WFHcO.mjs +0 -381
  62. package/dist/LexicalHtml.dev-C3ZSWBFZ.mjs +0 -684
  63. package/dist/LexicalHtml.node-D0TD152E.mjs +0 -24
  64. package/dist/LexicalHtml.prod-CX47X0zl.mjs +0 -430
  65. package/dist/LexicalMarkdown.prod-C-S7Ii6-.mjs +0 -754
  66. package/dist/LexicalRichText.prod-C8qXACDL.mjs +0 -427
  67. package/dist/esm-DRbkkY3r.mjs +0 -2
  68. /package/dist/{mxs-CM8-6uAr.d.mts → mxs-iqJBopvE.d.mts} +0 -0
@@ -1,7 +1,8 @@
1
- import { r as effect, s as namedSignals } from "./LexicalExtension.node-CF3EAPN7.mjs";
2
- import { $n as safeCast, At as COMMAND_PRIORITY_LOW, B as $getSiblingCaret, D as $getChildCaret, En as buildImportMap, Fn as getNearestEditorFromDOMNode, Gn as isHTMLElement, Ht as ElementNode, Ln as getStyleObjectFromCSS, Mn as defineExtension, N as $getNearestNodeFromDOMNode, On as createCommand, P as $getNodeByKey, Q as $isLeafNode, Y as $isElementNode, Zn as normalizeClassNames, Zt as INSERT_PARAGRAPH_COMMAND, _ as $createTextNode, _t as $setPointFromCaret, at as $isRootOrShadowRoot, bn as SKIP_DOM_SELECTION_TAG, c as $copyNode, cn as KEY_SPACE_COMMAND, ct as $isTextNode, dt as $normalizeCaret, en as KEY_ARROW_DOWN_COMMAND, er as setDOMStyleFromCSS, f as $createParagraphNode, ht as $rewindSiblingCaret, n as $applyNodeReplacement, nt as $isParagraphNode, rn as KEY_ARROW_UP_COMMAND, rt as $isRangeSelection, sn as KEY_ESCAPE_COMMAND, t as $addUpdateTag, tn as KEY_ARROW_LEFT_COMMAND, wn as TextNode, xn as SKIP_SELECTION_FOCUS_TAG, z as $getSelection } from "./Lexical.node-BUsI9gWr.mjs";
3
- import { _ as removeClassNamesFromElement, a as $getNearestNodeOfType, d as addClassNamesToElement, f as calculateZoomLevel, h as mergeRegister, l as $insertNodeToNearestRootAtCaret, m as isHTMLElement$1, r as $findMatchingParent } from "./LexicalUtils.node-lCWjRjoG.mjs";
4
- //#region ../../node_modules/.pnpm/@lexical+list@0.44.0/node_modules/@lexical/list/LexicalList.dev.mjs
1
+ import { f as namedSignals, l as effect } from "./LexicalExtension.node-BVlcrgOx.mjs";
2
+ import { $ as $isElementNode, $t as ElementNode, An as KEY_ARROW_UP_COMMAND, Bt as COMMAND_PRIORITY_LOW, Ct as $setPointFromCaret, Dn as KEY_ARROW_DOWN_COMMAND, Fn as KEY_SPACE_COMMAND, L as $getNearestNodeFromDOMNode, Mr as setDOMStyleFromCSS, On as KEY_ARROW_LEFT_COMMAND, Pn as KEY_ESCAPE_COMMAND, R as $getNodeByKey, Sr as isHTMLElement, St as $setFormatFromDOM, U as $getSelection, W as $getSiblingCaret, Yn as SKIP_DOM_SELECTION_TAG, Zn as SKIP_SELECTION_FOCUS_TAG, _ as $createTextNode, c as $copyNode, cn as INSERT_PARAGRAPH_COMMAND, cr as defineExtension, dr as getNearestEditorFromDOMNode, er as TextNode, f as $createParagraphNode, ft as $isTextNode, ht as $normalizeCaret, ir as createCommand, jr as safeCast, k as $getChildCaret, kr as normalizeClassNames, lt as $isRootOrShadowRoot, n as $applyNodeReplacement, nr as buildImportMap, nt as $isLeafNode, ot as $isParagraphNode, pr as getStyleObjectFromCSS, rr as configExtension, st as $isRangeSelection, t as $addUpdateTag, xt as $setDirectionFromDOM, yt as $rewindSiblingCaret } from "./Lexical.node-fXM8Jp7p.mjs";
3
+ import { a as CoreImportExtension, g as sel, h as isElementOfTag, o as DOMImportExtension, p as defineImportRule } from "./LexicalHtml.node-BvNF96jZ.mjs";
4
+ import { _ as removeClassNamesFromElement, a as $getNearestNodeOfType, d as addClassNamesToElement, f as calculateZoomLevel, h as mergeRegister, l as $insertNodeToNearestRootAtCaret, m as isHTMLElement$1, r as $findMatchingParent } from "./LexicalUtils.node-j3Llm7Y3.mjs";
5
+ //#region ../../node_modules/.pnpm/@lexical+list@0.45.0/node_modules/@lexical/list/dist/LexicalList.dev.mjs
5
6
  /**
6
7
  * Copyright (c) Meta Platforms, Inc. and affiliates.
7
8
  *
@@ -98,14 +99,6 @@ function $removeHighestEmptyListParent(sublist) {
98
99
  emptyListPtr.remove();
99
100
  }
100
101
  /**
101
- * Wraps a node into a ListItemNode.
102
- * @param node - The node to be wrapped into a ListItemNode
103
- * @returns The ListItemNode which the passed node is wrapped in.
104
- */
105
- function $wrapInListItem(node) {
106
- return $createListItemNode().append(node);
107
- }
108
- /**
109
102
  * Calculates the start value for a new list created by splitting an existing list.
110
103
  */
111
104
  function $getNewListStart(list, listItem) {
@@ -128,9 +121,7 @@ function $insertList(listType) {
128
121
  if (selection !== null) {
129
122
  let nodes = selection.getNodes();
130
123
  if ($isRangeSelection(selection)) {
131
- const anchorAndFocus = selection.getStartEndPoints();
132
- if (!(anchorAndFocus !== null)) formatDevErrorMessage(`insertList: anchor should be defined`);
133
- const [anchor] = anchorAndFocus;
124
+ const [anchor] = selection.getStartEndPoints();
134
125
  const anchorNode = anchor.getNode();
135
126
  const anchorNodeParent = anchorNode.getParent();
136
127
  if ($isRootOrShadowRoot(anchorNode)) {
@@ -494,7 +485,7 @@ var ListItemNode = class extends ElementNode {
494
485
  return element;
495
486
  }
496
487
  updateListItemDOM(prevNode, dom, config) {
497
- updateListItemChecked(dom, this, prevNode);
488
+ updateListItemChecked(dom, this);
498
489
  dom.value = this.__value;
499
490
  $setListItemThemeClassNames(dom, config.theme, this);
500
491
  const prevStyle = prevNode ? prevNode.__style : "";
@@ -567,11 +558,18 @@ var ListItemNode = class extends ElementNode {
567
558
  list.insertAfter(replaceWithNode);
568
559
  replaceWithNode.insertAfter(newList);
569
560
  }
561
+ const toReplaceKey = this.__key;
562
+ let prevSizeBeforeChildrenTransfer = 0;
570
563
  if (includeChildren) {
571
564
  if (!$isElementNode(replaceWithNode)) formatDevErrorMessage(`includeChildren should only be true for ElementNodes`);
572
- this.getChildren().forEach((child) => {
573
- replaceWithNode.append(child);
574
- });
565
+ prevSizeBeforeChildrenTransfer = replaceWithNode.getChildrenSize();
566
+ replaceWithNode.splice(prevSizeBeforeChildrenTransfer, 0, this.getChildren());
567
+ }
568
+ if (includeChildren && $isElementNode(replaceWithNode)) {
569
+ const selection = $getSelection();
570
+ if ($isRangeSelection(selection)) {
571
+ for (const point of selection.getStartEndPoints()) if (point.key === toReplaceKey && point.type === "element") point.set(replaceWithNode.getKey(), prevSizeBeforeChildrenTransfer + point.offset, "element");
572
+ }
575
573
  }
576
574
  this.remove();
577
575
  if (list.getChildrenSize() === 0) list.remove();
@@ -709,27 +707,26 @@ var ListItemNode = class extends ElementNode {
709
707
  }
710
708
  };
711
709
  function $setListItemThemeClassNames(dom, editorThemeClasses, node) {
712
- const classesToAdd = [];
713
- const classesToRemove = [];
714
710
  const listTheme = editorThemeClasses.list;
715
- const listItemClassName = listTheme ? listTheme.listitem : void 0;
716
- let nestedListItemClassName;
717
- if (listTheme && listTheme.nested) nestedListItemClassName = listTheme.nested.listitem;
711
+ if (!listTheme) return;
712
+ const listItemClassName = listTheme.listitem;
713
+ const nestedListItemClassName = listTheme.nested && listTheme.nested.listitem;
714
+ const parentNode = node.getParent();
715
+ const isCheckList = $isListNode(parentNode) && parentNode.getListType() === "check";
716
+ const checked = node.getChecked();
717
+ const isNested = node.getChildren().some((child) => $isListNode(child));
718
+ const classesToRemove = [];
719
+ if (listTheme.listitemChecked !== void 0) classesToRemove.push(listTheme.listitemChecked);
720
+ if (listTheme.listitemUnchecked !== void 0) classesToRemove.push(listTheme.listitemUnchecked);
721
+ if (nestedListItemClassName !== void 0) classesToRemove.push(...normalizeClassNames(nestedListItemClassName));
722
+ if (classesToRemove.length > 0) removeClassNamesFromElement(dom, ...classesToRemove);
723
+ const classesToAdd = [];
718
724
  if (listItemClassName !== void 0) classesToAdd.push(...normalizeClassNames(listItemClassName));
719
- if (listTheme) {
720
- const parentNode = node.getParent();
721
- const isCheckList = $isListNode(parentNode) && parentNode.getListType() === "check";
722
- const checked = node.getChecked();
723
- if (!isCheckList || checked) classesToRemove.push(listTheme.listitemUnchecked);
724
- if (!isCheckList || !checked) classesToRemove.push(listTheme.listitemChecked);
725
- if (isCheckList) classesToAdd.push(checked ? listTheme.listitemChecked : listTheme.listitemUnchecked);
726
- }
727
- if (nestedListItemClassName !== void 0) {
728
- const nestedListItemClasses = normalizeClassNames(nestedListItemClassName);
729
- if (node.getChildren().some((child) => $isListNode(child))) classesToAdd.push(...nestedListItemClasses);
730
- else classesToRemove.push(...nestedListItemClasses);
725
+ if (isCheckList) {
726
+ const checkClassName = checked ? listTheme.listitemChecked : listTheme.listitemUnchecked;
727
+ if (checkClassName !== void 0) classesToAdd.push(checkClassName);
731
728
  }
732
- if (classesToRemove.length > 0) removeClassNamesFromElement(dom, ...classesToRemove);
729
+ if (nestedListItemClassName !== void 0 && isNested) classesToAdd.push(...normalizeClassNames(nestedListItemClassName));
733
730
  if (classesToAdd.length > 0) addClassNamesToElement(dom, ...classesToAdd);
734
731
  }
735
732
  function updateListItemChecked(dom, listItemNode, prevListItemNode) {
@@ -741,7 +738,7 @@ function updateListItemChecked(dom, listItemNode, prevListItemNode) {
741
738
  } else {
742
739
  dom.setAttribute("role", "checkbox");
743
740
  dom.setAttribute("tabIndex", "-1");
744
- if (!prevListItemNode || listItemNode.__checked !== prevListItemNode.__checked) dom.setAttribute("aria-checked", listItemNode.getChecked() ? "true" : "false");
741
+ dom.setAttribute("aria-checked", listItemNode.getChecked() ? "true" : "false");
745
742
  }
746
743
  }
747
744
  function $convertListItemElement(domNode) {
@@ -752,11 +749,28 @@ function $convertListItemElement(domNode) {
752
749
  for (const child of domNode.children) if (child.classList.contains("checkbox-wrapper") && child.children.length > 0 && child.children[0].tagName === "INPUT") return $convertCheckboxInput(child.children[0]);
753
750
  }
754
751
  const ariaCheckedAttr = domNode.getAttribute("aria-checked");
755
- return { node: $createListItemNode(ariaCheckedAttr === "true" ? true : ariaCheckedAttr === "false" ? false : void 0) };
752
+ const node = $createListItemNode(ariaCheckedAttr === "true" ? true : ariaCheckedAttr === "false" ? false : void 0);
753
+ $setFormatFromDOM(node, domNode);
754
+ return {
755
+ after: setFormatFromChildren.bind(null, node),
756
+ node: $setDirectionFromDOM(node, domNode)
757
+ };
756
758
  }
757
759
  function $convertCheckboxInput(domNode) {
758
760
  if (!(domNode.getAttribute("type") === "checkbox")) return { node: null };
759
- return { node: $createListItemNode(domNode.hasAttribute("checked")) };
761
+ const node = $createListItemNode(domNode.hasAttribute("checked"));
762
+ return {
763
+ after: setFormatFromChildren.bind(null, node),
764
+ node
765
+ };
766
+ }
767
+ function setFormatFromChildren(listItemNode, children) {
768
+ const firstChild = children[0];
769
+ if (children.length === 1 && $isParagraphNode(firstChild) && !listItemNode.getFormatType() && firstChild.getFormatType()) {
770
+ listItemNode.setFormat(firstChild.getFormatType());
771
+ return firstChild.getChildren();
772
+ }
773
+ return children;
760
774
  }
761
775
  /**
762
776
  * Creates a new List Item node, passing true/false will convert it to a checkbox input.
@@ -882,14 +896,12 @@ var ListNode = class extends ElementNode {
882
896
  return false;
883
897
  }
884
898
  splice(start, deleteCount, nodesToInsert) {
885
- const exampleListItem = nodesToInsert.find($isListItemNode) ?? this.getChildren().find($isListItemNode);
886
- const $newListItem = exampleListItem ? () => $copyNode(exampleListItem) : $createListItemNode;
887
899
  let listItemNodesToInsert = nodesToInsert;
888
900
  for (let i = 0; i < nodesToInsert.length; i++) {
889
901
  const node = nodesToInsert[i];
890
902
  if (!$isListItemNode(node)) {
891
903
  if (listItemNodesToInsert === nodesToInsert) listItemNodesToInsert = [...nodesToInsert];
892
- listItemNodesToInsert[i] = $newListItem().append($isElementNode(node) && !($isListNode(node) || node.isInline()) ? $createTextNode(node.getTextContent()) : node);
904
+ listItemNodesToInsert[i] = this.createListItemNode().append($isElementNode(node) && !($isListNode(node) || node.isInline()) ? $createTextNode(node.getTextContent()) : node);
893
905
  }
894
906
  }
895
907
  return super.splice(start, deleteCount, listItemNodesToInsert);
@@ -897,6 +909,15 @@ var ListNode = class extends ElementNode {
897
909
  extractWithChild(child) {
898
910
  return $isListItemNode(child);
899
911
  }
912
+ /**
913
+ * Create an appropriate ListItemNode to be a child of this ListNode,
914
+ * {@link $createListItemNode} is the default implementation.
915
+ *
916
+ * @returns A new ListItemNode.
917
+ */
918
+ createListItemNode() {
919
+ return $createListItemNode();
920
+ }
900
921
  };
901
922
  function $setListThemeClassNames(dom, editorThemeClasses, node) {
902
923
  const classesToAdd = [];
@@ -927,7 +948,8 @@ function $setListThemeClassNames(dom, editorThemeClasses, node) {
927
948
  if (classesToRemove.length > 0) removeClassNamesFromElement(dom, ...classesToRemove);
928
949
  if (classesToAdd.length > 0) addClassNamesToElement(dom, ...classesToAdd);
929
950
  }
930
- function $normalizeChildren(nodes) {
951
+ function $normalizeChildren(nodes, listNode) {
952
+ const $createWrapperItem = listNode.createListItemNode.bind(listNode);
931
953
  const normalizedListItems = [];
932
954
  for (let i = 0; i < nodes.length; i++) {
933
955
  const node = nodes[i];
@@ -935,27 +957,30 @@ function $normalizeChildren(nodes) {
935
957
  normalizedListItems.push(node);
936
958
  const children = node.getChildren();
937
959
  if (children.length > 1) children.forEach((child) => {
938
- if ($isListNode(child)) normalizedListItems.push($wrapInListItem(child));
960
+ if ($isListNode(child)) normalizedListItems.push($createWrapperItem().append(child));
939
961
  });
940
- } else normalizedListItems.push($wrapInListItem(node));
962
+ } else normalizedListItems.push($createWrapperItem().append(node));
941
963
  }
942
964
  return normalizedListItems;
943
965
  }
944
- function isDomChecklist(domNode) {
966
+ function isDomChecklist$1(domNode) {
945
967
  if (domNode.getAttribute("__lexicallisttype") === "check" || domNode.classList.contains("contains-task-list") || domNode.getAttribute("data-is-checklist") === "1") return true;
946
968
  for (const child of domNode.childNodes) if (isHTMLElement$1(child) && child.hasAttribute("aria-checked")) return true;
947
969
  return false;
948
970
  }
971
+ function isHTMLOListElement(node) {
972
+ return isHTMLElement$1(node) && node.nodeName.toLowerCase() === "ol";
973
+ }
949
974
  function $convertListNode(domNode) {
950
- const nodeName = domNode.nodeName.toLowerCase();
951
- let node = null;
952
- if (nodeName === "ol") {
975
+ let node;
976
+ if (isHTMLOListElement(domNode)) {
953
977
  const start = domNode.start;
954
978
  node = $createListNode("number", start);
955
- } else if (nodeName === "ul") if (isDomChecklist(domNode)) node = $createListNode("check");
979
+ } else if (isDomChecklist$1(domNode)) node = $createListNode("check");
956
980
  else node = $createListNode("bullet");
981
+ $setDirectionFromDOM(node, domNode);
957
982
  return {
958
- after: $normalizeChildren,
983
+ after: (children) => $normalizeChildren(children, node),
959
984
  node
960
985
  };
961
986
  }
@@ -1285,32 +1310,12 @@ function $findChildrenEndListItemNode(listItemNode) {
1285
1310
  return current;
1286
1311
  }
1287
1312
  /**
1288
- * @deprecated use {@link $insertList} from an update or command listener.
1313
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
1289
1314
  *
1290
- * Inserts a new ListNode. If the selection's anchor node is an empty ListItemNode and is a child of
1291
- * the root/shadow root, it will replace the ListItemNode with a ListNode and the old ListItemNode.
1292
- * Otherwise it will replace its parent with a new ListNode and re-insert the ListItemNode and any previous children.
1293
- * If the selection's anchor node is not an empty ListItemNode, it will add a new ListNode or merge an existing ListNode,
1294
- * unless the the node is a leaf node, in which case it will attempt to find a ListNode up the branch and replace it with
1295
- * a new ListNode, or create a new ListNode at the nearest root/shadow root.
1296
- * @param editor - The lexical editor.
1297
- * @param listType - The type of list, "number" | "bullet" | "check".
1298
- */
1299
- function insertList(editor, listType) {
1300
- editor.update(() => $insertList(listType));
1301
- }
1302
- /**
1303
- * @deprecated use {@link $removeList} from an update or command listener.
1315
+ * This source code is licensed under the MIT license found in the
1316
+ * LICENSE file in the root directory of this source tree.
1304
1317
  *
1305
- * Searches for the nearest ancestral ListNode and removes it. If selection is an empty ListItemNode
1306
- * it will remove the whole list, including the ListItemNode. For each ListItemNode in the ListNode,
1307
- * removeList will also generate new ParagraphNodes in the removed ListNode's place. Any child node
1308
- * inside a ListItemNode will be appended to the new ParagraphNodes.
1309
- * @param editor - The lexical editor.
1310
1318
  */
1311
- function removeList(editor) {
1312
- editor.update(() => $removeList());
1313
- }
1314
1319
  /**
1315
1320
  * Configures {@link ListNode}, {@link ListItemNode} and registers
1316
1321
  * the strict indent transform if `hasStrictIndent` is true (default false).
@@ -1334,10 +1339,8 @@ const ListExtension = defineExtension({
1334
1339
  });
1335
1340
  /**
1336
1341
  * Registers checklist functionality for {@link ListNode} and
1337
- * {@link ListItemNode} with a
1338
- * {@link INSERT_CHECK_LIST_COMMAND} listener and
1339
- * the expected keyboard and mouse interactions for
1340
- * checkboxes.
1342
+ * {@link ListItemNode} with a `INSERT_CHECK_LIST_COMMAND` listener and
1343
+ * the expected keyboard and mouse interactions for checkboxes.
1341
1344
  */
1342
1345
  const CheckListExtension = defineExtension({
1343
1346
  build: (editor, config) => namedSignals(config),
@@ -1346,5 +1349,174 @@ const CheckListExtension = defineExtension({
1346
1349
  name: "@lexical/list/CheckList",
1347
1350
  register: (editor, config, state) => registerCheckList(editor, state.getOutput())
1348
1351
  });
1352
+ /**
1353
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
1354
+ *
1355
+ * This source code is licensed under the MIT license found in the
1356
+ * LICENSE file in the root directory of this source tree.
1357
+ *
1358
+ */
1359
+ /**
1360
+ * Mirrors the legacy `isDomChecklist` heuristic from
1361
+ * `@lexical/list`.
1362
+ */
1363
+ function isDomChecklist(domNode) {
1364
+ return domNode.matches("[__lexicallisttype=\"check\"], .contains-task-list, [data-is-checklist=\"1\"]") || domNode.querySelector(":scope > [aria-checked]") !== null;
1365
+ }
1366
+ /**
1367
+ * Lift nested `ListNode`s out of `ListItemNode`s into sibling
1368
+ * `ListItemNode`s (the legacy `$normalizeChildren` shape). Also wraps any
1369
+ * non-`ListItemNode` children in a new `ListItemNode`.
1370
+ */
1371
+ function $normalizeListChildren(children) {
1372
+ const out = [];
1373
+ for (const child of children) if ($isListItemNode(child)) {
1374
+ out.push(child);
1375
+ const innerChildren = child.getChildren();
1376
+ if (innerChildren.length > 1) {
1377
+ for (const inner of innerChildren) if ($isListNode(inner)) out.push($createListItemNode().append(inner));
1378
+ }
1379
+ } else out.push($createListItemNode().append(child));
1380
+ return out;
1381
+ }
1382
+ const ListRule = defineImportRule({
1383
+ $import: (ctx, el) => {
1384
+ let node;
1385
+ if (isElementOfTag(el, "ol")) node = $createListNode("number", el.start);
1386
+ else if (isDomChecklist(el)) node = $createListNode("check");
1387
+ else node = $createListNode("bullet");
1388
+ $setDirectionFromDOM(node, el);
1389
+ return [node.splice(0, 0, $normalizeListChildren(ctx.$importChildren(el)))];
1390
+ },
1391
+ match: sel.tag("ol", "ul"),
1392
+ name: "@lexical/list/list"
1393
+ });
1394
+ /**
1395
+ * Apply formatting from the first child paragraph of `<li>` to the list
1396
+ * item itself, then unwrap that paragraph (Google Docs sets the alignment
1397
+ * of the `<p>` inside the `<li>`). Mirrors the legacy
1398
+ * `setFormatFromChildren`.
1399
+ */
1400
+ function $liftFormatFromSingleParagraph(listItemNode, children) {
1401
+ if (children.length !== 1) return children;
1402
+ const firstChild = children[0];
1403
+ if ($isParagraphNode(firstChild) && !listItemNode.getFormatType() && firstChild.getFormatType()) {
1404
+ listItemNode.setFormat(firstChild.getFormatType());
1405
+ return firstChild.getChildren();
1406
+ }
1407
+ return children;
1408
+ }
1409
+ const ListItemRule = defineImportRule({
1410
+ $import: (ctx, el) => {
1411
+ const ariaChecked = el.getAttribute("aria-checked");
1412
+ const node = $createListItemNode(ariaChecked === "true" ? true : ariaChecked === "false" ? false : void 0);
1413
+ $setFormatFromDOM(node, el);
1414
+ $setDirectionFromDOM(node, el);
1415
+ return [node.splice(0, 0, $liftFormatFromSingleParagraph(node, ctx.$importChildren(el)))];
1416
+ },
1417
+ match: sel.tag("li"),
1418
+ name: "@lexical/list/li"
1419
+ });
1420
+ function $buildChecklistItem(ctx, el, checkboxOwner) {
1421
+ const checkboxInput = isElementOfTag(checkboxOwner, "input") ? checkboxOwner : checkboxOwner.querySelector("input[type=\"checkbox\"]");
1422
+ if (!checkboxInput || checkboxInput.getAttribute("type") !== "checkbox") return [];
1423
+ const node = $createListItemNode(checkboxInput.hasAttribute("checked"));
1424
+ $setFormatFromDOM(node, el);
1425
+ $setDirectionFromDOM(node, el);
1426
+ return [node.splice(0, 0, $liftFormatFromSingleParagraph(node, ctx.$importChildren(el)))];
1427
+ }
1428
+ const TaskListItemRule = defineImportRule({
1429
+ $import: (ctx, el, $next) => {
1430
+ const input = el.querySelector(":scope > input[type=\"checkbox\"]");
1431
+ if (!input) return $next();
1432
+ return $buildChecklistItem(ctx, el, input);
1433
+ },
1434
+ match: sel.tag("li").classAll("task-list-item"),
1435
+ name: "@lexical/list/li-task-list-item"
1436
+ });
1437
+ const JoplinChecklistItemRule = defineImportRule({
1438
+ $import: (ctx, el, $next) => {
1439
+ const wrapper = el.querySelector(":scope > .checkbox-wrapper");
1440
+ if (!wrapper) return $next();
1441
+ const input = wrapper.querySelector(":scope > input[type=\"checkbox\"]");
1442
+ if (!input) return $next();
1443
+ return $buildChecklistItem(ctx, el, input);
1444
+ },
1445
+ match: sel.tag("li").classAll("joplin-checkbox"),
1446
+ name: "@lexical/list/li-joplin-checkbox"
1447
+ });
1448
+ /**
1449
+ * A {@link ChildSchema} that enforces ListNode invariants: only
1450
+ * `ListItemNode` and (immediately-nested) `ListNode` children are
1451
+ * accepted; runs of other children get wrapped in a fresh
1452
+ * `ListItemNode`.
1453
+ *
1454
+ * @experimental
1455
+ */
1456
+ const ListSchema = {
1457
+ $accepts: (child) => $isListItemNode(child) || $isListNode(child),
1458
+ $packageRun: (run) => [$createListItemNode().splice(0, 0, run)],
1459
+ name: "ListSchema"
1460
+ };
1461
+ /**
1462
+ * Import rules for {@link ListNode} and {@link ListItemNode}, including
1463
+ * GitHub task-list and Joplin checkbox heuristics.
1464
+ *
1465
+ * @experimental
1466
+ */
1467
+ const ListImportRules = [
1468
+ TaskListItemRule,
1469
+ JoplinChecklistItemRule,
1470
+ ListRule,
1471
+ ListItemRule
1472
+ ];
1473
+ /**
1474
+ * Bundles {@link ListImportRules} (plus {@link CoreImportExtension}) into
1475
+ * a single dependency.
1476
+ *
1477
+ * @experimental
1478
+ */
1479
+ const ListImportExtension = defineExtension({
1480
+ dependencies: [
1481
+ CoreImportExtension,
1482
+ ListExtension,
1483
+ configExtension(DOMImportExtension, { rules: ListImportRules })
1484
+ ],
1485
+ name: "@lexical/list/Import"
1486
+ });
1487
+ /**
1488
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
1489
+ *
1490
+ * This source code is licensed under the MIT license found in the
1491
+ * LICENSE file in the root directory of this source tree.
1492
+ *
1493
+ */
1494
+ /**
1495
+ * @deprecated use {@link $insertList} from an update or command listener.
1496
+ *
1497
+ * Inserts a new ListNode. If the selection's anchor node is an empty ListItemNode and is a child of
1498
+ * the root/shadow root, it will replace the ListItemNode with a ListNode and the old ListItemNode.
1499
+ * Otherwise it will replace its parent with a new ListNode and re-insert the ListItemNode and any previous children.
1500
+ * If the selection's anchor node is not an empty ListItemNode, it will add a new ListNode or merge an existing ListNode,
1501
+ * unless the the node is a leaf node, in which case it will attempt to find a ListNode up the branch and replace it with
1502
+ * a new ListNode, or create a new ListNode at the nearest root/shadow root.
1503
+ * @param editor - The lexical editor.
1504
+ * @param listType - The type of list, "number" | "bullet" | "check".
1505
+ */
1506
+ function insertList(editor, listType) {
1507
+ editor.update(() => $insertList(listType));
1508
+ }
1509
+ /**
1510
+ * @deprecated use {@link $removeList} from an update or command listener.
1511
+ *
1512
+ * Searches for the nearest ancestral ListNode and removes it. If selection is an empty ListItemNode
1513
+ * it will remove the whole list, including the ListItemNode. For each ListItemNode in the ListNode,
1514
+ * removeList will also generate new ParagraphNodes in the removed ListNode's place. Any child node
1515
+ * inside a ListItemNode will be appended to the new ParagraphNodes.
1516
+ * @param editor - The lexical editor.
1517
+ */
1518
+ function removeList(editor) {
1519
+ editor.update(() => $removeList());
1520
+ }
1349
1521
  //#endregion
1350
- export { $createListItemNode, $createListNode, $getListDepth, $handleListInsertParagraph, $insertList, $isListItemNode, $isListNode, $removeList, CheckListExtension, INSERT_CHECK_LIST_COMMAND, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, ListExtension, ListItemNode, ListNode, REMOVE_LIST_COMMAND, UPDATE_LIST_START_COMMAND, insertList, registerCheckList, registerList, registerListStrictIndentTransform, removeList };
1522
+ export { $createListItemNode, $createListNode, $getListDepth, $handleListInsertParagraph, $insertList, $isListItemNode, $isListNode, $removeList, CheckListExtension, INSERT_CHECK_LIST_COMMAND, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, ListExtension, ListImportExtension, ListImportRules, ListItemNode, ListNode, ListSchema, REMOVE_LIST_COMMAND, UPDATE_LIST_START_COMMAND, insertList, registerCheckList, registerList, registerListStrictIndentTransform, removeList };