@mx-space/cli 0.7.8 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +30 -0
  2. package/ROADMAP.md +1 -0
  3. package/dist/{Lexical.dev-rcxzwpir.mjs → Lexical.dev-By5dOKBN.mjs} +1486 -356
  4. package/dist/{Lexical.node-BUsI9gWr.mjs → Lexical.node-fXM8Jp7p.mjs} +39 -17
  5. package/dist/{Lexical.prod-C8HtkSD6.mjs → Lexical.prod-BlCvXPGa.mjs} +2279 -1768
  6. package/dist/LexicalClipboard.dev--HxGoSkO.mjs +915 -0
  7. package/dist/{LexicalClipboard.node-CO-MCKx5.mjs → LexicalClipboard.node-C3mRbrmW.mjs} +10 -3
  8. package/dist/LexicalClipboard.prod-DNJzFMcT.mjs +371 -0
  9. package/dist/LexicalCodeCore.dev-DjSrd4A4.mjs +1109 -0
  10. package/dist/LexicalCodeCore.prod-DTDShkR3.mjs +642 -0
  11. package/dist/{LexicalDragon.dev-gBP8WSRS.mjs → LexicalDragon.dev-DwprRH0z.mjs} +3 -3
  12. package/dist/{LexicalDragon.node-OG6G55nl.mjs → LexicalDragon.node-BVhw4C7s.mjs} +2 -2
  13. package/dist/{LexicalDragon.prod-DP-_Q8cv.mjs → LexicalDragon.prod-nh4J-8vn.mjs} +3 -3
  14. package/dist/{LexicalExtension.dev-DVbjljrm.mjs → LexicalExtension.dev-BPNyvGqe.mjs} +335 -6
  15. package/dist/{LexicalExtension.node-CF3EAPN7.mjs → LexicalExtension.node-BVlcrgOx.mjs} +15 -8
  16. package/dist/{LexicalExtension.prod-DklHHErZ.mjs → LexicalExtension.prod-DFKbiNt-.mjs} +375 -265
  17. package/dist/{LexicalHeadless.dev-DdWLM7Nl.mjs → LexicalHeadless.dev-B-cj7Pr5.mjs} +2 -2
  18. package/dist/{LexicalHeadless.prod-CoiiTDzR.mjs → LexicalHeadless.prod-Byp1vNzT.mjs} +2 -2
  19. package/dist/LexicalHtml.dev-prBAwszN.mjs +2424 -0
  20. package/dist/LexicalHtml.node-BvNF96jZ.mjs +56 -0
  21. package/dist/LexicalHtml.prod-Sz3CW1ht.mjs +1207 -0
  22. package/dist/{LexicalLink.dev-BS1Bf-yD.mjs → LexicalLink.dev-NySTYhVR.mjs} +42 -8
  23. package/dist/{LexicalLink.prod-B_crkoHP.mjs → LexicalLink.prod-BuCM8gts.mjs} +209 -191
  24. package/dist/{LexicalList.dev-OMqmcnQ-.mjs → LexicalList.dev-DIMOvSFD.mjs} +252 -80
  25. package/dist/{LexicalList.prod-CpL1s8vS.mjs → LexicalList.prod-MVqfA6Vo.mjs} +364 -278
  26. package/dist/{LexicalMarkdown.dev-BHSdx_Gr.mjs → LexicalMarkdown.dev-C7aylvCG.mjs} +729 -552
  27. package/dist/LexicalMarkdown.prod-CfQSM406.mjs +868 -0
  28. package/dist/{LexicalRichText.dev-Bz9A_WbM.mjs → LexicalRichText.dev-DfICq6lU.mjs} +272 -77
  29. package/dist/{LexicalRichText.node-DDpwfE-P.mjs → LexicalRichText.node-Bg9jND3Q.mjs} +21 -8
  30. package/dist/LexicalRichText.prod-GsFzCK-o.mjs +550 -0
  31. package/dist/{LexicalSelection.dev-CQ380fnD.mjs → LexicalSelection.dev-DGjj12wW.mjs} +50 -38
  32. package/dist/{LexicalSelection.node-DesBMjIE.mjs → LexicalSelection.node-BU5L4193.mjs} +4 -4
  33. package/dist/{LexicalSelection.prod-D2jivCDB.mjs → LexicalSelection.prod-D-PwRbyK.mjs} +158 -140
  34. package/dist/{LexicalTable.dev-Ca7mQ7Jk.mjs → LexicalTable.dev-ChP7cugd.mjs} +215 -53
  35. package/dist/{LexicalTable.prod-DyPAcC7y.mjs → LexicalTable.prod-Bpr9YRXp.mjs} +668 -573
  36. package/dist/{LexicalUtils.dev-HxM8F0g6.mjs → LexicalUtils.dev-BiFU3789.mjs} +10 -47
  37. package/dist/{LexicalUtils.node-lCWjRjoG.mjs → LexicalUtils.node-j3Llm7Y3.mjs} +2 -2
  38. package/dist/{LexicalUtils.prod-Bti5w4ki.mjs → LexicalUtils.prod-DCvrA78p.mjs} +103 -105
  39. package/dist/bin/mxs.d.mts +1 -1
  40. package/dist/bin/mxs.mjs +1 -1
  41. package/dist/esm-By7trG9K.mjs +2 -0
  42. package/dist/{esm-CK9m5JKX.mjs → esm-Dg-WhPCe.mjs} +989 -989
  43. package/dist/index.d.mts +11 -2
  44. package/dist/index.mjs +1 -1
  45. package/dist/{mxs-BZt1cLW9.mjs → mxs-BR5Y5ash.mjs} +25141 -24672
  46. package/package.json +15 -14
  47. package/skills/commands-auth.md +1 -1
  48. package/skills/commands-category.md +1 -1
  49. package/skills/commands-comment.md +1 -1
  50. package/skills/commands-config.md +1 -1
  51. package/skills/commands-preview.md +1 -1
  52. package/skills/commands-profile.md +1 -1
  53. package/skills/commands-project.md +57 -0
  54. package/skills/commands-topic.md +1 -1
  55. package/skills/output-modes.md +1 -1
  56. package/skills/overview.md +2 -1
  57. package/skills/safety.md +10 -0
  58. package/dist/LexicalClipboard.dev-BpqRwTLP.mjs +0 -494
  59. package/dist/LexicalClipboard.prod-B_xdeiAC.mjs +0 -291
  60. package/dist/LexicalCodeCore.dev-7_cexm39.mjs +0 -537
  61. package/dist/LexicalCodeCore.prod-Bd6WFHcO.mjs +0 -381
  62. package/dist/LexicalHtml.dev-C3ZSWBFZ.mjs +0 -684
  63. package/dist/LexicalHtml.node-D0TD152E.mjs +0 -24
  64. package/dist/LexicalHtml.prod-CX47X0zl.mjs +0 -430
  65. package/dist/LexicalMarkdown.prod-C-S7Ii6-.mjs +0 -754
  66. package/dist/LexicalRichText.prod-C8qXACDL.mjs +0 -427
  67. package/dist/esm-DRbkkY3r.mjs +0 -2
  68. /package/dist/{mxs-CM8-6uAr.d.mts → mxs-iqJBopvE.d.mts} +0 -0
@@ -1,537 +0,0 @@
1
- import { o as getPeerDependencyFromEditor } from "./LexicalExtension.node-CF3EAPN7.mjs";
2
- import { At as COMMAND_PRIORITY_LOW, B as $getSiblingCaret, Gn as isHTMLElement, Ht as ElementNode, Mn as defineExtension, Qn as removeClassNamesFromElement, Rn as getTextDirection, Tn as addClassNamesToElement, Y as $isElementNode, ct as $isTextNode, er as setDOMStyleFromCSS, et as $isLineBreakNode, f as $createParagraphNode, g as $createTabNode, j as $getEditor, l as $create, n as $applyNodeReplacement, on as KEY_ENTER_COMMAND, rt as $isRangeSelection, st as $isTabNode, u as $createLineBreakNode, wn as TextNode, z as $getSelection } from "./Lexical.node-BUsI9gWr.mjs";
3
- //#region ../../node_modules/.pnpm/@lexical+code-core@0.44.0/node_modules/@lexical/code-core/LexicalCodeCore.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 warnOnlyOnce(message) {
19
- {
20
- let run = false;
21
- return () => {
22
- if (!run) console.warn(message);
23
- run = true;
24
- };
25
- }
26
- }
27
- /**
28
- * Copyright (c) Meta Platforms, Inc. and affiliates.
29
- *
30
- * This source code is licensed under the MIT license found in the
31
- * LICENSE file in the root directory of this source tree.
32
- *
33
- */
34
- function formatDevErrorMessage(message) {
35
- throw new Error(message);
36
- }
37
- function $getLastMatchingCodeNode(anchor, direction) {
38
- let matchingNode = anchor;
39
- for (let caret = $getSiblingCaret(anchor, direction); caret && ($isCodeHighlightNode(caret.origin) || $isTabNode(caret.origin)); caret = caret.getAdjacentCaret()) matchingNode = caret.origin;
40
- return matchingNode;
41
- }
42
- function $getFirstCodeNodeOfLine(anchor) {
43
- return $getLastMatchingCodeNode(anchor, "previous");
44
- }
45
- function $getLastCodeNodeOfLine(anchor) {
46
- return $getLastMatchingCodeNode(anchor, "next");
47
- }
48
- /**
49
- * Determines the visual writing direction of a code line.
50
- *
51
- * Scans the line segments (CodeHighlightNode/TabNode) from start to end
52
- * and returns the first strong direction found ("ltr" or "rtl").
53
- * If no strong character is found, falls back to the parent element's
54
- * direction. Returns null if indeterminate.
55
- */
56
- function $getCodeLineDirection(anchor) {
57
- const start = $getFirstCodeNodeOfLine(anchor);
58
- const end = $getLastCodeNodeOfLine(anchor);
59
- let node = start;
60
- while (node !== null) {
61
- if ($isCodeHighlightNode(node)) {
62
- const direction = getTextDirection(node.getTextContent());
63
- if (direction !== null) return direction;
64
- }
65
- if (node === end) break;
66
- node = node.getNextSibling();
67
- }
68
- const parent = start.getParent();
69
- if ($isElementNode(parent)) {
70
- const parentDirection = parent.getDirection();
71
- if (parentDirection === "ltr" || parentDirection === "rtl") return parentDirection;
72
- }
73
- return null;
74
- }
75
- function $getStartOfCodeInLine(anchor, offset) {
76
- let last = null;
77
- let lastNonBlank = null;
78
- let node = anchor;
79
- let nodeOffset = offset;
80
- let nodeTextContent = anchor.getTextContent();
81
- while (true) {
82
- if (nodeOffset === 0) {
83
- node = node.getPreviousSibling();
84
- if (node === null) break;
85
- if (!($isCodeHighlightNode(node) || $isTabNode(node) || $isLineBreakNode(node))) formatDevErrorMessage(`Expected a valid Code Node: CodeHighlightNode, TabNode, LineBreakNode`);
86
- if ($isLineBreakNode(node)) {
87
- last = {
88
- node,
89
- offset: 1
90
- };
91
- break;
92
- }
93
- nodeOffset = Math.max(0, node.getTextContentSize() - 1);
94
- nodeTextContent = node.getTextContent();
95
- } else nodeOffset--;
96
- const character = nodeTextContent[nodeOffset];
97
- if ($isCodeHighlightNode(node) && character !== " ") lastNonBlank = {
98
- node,
99
- offset: nodeOffset
100
- };
101
- }
102
- if (lastNonBlank !== null) return lastNonBlank;
103
- let codeCharacterAtAnchorOffset = null;
104
- if (offset < anchor.getTextContentSize()) {
105
- if ($isCodeHighlightNode(anchor)) codeCharacterAtAnchorOffset = anchor.getTextContent()[offset];
106
- } else {
107
- const nextSibling = anchor.getNextSibling();
108
- if ($isCodeHighlightNode(nextSibling)) codeCharacterAtAnchorOffset = nextSibling.getTextContent()[0];
109
- }
110
- if (codeCharacterAtAnchorOffset !== null && codeCharacterAtAnchorOffset !== " ") return last;
111
- else {
112
- const nextNonBlank = findNextNonBlankInLine(anchor, offset);
113
- if (nextNonBlank !== null) return nextNonBlank;
114
- else return last;
115
- }
116
- }
117
- function findNextNonBlankInLine(anchor, offset) {
118
- let node = anchor;
119
- let nodeOffset = offset;
120
- let nodeTextContent = anchor.getTextContent();
121
- let nodeTextContentSize = anchor.getTextContentSize();
122
- while (true) {
123
- if (!$isCodeHighlightNode(node) || nodeOffset === nodeTextContentSize) {
124
- node = node.getNextSibling();
125
- if (node === null || $isLineBreakNode(node)) return null;
126
- if ($isCodeHighlightNode(node)) {
127
- nodeOffset = 0;
128
- nodeTextContent = node.getTextContent();
129
- nodeTextContentSize = node.getTextContentSize();
130
- }
131
- }
132
- if ($isCodeHighlightNode(node)) {
133
- if (nodeTextContent[nodeOffset] !== " ") return {
134
- node,
135
- offset: nodeOffset
136
- };
137
- nodeOffset++;
138
- }
139
- }
140
- }
141
- function $getEndOfCodeInLine(anchor) {
142
- const lastNode = $getLastCodeNodeOfLine(anchor);
143
- if (!!$isLineBreakNode(lastNode)) formatDevErrorMessage(`Unexpected lineBreakNode in getEndOfCodeInLine`);
144
- return lastNode;
145
- }
146
- /**
147
- * Copyright (c) Meta Platforms, Inc. and affiliates.
148
- *
149
- * This source code is licensed under the MIT license found in the
150
- * LICENSE file in the root directory of this source tree.
151
- *
152
- */
153
- const DEFAULT_CODE_LANGUAGE = "javascript";
154
- const getDefaultCodeLanguage = () => DEFAULT_CODE_LANGUAGE;
155
- function hasChildDOMNodeTag(node, tagName) {
156
- for (const child of node.childNodes) {
157
- if (isHTMLElement(child) && child.tagName === tagName) return true;
158
- hasChildDOMNodeTag(child, tagName);
159
- }
160
- return false;
161
- }
162
- const LANGUAGE_DATA_ATTRIBUTE = "data-language";
163
- const HIGHLIGHT_LANGUAGE_DATA_ATTRIBUTE = "data-highlight-language";
164
- const THEME_DATA_ATTRIBUTE = "data-theme";
165
- const noExtensionDeprecation = warnOnlyOnce("Using CodeNode without CodeExtension is deprecated");
166
- /** @noInheritDoc */
167
- var CodeNode = class CodeNode extends ElementNode {
168
- /** @internal */
169
- __language;
170
- /** @internal */
171
- __theme;
172
- /** @internal */
173
- __isSyntaxHighlightSupported;
174
- static getType() {
175
- return "code";
176
- }
177
- static clone(node) {
178
- return new CodeNode(node.__language, node.__key);
179
- }
180
- constructor(language, key) {
181
- super(key);
182
- this.__language = language || void 0;
183
- this.__isSyntaxHighlightSupported = false;
184
- this.__theme = void 0;
185
- }
186
- afterCloneFrom(prevNode) {
187
- super.afterCloneFrom(prevNode);
188
- this.__language = prevNode.__language;
189
- this.__theme = prevNode.__theme;
190
- this.__isSyntaxHighlightSupported = prevNode.__isSyntaxHighlightSupported;
191
- }
192
- createDOM(config) {
193
- const element = document.createElement("code");
194
- addClassNamesToElement(element, config.theme.code);
195
- element.setAttribute("spellcheck", "false");
196
- const language = this.getLanguage();
197
- if (language) {
198
- element.setAttribute(LANGUAGE_DATA_ATTRIBUTE, language);
199
- if (this.getIsSyntaxHighlightSupported()) element.setAttribute(HIGHLIGHT_LANGUAGE_DATA_ATTRIBUTE, language);
200
- }
201
- const theme = this.getTheme();
202
- if (theme) element.setAttribute(THEME_DATA_ATTRIBUTE, theme);
203
- const style = this.getStyle();
204
- if (style) setDOMStyleFromCSS(element.style, style);
205
- return element;
206
- }
207
- updateDOM(prevNode, dom, config) {
208
- const language = this.__language;
209
- const prevLanguage = prevNode.__language;
210
- if (language) {
211
- if (language !== prevLanguage) dom.setAttribute(LANGUAGE_DATA_ATTRIBUTE, language);
212
- } else if (prevLanguage) dom.removeAttribute(LANGUAGE_DATA_ATTRIBUTE);
213
- const isSyntaxHighlightSupported = this.__isSyntaxHighlightSupported;
214
- if (prevNode.__isSyntaxHighlightSupported && prevLanguage) if (isSyntaxHighlightSupported && language) {
215
- if (language !== prevLanguage) dom.setAttribute(HIGHLIGHT_LANGUAGE_DATA_ATTRIBUTE, language);
216
- } else dom.removeAttribute(HIGHLIGHT_LANGUAGE_DATA_ATTRIBUTE);
217
- else if (isSyntaxHighlightSupported && language) dom.setAttribute(HIGHLIGHT_LANGUAGE_DATA_ATTRIBUTE, language);
218
- const theme = this.__theme;
219
- const prevTheme = prevNode.__theme;
220
- if (theme) {
221
- if (theme !== prevTheme) dom.setAttribute(THEME_DATA_ATTRIBUTE, theme);
222
- } else if (prevTheme) dom.removeAttribute(THEME_DATA_ATTRIBUTE);
223
- const style = this.__style;
224
- const prevStyle = prevNode.__style;
225
- if (style !== prevStyle) setDOMStyleFromCSS(dom.style, style, prevStyle);
226
- return false;
227
- }
228
- exportDOM(editor) {
229
- const element = document.createElement("pre");
230
- addClassNamesToElement(element, editor._config.theme.code);
231
- element.setAttribute("spellcheck", "false");
232
- const language = this.getLanguage();
233
- if (language) {
234
- element.setAttribute(LANGUAGE_DATA_ATTRIBUTE, language);
235
- if (this.getIsSyntaxHighlightSupported()) element.setAttribute(HIGHLIGHT_LANGUAGE_DATA_ATTRIBUTE, language);
236
- }
237
- const theme = this.getTheme();
238
- if (theme) element.setAttribute(THEME_DATA_ATTRIBUTE, theme);
239
- const style = this.getStyle();
240
- if (style) setDOMStyleFromCSS(element.style, style);
241
- return { element };
242
- }
243
- static importDOM() {
244
- return {
245
- code: (node) => {
246
- return node.textContent != null && (/\r?\n/.test(node.textContent) || hasChildDOMNodeTag(node, "BR")) ? {
247
- conversion: $convertPreElement,
248
- priority: 1
249
- } : null;
250
- },
251
- div: () => ({
252
- conversion: $convertDivElement,
253
- priority: 1
254
- }),
255
- pre: () => ({
256
- conversion: $convertPreElement,
257
- priority: 0
258
- }),
259
- table: (node) => {
260
- if (isGitHubCodeTable(node)) return {
261
- conversion: $convertTableElement,
262
- priority: 3
263
- };
264
- return null;
265
- },
266
- td: (node) => {
267
- const td = node;
268
- const table = td.closest("table");
269
- if (isGitHubCodeCell(td) || table && isGitHubCodeTable(table)) return {
270
- conversion: convertCodeNoop,
271
- priority: 3
272
- };
273
- return null;
274
- },
275
- tr: (node) => {
276
- const table = node.closest("table");
277
- if (table && isGitHubCodeTable(table)) return {
278
- conversion: convertCodeNoop,
279
- priority: 3
280
- };
281
- return null;
282
- }
283
- };
284
- }
285
- static importJSON(serializedNode) {
286
- return $createCodeNode().updateFromJSON(serializedNode);
287
- }
288
- updateFromJSON(serializedNode) {
289
- return super.updateFromJSON(serializedNode).setLanguage(serializedNode.language).setTheme(serializedNode.theme);
290
- }
291
- exportJSON() {
292
- return {
293
- ...super.exportJSON(),
294
- language: this.getLanguage(),
295
- theme: this.getTheme()
296
- };
297
- }
298
- insertNewAfter(selection, restoreSelection = true) {
299
- if (!getPeerDependencyFromEditor($getEditor(), "@lexical/code")) {
300
- noExtensionDeprecation();
301
- const el = $exitCodeNodeOnEnter(selection);
302
- if (el) return el;
303
- }
304
- const { anchor, focus } = selection;
305
- const firstSelectionNode = (anchor.isBefore(focus) ? anchor : focus).getNode();
306
- if ($isTextNode(firstSelectionNode)) {
307
- let node = $getFirstCodeNodeOfLine(firstSelectionNode);
308
- const insertNodes = [];
309
- while (true) if ($isTabNode(node)) {
310
- insertNodes.push($createTabNode());
311
- node = node.getNextSibling();
312
- } else if ($isCodeHighlightNode(node)) {
313
- let spaces = 0;
314
- const text = node.getTextContent();
315
- const textSize = node.getTextContentSize();
316
- while (spaces < textSize && text[spaces] === " ") spaces++;
317
- if (spaces !== 0) insertNodes.push($createCodeHighlightNode(" ".repeat(spaces)));
318
- if (spaces !== textSize) break;
319
- node = node.getNextSibling();
320
- } else break;
321
- const split = firstSelectionNode.splitText(anchor.offset)[0];
322
- const x = anchor.offset === 0 ? 0 : 1;
323
- const index = split.getIndexWithinParent() + x;
324
- const codeNode = firstSelectionNode.getParentOrThrow();
325
- const nodesToInsert = [$createLineBreakNode(), ...insertNodes];
326
- codeNode.splice(index, 0, nodesToInsert);
327
- const last = insertNodes[insertNodes.length - 1];
328
- if (last) last.select();
329
- else if (anchor.offset === 0) split.selectPrevious();
330
- else split.getNextSibling().selectNext(0, 0);
331
- }
332
- if ($isCodeNode(firstSelectionNode)) {
333
- const { offset } = selection.anchor;
334
- firstSelectionNode.splice(offset, 0, [$createLineBreakNode()]);
335
- firstSelectionNode.select(offset + 1, offset + 1);
336
- }
337
- return null;
338
- }
339
- canIndent() {
340
- return false;
341
- }
342
- collapseAtStart() {
343
- const paragraph = $createParagraphNode();
344
- this.getChildren().forEach((child) => paragraph.append(child));
345
- this.replace(paragraph);
346
- return true;
347
- }
348
- setLanguage(language) {
349
- const writable = this.getWritable();
350
- writable.__language = language || void 0;
351
- return writable;
352
- }
353
- getLanguage() {
354
- return this.getLatest().__language;
355
- }
356
- setIsSyntaxHighlightSupported(isSupported) {
357
- const writable = this.getWritable();
358
- writable.__isSyntaxHighlightSupported = isSupported;
359
- return writable;
360
- }
361
- getIsSyntaxHighlightSupported() {
362
- return this.getLatest().__isSyntaxHighlightSupported;
363
- }
364
- setTheme(theme) {
365
- const writable = this.getWritable();
366
- writable.__theme = theme || void 0;
367
- return writable;
368
- }
369
- getTheme() {
370
- return this.getLatest().__theme;
371
- }
372
- };
373
- function $createCodeNode(language, theme) {
374
- return $create(CodeNode).setLanguage(language).setTheme(theme);
375
- }
376
- function $isCodeNode(node) {
377
- return node instanceof CodeNode;
378
- }
379
- function $convertPreElement(domNode) {
380
- return { node: $createCodeNode(domNode.getAttribute(LANGUAGE_DATA_ATTRIBUTE)) };
381
- }
382
- function $convertDivElement(domNode) {
383
- const div = domNode;
384
- const isCode = isCodeElement(div);
385
- if (!isCode && !isCodeChildElement(div)) return { node: null };
386
- return { node: isCode ? $createCodeNode() : null };
387
- }
388
- function $convertTableElement() {
389
- return { node: $createCodeNode() };
390
- }
391
- function convertCodeNoop() {
392
- return { node: null };
393
- }
394
- function isCodeElement(div) {
395
- return div.style.fontFamily.match("monospace") !== null;
396
- }
397
- function isCodeChildElement(node) {
398
- let parent = node.parentElement;
399
- while (parent !== null) {
400
- if (isCodeElement(parent)) return true;
401
- parent = parent.parentElement;
402
- }
403
- return false;
404
- }
405
- function isGitHubCodeCell(cell) {
406
- return cell.classList.contains("js-file-line");
407
- }
408
- function isGitHubCodeTable(table) {
409
- return table.classList.contains("js-file-line-container");
410
- }
411
- function $exitCodeNodeOnEnter(selection) {
412
- const { anchor } = selection;
413
- if (selection.isCollapsed() && anchor.type === "element") {
414
- const codeNode = anchor.getNode();
415
- if ($isCodeNode(codeNode)) {
416
- const childrenSize = codeNode.getChildrenSize();
417
- if (childrenSize >= 2 && anchor.offset === childrenSize) {
418
- const lastChild = codeNode.getLastChild();
419
- if ($isLineBreakNode(lastChild) && $isLineBreakNode(lastChild.getPreviousSibling())) {
420
- const newElement = $createParagraphNode();
421
- codeNode.splice(childrenSize - 2, 2, []).insertAfter(newElement, false);
422
- newElement.select();
423
- return newElement;
424
- }
425
- }
426
- }
427
- }
428
- return null;
429
- }
430
- /**
431
- * Copyright (c) Meta Platforms, Inc. and affiliates.
432
- *
433
- * This source code is licensed under the MIT license found in the
434
- * LICENSE file in the root directory of this source tree.
435
- *
436
- */
437
- /** @noInheritDoc */
438
- var CodeHighlightNode = class CodeHighlightNode extends TextNode {
439
- /** @internal */
440
- __highlightType;
441
- constructor(text = "", highlightType, key) {
442
- super(text, key);
443
- this.__highlightType = highlightType;
444
- }
445
- static getType() {
446
- return "code-highlight";
447
- }
448
- static clone(node) {
449
- return new CodeHighlightNode(node.__text, node.__highlightType || void 0, node.__key);
450
- }
451
- afterCloneFrom(prevNode) {
452
- super.afterCloneFrom(prevNode);
453
- this.__highlightType = prevNode.__highlightType;
454
- }
455
- getHighlightType() {
456
- return this.getLatest().__highlightType;
457
- }
458
- setHighlightType(highlightType) {
459
- const self = this.getWritable();
460
- self.__highlightType = highlightType || void 0;
461
- return self;
462
- }
463
- canHaveFormat() {
464
- return false;
465
- }
466
- createDOM(config) {
467
- const element = super.createDOM(config);
468
- addClassNamesToElement(element, getHighlightThemeClass(config.theme, this.__highlightType));
469
- return element;
470
- }
471
- updateDOM(prevNode, dom, config) {
472
- const update = super.updateDOM(prevNode, dom, config);
473
- const prevClassName = getHighlightThemeClass(config.theme, prevNode.__highlightType);
474
- const nextClassName = getHighlightThemeClass(config.theme, this.__highlightType);
475
- if (prevClassName !== nextClassName) {
476
- if (prevClassName) removeClassNamesFromElement(dom, prevClassName);
477
- if (nextClassName) addClassNamesToElement(dom, nextClassName);
478
- }
479
- return update;
480
- }
481
- static importJSON(serializedNode) {
482
- return $createCodeHighlightNode().updateFromJSON(serializedNode);
483
- }
484
- updateFromJSON(serializedNode) {
485
- return super.updateFromJSON(serializedNode).setHighlightType(serializedNode.highlightType);
486
- }
487
- exportJSON() {
488
- return {
489
- ...super.exportJSON(),
490
- highlightType: this.getHighlightType()
491
- };
492
- }
493
- setFormat(format) {
494
- return this;
495
- }
496
- isParentRequired() {
497
- return true;
498
- }
499
- createParentElementNode() {
500
- return $createCodeNode();
501
- }
502
- };
503
- function getHighlightThemeClass(theme, highlightType) {
504
- return highlightType && theme && theme.codeHighlight && theme.codeHighlight[highlightType];
505
- }
506
- function $createCodeHighlightNode(text = "", highlightType) {
507
- return $applyNodeReplacement(new CodeHighlightNode(text, highlightType));
508
- }
509
- function $isCodeHighlightNode(node) {
510
- return node instanceof CodeHighlightNode;
511
- }
512
- /**
513
- * Copyright (c) Meta Platforms, Inc. and affiliates.
514
- *
515
- * This source code is licensed under the MIT license found in the
516
- * LICENSE file in the root directory of this source tree.
517
- *
518
- */
519
- /**
520
- * Add code blocks to the editor (syntax highlighting provided separately)
521
- */
522
- const CodeExtension = defineExtension({
523
- name: "@lexical/code",
524
- nodes: () => [CodeNode, CodeHighlightNode],
525
- register(editor) {
526
- return editor.registerCommand(KEY_ENTER_COMMAND, (event) => {
527
- const selection = $getSelection();
528
- if ($isRangeSelection(selection) && $exitCodeNodeOnEnter(selection)) {
529
- event.preventDefault();
530
- return true;
531
- }
532
- return false;
533
- }, COMMAND_PRIORITY_LOW);
534
- }
535
- });
536
- //#endregion
537
- export { $createCodeHighlightNode, $createCodeNode, $getCodeLineDirection, $getEndOfCodeInLine, $getFirstCodeNodeOfLine, $getLastCodeNodeOfLine, $getStartOfCodeInLine, $isCodeHighlightNode, $isCodeNode, CodeExtension, CodeHighlightNode, CodeNode, DEFAULT_CODE_LANGUAGE, getDefaultCodeLanguage };