@mx-space/cli 0.1.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 (190) hide show
  1. package/LICENSE +33 -0
  2. package/README.md +375 -0
  3. package/ROADMAP.md +42 -0
  4. package/bin/mxs.cjs +40 -0
  5. package/dist/Lexical.dev-DpU35QTu.mjs +10992 -0
  6. package/dist/Lexical.dev-DpU35QTu.mjs.map +1 -0
  7. package/dist/Lexical.node-gYNDt_p9.mjs +247 -0
  8. package/dist/Lexical.node-gYNDt_p9.mjs.map +1 -0
  9. package/dist/Lexical.prod-t4c3bHV3.mjs +5579 -0
  10. package/dist/Lexical.prod-t4c3bHV3.mjs.map +1 -0
  11. package/dist/LexicalClipboard.dev-CdeeWCIq.mjs +496 -0
  12. package/dist/LexicalClipboard.dev-CdeeWCIq.mjs.map +1 -0
  13. package/dist/LexicalClipboard.node-0e9GBL1g.mjs +26 -0
  14. package/dist/LexicalClipboard.node-0e9GBL1g.mjs.map +1 -0
  15. package/dist/LexicalClipboard.prod-CsCWYmV7.mjs +293 -0
  16. package/dist/LexicalClipboard.prod-CsCWYmV7.mjs.map +1 -0
  17. package/dist/LexicalCodeCore.dev-haI2cqH8.mjs +539 -0
  18. package/dist/LexicalCodeCore.dev-haI2cqH8.mjs.map +1 -0
  19. package/dist/LexicalCodeCore.prod-D_k7zuE5.mjs +383 -0
  20. package/dist/LexicalCodeCore.prod-D_k7zuE5.mjs.map +1 -0
  21. package/dist/LexicalDragon.dev-CAggdFh_.mjs +90 -0
  22. package/dist/LexicalDragon.dev-CAggdFh_.mjs.map +1 -0
  23. package/dist/LexicalDragon.node-QMR_wqJg.mjs +15 -0
  24. package/dist/LexicalDragon.node-QMR_wqJg.mjs.map +1 -0
  25. package/dist/LexicalDragon.prod-OssQhwS-.mjs +61 -0
  26. package/dist/LexicalDragon.prod-OssQhwS-.mjs.map +1 -0
  27. package/dist/LexicalExtension.dev-CtDZiMCU.mjs +1665 -0
  28. package/dist/LexicalExtension.dev-CtDZiMCU.mjs.map +1 -0
  29. package/dist/LexicalExtension.node-BM0gh8zu.mjs +51 -0
  30. package/dist/LexicalExtension.node-BM0gh8zu.mjs.map +1 -0
  31. package/dist/LexicalExtension.prod-Ug6emhEO.mjs +971 -0
  32. package/dist/LexicalExtension.prod-Ug6emhEO.mjs.map +1 -0
  33. package/dist/LexicalHeadless.dev-D4yQpl_s.mjs +45 -0
  34. package/dist/LexicalHeadless.dev-D4yQpl_s.mjs.map +1 -0
  35. package/dist/LexicalHeadless.prod-jeN65B3k.mjs +31 -0
  36. package/dist/LexicalHeadless.prod-jeN65B3k.mjs.map +1 -0
  37. package/dist/LexicalHtml.dev-BdU1_ITQ.mjs +686 -0
  38. package/dist/LexicalHtml.dev-BdU1_ITQ.mjs.map +1 -0
  39. package/dist/LexicalHtml.node-DLtAh00E.mjs +26 -0
  40. package/dist/LexicalHtml.node-DLtAh00E.mjs.map +1 -0
  41. package/dist/LexicalHtml.prod-DdLE1HHT.mjs +432 -0
  42. package/dist/LexicalHtml.prod-DdLE1HHT.mjs.map +1 -0
  43. package/dist/LexicalLink.dev-DK87Biuy.mjs +1084 -0
  44. package/dist/LexicalLink.dev-DK87Biuy.mjs.map +1 -0
  45. package/dist/LexicalLink.prod-fssuv6Sf.mjs +717 -0
  46. package/dist/LexicalLink.prod-fssuv6Sf.mjs.map +1 -0
  47. package/dist/LexicalList.dev-BJ4dr_rk.mjs +1352 -0
  48. package/dist/LexicalList.dev-BJ4dr_rk.mjs.map +1 -0
  49. package/dist/LexicalList.prod-jWBbaWfi.mjs +841 -0
  50. package/dist/LexicalList.prod-jWBbaWfi.mjs.map +1 -0
  51. package/dist/LexicalMarkdown.dev-C8e-eh6y.mjs +1207 -0
  52. package/dist/LexicalMarkdown.dev-C8e-eh6y.mjs.map +1 -0
  53. package/dist/LexicalMarkdown.prod-k73tZVb2.mjs +756 -0
  54. package/dist/LexicalMarkdown.prod-k73tZVb2.mjs.map +1 -0
  55. package/dist/LexicalRichText.dev-CrSqq3K-.mjs +645 -0
  56. package/dist/LexicalRichText.dev-CrSqq3K-.mjs.map +1 -0
  57. package/dist/LexicalRichText.node-B7k7wlQz.mjs +106 -0
  58. package/dist/LexicalRichText.node-B7k7wlQz.mjs.map +1 -0
  59. package/dist/LexicalRichText.prod-CqvyxQ9m.mjs +429 -0
  60. package/dist/LexicalRichText.prod-CqvyxQ9m.mjs.map +1 -0
  61. package/dist/LexicalSelection.dev-sNOHKHe_.mjs +725 -0
  62. package/dist/LexicalSelection.dev-sNOHKHe_.mjs.map +1 -0
  63. package/dist/LexicalSelection.node-Di7GwBCZ.mjs +38 -0
  64. package/dist/LexicalSelection.node-Di7GwBCZ.mjs.map +1 -0
  65. package/dist/LexicalSelection.prod-SWllPJop.mjs +388 -0
  66. package/dist/LexicalSelection.prod-SWllPJop.mjs.map +1 -0
  67. package/dist/LexicalTable.dev-CQkLHXJx.mjs +3262 -0
  68. package/dist/LexicalTable.dev-CQkLHXJx.mjs.map +1 -0
  69. package/dist/LexicalTable.prod-BtqCwKSi.mjs +2218 -0
  70. package/dist/LexicalTable.prod-BtqCwKSi.mjs.map +1 -0
  71. package/dist/LexicalUtils.dev-DiUpsXE8.mjs +850 -0
  72. package/dist/LexicalUtils.dev-DiUpsXE8.mjs.map +1 -0
  73. package/dist/LexicalUtils.node-CmK462d1.mjs +66 -0
  74. package/dist/LexicalUtils.node-CmK462d1.mjs.map +1 -0
  75. package/dist/LexicalUtils.prod-bWwV4GAF.mjs +377 -0
  76. package/dist/LexicalUtils.prod-bWwV4GAF.mjs.map +1 -0
  77. package/dist/auth-DIFZzoMm.mjs +211 -0
  78. package/dist/auth-DIFZzoMm.mjs.map +1 -0
  79. package/dist/bin/mxs.d.mts +927 -0
  80. package/dist/bin/mxs.mjs +3249 -0
  81. package/dist/bin/mxs.mjs.map +1 -0
  82. package/dist/chunk-hT5z_Zn9.mjs +35 -0
  83. package/dist/config-store-DIu7x0ao.mjs +121 -0
  84. package/dist/config-store-DIu7x0ao.mjs.map +1 -0
  85. package/dist/create-B2AOQL1e.mjs +24 -0
  86. package/dist/create-B2AOQL1e.mjs.map +1 -0
  87. package/dist/create-CwjGcv2n.mjs +23 -0
  88. package/dist/create-CwjGcv2n.mjs.map +1 -0
  89. package/dist/create-DT1l2hue.mjs +23 -0
  90. package/dist/create-DT1l2hue.mjs.map +1 -0
  91. package/dist/create-DjlRHPXy.mjs +23 -0
  92. package/dist/create-DjlRHPXy.mjs.map +1 -0
  93. package/dist/create-Dz6rJJSS.mjs +19 -0
  94. package/dist/create-Dz6rJJSS.mjs.map +1 -0
  95. package/dist/delete-B4dGrrus.mjs +22 -0
  96. package/dist/delete-B4dGrrus.mjs.map +1 -0
  97. package/dist/delete-BH6ZngTz.mjs +22 -0
  98. package/dist/delete-BH6ZngTz.mjs.map +1 -0
  99. package/dist/delete-BrY5zJ6S.mjs +22 -0
  100. package/dist/delete-BrY5zJ6S.mjs.map +1 -0
  101. package/dist/delete-CaG2d_xt.mjs +31 -0
  102. package/dist/delete-CaG2d_xt.mjs.map +1 -0
  103. package/dist/delete-YzRliRn8.mjs +31 -0
  104. package/dist/delete-YzRliRn8.mjs.map +1 -0
  105. package/dist/document-output-BVB8emLt.mjs +145 -0
  106. package/dist/document-output-BVB8emLt.mjs.map +1 -0
  107. package/dist/edit-Bb0Ze4w6.mjs +79 -0
  108. package/dist/edit-Bb0Ze4w6.mjs.map +1 -0
  109. package/dist/edit-BeFmC3XD.mjs +80 -0
  110. package/dist/edit-BeFmC3XD.mjs.map +1 -0
  111. package/dist/edit-DLDw_ZWX.mjs +86 -0
  112. package/dist/edit-DLDw_ZWX.mjs.map +1 -0
  113. package/dist/edit-z55ofr1S.mjs +40 -0
  114. package/dist/edit-z55ofr1S.mjs.map +1 -0
  115. package/dist/editor-xrF-j3UE.mjs +42 -0
  116. package/dist/editor-xrF-j3UE.mjs.map +1 -0
  117. package/dist/envelope-overlays-DPAlMNW1.mjs +26 -0
  118. package/dist/envelope-overlays-DPAlMNW1.mjs.map +1 -0
  119. package/dist/get-2qjq0wgG.mjs +28 -0
  120. package/dist/get-2qjq0wgG.mjs.map +1 -0
  121. package/dist/get-BGAk1Zmv.mjs +14 -0
  122. package/dist/get-BGAk1Zmv.mjs.map +1 -0
  123. package/dist/get-CRR13lgj.mjs +10 -0
  124. package/dist/get-CRR13lgj.mjs.map +1 -0
  125. package/dist/get-ClkpDBTL.mjs +13 -0
  126. package/dist/get-ClkpDBTL.mjs.map +1 -0
  127. package/dist/get-DJfUJ3sP.mjs +10 -0
  128. package/dist/get-DJfUJ3sP.mjs.map +1 -0
  129. package/dist/get-DiqaQvoS.mjs +14 -0
  130. package/dist/get-DiqaQvoS.mjs.map +1 -0
  131. package/dist/index.d.mts +338 -0
  132. package/dist/index.mjs +10 -0
  133. package/dist/list-BYzhflDg.mjs +14 -0
  134. package/dist/list-BYzhflDg.mjs.map +1 -0
  135. package/dist/list-DY-tPNG-.mjs +10 -0
  136. package/dist/list-DY-tPNG-.mjs.map +1 -0
  137. package/dist/list-DlQSkbqx.mjs +10 -0
  138. package/dist/list-DlQSkbqx.mjs.map +1 -0
  139. package/dist/list-DsrA5wIz.mjs +15 -0
  140. package/dist/list-DsrA5wIz.mjs.map +1 -0
  141. package/dist/list-Fp4nKfQb.mjs +10 -0
  142. package/dist/list-Fp4nKfQb.mjs.map +1 -0
  143. package/dist/list-s_tloiEX.mjs +10 -0
  144. package/dist/list-s_tloiEX.mjs.map +1 -0
  145. package/dist/litexml-codec-CDoRloiR.mjs +13451 -0
  146. package/dist/litexml-codec-CDoRloiR.mjs.map +1 -0
  147. package/dist/login-CLOJ-fTJ.mjs +579 -0
  148. package/dist/login-CLOJ-fTJ.mjs.map +1 -0
  149. package/dist/logout-v8ihxsim.mjs +11 -0
  150. package/dist/logout-v8ihxsim.mjs.map +1 -0
  151. package/dist/onboarding-640IldLz.mjs +888 -0
  152. package/dist/onboarding-640IldLz.mjs.map +1 -0
  153. package/dist/output-BM7aBFwt.mjs +120 -0
  154. package/dist/output-BM7aBFwt.mjs.map +1 -0
  155. package/dist/output-CTnO1lYt.d.mts +16 -0
  156. package/dist/payload-CN11pUto.mjs +547 -0
  157. package/dist/payload-CN11pUto.mjs.map +1 -0
  158. package/dist/publish-DkTYB-eK.mjs +23 -0
  159. package/dist/publish-DkTYB-eK.mjs.map +1 -0
  160. package/dist/publish-pRBfTJfe.mjs +23 -0
  161. package/dist/publish-pRBfTJfe.mjs.map +1 -0
  162. package/dist/resolve-BogJOR7R.mjs +119 -0
  163. package/dist/resolve-BogJOR7R.mjs.map +1 -0
  164. package/dist/resolve-Bp1AfBmM.mjs +26 -0
  165. package/dist/resolve-Bp1AfBmM.mjs.map +1 -0
  166. package/dist/resolve-Bw5Po9yK.mjs +16 -0
  167. package/dist/resolve-Bw5Po9yK.mjs.map +1 -0
  168. package/dist/resolve-CyjMlaoJ.mjs +23 -0
  169. package/dist/resolve-CyjMlaoJ.mjs.map +1 -0
  170. package/dist/resolve-helpers-CahPoJ0Y.mjs +30 -0
  171. package/dist/resolve-helpers-CahPoJ0Y.mjs.map +1 -0
  172. package/dist/set-BEGQz2si.mjs +43 -0
  173. package/dist/set-BEGQz2si.mjs.map +1 -0
  174. package/dist/shared-D0HVBDHI.mjs +39 -0
  175. package/dist/shared-D0HVBDHI.mjs.map +1 -0
  176. package/dist/status-LXrN9fI-.mjs +22 -0
  177. package/dist/status-LXrN9fI-.mjs.map +1 -0
  178. package/dist/update-B9ynFCdZ.mjs +30 -0
  179. package/dist/update-B9ynFCdZ.mjs.map +1 -0
  180. package/dist/update-BMZQPOvR.mjs +28 -0
  181. package/dist/update-BMZQPOvR.mjs.map +1 -0
  182. package/dist/update-BXz0l7Lz.mjs +36 -0
  183. package/dist/update-BXz0l7Lz.mjs.map +1 -0
  184. package/dist/update-Dx6AF8tf.mjs +30 -0
  185. package/dist/update-Dx6AF8tf.mjs.map +1 -0
  186. package/dist/update-q66TLS38.mjs +37 -0
  187. package/dist/update-q66TLS38.mjs.map +1 -0
  188. package/dist/whoami-CTkctOEd.mjs +22 -0
  189. package/dist/whoami-CTkctOEd.mjs.map +1 -0
  190. package/package.json +77 -0
@@ -0,0 +1,850 @@
1
+ import { A as $getCollapsedCaretRange, B as $getSiblingCaret, C as $getCaretInDirection, D as $getChildCaret, Gn as isHTMLElement, K as $isChildCaret, Kn as isInlineDomNode, L as $getPreviousSelection, M as $getEditorDOMRenderConfig, Pn as getDOMTextNode, Qn as removeClassNamesFromElement, R as $getRoot, S as $getAdjacentSiblingOrParentSiblingCaret, St as $splitNode, T as $getCaretRangeInDirection, Tn as addClassNamesToElement, V as $getState, Wn as isHTMLAnchorElement, Xn as mergeRegister, Y as $isElementNode, Yn as makeStepwiseIterator, a as $cloneWithProperties, b as $getAdjacentChildCaret, bt as $setState, dt as $normalizeCaret, f as $createParagraphNode, ht as $rewindSiblingCaret, i as $caretRangeFromSelection, j as $getEditor, k as $getChildCaretOrSelf, lt as $isTextPointCaret, mt as $removeTextFromCaretRange, ot as $isSiblingCaret, r as $caretFromPoint, rt as $isRangeSelection, vt as $setSelection, w as $getCaretRange, xt as $splitAtPointCaretNext, y as $findMatchingParent, yt as $setSelectionFromCaretRange, z as $getSelection, zn as isBlockDomNode } from "./Lexical.node-gYNDt_p9.mjs";
2
+ import { o as createRectsFromDOMRange } from "./LexicalSelection.node-Di7GwBCZ.mjs";
3
+ //#region ../../node_modules/.pnpm/@lexical+utils@0.44.0/node_modules/@lexical/utils/LexicalUtils.dev.mjs
4
+ /**
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ *
10
+ */
11
+ /**
12
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
13
+ *
14
+ * This source code is licensed under the MIT license found in the
15
+ * LICENSE file in the root directory of this source tree.
16
+ *
17
+ */
18
+ function formatDevErrorMessage(message) {
19
+ throw new Error(message);
20
+ }
21
+ /**
22
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
23
+ *
24
+ * This source code is licensed under the MIT license found in the
25
+ * LICENSE file in the root directory of this source tree.
26
+ *
27
+ */
28
+ const CAN_USE_DOM$1 = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
29
+ /**
30
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
31
+ *
32
+ * This source code is licensed under the MIT license found in the
33
+ * LICENSE file in the root directory of this source tree.
34
+ *
35
+ */
36
+ const documentMode = CAN_USE_DOM$1 && "documentMode" in document ? document.documentMode : null;
37
+ const IS_APPLE$1 = CAN_USE_DOM$1 && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
38
+ const IS_FIREFOX$1 = CAN_USE_DOM$1 && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
39
+ const CAN_USE_BEFORE_INPUT$1 = CAN_USE_DOM$1 && "InputEvent" in window && !documentMode ? "getTargetRanges" in new window.InputEvent("input") : false;
40
+ const IS_IOS$1 = CAN_USE_DOM$1 && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
41
+ const IS_ANDROID$1 = CAN_USE_DOM$1 && /Android/.test(navigator.userAgent);
42
+ const IS_SAFARI$1 = CAN_USE_DOM$1 && /Version\/[\d.]+.*Safari/.test(navigator.userAgent) && !IS_ANDROID$1;
43
+ const IS_CHROME$1 = CAN_USE_DOM$1 && /^(?=.*Chrome).*/i.test(navigator.userAgent);
44
+ const IS_ANDROID_CHROME$1 = CAN_USE_DOM$1 && IS_ANDROID$1 && IS_CHROME$1;
45
+ const IS_APPLE_WEBKIT$1 = CAN_USE_DOM$1 && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && IS_APPLE$1 && !IS_CHROME$1;
46
+ /**
47
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
48
+ *
49
+ * This source code is licensed under the MIT license found in the
50
+ * LICENSE file in the root directory of this source tree.
51
+ *
52
+ */
53
+ function px(value) {
54
+ return `${value}px`;
55
+ }
56
+ const mutationObserverConfig = {
57
+ attributes: true,
58
+ characterData: true,
59
+ childList: true,
60
+ subtree: true
61
+ };
62
+ function prependDOMNode(parent, node) {
63
+ parent.insertBefore(node, parent.firstChild);
64
+ }
65
+ /**
66
+ * Place one or multiple newly created Nodes at the passed Range's position.
67
+ * Multiple nodes will only be created when the Range spans multiple lines (aka
68
+ * client rects).
69
+ *
70
+ * This function can come particularly useful to highlight particular parts of
71
+ * the text without interfering with the EditorState, that will often replicate
72
+ * the state across collab and clipboard.
73
+ *
74
+ * This function accounts for DOM updates which can modify the passed Range.
75
+ * Hence, the function return to remove the listener.
76
+ */
77
+ function mlcPositionNodeOnRange(editor, range, onReposition) {
78
+ let rootDOMNode = null;
79
+ let parentDOMNode = null;
80
+ let observer = null;
81
+ let lastNodes = [];
82
+ const wrapperNode = document.createElement("div");
83
+ wrapperNode.style.position = "relative";
84
+ function position() {
85
+ if (!(rootDOMNode !== null)) formatDevErrorMessage(`Unexpected null rootDOMNode`);
86
+ if (!(parentDOMNode !== null)) formatDevErrorMessage(`Unexpected null parentDOMNode`);
87
+ const { left: parentLeft, top: parentTop } = parentDOMNode.getBoundingClientRect();
88
+ const rects = createRectsFromDOMRange(editor, range);
89
+ if (!wrapperNode.isConnected) prependDOMNode(parentDOMNode, wrapperNode);
90
+ let hasRepositioned = false;
91
+ for (let i = 0; i < rects.length; i++) {
92
+ const rect = rects[i];
93
+ const rectNode = lastNodes[i] || document.createElement("div");
94
+ const rectNodeStyle = rectNode.style;
95
+ if (rectNodeStyle.position !== "absolute") {
96
+ rectNodeStyle.position = "absolute";
97
+ hasRepositioned = true;
98
+ }
99
+ const left = px(rect.left - parentLeft);
100
+ if (rectNodeStyle.left !== left) {
101
+ rectNodeStyle.left = left;
102
+ hasRepositioned = true;
103
+ }
104
+ const top = px(rect.top - parentTop);
105
+ if (rectNodeStyle.top !== top) {
106
+ rectNode.style.top = top;
107
+ hasRepositioned = true;
108
+ }
109
+ const width = px(rect.width);
110
+ if (rectNodeStyle.width !== width) {
111
+ rectNode.style.width = width;
112
+ hasRepositioned = true;
113
+ }
114
+ const height = px(rect.height);
115
+ if (rectNodeStyle.height !== height) {
116
+ rectNode.style.height = height;
117
+ hasRepositioned = true;
118
+ }
119
+ if (rectNode.parentNode !== wrapperNode) {
120
+ wrapperNode.append(rectNode);
121
+ hasRepositioned = true;
122
+ }
123
+ lastNodes[i] = rectNode;
124
+ }
125
+ while (lastNodes.length > rects.length) lastNodes.pop();
126
+ if (hasRepositioned) onReposition(lastNodes);
127
+ }
128
+ function stop() {
129
+ parentDOMNode = null;
130
+ rootDOMNode = null;
131
+ if (observer !== null) observer.disconnect();
132
+ observer = null;
133
+ wrapperNode.remove();
134
+ for (const node of lastNodes) node.remove();
135
+ lastNodes = [];
136
+ }
137
+ function restart() {
138
+ const currentRootDOMNode = editor.getRootElement();
139
+ if (currentRootDOMNode === null) return stop();
140
+ const currentParentDOMNode = currentRootDOMNode.parentElement;
141
+ if (!isHTMLElement(currentParentDOMNode)) return stop();
142
+ stop();
143
+ rootDOMNode = currentRootDOMNode;
144
+ parentDOMNode = currentParentDOMNode;
145
+ observer = new MutationObserver((mutations) => {
146
+ const nextRootDOMNode = editor.getRootElement();
147
+ const nextParentDOMNode = nextRootDOMNode && nextRootDOMNode.parentElement;
148
+ if (nextRootDOMNode !== rootDOMNode || nextParentDOMNode !== parentDOMNode) return restart();
149
+ for (const mutation of mutations) if (!wrapperNode.contains(mutation.target)) return position();
150
+ });
151
+ observer.observe(currentParentDOMNode, mutationObserverConfig);
152
+ position();
153
+ }
154
+ const removeRootListener = editor.registerRootListener(restart);
155
+ return () => {
156
+ removeRootListener();
157
+ stop();
158
+ };
159
+ }
160
+ /**
161
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
162
+ *
163
+ * This source code is licensed under the MIT license found in the
164
+ * LICENSE file in the root directory of this source tree.
165
+ *
166
+ */
167
+ function $getOrderedSelectionPoints(selection) {
168
+ const points = selection.getStartEndPoints();
169
+ return selection.isBackward() ? [points[1], points[0]] : points;
170
+ }
171
+ function $rangeTargetFromPoint(point, node, dom) {
172
+ if (point.type === "text" || !$isElementNode(node)) return [getDOMTextNode(dom) || dom, point.offset];
173
+ else {
174
+ const editor = $getEditor();
175
+ const slot = $getEditorDOMRenderConfig(editor).$getDOMSlot(node, dom, editor);
176
+ return [slot.element, slot.getFirstChildOffset() + point.offset];
177
+ }
178
+ }
179
+ function $rangeFromPoints(editor, start, startNode, startDOM, end, endNode, endDOM) {
180
+ const range = (editor._window ? editor._window.document : document).createRange();
181
+ range.setStart(...$rangeTargetFromPoint(start, startNode, startDOM));
182
+ range.setEnd(...$rangeTargetFromPoint(end, endNode, endDOM));
183
+ return range;
184
+ }
185
+ function defaultOnReposition(domNodes) {
186
+ for (const domNode of domNodes) {
187
+ const domNodeStyle = domNode.style;
188
+ if (domNodeStyle.background !== "Highlight") domNodeStyle.background = "Highlight";
189
+ if (domNodeStyle.color !== "HighlightText") domNodeStyle.color = "HighlightText";
190
+ if (domNodeStyle.marginTop !== px(-1.5)) domNodeStyle.marginTop = px(-1.5);
191
+ if (domNodeStyle.paddingTop !== px(4)) domNodeStyle.paddingTop = px(4);
192
+ if (domNodeStyle.paddingBottom !== px(0)) domNodeStyle.paddingBottom = px(0);
193
+ }
194
+ }
195
+ /**
196
+ * Place one or multiple newly created Nodes at the current selection. Multiple
197
+ * nodes will only be created when the selection spans multiple lines (aka
198
+ * client rects).
199
+ *
200
+ * This function can come useful when you want to show the selection but the
201
+ * editor has been focused away.
202
+ */
203
+ function markSelection(editor, onReposition = defaultOnReposition) {
204
+ let previousAnchorNode = null;
205
+ let previousAnchorNodeDOM = null;
206
+ let previousAnchorOffset = null;
207
+ let previousFocusNode = null;
208
+ let previousFocusNodeDOM = null;
209
+ let previousFocusOffset = null;
210
+ let removeRangeListener = () => {};
211
+ function compute(editorState) {
212
+ editorState.read(() => {
213
+ const selection = $getSelection();
214
+ if (!$isRangeSelection(selection)) {
215
+ previousAnchorNode = null;
216
+ previousAnchorOffset = null;
217
+ previousFocusNode = null;
218
+ previousFocusOffset = null;
219
+ removeRangeListener();
220
+ removeRangeListener = () => {};
221
+ return;
222
+ }
223
+ const [start, end] = $getOrderedSelectionPoints(selection);
224
+ const currentStartNode = start.getNode();
225
+ const currentStartNodeKey = currentStartNode.getKey();
226
+ const currentStartOffset = start.offset;
227
+ const currentEndNode = end.getNode();
228
+ const currentEndNodeKey = currentEndNode.getKey();
229
+ const currentEndOffset = end.offset;
230
+ const currentStartNodeDOM = editor.getElementByKey(currentStartNodeKey);
231
+ const currentEndNodeDOM = editor.getElementByKey(currentEndNodeKey);
232
+ const differentStartDOM = previousAnchorNode === null || currentStartNodeDOM !== previousAnchorNodeDOM || currentStartOffset !== previousAnchorOffset || currentStartNodeKey !== previousAnchorNode.getKey();
233
+ const differentEndDOM = previousFocusNode === null || currentEndNodeDOM !== previousFocusNodeDOM || currentEndOffset !== previousFocusOffset || currentEndNodeKey !== previousFocusNode.getKey();
234
+ if ((differentStartDOM || differentEndDOM) && currentStartNodeDOM !== null && currentEndNodeDOM !== null) {
235
+ const range = $rangeFromPoints(editor, start, currentStartNode, currentStartNodeDOM, end, currentEndNode, currentEndNodeDOM);
236
+ removeRangeListener();
237
+ removeRangeListener = mlcPositionNodeOnRange(editor, range, onReposition);
238
+ }
239
+ previousAnchorNode = currentStartNode;
240
+ previousAnchorNodeDOM = currentStartNodeDOM;
241
+ previousAnchorOffset = currentStartOffset;
242
+ previousFocusNode = currentEndNode;
243
+ previousFocusNodeDOM = currentEndNodeDOM;
244
+ previousFocusOffset = currentEndOffset;
245
+ });
246
+ }
247
+ compute(editor.getEditorState());
248
+ return mergeRegister(editor.registerUpdateListener(({ editorState }) => compute(editorState)), () => {
249
+ removeRangeListener();
250
+ });
251
+ }
252
+ /**
253
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
254
+ *
255
+ * This source code is licensed under the MIT license found in the
256
+ * LICENSE file in the root directory of this source tree.
257
+ *
258
+ */
259
+ function selectionAlwaysOnDisplay(editor, onReposition) {
260
+ let removeSelectionMark = null;
261
+ const onSelectionChange = () => {
262
+ const domSelection = getSelection();
263
+ const domAnchorNode = domSelection && domSelection.anchorNode;
264
+ const editorRootElement = editor.getRootElement();
265
+ if (domAnchorNode !== null && editorRootElement !== null && editorRootElement.contains(domAnchorNode)) {
266
+ if (removeSelectionMark !== null) {
267
+ removeSelectionMark();
268
+ removeSelectionMark = null;
269
+ }
270
+ } else if (removeSelectionMark === null) removeSelectionMark = markSelection(editor, onReposition);
271
+ };
272
+ return editor.registerRootListener((rootElement) => {
273
+ if (rootElement) {
274
+ const document = rootElement.ownerDocument;
275
+ document.addEventListener("selectionchange", onSelectionChange);
276
+ onSelectionChange();
277
+ return () => {
278
+ if (removeSelectionMark !== null) removeSelectionMark();
279
+ document.removeEventListener("selectionchange", onSelectionChange);
280
+ };
281
+ }
282
+ });
283
+ }
284
+ const CAN_USE_BEFORE_INPUT = CAN_USE_BEFORE_INPUT$1;
285
+ const CAN_USE_DOM = CAN_USE_DOM$1;
286
+ const IS_ANDROID = IS_ANDROID$1;
287
+ const IS_ANDROID_CHROME = IS_ANDROID_CHROME$1;
288
+ const IS_APPLE = IS_APPLE$1;
289
+ const IS_APPLE_WEBKIT = IS_APPLE_WEBKIT$1;
290
+ const IS_CHROME = IS_CHROME$1;
291
+ const IS_FIREFOX = IS_FIREFOX$1;
292
+ const IS_IOS = IS_IOS$1;
293
+ const IS_SAFARI = IS_SAFARI$1;
294
+ /**
295
+ * Returns true if the file type matches the types passed within the acceptableMimeTypes array, false otherwise.
296
+ * The types passed must be strings and are CASE-SENSITIVE.
297
+ * eg. if file is of type 'text' and acceptableMimeTypes = ['TEXT', 'IMAGE'] the function will return false.
298
+ * @param file - The file you want to type check.
299
+ * @param acceptableMimeTypes - An array of strings of types which the file is checked against.
300
+ * @returns true if the file is an acceptable mime type, false otherwise.
301
+ */
302
+ function isMimeType(file, acceptableMimeTypes) {
303
+ for (const acceptableType of acceptableMimeTypes) if (file.type.startsWith(acceptableType)) return true;
304
+ return false;
305
+ }
306
+ /**
307
+ * Lexical File Reader with:
308
+ * 1. MIME type support
309
+ * 2. batched results (HistoryPlugin compatibility)
310
+ * 3. Order aware (respects the order when multiple Files are passed)
311
+ *
312
+ * const filesResult = await mediaFileReader(files, ['image/']);
313
+ * filesResult.forEach(file => editor.dispatchCommand('INSERT_IMAGE', \\{
314
+ * src: file.result,
315
+ * \\}));
316
+ */
317
+ function mediaFileReader(files, acceptableMimeTypes) {
318
+ const filesIterator = files[Symbol.iterator]();
319
+ return new Promise((resolve, reject) => {
320
+ const processed = [];
321
+ const handleNextFile = () => {
322
+ const { done, value: file } = filesIterator.next();
323
+ if (done) return resolve(processed);
324
+ const fileReader = new FileReader();
325
+ fileReader.addEventListener("error", reject);
326
+ fileReader.addEventListener("load", () => {
327
+ const result = fileReader.result;
328
+ if (typeof result === "string") processed.push({
329
+ file,
330
+ result
331
+ });
332
+ handleNextFile();
333
+ });
334
+ if (isMimeType(file, acceptableMimeTypes)) fileReader.readAsDataURL(file);
335
+ else handleNextFile();
336
+ };
337
+ handleNextFile();
338
+ });
339
+ }
340
+ /**
341
+ * "Depth-First Search" starts at the root/top node of a tree and goes as far as it can down a branch end
342
+ * before backtracking and finding a new path. Consider solving a maze by hugging either wall, moving down a
343
+ * branch until you hit a dead-end (leaf) and backtracking to find the nearest branching path and repeat.
344
+ * It will then return all the nodes found in the search in an array of objects.
345
+ * Preorder traversal is used, meaning that nodes are listed in the order of when they are FIRST encountered.
346
+ * @param startNode - The node to start the search (inclusive), if omitted, it will start at the root node.
347
+ * @param endNode - The node to end the search (inclusive), if omitted, it will find all descendants of the startingNode. If endNode
348
+ * is an ElementNode, it will stop before visiting any of its children.
349
+ * @returns An array of objects of all the nodes found by the search, including their depth into the tree.
350
+ * \\{depth: number, node: LexicalNode\\} It will always return at least 1 node (the start node).
351
+ */
352
+ function $dfs(startNode, endNode) {
353
+ return Array.from($dfsIterator(startNode, endNode));
354
+ }
355
+ /**
356
+ * Get the adjacent caret in the same direction
357
+ *
358
+ * @param caret A caret or null
359
+ * @returns `caret.getAdjacentCaret()` or `null`
360
+ */
361
+ function $getAdjacentCaret(caret) {
362
+ return caret ? caret.getAdjacentCaret() : null;
363
+ }
364
+ /**
365
+ * $dfs iterator (right to left). Tree traversal is done on the fly as new values are requested with O(1) memory.
366
+ * @param startNode - The node to start the search, if omitted, it will start at the root node.
367
+ * @param endNode - The node to end the search, if omitted, it will find all descendants of the startingNode.
368
+ * @returns An iterator, each yielded value is a DFSNode. It will always return at least 1 node (the start node).
369
+ */
370
+ function $reverseDfs(startNode, endNode) {
371
+ return Array.from($reverseDfsIterator(startNode, endNode));
372
+ }
373
+ /**
374
+ * $dfs iterator (left to right). Tree traversal is done on the fly as new values are requested with O(1) memory.
375
+ * Preorder traversal is used, meaning that nodes are iterated over in the order of when they are FIRST encountered.
376
+ * @param startNode - The node to start the search (inclusive), if omitted, it will start at the root node.
377
+ * @param endNode - The node to end the search (inclusive), if omitted, it will find all descendants of the startingNode.
378
+ * If endNode is an ElementNode, the iterator will end as soon as it reaches the endNode (no children will be visited).
379
+ * @returns An iterator, each yielded value is a DFSNode. It will always return at least 1 node (the start node).
380
+ */
381
+ function $dfsIterator(startNode, endNode) {
382
+ return $dfsCaretIterator("next", startNode, endNode);
383
+ }
384
+ function $getEndCaret(startNode, direction) {
385
+ const rval = $getAdjacentSiblingOrParentSiblingCaret($getSiblingCaret(startNode, direction));
386
+ return rval && rval[0];
387
+ }
388
+ function $dfsCaretIterator(direction, startNode, endNode) {
389
+ const root = $getRoot();
390
+ const start = startNode || root;
391
+ const startCaret = $isElementNode(start) ? $getChildCaret(start, direction) : $getSiblingCaret(start, direction);
392
+ const startDepth = $getDepth(start);
393
+ const endCaret = endNode ? $getAdjacentChildCaret($getChildCaretOrSelf($getSiblingCaret(endNode, direction))) || $getEndCaret(endNode, direction) : $getEndCaret(start, direction);
394
+ let depth = startDepth;
395
+ return makeStepwiseIterator({
396
+ hasNext: (state) => state !== null,
397
+ initial: startCaret,
398
+ map: (state) => ({
399
+ depth,
400
+ node: state.origin
401
+ }),
402
+ step: (state) => {
403
+ if (state.isSameNodeCaret(endCaret)) return null;
404
+ if ($isChildCaret(state)) depth++;
405
+ const rval = $getAdjacentSiblingOrParentSiblingCaret(state);
406
+ if (!rval || rval[0].isSameNodeCaret(endCaret)) return null;
407
+ depth += rval[1];
408
+ return rval[0];
409
+ }
410
+ });
411
+ }
412
+ /**
413
+ * Returns the Node sibling when this exists, otherwise the closest parent sibling. For example
414
+ * R -> P -> T1, T2
415
+ * -> P2
416
+ * returns T2 for node T1, P2 for node T2, and null for node P2.
417
+ * @param node LexicalNode.
418
+ * @returns An array (tuple) containing the found Lexical node and the depth difference, or null, if this node doesn't exist.
419
+ */
420
+ function $getNextSiblingOrParentSibling(node) {
421
+ const rval = $getAdjacentSiblingOrParentSiblingCaret($getSiblingCaret(node, "next"));
422
+ return rval && [rval[0].origin, rval[1]];
423
+ }
424
+ function $getDepth(node) {
425
+ let depth = -1;
426
+ for (let innerNode = node; innerNode !== null; innerNode = innerNode.getParent()) depth++;
427
+ return depth;
428
+ }
429
+ /**
430
+ * Performs a right-to-left preorder tree traversal.
431
+ * From the starting node it goes to the rightmost child, than backtracks to parent and finds new rightmost path.
432
+ * It will return the next node in traversal sequence after the startingNode.
433
+ * The traversal is similar to $dfs functions above, but the nodes are visited right-to-left, not left-to-right.
434
+ * @param startingNode - The node to start the search.
435
+ * @returns The next node in pre-order right to left traversal sequence or `null`, if the node does not exist
436
+ */
437
+ function $getNextRightPreorderNode(startingNode) {
438
+ const next = $getAdjacentSiblingOrParentSiblingCaret($getChildCaretOrSelf($getSiblingCaret(startingNode, "previous")), "root");
439
+ return next && next[0].origin;
440
+ }
441
+ /**
442
+ * $dfs iterator (right to left). Tree traversal is done on the fly as new values are requested with O(1) memory.
443
+ * @param startNode - The node to start the search, if omitted, it will start at the root node.
444
+ * @param endNode - The node to end the search, if omitted, it will find all descendants of the startingNode.
445
+ * @returns An iterator, each yielded value is a DFSNode. It will always return at least 1 node (the start node).
446
+ */
447
+ function $reverseDfsIterator(startNode, endNode) {
448
+ return $dfsCaretIterator("previous", startNode, endNode);
449
+ }
450
+ /**
451
+ * Takes a node and traverses up its ancestors (toward the root node)
452
+ * in order to find a specific type of node.
453
+ * @param node - the node to begin searching.
454
+ * @param klass - an instance of the type of node to look for.
455
+ * @returns the node of type klass that was passed, or null if none exist.
456
+ */
457
+ function $getNearestNodeOfType(node, klass) {
458
+ let parent = node;
459
+ while (parent != null) {
460
+ if (parent instanceof klass) return parent;
461
+ parent = parent.getParent();
462
+ }
463
+ return null;
464
+ }
465
+ /**
466
+ * Returns the element node of the nearest ancestor, otherwise throws an error.
467
+ * @param startNode - The starting node of the search
468
+ * @returns The ancestor node found
469
+ */
470
+ function $getNearestBlockElementAncestorOrThrow(startNode) {
471
+ const blockNode = $findMatchingParent(startNode, (node) => $isElementNode(node) && !node.isInline());
472
+ if (!$isElementNode(blockNode)) formatDevErrorMessage(`Expected node ${startNode.__key} to have closest block element node.`);
473
+ return blockNode;
474
+ }
475
+ /**
476
+ * Attempts to resolve nested element nodes of the same type into a single node of that type.
477
+ * It is generally used for marks/commenting
478
+ * @param editor - The lexical editor
479
+ * @param targetNode - The target for the nested element to be extracted from.
480
+ * @param cloneNode - See {@link $createMarkNode}
481
+ * @param handleOverlap - Handles any overlap between the node to extract and the targetNode
482
+ * @returns The lexical editor
483
+ */
484
+ function registerNestedElementResolver(editor, targetNode, cloneNode, handleOverlap) {
485
+ const $isTargetNode = (node) => {
486
+ return node instanceof targetNode;
487
+ };
488
+ const $findMatch = (node) => {
489
+ const children = node.getChildren();
490
+ for (let i = 0; i < children.length; i++) {
491
+ const child = children[i];
492
+ if ($isTargetNode(child)) return null;
493
+ }
494
+ let parentNode = node;
495
+ let childNode = node;
496
+ while (parentNode !== null) {
497
+ childNode = parentNode;
498
+ parentNode = parentNode.getParent();
499
+ if ($isTargetNode(parentNode)) return {
500
+ child: childNode,
501
+ parent: parentNode
502
+ };
503
+ }
504
+ return null;
505
+ };
506
+ const $elementNodeTransform = (node) => {
507
+ const match = $findMatch(node);
508
+ if (match !== null) {
509
+ const { child, parent } = match;
510
+ if (child.is(node)) {
511
+ handleOverlap(parent, node);
512
+ const nextSiblings = child.getNextSiblings();
513
+ const nextSiblingsLength = nextSiblings.length;
514
+ parent.insertAfter(child);
515
+ if (nextSiblingsLength !== 0) {
516
+ const newParent = cloneNode(parent);
517
+ child.insertAfter(newParent);
518
+ for (let i = 0; i < nextSiblingsLength; i++) newParent.append(nextSiblings[i]);
519
+ }
520
+ if (!parent.canBeEmpty() && parent.getChildrenSize() === 0) parent.remove();
521
+ }
522
+ }
523
+ };
524
+ return editor.registerNodeTransform(targetNode, $elementNodeTransform);
525
+ }
526
+ /**
527
+ * Clones the editor and marks it as dirty to be reconciled. If there was a selection,
528
+ * it would be set back to its previous state, or null otherwise.
529
+ * @param editor - The lexical editor
530
+ * @param editorState - The editor's state
531
+ */
532
+ function $restoreEditorState(editor, editorState) {
533
+ const FULL_RECONCILE = 2;
534
+ const nodeMap = /* @__PURE__ */ new Map();
535
+ const activeEditorState = editor._pendingEditorState;
536
+ for (const [key, node] of editorState._nodeMap) nodeMap.set(key, $cloneWithProperties(node));
537
+ if (activeEditorState) activeEditorState._nodeMap = nodeMap;
538
+ editor._dirtyType = FULL_RECONCILE;
539
+ const selection = editorState._selection;
540
+ $setSelection(selection === null ? null : selection.clone());
541
+ }
542
+ /**
543
+ * If the selected insertion area is the root/shadow root node (see {@link lexical!$isRootOrShadowRoot}),
544
+ * the node will be appended there, otherwise, it will be inserted before the insertion area.
545
+ * If there is no selection where the node is to be inserted, it will be appended after any current nodes
546
+ * within the tree, as a child of the root node. A paragraph will then be added after the inserted node and selected.
547
+ * @param node - The node to be inserted
548
+ * @returns The node after its insertion
549
+ */
550
+ function $insertNodeToNearestRoot(node) {
551
+ const selection = $getSelection() || $getPreviousSelection();
552
+ let initialCaret;
553
+ if ($isRangeSelection(selection)) initialCaret = $caretFromPoint(selection.focus, "next");
554
+ else {
555
+ if (selection != null) {
556
+ const nodes = selection.getNodes();
557
+ const lastNode = nodes[nodes.length - 1];
558
+ if (lastNode) initialCaret = $getSiblingCaret(lastNode, "next");
559
+ }
560
+ initialCaret = initialCaret || $getChildCaret($getRoot(), "previous").getFlipped().insert($createParagraphNode());
561
+ }
562
+ const insertCaret = $insertNodeToNearestRootAtCaret(node, initialCaret);
563
+ const adjacent = $getAdjacentChildCaret(insertCaret);
564
+ $setSelectionFromCaretRange($getCollapsedCaretRange($isChildCaret(adjacent) ? $normalizeCaret(adjacent) : insertCaret));
565
+ return node.getLatest();
566
+ }
567
+ /**
568
+ * If the insertion caret is the root/shadow root node (see {@link lexical!$isRootOrShadowRoot}),
569
+ * the node will be inserted there, otherwise the parent nodes will be split according to the
570
+ * given options.
571
+ * @param node - The node to be inserted
572
+ * @param caret - The location to insert or split from
573
+ * @returns The node after its insertion
574
+ */
575
+ function $insertNodeToNearestRootAtCaret(node, caret, options) {
576
+ let insertCaret = $getCaretInDirection(caret, "next");
577
+ if ($isTextPointCaret(insertCaret)) {
578
+ if (insertCaret.offset === 0) insertCaret = $getSiblingCaret(insertCaret.origin, "previous").getFlipped();
579
+ else if (insertCaret.offset === insertCaret.origin.getTextContentSize()) insertCaret = $getSiblingCaret(insertCaret.origin, "next");
580
+ }
581
+ if (insertCaret.origin.is(node)) {
582
+ if (!$isSiblingCaret(insertCaret)) formatDevErrorMessage(`$insertNodeToNearestRootAtCaret node ${node.getKey()} of type ${node.getType()} can not be inserted into itself`);
583
+ insertCaret = $rewindSiblingCaret(insertCaret);
584
+ }
585
+ if (node.is(insertCaret.getNodeAtCaret()) || node.is(insertCaret.getFlipped().getNodeAtCaret())) node.remove(true);
586
+ for (let nextCaret = insertCaret; nextCaret; nextCaret = $splitAtPointCaretNext(nextCaret, options)) insertCaret = nextCaret;
587
+ if (!!$isTextPointCaret(insertCaret)) formatDevErrorMessage(`$insertNodeToNearestRootAtCaret: An unattached TextNode can not be split`);
588
+ insertCaret.insert(node.isInline() ? $createParagraphNode().append(node) : node);
589
+ return $getCaretInDirection($getSiblingCaret(node.getLatest(), "next"), caret.direction);
590
+ }
591
+ /**
592
+ * Inserts a node into leaf — the deepest accessible node at the carriage position
593
+ * @param node - The node to be inserted
594
+ */
595
+ function $insertNodeIntoLeaf(node) {
596
+ const selection = $getSelection();
597
+ if (!$isRangeSelection(selection)) {
598
+ if (selection) selection.insertNodes([node]);
599
+ return;
600
+ }
601
+ let insertCaret = $getCaretRangeInDirection($removeTextFromCaretRange($caretRangeFromSelection(selection)), "next").anchor;
602
+ if ($isTextPointCaret(insertCaret)) {
603
+ const nextAnchor = $splitAtPointCaretNext(insertCaret);
604
+ if (!nextAnchor) return;
605
+ insertCaret = nextAnchor;
606
+ }
607
+ const focus = insertCaret.getFlipped();
608
+ focus.insert(node);
609
+ $setSelectionFromCaretRange($getCaretRange(focus, focus));
610
+ }
611
+ /**
612
+ * Wraps the node into another node created from a createElementNode function, eg. $createParagraphNode
613
+ * @param node - Node to be wrapped.
614
+ * @param createElementNode - Creates a new lexical element to wrap the to-be-wrapped node and returns it.
615
+ * @returns A new lexical element with the previous node appended within (as a child, including its children).
616
+ */
617
+ function $wrapNodeInElement(node, createElementNode) {
618
+ const elementNode = createElementNode();
619
+ node.replace(elementNode);
620
+ elementNode.append(node);
621
+ return elementNode;
622
+ }
623
+ /**
624
+ * @param object = The instance of the type
625
+ * @param objectClass = The class of the type
626
+ * @returns Whether the object is has the same Klass of the objectClass, ignoring the difference across window (e.g. different iframes)
627
+ */
628
+ function objectKlassEquals(object, objectClass) {
629
+ return object !== null ? Object.getPrototypeOf(object).constructor.name === objectClass.name : false;
630
+ }
631
+ /**
632
+ * @deprecated Use Array filter or flatMap
633
+ *
634
+ * Filter the nodes
635
+ * @param nodes Array of nodes that needs to be filtered
636
+ * @param filterFn A filter function that returns node if the current node satisfies the condition otherwise null
637
+ * @returns Array of filtered nodes
638
+ */
639
+ function $filter(nodes, filterFn) {
640
+ const result = [];
641
+ for (let i = 0; i < nodes.length; i++) {
642
+ const node = filterFn(nodes[i]);
643
+ if (node !== null) result.push(node);
644
+ }
645
+ return result;
646
+ }
647
+ /**
648
+ * Applies the provided callback to each indentable block element in the Selection
649
+ *
650
+ * @param indentOrOutdent callback for performing the indent or outdent action
651
+ * on a given block element.
652
+ * @returns true if at least one block was handled, false otherwise.
653
+ */
654
+ function $handleIndentAndOutdent(indentOrOutdent) {
655
+ const selection = $getSelection();
656
+ if (!$isRangeSelection(selection)) return false;
657
+ const alreadyHandled = /* @__PURE__ */ new Set();
658
+ const nodes = selection.getNodes();
659
+ for (let i = 0; i < nodes.length; i++) {
660
+ const node = nodes[i];
661
+ const key = node.getKey();
662
+ if (alreadyHandled.has(key)) continue;
663
+ const parentBlock = $findMatchingParent(node, (parentNode) => $isElementNode(parentNode) && !parentNode.isInline());
664
+ if (parentBlock === null) continue;
665
+ const parentKey = parentBlock.getKey();
666
+ if (parentBlock.canIndent() && !alreadyHandled.has(parentKey)) {
667
+ alreadyHandled.add(parentKey);
668
+ indentOrOutdent(parentBlock);
669
+ }
670
+ }
671
+ return alreadyHandled.size > 0;
672
+ }
673
+ /**
674
+ * Appends the node before the first child of the parent node
675
+ * @param parent A parent node
676
+ * @param node Node that needs to be appended
677
+ */
678
+ function $insertFirst(parent, node) {
679
+ $getChildCaret(parent, "next").insert(node);
680
+ }
681
+ let NEEDS_MANUAL_ZOOM = IS_FIREFOX || !CAN_USE_DOM ? false : void 0;
682
+ function needsManualZoom() {
683
+ if (NEEDS_MANUAL_ZOOM === void 0) {
684
+ const div = document.createElement("div");
685
+ div.style.position = "absolute";
686
+ div.style.opacity = "0";
687
+ div.style.width = "100px";
688
+ div.style.left = "-1000px";
689
+ document.body.appendChild(div);
690
+ const noZoom = div.getBoundingClientRect();
691
+ div.style.setProperty("zoom", "2");
692
+ NEEDS_MANUAL_ZOOM = div.getBoundingClientRect().width === noZoom.width;
693
+ document.body.removeChild(div);
694
+ }
695
+ return NEEDS_MANUAL_ZOOM;
696
+ }
697
+ /**
698
+ * Calculates the zoom level of an element as a result of using
699
+ * css zoom property. For browsers that implement standardized CSS
700
+ * zoom (Firefox, Chrome >= 128), this will always return 1.
701
+ * @param element
702
+ * @param useManualZoom - If true, always use zoom level will be calculated manually, otherwise it will be calculated on as needed basis.
703
+ */
704
+ function calculateZoomLevel(element, useManualZoom = false) {
705
+ let zoom = 1;
706
+ if (needsManualZoom() || useManualZoom) while (element) {
707
+ zoom *= Number(window.getComputedStyle(element).getPropertyValue("zoom"));
708
+ element = element.parentElement;
709
+ }
710
+ return zoom;
711
+ }
712
+ /**
713
+ * Checks if the editor is a nested editor created by LexicalNestedComposer
714
+ */
715
+ function $isEditorIsNestedEditor(editor) {
716
+ return editor._parentEditor !== null;
717
+ }
718
+ /**
719
+ * A depth first last-to-first traversal of root that stops at each node that matches
720
+ * $predicate and ensures that its parent is root. This is typically used to discard
721
+ * invalid or unsupported wrapping nodes. For example, a TableNode must only have
722
+ * TableRowNode as children, but an importer might add invalid nodes based on
723
+ * caption, tbody, thead, etc. and this will unwrap and discard those.
724
+ *
725
+ * @param root The root to start the traversal
726
+ * @param $predicate Should return true for nodes that are permitted to be children of root
727
+ * @returns true if this unwrapped or removed any nodes
728
+ */
729
+ function $unwrapAndFilterDescendants(root, $predicate) {
730
+ return $unwrapAndFilterDescendantsImpl(root, $predicate, null);
731
+ }
732
+ function $unwrapAndFilterDescendantsImpl(root, $predicate, $onSuccess) {
733
+ let didMutate = false;
734
+ for (const node of $lastToFirstIterator(root)) {
735
+ if ($predicate(node)) {
736
+ if ($onSuccess !== null) $onSuccess(node);
737
+ continue;
738
+ }
739
+ didMutate = true;
740
+ if ($isElementNode(node)) $unwrapAndFilterDescendantsImpl(node, $predicate, $onSuccess || ((child) => node.insertAfter(child)));
741
+ node.remove();
742
+ }
743
+ return didMutate;
744
+ }
745
+ /**
746
+ * A depth first traversal of the children array that stops at and collects
747
+ * each node that `$predicate` matches. This is typically used to discard
748
+ * invalid or unsupported wrapping nodes on a children array in the `after`
749
+ * of an {@link lexical!DOMConversionOutput}. For example, a TableNode must only have
750
+ * TableRowNode as children, but an importer might add invalid nodes based on
751
+ * caption, tbody, thead, etc. and this will unwrap and discard those.
752
+ *
753
+ * This function is read-only and performs no mutation operations, which makes
754
+ * it suitable for import and export purposes but likely not for any in-place
755
+ * mutation. You should use {@link $unwrapAndFilterDescendants} for in-place
756
+ * mutations such as node transforms.
757
+ *
758
+ * @param children The children to traverse
759
+ * @param $predicate Should return true for nodes that are permitted to be children of root
760
+ * @returns The children or their descendants that match $predicate
761
+ */
762
+ function $descendantsMatching(children, $predicate) {
763
+ const result = [];
764
+ const stack = Array.from(children).reverse();
765
+ for (let child = stack.pop(); child !== void 0; child = stack.pop()) if ($predicate(child)) result.push(child);
766
+ else if ($isElementNode(child)) for (const grandchild of $lastToFirstIterator(child)) stack.push(grandchild);
767
+ return result;
768
+ }
769
+ /**
770
+ * Return an iterator that yields each child of node from first to last, taking
771
+ * care to preserve the next sibling before yielding the value in case the caller
772
+ * removes the yielded node.
773
+ *
774
+ * @param node The node whose children to iterate
775
+ * @returns An iterator of the node's children
776
+ */
777
+ function $firstToLastIterator(node) {
778
+ return $childIterator($getChildCaret(node, "next"));
779
+ }
780
+ /**
781
+ * Return an iterator that yields each child of node from last to first, taking
782
+ * care to preserve the previous sibling before yielding the value in case the caller
783
+ * removes the yielded node.
784
+ *
785
+ * @param node The node whose children to iterate
786
+ * @returns An iterator of the node's children
787
+ */
788
+ function $lastToFirstIterator(node) {
789
+ return $childIterator($getChildCaret(node, "previous"));
790
+ }
791
+ function $childIterator(startCaret) {
792
+ const seen = /* @__PURE__ */ new Set();
793
+ return makeStepwiseIterator({
794
+ hasNext: $isSiblingCaret,
795
+ initial: startCaret.getAdjacentCaret(),
796
+ map: (caret) => {
797
+ const origin = caret.origin.getLatest();
798
+ if (seen !== null) {
799
+ const key = origin.getKey();
800
+ if (!!seen.has(key)) formatDevErrorMessage(`$childIterator: Cycle detected, node with key ${String(key)} has already been traversed`);
801
+ seen.add(key);
802
+ }
803
+ return origin;
804
+ },
805
+ step: (caret) => caret.getAdjacentCaret()
806
+ });
807
+ }
808
+ /**
809
+ * Replace this node with its children
810
+ *
811
+ * @param node The ElementNode to unwrap and remove
812
+ */
813
+ function $unwrapNode(node) {
814
+ $rewindSiblingCaret($getSiblingCaret(node, "next")).splice(1, node.getChildren());
815
+ }
816
+ /**
817
+ * A wrapper that creates bound functions and methods for the
818
+ * StateConfig to save some boilerplate when defining methods
819
+ * or exporting only the accessors from your modules rather
820
+ * than exposing the StateConfig directly.
821
+ */
822
+ /**
823
+ * EXPERIMENTAL
824
+ *
825
+ * A convenience interface for working with {@link $getState} and
826
+ * {@link $setState}.
827
+ *
828
+ * @param stateConfig The stateConfig to wrap with convenience functionality
829
+ * @returns a StateWrapper
830
+ */
831
+ function makeStateWrapper(stateConfig) {
832
+ const $get = (node) => $getState(node, stateConfig);
833
+ const $set = (node, valueOrUpdater) => $setState(node, stateConfig, valueOrUpdater);
834
+ return {
835
+ $get,
836
+ $set,
837
+ accessors: [$get, $set],
838
+ makeGetterMethod: () => function $getter() {
839
+ return $get(this);
840
+ },
841
+ makeSetterMethod: () => function $setter(valueOrUpdater) {
842
+ return $set(this, valueOrUpdater);
843
+ },
844
+ stateConfig
845
+ };
846
+ }
847
+ //#endregion
848
+ export { $descendantsMatching, $dfs, $dfsIterator, $filter, $findMatchingParent, $firstToLastIterator, $getAdjacentCaret, $getAdjacentSiblingOrParentSiblingCaret, $getDepth, $getNearestBlockElementAncestorOrThrow, $getNearestNodeOfType, $getNextRightPreorderNode, $getNextSiblingOrParentSibling, $handleIndentAndOutdent, $insertFirst, $insertNodeIntoLeaf, $insertNodeToNearestRoot, $insertNodeToNearestRootAtCaret, $isEditorIsNestedEditor, $lastToFirstIterator, $restoreEditorState, $reverseDfs, $reverseDfsIterator, $splitNode, $unwrapAndFilterDescendants, $unwrapNode, $wrapNodeInElement, CAN_USE_BEFORE_INPUT, CAN_USE_DOM, IS_ANDROID, IS_ANDROID_CHROME, IS_APPLE, IS_APPLE_WEBKIT, IS_CHROME, IS_FIREFOX, IS_IOS, IS_SAFARI, addClassNamesToElement, calculateZoomLevel, isBlockDomNode, isHTMLAnchorElement, isHTMLElement, isInlineDomNode, isMimeType, makeStateWrapper, markSelection, mediaFileReader, mergeRegister, objectKlassEquals, mlcPositionNodeOnRange as positionNodeOnRange, registerNestedElementResolver, removeClassNamesFromElement, selectionAlwaysOnDisplay };
849
+
850
+ //# sourceMappingURL=LexicalUtils.dev-DiUpsXE8.mjs.map