@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,725 @@
1
+ import { $t as INTERNAL_$isBlock, E as $getCharacterOffsets, K as $isChildCaret, L as $getPreviousSelection, Ln as getStyleObjectFromCSS$1, P as $getNodeByKey, Q as $isLeafNode, U as $hasAncestor, X as $isExtendableTextPointCaret, Y as $isElementNode, _ as $createTextNode, a as $cloneWithProperties, at as $isRootOrShadowRoot, ct as $isTextNode, gt as $selectAll, i as $caretRangeFromSelection, it as $isRootNode, j as $getEditor, m as $createRangeSelection, o as $cloneWithPropertiesEphemeral, q as $isDecoratorNode, r as $caretFromPoint, rt as $isRangeSelection, ut as $isTokenOrSegmented, v as $extendCaretToRange, vt as $setSelection, y as $findMatchingParent, z as $getSelection } from "./Lexical.node-gYNDt_p9.mjs";
2
+ //#region ../../node_modules/.pnpm/@lexical+selection@0.44.0/node_modules/@lexical/selection/LexicalSelection.dev.mjs
3
+ /**
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ *
9
+ */
10
+ /**
11
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
12
+ *
13
+ * This source code is licensed under the MIT license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ *
16
+ */
17
+ function formatDevErrorMessage(message) {
18
+ throw new Error(message);
19
+ }
20
+ /**
21
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ *
26
+ */
27
+ function warnOnlyOnce(message) {
28
+ {
29
+ let run = false;
30
+ return () => {
31
+ if (!run) console.warn(message);
32
+ run = true;
33
+ };
34
+ }
35
+ }
36
+ /**
37
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
38
+ *
39
+ * This source code is licensed under the MIT license found in the
40
+ * LICENSE file in the root directory of this source tree.
41
+ *
42
+ */
43
+ function getDOMTextNode(element) {
44
+ let node = element;
45
+ while (node != null) {
46
+ if (node.nodeType === Node.TEXT_NODE) return node;
47
+ node = node.firstChild;
48
+ }
49
+ return null;
50
+ }
51
+ function getDOMIndexWithinParent(node) {
52
+ const parent = node.parentNode;
53
+ if (parent == null) throw new Error("Should never happen");
54
+ return [parent, Array.from(parent.childNodes).indexOf(node)];
55
+ }
56
+ /**
57
+ * Creates a selection range for the DOM.
58
+ * @param editor - The lexical editor.
59
+ * @param anchorNode - The anchor node of a selection.
60
+ * @param _anchorOffset - The amount of space offset from the anchor to the focus.
61
+ * @param focusNode - The current focus.
62
+ * @param _focusOffset - The amount of space offset from the focus to the anchor.
63
+ * @returns The range of selection for the DOM that was created.
64
+ */
65
+ function createDOMRange(editor, anchorNode, _anchorOffset, focusNode, _focusOffset) {
66
+ const anchorKey = anchorNode.getKey();
67
+ const focusKey = focusNode.getKey();
68
+ const range = document.createRange();
69
+ let anchorDOM = editor.getElementByKey(anchorKey);
70
+ let focusDOM = editor.getElementByKey(focusKey);
71
+ let anchorOffset = _anchorOffset;
72
+ let focusOffset = _focusOffset;
73
+ if ($isTextNode(anchorNode)) anchorDOM = getDOMTextNode(anchorDOM);
74
+ if ($isTextNode(focusNode)) focusDOM = getDOMTextNode(focusDOM);
75
+ if (anchorNode === void 0 || focusNode === void 0 || anchorDOM === null || focusDOM === null) return null;
76
+ if (anchorDOM.nodeName === "BR") [anchorDOM, anchorOffset] = getDOMIndexWithinParent(anchorDOM);
77
+ if (focusDOM.nodeName === "BR") [focusDOM, focusOffset] = getDOMIndexWithinParent(focusDOM);
78
+ const firstChild = anchorDOM.firstChild;
79
+ if (anchorDOM === focusDOM && firstChild != null && firstChild.nodeName === "BR" && anchorOffset === 0 && focusOffset === 0) focusOffset = 1;
80
+ try {
81
+ range.setStart(anchorDOM, anchorOffset);
82
+ range.setEnd(focusDOM, focusOffset);
83
+ } catch (_e) {
84
+ return null;
85
+ }
86
+ if (range.collapsed && (anchorOffset !== focusOffset || anchorKey !== focusKey)) {
87
+ range.setStart(focusDOM, focusOffset);
88
+ range.setEnd(anchorDOM, anchorOffset);
89
+ }
90
+ return range;
91
+ }
92
+ /**
93
+ * Creates DOMRects, generally used to help the editor find a specific location on the screen.
94
+ * @param editor - The lexical editor
95
+ * @param range - A fragment of a document that can contain nodes and parts of text nodes.
96
+ * @returns The selectionRects as an array.
97
+ */
98
+ function createRectsFromDOMRange(editor, range) {
99
+ const rootElement = editor.getRootElement();
100
+ if (rootElement === null) return [];
101
+ const rootRect = rootElement.getBoundingClientRect();
102
+ const computedStyle = getComputedStyle(rootElement);
103
+ const rootPadding = parseFloat(computedStyle.paddingLeft) + parseFloat(computedStyle.paddingRight);
104
+ const selectionRects = Array.from(range.getClientRects());
105
+ let selectionRectsLength = selectionRects.length;
106
+ selectionRects.sort((a, b) => {
107
+ const top = a.top - b.top;
108
+ if (Math.abs(top) <= 3) return a.left - b.left;
109
+ return top;
110
+ });
111
+ let prevRect;
112
+ for (let i = 0; i < selectionRectsLength; i++) {
113
+ const selectionRect = selectionRects[i];
114
+ const isOverlappingRect = prevRect && prevRect.top <= selectionRect.top && prevRect.top + prevRect.height > selectionRect.top && prevRect.left + prevRect.width > selectionRect.left;
115
+ const selectionSpansElement = selectionRect.width + rootPadding === rootRect.width;
116
+ if (isOverlappingRect || selectionSpansElement) {
117
+ selectionRects.splice(i--, 1);
118
+ selectionRectsLength--;
119
+ continue;
120
+ }
121
+ prevRect = selectionRect;
122
+ }
123
+ return selectionRects;
124
+ }
125
+ /**
126
+ * Given a CSS string, returns the parsed style object.
127
+ * @param css - The CSS property as a string.
128
+ * @returns The value of the given CSS property.
129
+ */
130
+ function getCSSFromStyleObject(styles) {
131
+ let css = "";
132
+ for (const style in styles) if (style) css += `${style}: ${styles[style]};`;
133
+ return css;
134
+ }
135
+ /**
136
+ * Gets the computed DOM styles of the element.
137
+ * @param element - The node to check the styles for.
138
+ * @returns the computed styles of the element or null if there is no DOM element or no default view for the document.
139
+ */
140
+ function $getComputedStyleForElement(element) {
141
+ const domElement = $getEditor().getElementByKey(element.getKey());
142
+ if (domElement === null) return null;
143
+ const view = domElement.ownerDocument.defaultView;
144
+ if (view === null) return null;
145
+ return view.getComputedStyle(domElement);
146
+ }
147
+ /**
148
+ * Gets the computed DOM styles of the parent of the node.
149
+ * @param node - The node to check its parent's styles for.
150
+ * @returns the computed styles of the node or null if there is no DOM element or no default view for the document.
151
+ */
152
+ function $getComputedStyleForParent(node) {
153
+ return $getComputedStyleForElement($isRootNode(node) ? node : node.getParentOrThrow());
154
+ }
155
+ /**
156
+ * Determines whether a node's parent is RTL.
157
+ * @param node - The node to check whether it is RTL.
158
+ * @returns whether the node is RTL.
159
+ */
160
+ function $isParentRTL(node) {
161
+ const styles = $getComputedStyleForParent(node);
162
+ return styles !== null && styles.direction === "rtl";
163
+ }
164
+ /**
165
+ * Generally used to append text content to HTML and JSON. Grabs the text content and "slices"
166
+ * it to be generated into the new TextNode.
167
+ * @param selection - The selection containing the node whose TextNode is to be edited.
168
+ * @param textNode - The TextNode to be edited.
169
+ * @param mutates - 'clone' to return a clone before mutating, 'self' to update in-place
170
+ * @returns The updated TextNode or clone.
171
+ */
172
+ function $sliceSelectedTextNodeContent(selection, textNode, mutates = "self") {
173
+ const anchorAndFocus = selection.getStartEndPoints();
174
+ if (textNode.isSelected(selection) && !$isTokenOrSegmented(textNode) && anchorAndFocus !== null) {
175
+ const [anchor, focus] = anchorAndFocus;
176
+ const isBackward = selection.isBackward();
177
+ const anchorNode = anchor.getNode();
178
+ const focusNode = focus.getNode();
179
+ const isAnchor = textNode.is(anchorNode);
180
+ const isFocus = textNode.is(focusNode);
181
+ if (isAnchor || isFocus) {
182
+ const [anchorOffset, focusOffset] = $getCharacterOffsets(selection);
183
+ const isSame = anchorNode.is(focusNode);
184
+ const isFirst = textNode.is(isBackward ? focusNode : anchorNode);
185
+ const isLast = textNode.is(isBackward ? anchorNode : focusNode);
186
+ let startOffset = 0;
187
+ let endOffset = void 0;
188
+ if (isSame) {
189
+ startOffset = anchorOffset > focusOffset ? focusOffset : anchorOffset;
190
+ endOffset = anchorOffset > focusOffset ? anchorOffset : focusOffset;
191
+ } else if (isFirst) {
192
+ startOffset = isBackward ? focusOffset : anchorOffset;
193
+ endOffset = void 0;
194
+ } else if (isLast) {
195
+ const offset = isBackward ? anchorOffset : focusOffset;
196
+ startOffset = 0;
197
+ endOffset = offset;
198
+ }
199
+ const text = textNode.__text.slice(startOffset, endOffset);
200
+ if (text !== textNode.__text) {
201
+ if (mutates === "clone") textNode = $cloneWithPropertiesEphemeral(textNode);
202
+ textNode.__text = text;
203
+ }
204
+ }
205
+ }
206
+ return textNode;
207
+ }
208
+ /**
209
+ * Determines if the current selection is at the end of the node.
210
+ * @param point - The point of the selection to test.
211
+ * @returns true if the provided point offset is in the last possible position, false otherwise.
212
+ */
213
+ function $isAtNodeEnd(point) {
214
+ if (point.type === "text") return point.offset === point.getNode().getTextContentSize();
215
+ const node = point.getNode();
216
+ if (!$isElementNode(node)) formatDevErrorMessage(`isAtNodeEnd: node must be a TextNode or ElementNode`);
217
+ return point.offset === node.getChildrenSize();
218
+ }
219
+ /**
220
+ * Trims text from a node in order to shorten it, eg. to enforce a text's max length. If it deletes text
221
+ * that is an ancestor of the anchor then it will leave 2 indents, otherwise, if no text content exists, it deletes
222
+ * the TextNode. It will move the focus to either the end of any left over text or beginning of a new TextNode.
223
+ * @param editor - The lexical editor.
224
+ * @param anchor - The anchor of the current selection, where the selection should be pointing.
225
+ * @param delCount - The amount of characters to delete. Useful as a dynamic variable eg. textContentSize - maxLength;
226
+ */
227
+ function $trimTextContentFromAnchor(editor, anchor, delCount) {
228
+ let currentNode = anchor.getNode();
229
+ let remaining = delCount;
230
+ if ($isElementNode(currentNode)) {
231
+ const descendantNode = currentNode.getDescendantByIndex(anchor.offset);
232
+ if (descendantNode !== null) currentNode = descendantNode;
233
+ }
234
+ while (remaining > 0 && currentNode !== null) {
235
+ if ($isElementNode(currentNode)) {
236
+ const lastDescendant = currentNode.getLastDescendant();
237
+ if (lastDescendant !== null) currentNode = lastDescendant;
238
+ }
239
+ let nextNode = currentNode.getPreviousSibling();
240
+ let additionalElementWhitespace = 0;
241
+ if (nextNode === null) {
242
+ let parent = currentNode.getParentOrThrow();
243
+ let parentSibling = parent.getPreviousSibling();
244
+ while (parentSibling === null) {
245
+ parent = parent.getParent();
246
+ if (parent === null) {
247
+ nextNode = null;
248
+ break;
249
+ }
250
+ parentSibling = parent.getPreviousSibling();
251
+ }
252
+ if (parent !== null) {
253
+ additionalElementWhitespace = parent.isInline() ? 0 : 2;
254
+ nextNode = parentSibling;
255
+ }
256
+ }
257
+ let text = currentNode.getTextContent();
258
+ if (text === "" && $isElementNode(currentNode) && !currentNode.isInline()) text = "\n\n";
259
+ const currentNodeSize = text.length;
260
+ if (!$isTextNode(currentNode) || remaining >= currentNodeSize) {
261
+ const parent = currentNode.getParent();
262
+ currentNode.remove();
263
+ if (parent != null && parent.getChildrenSize() === 0 && !$isRootNode(parent)) parent.remove();
264
+ remaining -= currentNodeSize + additionalElementWhitespace;
265
+ currentNode = nextNode;
266
+ } else {
267
+ const key = currentNode.getKey();
268
+ const prevTextContent = editor.getEditorState().read(() => {
269
+ const prevNode = $getNodeByKey(key);
270
+ if ($isTextNode(prevNode) && prevNode.isSimpleText()) return prevNode.getTextContent();
271
+ return null;
272
+ });
273
+ const offset = currentNodeSize - remaining;
274
+ const slicedText = text.slice(0, offset);
275
+ if (prevTextContent !== null && prevTextContent !== text) {
276
+ const prevSelection = $getPreviousSelection();
277
+ let target = currentNode;
278
+ if (!currentNode.isSimpleText()) {
279
+ const textNode = $createTextNode(prevTextContent);
280
+ currentNode.replace(textNode);
281
+ target = textNode;
282
+ } else currentNode.setTextContent(prevTextContent);
283
+ if ($isRangeSelection(prevSelection) && prevSelection.isCollapsed()) {
284
+ const prevOffset = prevSelection.anchor.offset;
285
+ target.select(prevOffset, prevOffset);
286
+ }
287
+ } else if (currentNode.isSimpleText()) {
288
+ const isSelected = anchor.key === key;
289
+ let anchorOffset = anchor.offset;
290
+ if (anchorOffset < remaining) anchorOffset = currentNodeSize;
291
+ const splitStart = isSelected ? anchorOffset - remaining : 0;
292
+ const splitEnd = isSelected ? anchorOffset : offset;
293
+ if (isSelected && splitStart === 0) {
294
+ const [excessNode] = currentNode.splitText(splitStart, splitEnd);
295
+ excessNode.remove();
296
+ } else {
297
+ const [, excessNode] = currentNode.splitText(splitStart, splitEnd);
298
+ excessNode.remove();
299
+ }
300
+ } else {
301
+ const textNode = $createTextNode(slicedText);
302
+ currentNode.replace(textNode);
303
+ }
304
+ remaining = 0;
305
+ }
306
+ }
307
+ }
308
+ /**
309
+ * @deprecated node styles are parsed on demand and not cached eternally
310
+ */
311
+ const $addNodeStyle = warnOnlyOnce("$addNodeStyle is a deprecated no-op and calls should be removed");
312
+ /**
313
+ * Applies the provided styles to the given TextNode, ElementNode, or
314
+ * collapsed RangeSelection.
315
+ *
316
+ * @param target - The TextNode, ElementNode, or collapsed RangeSelection to apply the styles to
317
+ * @param patch - The patch to apply, which can include multiple styles. \\{CSSProperty: value\\} . Can also accept a function that returns the new property value.
318
+ */
319
+ function $patchStyle(target, patch) {
320
+ if (!($isRangeSelection(target) ? target.isCollapsed() : $isTextNode(target) || $isElementNode(target))) formatDevErrorMessage(`$patchStyle must only be called with a TextNode, ElementNode, or collapsed RangeSelection`);
321
+ const prevStyles = getStyleObjectFromCSS$1($isRangeSelection(target) ? target.style : $isTextNode(target) ? target.getStyle() : target.getTextStyle());
322
+ const newCSSText = getCSSFromStyleObject(Object.entries(patch).reduce((styles, [key, value]) => {
323
+ if (typeof value === "function") styles[key] = value(prevStyles[key], target);
324
+ else if (value === null) delete styles[key];
325
+ else styles[key] = value;
326
+ return styles;
327
+ }, { ...prevStyles }));
328
+ if ($isRangeSelection(target) || $isTextNode(target)) target.setStyle(newCSSText);
329
+ else target.setTextStyle(newCSSText);
330
+ }
331
+ /**
332
+ * Applies the provided styles to the TextNodes in the provided Selection.
333
+ * Will update partially selected TextNodes by splitting the TextNode and applying
334
+ * the styles to the appropriate one.
335
+ * @param selection - The selected node(s) to update.
336
+ * @param patch - The patch to apply, which can include multiple styles. \\{CSSProperty: value\\} . Can also accept a function that returns the new property value.
337
+ */
338
+ function $patchStyleText(selection, patch) {
339
+ if ($isRangeSelection(selection) && selection.isCollapsed()) {
340
+ $patchStyle(selection, patch);
341
+ const emptyNode = selection.anchor.getNode();
342
+ if ($isElementNode(emptyNode) && emptyNode.isEmpty()) $patchStyle(emptyNode, patch);
343
+ }
344
+ $forEachSelectedTextNode((textNode) => {
345
+ $patchStyle(textNode, patch);
346
+ });
347
+ const nodes = selection.getNodes();
348
+ if (nodes.length > 0) {
349
+ const patchedElementKeys = /* @__PURE__ */ new Set();
350
+ for (const node of nodes) {
351
+ if (!$isElementNode(node) || !node.canBeEmpty() || node.getChildrenSize() !== 0) continue;
352
+ const key = node.getKey();
353
+ if (patchedElementKeys.has(key)) continue;
354
+ patchedElementKeys.add(key);
355
+ $patchStyle(node, patch);
356
+ }
357
+ }
358
+ }
359
+ function $forEachSelectedTextNode(fn) {
360
+ const selection = $getSelection();
361
+ if (!selection) return;
362
+ const slicedTextNodes = /* @__PURE__ */ new Map();
363
+ const getSliceIndices = (node) => slicedTextNodes.get(node.getKey()) || [0, node.getTextContentSize()];
364
+ if ($isRangeSelection(selection)) {
365
+ for (const slice of $caretRangeFromSelection(selection).getTextSlices()) if (slice) slicedTextNodes.set(slice.caret.origin.getKey(), slice.getSliceIndices());
366
+ }
367
+ const selectedNodes = selection.getNodes();
368
+ for (const selectedNode of selectedNodes) {
369
+ if (!($isTextNode(selectedNode) && selectedNode.canHaveFormat())) continue;
370
+ const [startOffset, endOffset] = getSliceIndices(selectedNode);
371
+ if (endOffset === startOffset) continue;
372
+ if ($isTokenOrSegmented(selectedNode) || startOffset === 0 && endOffset === selectedNode.getTextContentSize()) fn(selectedNode);
373
+ else {
374
+ const replacement = selectedNode.splitText(startOffset, endOffset)[startOffset === 0 ? 0 : 1];
375
+ fn(replacement);
376
+ }
377
+ }
378
+ if ($isRangeSelection(selection) && selection.anchor.type === "text" && selection.focus.type === "text" && selection.anchor.key === selection.focus.key) $ensureForwardRangeSelection(selection);
379
+ }
380
+ /**
381
+ * Ensure that the given RangeSelection is not backwards. If it
382
+ * is backwards, then the anchor and focus points will be swapped
383
+ * in-place. Ensuring that the selection is a writable RangeSelection
384
+ * is the responsibility of the caller (e.g. in a read-only context
385
+ * you will want to clone $getSelection() before using this).
386
+ *
387
+ * @param selection a writable RangeSelection
388
+ */
389
+ function $ensureForwardRangeSelection(selection) {
390
+ if (selection.isBackward()) {
391
+ const { anchor, focus } = selection;
392
+ const { key, offset, type } = anchor;
393
+ anchor.set(focus.key, focus.offset, focus.type);
394
+ focus.set(key, offset, type);
395
+ }
396
+ }
397
+ function $copyBlockFormatIndent(srcNode, destNode) {
398
+ const format = srcNode.getFormatType();
399
+ const indent = srcNode.getIndent();
400
+ if (format !== destNode.getFormatType()) destNode.setFormat(format);
401
+ if (indent !== destNode.getIndent()) destNode.setIndent(indent);
402
+ }
403
+ /**
404
+ * Converts all nodes in the selection that are of one block type to another.
405
+ * @param selection - The selected blocks to be converted.
406
+ * @param $createElement - The function that creates the node. eg. $createParagraphNode.
407
+ * @param $afterCreateElement - The function that updates the new node based on the previous one ($copyBlockFormatIndent by default)
408
+ */
409
+ function $setBlocksType(selection, $createElement, $afterCreateElement = $copyBlockFormatIndent) {
410
+ if (selection === null) return;
411
+ const anchorAndFocus = selection.getStartEndPoints();
412
+ const blockMap = /* @__PURE__ */ new Map();
413
+ let newSelection = null;
414
+ if (anchorAndFocus) {
415
+ const [anchor, focus] = anchorAndFocus;
416
+ newSelection = $createRangeSelection();
417
+ newSelection.anchor.set(anchor.key, anchor.offset, anchor.type);
418
+ newSelection.focus.set(focus.key, focus.offset, focus.type);
419
+ const anchorBlock = $findMatchingParent(anchor.getNode(), INTERNAL_$isBlock);
420
+ const focusBlock = $findMatchingParent(focus.getNode(), INTERNAL_$isBlock);
421
+ if ($isElementNode(anchorBlock)) blockMap.set(anchorBlock.getKey(), anchorBlock);
422
+ if ($isElementNode(focusBlock)) blockMap.set(focusBlock.getKey(), focusBlock);
423
+ }
424
+ for (const node of selection.getNodes()) if ($isElementNode(node) && INTERNAL_$isBlock(node)) blockMap.set(node.getKey(), node);
425
+ else if (anchorAndFocus === null) {
426
+ const ancestorBlock = $findMatchingParent(node, INTERNAL_$isBlock);
427
+ if ($isElementNode(ancestorBlock)) blockMap.set(ancestorBlock.getKey(), ancestorBlock);
428
+ }
429
+ for (const [key, prevNode] of blockMap) {
430
+ const element = $createElement();
431
+ $afterCreateElement(prevNode, element);
432
+ prevNode.replace(element, true);
433
+ if (newSelection) {
434
+ if (key === newSelection.anchor.key) newSelection.anchor.set(element.getKey(), newSelection.anchor.offset, newSelection.anchor.type);
435
+ if (key === newSelection.focus.key) newSelection.focus.set(element.getKey(), newSelection.focus.offset, newSelection.focus.type);
436
+ }
437
+ }
438
+ if (newSelection && selection.is($getSelection())) $setSelection(newSelection);
439
+ }
440
+ function isPointAttached(point) {
441
+ return point.getNode().isAttached();
442
+ }
443
+ function $removeParentEmptyElements(startingNode) {
444
+ let node = startingNode;
445
+ while (node !== null && !$isRootOrShadowRoot(node)) {
446
+ const latest = node.getLatest();
447
+ const parentNode = node.getParent();
448
+ if (latest.getChildrenSize() === 0) node.remove(true);
449
+ node = parentNode;
450
+ }
451
+ }
452
+ /**
453
+ * @deprecated In favor of $setBlockTypes
454
+ * Wraps all nodes in the selection into another node of the type returned by createElement.
455
+ * @param selection - The selection of nodes to be wrapped.
456
+ * @param createElement - A function that creates the wrapping ElementNode. eg. $createParagraphNode.
457
+ * @param wrappingElement - An element to append the wrapped selection and its children to.
458
+ */
459
+ function $wrapNodes(selection, createElement, wrappingElement = null) {
460
+ const anchorAndFocus = selection.getStartEndPoints();
461
+ const anchor = anchorAndFocus ? anchorAndFocus[0] : null;
462
+ const nodes = selection.getNodes();
463
+ const nodesLength = nodes.length;
464
+ if (anchor !== null && (nodesLength === 0 || nodesLength === 1 && anchor.type === "element" && anchor.getNode().getChildrenSize() === 0)) {
465
+ const target = anchor.type === "text" ? anchor.getNode().getParentOrThrow() : anchor.getNode();
466
+ const children = target.getChildren();
467
+ let element = createElement();
468
+ element.setFormat(target.getFormatType());
469
+ element.setIndent(target.getIndent());
470
+ children.forEach((child) => element.append(child));
471
+ if (wrappingElement) element = wrappingElement.append(element);
472
+ target.replace(element);
473
+ return;
474
+ }
475
+ let topLevelNode = null;
476
+ let descendants = [];
477
+ for (let i = 0; i < nodesLength; i++) {
478
+ const node = nodes[i];
479
+ if ($isRootOrShadowRoot(node)) {
480
+ $wrapNodesImpl(selection, descendants, descendants.length, createElement, wrappingElement);
481
+ descendants = [];
482
+ topLevelNode = node;
483
+ } else if (topLevelNode === null || topLevelNode !== null && $hasAncestor(node, topLevelNode)) descendants.push(node);
484
+ else {
485
+ $wrapNodesImpl(selection, descendants, descendants.length, createElement, wrappingElement);
486
+ descendants = [node];
487
+ }
488
+ }
489
+ $wrapNodesImpl(selection, descendants, descendants.length, createElement, wrappingElement);
490
+ }
491
+ /**
492
+ * Wraps each node into a new ElementNode.
493
+ * @param selection - The selection of nodes to wrap.
494
+ * @param nodes - An array of nodes, generally the descendants of the selection.
495
+ * @param nodesLength - The length of nodes.
496
+ * @param createElement - A function that creates the wrapping ElementNode. eg. $createParagraphNode.
497
+ * @param wrappingElement - An element to wrap all the nodes into.
498
+ * @returns
499
+ */
500
+ function $wrapNodesImpl(selection, nodes, nodesLength, createElement, wrappingElement = null) {
501
+ if (nodes.length === 0) return;
502
+ const firstNode = nodes[0];
503
+ const elementMapping = /* @__PURE__ */ new Map();
504
+ const elements = [];
505
+ let target = $isElementNode(firstNode) ? firstNode : firstNode.getParentOrThrow();
506
+ if (target.isInline()) target = target.getParentOrThrow();
507
+ let targetIsPrevSibling = false;
508
+ while (target !== null) {
509
+ const prevSibling = target.getPreviousSibling();
510
+ if (prevSibling !== null) {
511
+ target = prevSibling;
512
+ targetIsPrevSibling = true;
513
+ break;
514
+ }
515
+ target = target.getParentOrThrow();
516
+ if ($isRootOrShadowRoot(target)) break;
517
+ }
518
+ const emptyElements = /* @__PURE__ */ new Set();
519
+ for (let i = 0; i < nodesLength; i++) {
520
+ const node = nodes[i];
521
+ if ($isElementNode(node) && node.getChildrenSize() === 0) emptyElements.add(node.getKey());
522
+ }
523
+ const movedNodes = /* @__PURE__ */ new Set();
524
+ for (let i = 0; i < nodesLength; i++) {
525
+ const node = nodes[i];
526
+ let parent = node.getParent();
527
+ if (parent !== null && parent.isInline()) parent = parent.getParent();
528
+ if (parent !== null && $isLeafNode(node) && !movedNodes.has(node.getKey())) {
529
+ const parentKey = parent.getKey();
530
+ if (elementMapping.get(parentKey) === void 0) {
531
+ const targetElement = createElement();
532
+ targetElement.setFormat(parent.getFormatType());
533
+ targetElement.setIndent(parent.getIndent());
534
+ elements.push(targetElement);
535
+ elementMapping.set(parentKey, targetElement);
536
+ parent.getChildren().forEach((child) => {
537
+ targetElement.append(child);
538
+ movedNodes.add(child.getKey());
539
+ if ($isElementNode(child)) child.getChildrenKeys().forEach((key) => movedNodes.add(key));
540
+ });
541
+ $removeParentEmptyElements(parent);
542
+ }
543
+ } else if (emptyElements.has(node.getKey())) {
544
+ if (!$isElementNode(node)) formatDevErrorMessage(`Expected node in emptyElements to be an ElementNode`);
545
+ const targetElement = createElement();
546
+ targetElement.setFormat(node.getFormatType());
547
+ targetElement.setIndent(node.getIndent());
548
+ elements.push(targetElement);
549
+ node.remove(true);
550
+ }
551
+ }
552
+ if (wrappingElement !== null) for (let i = 0; i < elements.length; i++) {
553
+ const element = elements[i];
554
+ wrappingElement.append(element);
555
+ }
556
+ let lastElement = null;
557
+ if ($isRootOrShadowRoot(target)) if (targetIsPrevSibling) if (wrappingElement !== null) target.insertAfter(wrappingElement);
558
+ else for (let i = elements.length - 1; i >= 0; i--) {
559
+ const element = elements[i];
560
+ target.insertAfter(element);
561
+ }
562
+ else {
563
+ const firstChild = target.getFirstChild();
564
+ if ($isElementNode(firstChild)) target = firstChild;
565
+ if (firstChild === null) if (wrappingElement) target.append(wrappingElement);
566
+ else for (let i = 0; i < elements.length; i++) {
567
+ const element = elements[i];
568
+ target.append(element);
569
+ lastElement = element;
570
+ }
571
+ else if (wrappingElement !== null) firstChild.insertBefore(wrappingElement);
572
+ else for (let i = 0; i < elements.length; i++) {
573
+ const element = elements[i];
574
+ firstChild.insertBefore(element);
575
+ lastElement = element;
576
+ }
577
+ }
578
+ else if (wrappingElement) target.insertAfter(wrappingElement);
579
+ else for (let i = elements.length - 1; i >= 0; i--) {
580
+ const element = elements[i];
581
+ target.insertAfter(element);
582
+ lastElement = element;
583
+ }
584
+ const prevSelection = $getPreviousSelection();
585
+ if ($isRangeSelection(prevSelection) && isPointAttached(prevSelection.anchor) && isPointAttached(prevSelection.focus)) $setSelection(prevSelection.clone());
586
+ else if (lastElement !== null) lastElement.selectEnd();
587
+ else selection.dirty = true;
588
+ }
589
+ /**
590
+ * Tests if the selection's parent element has vertical writing mode.
591
+ * @param selection - The selection whose parent to test.
592
+ * @returns true if the selection's parent has vertical writing mode (writing-mode: vertical-rl), false otherwise.
593
+ */
594
+ function $isEditorVerticalOrientation(selection) {
595
+ const computedStyle = $getComputedStyle(selection);
596
+ return computedStyle !== null && computedStyle.writingMode === "vertical-rl";
597
+ }
598
+ /**
599
+ * Gets the computed DOM styles of the parent of the selection's anchor node.
600
+ * @param selection - The selection to check the styles for.
601
+ * @returns the computed styles of the node or null if there is no DOM element or no default view for the document.
602
+ */
603
+ function $getComputedStyle(selection) {
604
+ const anchorNode = selection.anchor.getNode();
605
+ if ($isElementNode(anchorNode)) return $getComputedStyleForElement(anchorNode);
606
+ return $getComputedStyleForParent(anchorNode);
607
+ }
608
+ /**
609
+ * Determines if the default character selection should be overridden. Used with DecoratorNodes
610
+ * @param selection - The selection whose default character selection may need to be overridden.
611
+ * @param isBackward - Is the selection backwards (the focus comes before the anchor)?
612
+ * @returns true if it should be overridden, false if not.
613
+ */
614
+ function $shouldOverrideDefaultCharacterSelection(selection, isBackward) {
615
+ let adjustedIsBackward = $isEditorVerticalOrientation(selection) ? !isBackward : isBackward;
616
+ if ($isParentElementRTL(selection)) adjustedIsBackward = !adjustedIsBackward;
617
+ const focusCaret = $caretFromPoint(selection.focus, adjustedIsBackward ? "previous" : "next");
618
+ if ($isExtendableTextPointCaret(focusCaret)) return false;
619
+ for (const nextCaret of $extendCaretToRange(focusCaret)) {
620
+ if ($isChildCaret(nextCaret)) return !nextCaret.origin.isInline();
621
+ else if ($isElementNode(nextCaret.origin)) continue;
622
+ else if ($isDecoratorNode(nextCaret.origin)) return true;
623
+ break;
624
+ }
625
+ return false;
626
+ }
627
+ /**
628
+ * Moves the selection according to the arguments.
629
+ * @param selection - The selected text or nodes.
630
+ * @param isHoldingShift - Is the shift key being held down during the operation.
631
+ * @param isBackward - Is the selection selected backwards (the focus comes before the anchor)?
632
+ * @param granularity - The distance to adjust the current selection.
633
+ */
634
+ function $moveCaretSelection(selection, isHoldingShift, isBackward, granularity) {
635
+ selection.modify(isHoldingShift ? "extend" : "move", isBackward, granularity);
636
+ }
637
+ /**
638
+ * Tests a parent element for right to left direction.
639
+ * @param selection - The selection whose parent is to be tested.
640
+ * @returns true if the selections' parent element has a direction of 'rtl' (right to left), false otherwise.
641
+ */
642
+ function $isParentElementRTL(selection) {
643
+ const computedStyle = $getComputedStyle(selection);
644
+ return computedStyle !== null && computedStyle.direction === "rtl";
645
+ }
646
+ /**
647
+ * Moves selection by character according to arguments.
648
+ * @param selection - The selection of the characters to move.
649
+ * @param isHoldingShift - Is the shift key being held down during the operation.
650
+ * @param isBackward - Is the selection backward (the focus comes before the anchor)?
651
+ */
652
+ function $moveCharacter(selection, isHoldingShift, isBackward) {
653
+ const isRTL = $isParentElementRTL(selection);
654
+ const isVertical = $isEditorVerticalOrientation(selection);
655
+ let adjustedIsBackward;
656
+ if (isVertical) adjustedIsBackward = !isBackward;
657
+ else if (isRTL) adjustedIsBackward = !isBackward;
658
+ else adjustedIsBackward = isBackward;
659
+ $moveCaretSelection(selection, isHoldingShift, adjustedIsBackward, "character");
660
+ }
661
+ /**
662
+ * Returns the current value of a CSS property for Nodes, if set. If not set, it returns the defaultValue.
663
+ * @param node - The node whose style value to get.
664
+ * @param styleProperty - The CSS style property.
665
+ * @param defaultValue - The default value for the property.
666
+ * @returns The value of the property for node.
667
+ */
668
+ function $getNodeStyleValueForProperty(node, styleProperty, defaultValue) {
669
+ const styleObject = getStyleObjectFromCSS$1(node.getStyle());
670
+ if (styleObject !== null) return styleObject[styleProperty] || defaultValue;
671
+ return defaultValue;
672
+ }
673
+ /**
674
+ * Returns the current value of a CSS property for TextNodes in the Selection, if set. If not set, it returns the defaultValue.
675
+ * If all TextNodes do not have the same value, it returns an empty string.
676
+ * @param selection - The selection of TextNodes whose value to find.
677
+ * @param styleProperty - The CSS style property.
678
+ * @param defaultValue - The default value for the property, defaults to an empty string.
679
+ * @returns The value of the property for the selected TextNodes.
680
+ */
681
+ function $getSelectionStyleValueForProperty(selection, styleProperty, defaultValue = "") {
682
+ let styleValue = null;
683
+ const nodes = selection.getNodes();
684
+ const anchor = selection.anchor;
685
+ const focus = selection.focus;
686
+ const isBackward = selection.isBackward();
687
+ const startNode = isBackward ? focus.getNode() : anchor.getNode();
688
+ const endNode = isBackward ? anchor.getNode() : focus.getNode();
689
+ const startOffset = isBackward ? focus.offset : anchor.offset;
690
+ const endOffset = isBackward ? anchor.offset : focus.offset;
691
+ if ($isRangeSelection(selection) && selection.isCollapsed() && selection.style !== "") {
692
+ const css = selection.style;
693
+ const styleObject = getStyleObjectFromCSS$1(css);
694
+ if (styleObject !== null && styleProperty in styleObject) return styleObject[styleProperty];
695
+ }
696
+ for (let i = 0; i < nodes.length; i++) {
697
+ const node = nodes[i];
698
+ if (i === 0 && node.is(startNode) && $isTextNode(node) && startOffset === node.getTextContentSize()) continue;
699
+ if (i !== 0 && node.is(endNode) && endOffset === 0) continue;
700
+ if ($isTextNode(node)) {
701
+ const nodeStyleValue = $getNodeStyleValueForProperty(node, styleProperty, defaultValue);
702
+ if (styleValue === null) styleValue = nodeStyleValue;
703
+ else if (styleValue !== nodeStyleValue) {
704
+ styleValue = "";
705
+ break;
706
+ }
707
+ }
708
+ }
709
+ return styleValue === null ? defaultValue : styleValue;
710
+ }
711
+ /**
712
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
713
+ *
714
+ * This source code is licensed under the MIT license found in the
715
+ * LICENSE file in the root directory of this source tree.
716
+ *
717
+ */
718
+ /** @deprecated moved to the `lexical` package */
719
+ const getStyleObjectFromCSS = getStyleObjectFromCSS$1;
720
+ /** @deprecated renamed to {@link $trimTextContentFromAnchor} by @lexical/eslint-plugin rules-of-lexical */
721
+ const trimTextContentFromAnchor = $trimTextContentFromAnchor;
722
+ //#endregion
723
+ export { $addNodeStyle, $cloneWithProperties, $copyBlockFormatIndent, $ensureForwardRangeSelection, $forEachSelectedTextNode, $getComputedStyleForElement, $getComputedStyleForParent, $getSelectionStyleValueForProperty, $isAtNodeEnd, $isParentElementRTL, $isParentRTL, $moveCaretSelection, $moveCharacter, $patchStyleText, $selectAll, $setBlocksType, $shouldOverrideDefaultCharacterSelection, $sliceSelectedTextNodeContent, $trimTextContentFromAnchor, $wrapNodes, createDOMRange, createRectsFromDOMRange, getCSSFromStyleObject, getStyleObjectFromCSS, trimTextContentFromAnchor };
724
+
725
+ //# sourceMappingURL=LexicalSelection.dev-sNOHKHe_.mjs.map