@mx-space/cli 0.13.0 → 0.13.2

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 (55) hide show
  1. package/README.md +23 -1
  2. package/dist/{Lexical.dev-By5dOKBN.mjs → Lexical.dev-BsbWMhb3.mjs} +2265 -429
  3. package/dist/{Lexical.node-fXM8Jp7p.mjs → Lexical.node-DnR_u_Ke.mjs} +47 -10
  4. package/dist/Lexical.prod-B7L8eVsO.mjs +6816 -0
  5. package/dist/{LexicalClipboard.dev--HxGoSkO.mjs → LexicalClipboard.dev-BGSFbuTA.mjs} +131 -39
  6. package/dist/{LexicalClipboard.node-C3mRbrmW.mjs → LexicalClipboard.node-CUD_tpWb.mjs} +2 -2
  7. package/dist/LexicalClipboard.prod-DQXfRt3h.mjs +429 -0
  8. package/dist/{LexicalCodeCore.dev-DjSrd4A4.mjs → LexicalCodeCore.dev-B9lK_GSN.mjs} +81 -67
  9. package/dist/LexicalCodeCore.prod-CNWMPXhg.mjs +651 -0
  10. package/dist/LexicalDragon.dev-DRm2bGZ1.mjs +186 -0
  11. package/dist/{LexicalDragon.node-BVhw4C7s.mjs → LexicalDragon.node-d8gPruly.mjs} +3 -2
  12. package/dist/LexicalDragon.prod-ey3uKDJF.mjs +121 -0
  13. package/dist/{LexicalExtension.dev-BPNyvGqe.mjs → LexicalExtension.dev-CXtOJb83.mjs} +349 -35
  14. package/dist/{LexicalExtension.node-BVlcrgOx.mjs → LexicalExtension.node-CMsupJZs.mjs} +9 -4
  15. package/dist/{LexicalExtension.prod-DFKbiNt-.mjs → LexicalExtension.prod-BCLGhzcg.mjs} +477 -328
  16. package/dist/{LexicalHeadless.dev-B-cj7Pr5.mjs → LexicalHeadless.dev-yVDOBd64.mjs} +2 -2
  17. package/dist/{LexicalHeadless.prod-Byp1vNzT.mjs → LexicalHeadless.prod-B8qauuEA.mjs} +2 -2
  18. package/dist/{LexicalHtml.dev-prBAwszN.mjs → LexicalHtml.dev-3rdckXIU.mjs} +323 -265
  19. package/dist/{LexicalHtml.node-BvNF96jZ.mjs → LexicalHtml.node-DagZUjQ_.mjs} +6 -4
  20. package/dist/{LexicalHtml.prod-Sz3CW1ht.mjs → LexicalHtml.prod-B5AQaJDb.mjs} +354 -352
  21. package/dist/{LexicalLink.dev-NySTYhVR.mjs → LexicalLink.dev-CspSwLNB.mjs} +69 -58
  22. package/dist/{LexicalLink.prod-BuCM8gts.mjs → LexicalLink.prod-Da-ZW6H5.mjs} +210 -211
  23. package/dist/{LexicalList.dev-DIMOvSFD.mjs → LexicalList.dev-CNXmV6v8.mjs} +246 -198
  24. package/dist/LexicalList.prod-DgQzj4v9.mjs +944 -0
  25. package/dist/{LexicalMarkdown.dev-C7aylvCG.mjs → LexicalMarkdown.dev-0XURdo96.mjs} +129 -37
  26. package/dist/LexicalMarkdown.prod-qUsIQfJx.mjs +932 -0
  27. package/dist/{LexicalRichText.dev-DfICq6lU.mjs → LexicalRichText.dev-BqsEA7I9.mjs} +151 -122
  28. package/dist/{LexicalRichText.node-Bg9jND3Q.mjs → LexicalRichText.node-D73RR0Ck.mjs} +8 -11
  29. package/dist/LexicalRichText.prod-4Atyd7OR.mjs +538 -0
  30. package/dist/{LexicalSelection.dev-DGjj12wW.mjs → LexicalSelection.dev-DK5xfxKP.mjs} +10 -9
  31. package/dist/{LexicalSelection.node-BU5L4193.mjs → LexicalSelection.node-pyZyrANz.mjs} +4 -4
  32. package/dist/{LexicalSelection.prod-D-PwRbyK.mjs → LexicalSelection.prod-C5GrCbDC.mjs} +144 -146
  33. package/dist/{LexicalTable.dev-ChP7cugd.mjs → LexicalTable.dev-DiR_4rdI.mjs} +184 -119
  34. package/dist/LexicalTable.prod-Cbc5EasT.mjs +2336 -0
  35. package/dist/{LexicalUtils.dev-BiFU3789.mjs → LexicalUtils.dev-jhPjn1vQ.mjs} +375 -35
  36. package/dist/{LexicalUtils.node-j3Llm7Y3.mjs → LexicalUtils.node-Ck74ludK.mjs} +24 -12
  37. package/dist/LexicalUtils.prod-nuTBxnk_.mjs +504 -0
  38. package/dist/bin/mxs.mjs +1 -1
  39. package/dist/esm-BumPuCXw.mjs +2 -0
  40. package/dist/{esm-lpolVSUJ.mjs → esm-DupC6TTP.mjs} +172 -172
  41. package/dist/index.d.mts +16 -16
  42. package/dist/index.mjs +1 -1
  43. package/dist/{mxs-PFV8OJ-M.mjs → mxs-BgAyMQdq.mjs} +1595 -314
  44. package/package.json +17 -17
  45. package/dist/Lexical.prod-BlCvXPGa.mjs +0 -6088
  46. package/dist/LexicalClipboard.prod-DNJzFMcT.mjs +0 -371
  47. package/dist/LexicalCodeCore.prod-DTDShkR3.mjs +0 -642
  48. package/dist/LexicalDragon.dev-DwprRH0z.mjs +0 -88
  49. package/dist/LexicalDragon.prod-nh4J-8vn.mjs +0 -59
  50. package/dist/LexicalList.prod-MVqfA6Vo.mjs +0 -925
  51. package/dist/LexicalMarkdown.prod-CfQSM406.mjs +0 -868
  52. package/dist/LexicalRichText.prod-GsFzCK-o.mjs +0 -550
  53. package/dist/LexicalTable.prod-Bpr9YRXp.mjs +0 -2311
  54. package/dist/LexicalUtils.prod-DCvrA78p.mjs +0 -373
  55. package/dist/esm-DGvoYR6n.mjs +0 -2
@@ -1,6 +1,6 @@
1
- import { $ as $isElementNode, Ar as removeClassNamesFromElement, D as $getCaretRangeInDirection, Dr as makeStepwiseIterator, Dt as $splitAtPointCaretNext, E as $getCaretRange, Et as $setState, G as $getState, H as $getRoot, M as $getCollapsedCaretRange, Mt as CAN_USE_DOM, N as $getDOMSlot, Or as mergeRegister, Ot as $splitNode, P as $getDOMTextNode, S as $getAdjacentChildCaret, Sn as IS_SAFARI, Sr as isHTMLElement, T as $getCaretInDirection, Tt as $setSelectionFromCaretRange, U as $getSelection, V as $getPreviousSelection, W as $getSiblingCaret, X as $isChildCaret, a as $cloneWithProperties, b as $fullReconcile, bn as IS_IOS, dn as IS_ANDROID, f as $createParagraphNode, fn as IS_ANDROID_CHROME, ft as $isTextNode, gn as IS_CHROME, hr as isBlockDomNode, ht as $normalizeCaret, i as $caretRangeFromSelection, j as $getChildCaretOrSelf, jt as CAN_USE_BEFORE_INPUT, k as $getChildCaret, mn as IS_APPLE_WEBKIT, pn as IS_APPLE, pt as $isTextPointCaret, r as $caretFromPoint, st as $isRangeSelection, tr as addClassNamesToElement, ur as getDOMTextNode, ut as $isSiblingCaret, vn as IS_FIREFOX, vt as $removeTextFromCaretRange, w as $getAdjacentSiblingOrParentSiblingCaret, wr as isInlineDomNode, wt as $setSelection, xr as isHTMLAnchorElement, y as $findMatchingParent, yt as $rewindSiblingCaret } from "./Lexical.node-fXM8Jp7p.mjs";
2
- import { a as createRectsFromDOMRange } from "./LexicalSelection.node-BU5L4193.mjs";
3
- //#region ../../node_modules/.pnpm/@lexical+utils@0.45.0/node_modules/@lexical/utils/dist/LexicalUtils.dev.mjs
1
+ import { $ as $insertNodeToNearestRootAtCaret, A as $getChildCaret, An as IS_FIREFOX, Bt as CAN_USE_DOM, C as $getAdjacentChildCaret, Cn as IS_ANDROID, Ct as $normalizeCaret, D as $getCaretRange, Dt as $rewindSiblingCaret, E as $getCaretInDirection, En as IS_APPLE_WEBKIT, Er as getDOMSelectionPoints, Et as $removeTextFromCaretRange, F as $getDOMTextNode, Ft as $splitAtPointCaretNext, G as $getSiblingCaret, H as $getPreviousSelection, It as $splitNode, J as $getSlotHost, K as $getSlot, Kr as isHTMLAnchorElement, M as $getChildCaretOrSelf, Mn as IS_IOS, Mr as getParentElement, Mt as $setSelection, N as $getCollapsedCaretRange, Nt as $setSelectionFromCaretRange, O as $getCaretRangeInDirection, On as IS_CHROME, P as $getDOMSlot, Pn as IS_SAFARI, Pt as $setState, Rr as isBlockDomNode, T as $getAdjacentSiblingOrParentSiblingCaret, Tn as IS_APPLE, U as $getRoot, W as $getSelection, X as $getState, Y as $getSlotNames, Yr as isInlineDomNode, _t as $isSiblingCaret, a as $caretRangeFromSelection, at as $isElementNode, b as $findMatchingParent, bt as $isTextNode, c as $comparePointCaretNext, i as $caretFromPoint, ii as removeClassNamesFromElement, kr as getDOMTextNode, ni as mergeRegister, nt as $isChildCaret, o as $cloneWithProperties, p as $createParagraphNode, pr as addClassNamesToElement, pt as $isRangeSelection, q as $getSlotFrame, qr as isHTMLElement, ti as makeStepwiseIterator, vt as $isSlotHost, wn as IS_ANDROID_CHROME, x as $fullReconcile, xt as $isTextPointCaret, zt as CAN_USE_BEFORE_INPUT } from "./Lexical.node-DnR_u_Ke.mjs";
2
+ import { o as createRectsFromDOMRange, t as $isAtNodeEnd } from "./LexicalSelection.node-pyZyrANz.mjs";
3
+ //#region ../../node_modules/.pnpm/@lexical+utils@0.46.0_typescript@6.0.3/node_modules/@lexical/utils/dist/LexicalUtils.dev.mjs
4
4
  /**
5
5
  * Copyright (c) Meta Platforms, Inc. and affiliates.
6
6
  *
@@ -25,6 +25,61 @@ function formatDevErrorMessage(message) {
25
25
  * LICENSE file in the root directory of this source tree.
26
26
  *
27
27
  */
28
+ /**
29
+ * Dedupe a list of selection client-rects before they are drawn as fills.
30
+ *
31
+ * `Range.getClientRects()` can return rects that are duplicated or contained
32
+ * within another, and WebKit in particular emits a spurious wider rect alongside
33
+ * the real text rect on some blocks (balanced or letter-spaced headings are the
34
+ * reproducible case). Drawn as semi-transparent fills, duplicates read brighter
35
+ * than a single rect, and the wider rect paints the "extra empty selection area"
36
+ * reported in facebook/lexical#7106.
37
+ *
38
+ * This drops zero-area rects and any rect that contains another, keeping the
39
+ * smaller text-hugging one, with a 1px tolerance for sub-pixel jitter. The
40
+ * assumption is that genuine same-line rects are horizontally disjoint (one rect
41
+ * per visual row; inline boxes on a row tile side by side), so containment only
42
+ * holds for the duplicate or spurious-wider cases, never for a legitimate
43
+ * sub-fragment that should be kept.
44
+ *
45
+ * On the `createRectsFromDOMRange` path (e.g. `positionNodeOnRange`): that
46
+ * helper's own `selectionSpansElement` filter already drops the full-block-width
47
+ * spurious rect, so there this mainly prevents the duplicate-doubling. The #7106
48
+ * extra-area paint is addressed for consumers that feed raw `getClientRects()`,
49
+ * where `selectionSpansElement` does not run — that is the path that needs it.
50
+ *
51
+ * Known limitation: the disjoint assumption holds for normal flow. Overlapping
52
+ * inline content — a negative margin, a transform, or a baseline-shifted inline
53
+ * decorator — can place a real sub-fragment inside a wider real-text rect on the
54
+ * same row; if a sub-pixel top offset also lets both clear
55
+ * `createRectsFromDOMRange`'s asymmetric overlap filter, keep-smaller drops the
56
+ * wider rect and under-paints the glyphs it uniquely covered. There is no
57
+ * rect-only fix: that wider rect is geometrically indistinguishable from the
58
+ * spurious-wider (#7106) rect, so keeping it would re-introduce the extra-area
59
+ * paint. See the under-paint characterization browser test.
60
+ *
61
+ * Typed on the structural subset of `DOMRect` it reads, so it accepts a live
62
+ * `DOMRectList` from `getClientRects()` as well as the `DOMRect[]` returned by
63
+ * `createRectsFromDOMRange`, and is unit-testable without a DOM.
64
+ */
65
+ function dedupeSelectionRects(rects) {
66
+ const contains = (a, b) => b.left >= a.left - 1 && b.top >= a.top - 1 && b.right <= a.right + 1 && b.bottom <= a.bottom + 1;
67
+ const kept = [];
68
+ for (const rect of Array.from(rects)) {
69
+ if (rect.width < .5 || rect.height < .5) continue;
70
+ if (kept.some((keptRect) => contains(rect, keptRect))) continue;
71
+ for (let i = kept.length - 1; i >= 0; i--) if (contains(kept[i], rect)) kept.splice(i, 1);
72
+ kept.push(rect);
73
+ }
74
+ return kept;
75
+ }
76
+ /**
77
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
78
+ *
79
+ * This source code is licensed under the MIT license found in the
80
+ * LICENSE file in the root directory of this source tree.
81
+ *
82
+ */
28
83
  function px(value) {
29
84
  return `${value}px`;
30
85
  }
@@ -60,7 +115,7 @@ function mlcPositionNodeOnRange(editor, range, onReposition) {
60
115
  if (!(rootDOMNode !== null)) formatDevErrorMessage(`Unexpected null rootDOMNode`);
61
116
  if (!(parentDOMNode !== null)) formatDevErrorMessage(`Unexpected null parentDOMNode`);
62
117
  const { left: parentLeft, top: parentTop } = parentDOMNode.getBoundingClientRect();
63
- const rects = createRectsFromDOMRange(editor, range);
118
+ const rects = dedupeSelectionRects(createRectsFromDOMRange(editor, range));
64
119
  if (!wrapperNode.isConnected) prependDOMNode(parentDOMNode, wrapperNode);
65
120
  let hasRepositioned = false;
66
121
  for (let i = 0; i < rects.length; i++) {
@@ -233,9 +288,10 @@ function markSelection(editor, onReposition = defaultOnReposition) {
233
288
  function selectionAlwaysOnDisplay(editor, onReposition) {
234
289
  let removeSelectionMark = null;
235
290
  const onSelectionChange = () => {
236
- const domSelection = getSelection();
237
- const domAnchorNode = domSelection && domSelection.anchorNode;
238
291
  const editorRootElement = editor.getRootElement();
292
+ const targetWindow = editorRootElement !== null ? editorRootElement.ownerDocument.defaultView : null;
293
+ const domSelection = targetWindow !== null ? targetWindow.getSelection() : null;
294
+ const domAnchorNode = domSelection !== null ? getDOMSelectionPoints(domSelection, editorRootElement).anchorNode : null;
239
295
  if (domAnchorNode !== null && editorRootElement !== null && editorRootElement.contains(domAnchorNode)) {
240
296
  if (removeSelectionMark !== null) {
241
297
  removeSelectionMark();
@@ -256,6 +312,38 @@ function selectionAlwaysOnDisplay(editor, onReposition) {
256
312
  });
257
313
  }
258
314
  /**
315
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
316
+ *
317
+ * This source code is licensed under the MIT license found in the
318
+ * LICENSE file in the root directory of this source tree.
319
+ *
320
+ */
321
+ /**
322
+ * Walks up from `element` and returns the nearest scrollable ancestor (or
323
+ * `ownerDocument.body` if none is found), used to keep the active typeahead
324
+ * option scrolled into view. Set `includeHidden` to also treat
325
+ * `overflow: hidden` ancestors as scroll parents.
326
+ *
327
+ * The walk crosses ShadowRoot→host (via `getParentElement`) so a
328
+ * shadow-mounted editor's scroll parent is found in the enclosing light-DOM
329
+ * ancestor chain, and the styles / body are resolved through the element's
330
+ * own realm so an iframe-mounted editor stays inside its document.
331
+ */
332
+ function getScrollParent(element, includeHidden) {
333
+ const ownerDocument = element.ownerDocument;
334
+ const win = ownerDocument.defaultView || window;
335
+ let style = win.getComputedStyle(element);
336
+ const excludeStaticParent = style.position === "absolute";
337
+ const overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/;
338
+ if (style.position === "fixed") return ownerDocument.body;
339
+ for (let parent = element; parent = getParentElement(parent);) {
340
+ style = win.getComputedStyle(parent);
341
+ if (excludeStaticParent && style.position === "static") continue;
342
+ if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX)) return parent;
343
+ }
344
+ return ownerDocument.body;
345
+ }
346
+ /**
259
347
  * Returns true if the file type matches the types passed within the acceptableMimeTypes array, false otherwise.
260
348
  * The types passed must be strings and are CASE-SENSITIVE.
261
349
  * eg. if file is of type 'text' and acceptableMimeTypes = ['TEXT', 'IMAGE'] the function will return false.
@@ -307,6 +395,11 @@ function mediaFileReader(files, acceptableMimeTypes) {
307
395
  * branch until you hit a dead-end (leaf) and backtracking to find the nearest branching path and repeat.
308
396
  * It will then return all the nodes found in the search in an array of objects.
309
397
  * Preorder traversal is used, meaning that nodes are listed in the order of when they are FIRST encountered.
398
+ *
399
+ * Children-only spine: named slot subtrees are skipped. Use {@link $dfsWithSlots}
400
+ * when you need to descend into slots (e.g. character counting, slot-aware
401
+ * content extraction).
402
+ *
310
403
  * @param startNode - The node to start the search (inclusive), if omitted, it will start at the root node.
311
404
  * @param endNode - The node to end the search (inclusive), if omitted, it will find all descendants of the startingNode. If endNode
312
405
  * is an ElementNode, it will stop before visiting any of its children.
@@ -337,6 +430,12 @@ function $reverseDfs(startNode, endNode) {
337
430
  /**
338
431
  * $dfs iterator (left to right). Tree traversal is done on the fly as new values are requested with O(1) memory.
339
432
  * Preorder traversal is used, meaning that nodes are iterated over in the order of when they are FIRST encountered.
433
+ *
434
+ * Children-only spine: named slot subtrees are skipped. Use {@link $dfsWithSlotsIterator}
435
+ * (or {@link $dfsWithSlots}) when you need to descend into slots — e.g. character
436
+ * counting, content extraction, or any cross-tree analysis where slotted content
437
+ * should be visited.
438
+ *
340
439
  * @param startNode - The node to start the search (inclusive), if omitted, it will start at the root node.
341
440
  * @param endNode - The node to end the search (inclusive), if omitted, it will find all descendants of the startingNode.
342
441
  * If endNode is an ElementNode, the iterator will end as soon as it reaches the endNode (no children will be visited).
@@ -345,6 +444,61 @@ function $reverseDfs(startNode, endNode) {
345
444
  function $dfsIterator(startNode, endNode) {
346
445
  return $dfsCaretIterator("next", startNode, endNode);
347
446
  }
447
+ /**
448
+ * Like {@link $dfs}, but also descends into named slots. Slots are not on the
449
+ * linked-list spine, so each host's slot subtrees are emitted slots-first,
450
+ * right after the host node and before its linked-list children.
451
+ * @experimental
452
+ * @param startNode - The node to start the search (inclusive), defaults to the root node.
453
+ * @param endNode - The node to end the search (inclusive), defaults to all descendants of startNode.
454
+ * Like {@link $dfs}, reaching endNode stops the traversal before visiting any of its
455
+ * children — including its slot subtrees. An endNode strictly inside a slot subtree
456
+ * is never reached (slot subtrees are spliced in whole), so it does not truncate
457
+ * the traversal.
458
+ * @returns An array of DFSNodes. It will always return at least 1 node (the start node).
459
+ */
460
+ function $dfsWithSlots(startNode, endNode) {
461
+ return Array.from($dfsWithSlotsIterator(startNode, endNode));
462
+ }
463
+ /**
464
+ * Slot-aware {@link $dfsIterator}: a host's slot subtrees are emitted
465
+ * slots-first, right after the host node and before its linked-list children.
466
+ * The caret iterator drives the linked-list spine untouched.
467
+ * @experimental
468
+ * @param startNode - The node to start the search (inclusive), defaults to the root node.
469
+ * @param endNode - The node to end the search (inclusive), defaults to all descendants of startNode.
470
+ * Like {@link $dfs}, reaching endNode stops the traversal before visiting any of its
471
+ * children — including its slot subtrees. An endNode strictly inside a slot subtree
472
+ * is never reached (slot subtrees are spliced in whole), so it does not truncate
473
+ * the traversal.
474
+ * @returns An iterator, each yielded value is a DFSNode. It will always return at least 1 node (the start node).
475
+ */
476
+ function* $dfsWithSlotsIterator(startNode, endNode) {
477
+ for (const dfsNode of $dfsCaretIterator("next", startNode, endNode)) {
478
+ yield dfsNode;
479
+ const { node, depth } = dfsNode;
480
+ if ($isSlotHost(node) && !node.is(endNode)) for (const name of $getSlotNames(node)) {
481
+ const slot = $getSlot(node, name);
482
+ if (slot !== null) yield* $dfsSubtreeIterator(slot, depth + 1);
483
+ }
484
+ }
485
+ }
486
+ /**
487
+ * Slots-first preorder traversal of a self-contained subtree (a slot node and
488
+ * everything it owns). Used to splice slot subtrees into $dfsWithSlotsIterator.
489
+ */
490
+ function* $dfsSubtreeIterator(node, depth) {
491
+ yield {
492
+ depth,
493
+ node
494
+ };
495
+ const childDepth = depth + 1;
496
+ if ($isSlotHost(node)) for (const name of $getSlotNames(node)) {
497
+ const slot = $getSlot(node, name);
498
+ if (slot !== null) yield* $dfsSubtreeIterator(slot, childDepth);
499
+ }
500
+ if ($isElementNode(node)) for (const child of node.getChildren()) yield* $dfsSubtreeIterator(child, childDepth);
501
+ }
348
502
  function $getEndCaret(startNode, direction) {
349
503
  const rval = $getAdjacentSiblingOrParentSiblingCaret($getSiblingCaret(startNode, direction));
350
504
  return rval && rval[0];
@@ -387,7 +541,7 @@ function $getNextSiblingOrParentSibling(node) {
387
541
  }
388
542
  function $getDepth(node) {
389
543
  let depth = -1;
390
- for (let innerNode = node; innerNode !== null; innerNode = innerNode.getParent()) depth++;
544
+ for (let innerNode = node; innerNode !== null; innerNode = innerNode.getParent() ?? $getSlotHost(innerNode)) depth++;
391
545
  return depth;
392
546
  }
393
547
  /**
@@ -412,6 +566,80 @@ function $reverseDfsIterator(startNode, endNode) {
412
566
  return $dfsCaretIterator("previous", startNode, endNode);
413
567
  }
414
568
  /**
569
+ * Like {@link $reverseDfs}, but also descends into named slots. Mirror of
570
+ * {@link $dfsWithSlots}.
571
+ * @experimental
572
+ * @param startNode - The node to start the search (inclusive), defaults to the root node.
573
+ * @param endNode - The node to end the search (inclusive), defaults to all descendants of startNode.
574
+ * Mirroring {@link $dfsWithSlots}, reaching endNode stops the traversal without
575
+ * emitting its slot subtrees. An endNode strictly inside a slot subtree is never
576
+ * reached (slot subtrees are spliced in whole), so it does not truncate the
577
+ * traversal.
578
+ * @returns An array of DFSNodes. It will always return at least 1 node (the start node).
579
+ */
580
+ function $reverseDfsWithSlots(startNode, endNode) {
581
+ return Array.from($reverseDfsWithSlotsIterator(startNode, endNode));
582
+ }
583
+ /**
584
+ * Right-to-left mirror of {@link $dfsWithSlotsIterator}. Forward visits slots
585
+ * before children, so the mirror visits them last: a host's slot subtrees are
586
+ * emitted (in reverse slot order) only once its linked-list subtree is fully
587
+ * traversed. Because the caret spine streams nodes, "left the host subtree" is
588
+ * detected when a node at the host's depth or shallower arrives, flushing the
589
+ * host's pending slots. The caret iterator drives the spine untouched.
590
+ * @experimental
591
+ * @param startNode - The node to start the search (inclusive), defaults to the root node.
592
+ * @param endNode - The node to end the search (inclusive), defaults to all descendants of startNode.
593
+ * Mirroring {@link $dfsWithSlotsIterator}, reaching endNode stops the traversal
594
+ * without emitting its slot subtrees. An endNode strictly inside a slot subtree is
595
+ * never reached (slot subtrees are spliced in whole), so it does not truncate the
596
+ * traversal.
597
+ * @returns An iterator, each yielded value is a DFSNode. It will always return at least 1 node (the start node).
598
+ */
599
+ function* $reverseDfsWithSlotsIterator(startNode, endNode) {
600
+ const pending = [];
601
+ for (const dfsNode of $dfsCaretIterator("previous", startNode, endNode)) {
602
+ while (pending.length > 0 && dfsNode.depth <= pending[pending.length - 1].depth) {
603
+ const host = pending.pop();
604
+ yield* $reverseSlotsOf(host.node, host.depth + 1);
605
+ }
606
+ yield dfsNode;
607
+ const { node, depth } = dfsNode;
608
+ if ($isSlotHost(node) && $getSlotNames(node).length > 0 && !node.is(endNode)) pending.push({
609
+ depth,
610
+ node
611
+ });
612
+ }
613
+ while (pending.length > 0) {
614
+ const host = pending.pop();
615
+ yield* $reverseSlotsOf(host.node, host.depth + 1);
616
+ }
617
+ }
618
+ /** Emit a host's slot subtrees in reverse slot order (mirror of slots-first). */
619
+ function* $reverseSlotsOf(host, childDepth) {
620
+ const names = $getSlotNames(host);
621
+ for (let i = names.length - 1; i >= 0; i--) {
622
+ const slot = $getSlot(host, names[i]);
623
+ if (slot !== null) yield* $reverseDfsSubtreeIterator(slot, childDepth);
624
+ }
625
+ }
626
+ /**
627
+ * Right-to-left slots-last preorder of a self-contained subtree: children in
628
+ * reverse order, then slots in reverse order. Mirror of $dfsSubtreeIterator.
629
+ */
630
+ function* $reverseDfsSubtreeIterator(node, depth) {
631
+ yield {
632
+ depth,
633
+ node
634
+ };
635
+ const childDepth = depth + 1;
636
+ if ($isElementNode(node)) {
637
+ const children = node.getChildren();
638
+ for (let i = children.length - 1; i >= 0; i--) yield* $reverseDfsSubtreeIterator(children[i], childDepth);
639
+ }
640
+ if ($isSlotHost(node)) yield* $reverseSlotsOf(node, childDepth);
641
+ }
642
+ /**
415
643
  * Takes a node and traverses up its ancestors (toward the root node)
416
644
  * in order to find a specific type of node.
417
645
  * @param node - the node to begin searching.
@@ -437,6 +665,27 @@ function $getNearestBlockElementAncestorOrThrow(startNode) {
437
665
  return blockNode;
438
666
  }
439
667
  /**
668
+ * Checks whether the selection covers the entire block: the selection's
669
+ * start point is at or before the first position inside blockNode and its
670
+ * end point is at or after the last position inside blockNode. A selection
671
+ * that extends beyond the block's boundaries still fully selects the block,
672
+ * and an empty block is fully selected by any selection that touches or
673
+ * surrounds it.
674
+ *
675
+ * @param blockNode - The ElementNode to check, typically a top-level block or the RootNode
676
+ * @param selectionOrRange - The RangeSelection or CaretRange to check
677
+ * @returns true if the selection covers the entire blockNode
678
+ */
679
+ function $isBlockFullySelected(blockNode, selectionOrRange) {
680
+ const range = $getCaretRangeInDirection($isRangeSelection(selectionOrRange) ? $caretRangeFromSelection(selectionOrRange) : selectionOrRange, "next");
681
+ const anchorFrame = $getSlotFrame(range.anchor.origin);
682
+ const blockFrame = $getSlotFrame(blockNode.getLatest());
683
+ if (anchorFrame === null ? blockFrame !== null : !anchorFrame.is(blockFrame)) return false;
684
+ const blockStart = $normalizeCaret($getChildCaret(blockNode, "next"));
685
+ const blockEnd = $getCaretInDirection($normalizeCaret($getChildCaret(blockNode, "previous")), "next");
686
+ return $comparePointCaretNext(range.anchor, blockStart) <= 0 && $comparePointCaretNext(range.focus, blockEnd) >= 0;
687
+ }
688
+ /**
440
689
  * Attempts to resolve nested element nodes of the same type into a single node of that type.
441
690
  * It is generally used for marks/commenting
442
691
  * @param editor - The lexical editor
@@ -528,30 +777,6 @@ function $insertNodeToNearestRoot(node) {
528
777
  return node.getLatest();
529
778
  }
530
779
  /**
531
- * If the insertion caret is the root/shadow root node (see {@link lexical!$isRootOrShadowRoot}),
532
- * the node will be inserted there, otherwise the parent nodes will be split according to the
533
- * given options.
534
- * @param node - The node to be inserted
535
- * @param caret - The location to insert or split from
536
- * @returns The node after its insertion
537
- */
538
- function $insertNodeToNearestRootAtCaret(node, caret, options) {
539
- let insertCaret = $getCaretInDirection(caret, "next");
540
- if ($isTextPointCaret(insertCaret)) {
541
- if (insertCaret.offset === 0) insertCaret = $getSiblingCaret(insertCaret.origin, "previous").getFlipped();
542
- else if (insertCaret.offset === insertCaret.origin.getTextContentSize()) insertCaret = $getSiblingCaret(insertCaret.origin, "next");
543
- }
544
- if (insertCaret.origin.is(node)) {
545
- if (!$isSiblingCaret(insertCaret)) formatDevErrorMessage(`$insertNodeToNearestRootAtCaret node ${node.getKey()} of type ${node.getType()} can not be inserted into itself`);
546
- insertCaret = $rewindSiblingCaret(insertCaret);
547
- }
548
- if (node.is(insertCaret.getNodeAtCaret()) || node.is(insertCaret.getFlipped().getNodeAtCaret())) node.remove(true);
549
- for (let nextCaret = insertCaret; nextCaret; nextCaret = $splitAtPointCaretNext(nextCaret, options)) insertCaret = nextCaret;
550
- if (!!$isTextPointCaret(insertCaret)) formatDevErrorMessage(`$insertNodeToNearestRootAtCaret: An unattached TextNode can not be split`);
551
- insertCaret.insert(node.isInline() ? $createParagraphNode().append(node) : node);
552
- return $getCaretInDirection($getSiblingCaret(node.getLatest(), "next"), caret.direction);
553
- }
554
- /**
555
780
  * Inserts a node into leaf — the deepest accessible node at the carriage position
556
781
  * @param node - The node to be inserted
557
782
  */
@@ -591,6 +816,24 @@ function $wrapNodeInElement(node, createElementNode) {
591
816
  function objectKlassEquals(object, objectClass) {
592
817
  return object !== null ? Object.getPrototypeOf(object).constructor.name === objectClass.name : false;
593
818
  }
819
+ function eventFiles(event) {
820
+ let dataTransfer = null;
821
+ if (objectKlassEquals(event, DragEvent)) dataTransfer = event.dataTransfer;
822
+ else if (objectKlassEquals(event, ClipboardEvent)) dataTransfer = event.clipboardData;
823
+ if (dataTransfer === null) return [
824
+ false,
825
+ [],
826
+ false
827
+ ];
828
+ const types = dataTransfer.types;
829
+ const hasFiles = types.includes("Files");
830
+ const hasContent = types.includes("text/html") || types.includes("text/plain");
831
+ return [
832
+ hasFiles,
833
+ Array.from(dataTransfer.files),
834
+ hasContent
835
+ ];
836
+ }
594
837
  /**
595
838
  * @deprecated Use Array filter or flatMap
596
839
  *
@@ -666,9 +909,12 @@ function needsManualZoom() {
666
909
  */
667
910
  function calculateZoomLevel(element, useManualZoom = false) {
668
911
  let zoom = 1;
669
- if (needsManualZoom() || useManualZoom) while (element) {
670
- zoom *= Number(window.getComputedStyle(element).getPropertyValue("zoom"));
671
- element = element.parentElement;
912
+ if (needsManualZoom() || useManualZoom) {
913
+ const win = element && element.ownerDocument.defaultView || window;
914
+ while (element) {
915
+ zoom *= Number(win.getComputedStyle(element).getPropertyValue("zoom"));
916
+ element = getParentElement(element);
917
+ }
672
918
  }
673
919
  return zoom;
674
920
  }
@@ -807,5 +1053,99 @@ function makeStateWrapper(stateConfig) {
807
1053
  stateConfig
808
1054
  };
809
1055
  }
1056
+ /**
1057
+ * Inserts a new paragraph before a container node when the cursor moves outside the container element
1058
+ *
1059
+ * Intended for use ArrowLeft/ArrowUp keyboard handlers to allow the user to break out
1060
+ * of a container node by creating a new paragraph before it.
1061
+ *
1062
+ * A paragraph is inserted if that the cursor is positioned at the beginning inside the container,
1063
+ * and the container itself is the first element in the document and has no preceding sibling
1064
+ *
1065
+ * When a paragraph is inserted the selection is moved to it and, if the
1066
+ * triggering keyboard event is provided, its default action is prevented so
1067
+ * the browser does not additionally move the selection. Relying on the native
1068
+ * caret movement is not portable: Chromium moves into the freshly inserted
1069
+ * paragraph while Firefox leaves the caret inside the container.
1070
+ *
1071
+ * @param $isContainerNode - Type guard identifying the container node type to escape from.
1072
+ * @param event - The keyboard event that triggered the escape, if any. Its
1073
+ * default action is prevented when a paragraph is inserted.
1074
+ * @returns `true` if a paragraph was inserted, `false` otherwise.
1075
+ */
1076
+ function $onEscapeUp($isContainerNode, event) {
1077
+ const selection = $getSelection();
1078
+ if ($isRangeSelection(selection) && selection.isCollapsed()) {
1079
+ const containerNode = $findMatchingParent(selection.anchor.getNode(), $isContainerNode);
1080
+ if (containerNode) {
1081
+ const parent = containerNode.getParent();
1082
+ if (parent !== null && parent.getFirstChild() === containerNode && $isAtStartOfNode(selection.anchor, containerNode)) {
1083
+ containerNode.insertBefore($createParagraphNode()).selectEnd();
1084
+ if (event) event.preventDefault();
1085
+ return true;
1086
+ }
1087
+ }
1088
+ }
1089
+ return false;
1090
+ }
1091
+ /**
1092
+ * Inserts a new paragraph after a container node when the cursor moves outside the container element
1093
+ *
1094
+ * Intended for use ArrowRight/ArrowDown keyboard handlers to allow the user to break out
1095
+ * of a container node by creating a new paragraph after it.
1096
+ *
1097
+ * A paragraph is inserted if that the cursor is positioned at the ending inside the container,
1098
+ * and the container itself is the last element in the document and has no next sibling
1099
+ *
1100
+ * When a paragraph is inserted the selection is moved to it and, if the
1101
+ * triggering keyboard event is provided, its default action is prevented so
1102
+ * the browser does not additionally move the selection. Relying on the native
1103
+ * caret movement is not portable: Chromium moves into the freshly inserted
1104
+ * paragraph while Firefox leaves the caret inside the container.
1105
+ *
1106
+ * @param $isContainerNode - Type guard identifying the container node type to escape from.
1107
+ * @param event - The keyboard event that triggered the escape, if any. Its
1108
+ * default action is prevented when a paragraph is inserted.
1109
+ * @returns `true` if a paragraph was inserted, `false` otherwise.
1110
+ */
1111
+ function $onEscapeDown($isContainerNode, event) {
1112
+ const selection = $getSelection();
1113
+ if ($isRangeSelection(selection) && selection.isCollapsed()) {
1114
+ const containerNode = $findMatchingParent(selection.anchor.getNode(), $isContainerNode);
1115
+ if (containerNode) {
1116
+ const parent = containerNode.getParent();
1117
+ if (parent !== null && parent.getLastChild() === containerNode && $isAtEndOfNode(selection.anchor, containerNode)) {
1118
+ containerNode.insertAfter($createParagraphNode()).selectEnd();
1119
+ if (event) event.preventDefault();
1120
+ return true;
1121
+ }
1122
+ }
1123
+ }
1124
+ return false;
1125
+ }
1126
+ /**
1127
+ * Whether the collapsed `point` sits at the very start of `node`'s content —
1128
+ * on its first descendant (or on the empty node itself) at offset 0. Shared by
1129
+ * {@link $onEscapeUp} and slot-aware variants so the "at the leading edge of a
1130
+ * container" test stays in one place.
1131
+ */
1132
+ function $isAtStartOfNode(point, node) {
1133
+ if (point.offset !== 0) return false;
1134
+ const first = node.getFirstDescendant() ?? node;
1135
+ const anchorNode = point.getNode();
1136
+ return anchorNode === first || $isElementNode(anchorNode) && anchorNode.getFirstDescendant() === first;
1137
+ }
1138
+ /**
1139
+ * Whether the collapsed `point` sits at the very end of `node`'s content — on
1140
+ * its last descendant (or on the empty node itself) at that node's end. Shared
1141
+ * by {@link $onEscapeDown} and slot-aware variants so the "at the trailing edge
1142
+ * of a container" test stays in one place.
1143
+ */
1144
+ function $isAtEndOfNode(point, node) {
1145
+ if (!$isAtNodeEnd(point)) return false;
1146
+ const last = node.getLastDescendant() ?? node;
1147
+ const anchorNode = point.getNode();
1148
+ return anchorNode === last || $isElementNode(anchorNode) && anchorNode.getLastDescendant() === last;
1149
+ }
810
1150
  //#endregion
811
- 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 };
1151
+ export { $descendantsMatching, $dfs, $dfsIterator, $dfsWithSlots, $dfsWithSlotsIterator, $filter, $findMatchingParent, $firstToLastIterator, $getAdjacentCaret, $getAdjacentSiblingOrParentSiblingCaret, $getDepth, $getNearestBlockElementAncestorOrThrow, $getNearestNodeOfType, $getNextRightPreorderNode, $getNextSiblingOrParentSibling, $handleIndentAndOutdent, $insertFirst, $insertNodeIntoLeaf, $insertNodeToNearestRoot, $insertNodeToNearestRootAtCaret, $isAtEndOfNode, $isAtStartOfNode, $isBlockFullySelected, $isEditorIsNestedEditor, $lastToFirstIterator, $onEscapeDown, $onEscapeUp, $restoreEditorState, $reverseDfs, $reverseDfsIterator, $reverseDfsWithSlots, $reverseDfsWithSlotsIterator, $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, dedupeSelectionRects, eventFiles, getScrollParent, isBlockDomNode, isHTMLAnchorElement, isHTMLElement, isInlineDomNode, isMimeType, makeStateWrapper, markSelection, mediaFileReader, mergeRegister, objectKlassEquals, mlcPositionNodeOnRange as positionNodeOnRange, registerNestedElementResolver, removeClassNamesFromElement, selectionAlwaysOnDisplay };
@@ -1,4 +1,4 @@
1
- //#region ../../node_modules/.pnpm/@lexical+utils@0.45.0/node_modules/@lexical/utils/dist/LexicalUtils.node.mjs
1
+ //#region ../../node_modules/.pnpm/@lexical+utils@0.46.0_typescript@6.0.3/node_modules/@lexical/utils/dist/LexicalUtils.node.mjs
2
2
  /**
3
3
  * Copyright (c) Meta Platforms, Inc. and affiliates.
4
4
  *
@@ -6,12 +6,14 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  */
9
- const mod = await (process.env.NODE_ENV !== "production" ? import("./LexicalUtils.dev-BiFU3789.mjs") : import("./LexicalUtils.prod-DCvrA78p.mjs"));
9
+ const mod = await (process.env.NODE_ENV !== "production" ? import("./LexicalUtils.dev-jhPjn1vQ.mjs") : import("./LexicalUtils.prod-nuTBxnk_.mjs"));
10
10
  const $descendantsMatching = mod.$descendantsMatching;
11
- const $dfs = mod.$dfs;
11
+ mod.$dfs;
12
12
  mod.$dfsIterator;
13
+ const $dfsWithSlots = mod.$dfsWithSlots;
14
+ mod.$dfsWithSlotsIterator;
13
15
  mod.$filter;
14
- const $findMatchingParent = mod.$findMatchingParent;
16
+ mod.$findMatchingParent;
15
17
  mod.$firstToLastIterator;
16
18
  mod.$getAdjacentCaret;
17
19
  mod.$getAdjacentSiblingOrParentSiblingCaret;
@@ -24,12 +26,19 @@ const $handleIndentAndOutdent = mod.$handleIndentAndOutdent;
24
26
  const $insertFirst = mod.$insertFirst;
25
27
  mod.$insertNodeIntoLeaf;
26
28
  const $insertNodeToNearestRoot = mod.$insertNodeToNearestRoot;
27
- const $insertNodeToNearestRootAtCaret = mod.$insertNodeToNearestRootAtCaret;
29
+ mod.$insertNodeToNearestRootAtCaret;
30
+ mod.$isAtEndOfNode;
31
+ mod.$isAtStartOfNode;
32
+ const $isBlockFullySelected = mod.$isBlockFullySelected;
28
33
  mod.$isEditorIsNestedEditor;
29
34
  mod.$lastToFirstIterator;
35
+ const $onEscapeDown = mod.$onEscapeDown;
36
+ const $onEscapeUp = mod.$onEscapeUp;
30
37
  mod.$restoreEditorState;
31
38
  mod.$reverseDfs;
32
39
  mod.$reverseDfsIterator;
40
+ mod.$reverseDfsWithSlots;
41
+ mod.$reverseDfsWithSlotsIterator;
33
42
  mod.$splitNode;
34
43
  const $unwrapAndFilterDescendants = mod.$unwrapAndFilterDescendants;
35
44
  mod.$unwrapNode;
@@ -38,27 +47,30 @@ mod.CAN_USE_BEFORE_INPUT;
38
47
  mod.CAN_USE_DOM;
39
48
  mod.IS_ANDROID;
40
49
  mod.IS_ANDROID_CHROME;
41
- mod.IS_APPLE;
50
+ const IS_APPLE = mod.IS_APPLE;
42
51
  mod.IS_APPLE_WEBKIT;
43
52
  mod.IS_CHROME;
44
53
  mod.IS_FIREFOX;
45
54
  mod.IS_IOS;
46
55
  mod.IS_SAFARI;
47
- const addClassNamesToElement = mod.addClassNamesToElement;
56
+ mod.addClassNamesToElement;
48
57
  const calculateZoomLevel = mod.calculateZoomLevel;
58
+ mod.dedupeSelectionRects;
59
+ const eventFiles = mod.eventFiles;
60
+ mod.getScrollParent;
49
61
  mod.isBlockDomNode;
50
- const isHTMLAnchorElement = mod.isHTMLAnchorElement;
51
- const isHTMLElement = mod.isHTMLElement;
62
+ mod.isHTMLAnchorElement;
63
+ mod.isHTMLElement;
52
64
  mod.isInlineDomNode;
53
65
  mod.isMimeType;
54
66
  mod.makeStateWrapper;
55
67
  mod.markSelection;
56
68
  mod.mediaFileReader;
57
- const mergeRegister = mod.mergeRegister;
69
+ mod.mergeRegister;
58
70
  const objectKlassEquals = mod.objectKlassEquals;
59
71
  mod.positionNodeOnRange;
60
72
  mod.registerNestedElementResolver;
61
- const removeClassNamesFromElement = mod.removeClassNamesFromElement;
73
+ mod.removeClassNamesFromElement;
62
74
  const selectionAlwaysOnDisplay = mod.selectionAlwaysOnDisplay;
63
75
  //#endregion
64
- export { removeClassNamesFromElement as _, $getNearestNodeOfType as a, $insertNodeToNearestRoot as c, addClassNamesToElement as d, calculateZoomLevel as f, objectKlassEquals as g, mergeRegister as h, $getNearestBlockElementAncestorOrThrow as i, $insertNodeToNearestRootAtCaret as l, isHTMLElement as m, $dfs as n, $handleIndentAndOutdent as o, isHTMLAnchorElement as p, $findMatchingParent as r, $insertFirst as s, $descendantsMatching as t, $unwrapAndFilterDescendants as u, selectionAlwaysOnDisplay as v };
76
+ export { $handleIndentAndOutdent as a, $isBlockFullySelected as c, $unwrapAndFilterDescendants as d, IS_APPLE as f, selectionAlwaysOnDisplay as g, objectKlassEquals as h, $getNearestNodeOfType as i, $onEscapeDown as l, eventFiles as m, $dfsWithSlots as n, $insertFirst as o, calculateZoomLevel as p, $getNearestBlockElementAncestorOrThrow as r, $insertNodeToNearestRoot as s, $descendantsMatching as t, $onEscapeUp as u };