camox 0.40.0 → 0.41.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 (97) hide show
  1. package/dist/components/PlatformLabel.js +62 -0
  2. package/dist/core/components/lexical/GradientNode.js +126 -0
  3. package/dist/core/components/lexical/InlineLexicalEditor.js +37 -56
  4. package/dist/core/components/lexical/InlineStylesPlugin.js +183 -0
  5. package/dist/core/components/lexical/SelectionBroadcaster.js +49 -46
  6. package/dist/core/components/lexical/SidebarLexicalEditor.js +197 -151
  7. package/dist/core/components/lexical/editorConfig.js +25 -7
  8. package/dist/core/components/lexical/selectTextLink.js +21 -0
  9. package/dist/core/createApp.d.ts +30 -17
  10. package/dist/core/createApp.js +14 -3
  11. package/dist/core/createBlock.d.ts +2 -2
  12. package/dist/core/createBlock.js +18 -15
  13. package/dist/core/createLayout.d.ts +48 -4
  14. package/dist/core/createLayout.js +51 -23
  15. package/dist/core/derivedRoutes.js +36 -0
  16. package/dist/core/editing/createEditableBlock.d.ts +9 -8
  17. package/dist/core/editing/createEditableBlock.js +167 -168
  18. package/dist/core/lib/lexicalReact.d.ts +1 -26
  19. package/dist/core/lib/lexicalReact.js +46 -60
  20. package/dist/core/lib/lexicalState.js +164 -81
  21. package/dist/core/lib/modifierFormats.js +4 -15
  22. package/dist/core/lib/textStyles.d.ts +27 -0
  23. package/dist/core/lib/textStyles.js +47 -0
  24. package/dist/features/navigation/navigation.d.ts +2 -0
  25. package/dist/features/navigation/navigation.js +51 -46
  26. package/dist/features/page/DerivedPageContent.js +61 -0
  27. package/dist/features/page/PublishedPageContent.js +52 -83
  28. package/dist/features/page/SharedLayoutContent.js +66 -0
  29. package/dist/features/preview/CamoxPreview.d.ts +16 -1
  30. package/dist/features/preview/CamoxPreview.js +242 -265
  31. package/dist/features/preview/DerivedPreview.js +137 -0
  32. package/dist/features/preview/EditablePageExperience.js +25 -8
  33. package/dist/features/preview/components/AddBlockSidebar.js +43 -33
  34. package/dist/features/preview/components/AssetLightbox.js +1 -1
  35. package/dist/features/preview/components/BlockThumbnail.js +192 -0
  36. package/dist/features/preview/components/CreatePageModal.js +123 -115
  37. package/dist/features/preview/components/DerivedLayoutDialog.js +100 -0
  38. package/dist/features/preview/components/DerivedLayoutSidebar.d.ts +5 -0
  39. package/dist/features/preview/components/DerivedLayoutSidebar.js +163 -0
  40. package/dist/features/preview/components/DerivedPageInfoSidebar.js +57 -0
  41. package/dist/features/preview/components/FieldToolbar.js +42 -20
  42. package/dist/features/preview/components/Frame.js +133 -140
  43. package/dist/features/preview/components/LeftSidebar.js +42 -38
  44. package/dist/features/preview/components/MobilePreviewDrawer.js +4 -4
  45. package/dist/features/preview/components/Overlays.js +57 -42
  46. package/dist/features/preview/components/PageInfoSidebar.js +63 -55
  47. package/dist/features/preview/components/PageNavigatorSidebar.js +34 -483
  48. package/dist/features/preview/components/PagePicker.js +205 -153
  49. package/dist/features/preview/components/PageTree.js +298 -206
  50. package/dist/features/preview/components/PreviewActivation.js +78 -0
  51. package/dist/features/preview/components/PreviewPanel.js +67 -35
  52. package/dist/features/preview/components/PreviewToolbar.js +218 -232
  53. package/dist/features/preview/components/PublicationRow.js +431 -0
  54. package/dist/features/preview/components/PublishDialog.js +180 -97
  55. package/dist/features/preview/components/RightSidebar.js +19 -34
  56. package/dist/features/preview/components/previewStyles.js +8 -0
  57. package/dist/features/preview/components/useUpdateBlockPosition.js +7 -13
  58. package/dist/features/preview/previewConstants.js +8 -0
  59. package/dist/features/preview/previewStore.js +0 -10
  60. package/dist/features/preview/publication.js +71 -0
  61. package/dist/features/provider/AuthenticatedCamoxProvider.js +2 -1
  62. package/dist/features/provider/CoreCamoxProvider.js +11 -2
  63. package/dist/features/provider/LocalhostPreviewProvider.js +6 -7
  64. package/dist/features/routes/pageRuntime.d.ts +10 -0
  65. package/dist/features/routes/pageRuntime.js +7 -9
  66. package/dist/features/runtime/PreviewDocumentContext.js +7 -0
  67. package/dist/features/runtime/RuntimeChrome.js +137 -0
  68. package/dist/features/runtime/SharedChromeContext.js +7 -0
  69. package/dist/features/runtime/navigationRequest.js +21 -0
  70. package/dist/features/runtime/navigationTarget.js +23 -0
  71. package/dist/features/runtime/pageApp.js +196 -121
  72. package/dist/features/runtime/pageNavigation.js +79 -130
  73. package/dist/features/runtime/runtime.d.ts +11 -0
  74. package/dist/features/runtime/runtime.js +183 -47
  75. package/dist/features/runtime/studioApp.d.ts +2 -11
  76. package/dist/features/runtime/studioApp.js +14 -177
  77. package/dist/features/studio/CamoxStudio.js +27 -13
  78. package/dist/features/studio/components/Navbar.js +80 -74
  79. package/dist/features/studio/studioTheme.js +25 -0
  80. package/dist/features/studio/useTheme.js +94 -109
  81. package/dist/features/vite/appGeneration.js +12 -3
  82. package/dist/features/vite/definitionsSync.js +4 -2
  83. package/dist/features/vite/layoutGeneration.js +38 -0
  84. package/dist/features/vite/runtimeDev.js +3 -1
  85. package/dist/lib/auth.js +15 -13
  86. package/dist/lib/normalized-data.js +4 -4
  87. package/dist/lib/platform.js +13 -0
  88. package/dist/lib/utils.js +90 -38
  89. package/dist/studio-overlays.css +5 -40
  90. package/dist/studio.css +1 -1
  91. package/package.json +8 -4
  92. package/skills/camox/SKILL.md +2 -0
  93. package/skills/camox/references/block-definitions.md +31 -12
  94. package/skills/camox/references/layout-definitions.md +2 -0
  95. package/dist/core/lib/modifiers.js +0 -24
  96. package/dist/features/preview/previewQueryFns.js +0 -23
  97. package/dist/features/runtime/studioNavigation.js +0 -120
@@ -11,7 +11,7 @@ import * as React from "react";
11
11
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
12
  import { useSelector } from "@xstate/store-react";
13
13
  import { Button } from "@camox/ui/button";
14
- import { Ellipsis, GripVertical, LayoutTemplate, Plus } from "lucide-react";
14
+ import { Ellipsis, GripVertical, LayoutTemplate, Pencil, Plus } from "lucide-react";
15
15
  import { Tooltip, TooltipContent, TooltipTrigger } from "@camox/ui/tooltip";
16
16
  import { DndContext, DragOverlay, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
17
17
  import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
@@ -21,17 +21,17 @@ import { CSS } from "@dnd-kit/utilities";
21
21
  //#region src/features/preview/components/PageTree.tsx
22
22
  const usePreviewSource = () => {
23
23
  const $ = c(1);
24
- if ($[0] !== "e2e18e0d8166e0ab2847dfaad4af267e4cb38ede982af367ff19b699a6d19a10") {
24
+ if ($[0] !== "eb6753965d39814f517f29742d376441f9199b2f64da5f504a380a03bff336c8") {
25
25
  for (let $i = 0; $i < 1; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
26
- $[0] = "e2e18e0d8166e0ab2847dfaad4af267e4cb38ede982af367ff19b699a6d19a10";
26
+ $[0] = "eb6753965d39814f517f29742d376441f9199b2f64da5f504a380a03bff336c8";
27
27
  }
28
28
  return useSelector(previewStore, _temp);
29
29
  };
30
30
  function useBlockTreeItem(block, t0) {
31
31
  const $ = c(17);
32
- if ($[0] !== "e2e18e0d8166e0ab2847dfaad4af267e4cb38ede982af367ff19b699a6d19a10") {
32
+ if ($[0] !== "eb6753965d39814f517f29742d376441f9199b2f64da5f504a380a03bff336c8") {
33
33
  for (let $i = 0; $i < 17; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
34
- $[0] = "e2e18e0d8166e0ab2847dfaad4af267e4cb38ede982af367ff19b699a6d19a10";
34
+ $[0] = "eb6753965d39814f517f29742d376441f9199b2f64da5f504a380a03bff336c8";
35
35
  }
36
36
  const isDragging = t0 === void 0 ? false : t0;
37
37
  const [ellipsisPopoverOpen, setEllipsisPopoverOpen] = React.useState(false);
@@ -114,9 +114,9 @@ function _temp2(state) {
114
114
  }
115
115
  const BlockTreeItemHeader = (t0) => {
116
116
  const $ = c(17);
117
- if ($[0] !== "e2e18e0d8166e0ab2847dfaad4af267e4cb38ede982af367ff19b699a6d19a10") {
117
+ if ($[0] !== "eb6753965d39814f517f29742d376441f9199b2f64da5f504a380a03bff336c8") {
118
118
  for (let $i = 0; $i < 17; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
119
- $[0] = "e2e18e0d8166e0ab2847dfaad4af267e4cb38ede982af367ff19b699a6d19a10";
119
+ $[0] = "eb6753965d39814f517f29742d376441f9199b2f64da5f504a380a03bff336c8";
120
120
  }
121
121
  let children;
122
122
  let className;
@@ -169,9 +169,9 @@ const BlockTreeItemHeader = (t0) => {
169
169
  };
170
170
  const BlockTreeItemTrigger = (t0) => {
171
171
  const $ = c(5);
172
- if ($[0] !== "e2e18e0d8166e0ab2847dfaad4af267e4cb38ede982af367ff19b699a6d19a10") {
172
+ if ($[0] !== "eb6753965d39814f517f29742d376441f9199b2f64da5f504a380a03bff336c8") {
173
173
  for (let $i = 0; $i < 5; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
174
- $[0] = "e2e18e0d8166e0ab2847dfaad4af267e4cb38ede982af367ff19b699a6d19a10";
174
+ $[0] = "eb6753965d39814f517f29742d376441f9199b2f64da5f504a380a03bff336c8";
175
175
  }
176
176
  const { displayText, onClick } = t0;
177
177
  let t1;
@@ -196,9 +196,9 @@ const BlockTreeItemTrigger = (t0) => {
196
196
  };
197
197
  const BlockTreeItemEllipsis = (t0) => {
198
198
  const $ = c(12);
199
- if ($[0] !== "e2e18e0d8166e0ab2847dfaad4af267e4cb38ede982af367ff19b699a6d19a10") {
199
+ if ($[0] !== "eb6753965d39814f517f29742d376441f9199b2f64da5f504a380a03bff336c8") {
200
200
  for (let $i = 0; $i < 12; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
201
- $[0] = "e2e18e0d8166e0ab2847dfaad4af267e4cb38ede982af367ff19b699a6d19a10";
201
+ $[0] = "eb6753965d39814f517f29742d376441f9199b2f64da5f504a380a03bff336c8";
202
202
  }
203
203
  let className;
204
204
  let open;
@@ -249,9 +249,9 @@ const animateLayoutChanges = (args) => {
249
249
  };
250
250
  const SortableBlock = (t0) => {
251
251
  const $ = c(52);
252
- if ($[0] !== "e2e18e0d8166e0ab2847dfaad4af267e4cb38ede982af367ff19b699a6d19a10") {
252
+ if ($[0] !== "eb6753965d39814f517f29742d376441f9199b2f64da5f504a380a03bff336c8") {
253
253
  for (let $i = 0; $i < 52; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
254
- $[0] = "e2e18e0d8166e0ab2847dfaad4af267e4cb38ede982af367ff19b699a6d19a10";
254
+ $[0] = "eb6753965d39814f517f29742d376441f9199b2f64da5f504a380a03bff336c8";
255
255
  }
256
256
  const { block } = t0;
257
257
  const [gripPopoverOpen, setGripPopoverOpen] = React.useState(false);
@@ -433,73 +433,89 @@ const SortableBlock = (t0) => {
433
433
  return t18;
434
434
  };
435
435
  const LayoutBlockItem = (t0) => {
436
- const $ = c(27);
437
- if ($[0] !== "e2e18e0d8166e0ab2847dfaad4af267e4cb38ede982af367ff19b699a6d19a10") {
438
- for (let $i = 0; $i < 27; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
439
- $[0] = "e2e18e0d8166e0ab2847dfaad4af267e4cb38ede982af367ff19b699a6d19a10";
436
+ const $ = c(30);
437
+ if ($[0] !== "eb6753965d39814f517f29742d376441f9199b2f64da5f504a380a03bff336c8") {
438
+ for (let $i = 0; $i < 30; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
439
+ $[0] = "eb6753965d39814f517f29742d376441f9199b2f64da5f504a380a03bff336c8";
440
440
  }
441
- const { block, layoutName } = t0;
441
+ const { block, layoutName, derived: t1 } = t0;
442
+ const derived = t1 === void 0 ? false : t1;
442
443
  const camoxApp = useCamoxApp();
443
- let t1;
444
+ let t2;
444
445
  if ($[1] !== block.type || $[2] !== camoxApp) {
445
- t1 = camoxApp.getBlockById(block.type);
446
+ t2 = camoxApp.getBlockById(block.type);
446
447
  $[1] = block.type;
447
448
  $[2] = camoxApp;
448
- $[3] = t1;
449
- } else t1 = $[3];
450
- const blockDef = t1;
449
+ $[3] = t2;
450
+ } else t2 = $[3];
451
+ const blockDef = t2;
451
452
  const ctx = useBlockTreeItem(block);
452
453
  const previewSource = usePreviewSource();
453
454
  const requireDraft = useRequireDraftSource();
454
455
  const isReadOnly = previewSource !== "draft";
455
456
  const displayText = blockDef?._internal.title ?? block.type;
456
- let t2;
457
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
458
- t2 = /* @__PURE__ */ jsx(TooltipTrigger, { children: /* @__PURE__ */ jsx(LayoutTemplate, { className: "h-4 w-4" }) });
459
- $[4] = t2;
460
- } else t2 = $[4];
461
457
  let t3;
458
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
459
+ t3 = /* @__PURE__ */ jsx(TooltipTrigger, { children: /* @__PURE__ */ jsx(LayoutTemplate, { className: "h-4 w-4" }) });
460
+ $[4] = t3;
461
+ } else t3 = $[4];
462
+ let t4;
462
463
  if ($[5] !== layoutName) {
463
- t3 = /* @__PURE__ */ jsx("span", {
464
+ t4 = /* @__PURE__ */ jsx("span", {
464
465
  className: "font-semibold",
465
466
  children: layoutName
466
467
  });
467
468
  $[5] = layoutName;
468
- $[6] = t3;
469
- } else t3 = $[6];
470
- let t4;
471
- if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
472
- t4 = /* @__PURE__ */ jsx("br", {});
473
- $[7] = t4;
474
- } else t4 = $[7];
469
+ $[6] = t4;
470
+ } else t4 = $[6];
475
471
  let t5;
476
- if ($[8] !== t3) {
477
- t5 = /* @__PURE__ */ jsx("div", {
472
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
473
+ t5 = /* @__PURE__ */ jsx("br", {});
474
+ $[7] = t5;
475
+ } else t5 = $[7];
476
+ const t6 = blockDef?._internal.synced ? "Synced: editing this block updates it across all layouts and pages" : "Changing the content may affect other pages";
477
+ let t7;
478
+ if ($[8] !== t4 || $[9] !== t6) {
479
+ t7 = /* @__PURE__ */ jsx("div", {
478
480
  className: "text-muted-foreground flex size-8 shrink-0 items-center justify-center",
479
- children: /* @__PURE__ */ jsxs(Tooltip, { children: [t2, /* @__PURE__ */ jsxs(TooltipContent, { children: [
481
+ children: /* @__PURE__ */ jsxs(Tooltip, { children: [t3, /* @__PURE__ */ jsxs(TooltipContent, { children: [
480
482
  "From ",
481
- t3,
482
- " layout.",
483
483
  t4,
484
- "Changing the content may affect other pages"
484
+ " layout.",
485
+ t5,
486
+ t6
485
487
  ] })] })
486
488
  });
487
- $[8] = t3;
488
- $[9] = t5;
489
- } else t5 = $[9];
490
- let t6;
491
- if ($[10] !== ctx.toggleSelection || $[11] !== displayText) {
492
- t6 = /* @__PURE__ */ jsx(BlockTreeItemTrigger, {
489
+ $[8] = t4;
490
+ $[9] = t6;
491
+ $[10] = t7;
492
+ } else t7 = $[10];
493
+ let t8;
494
+ if ($[11] !== ctx.toggleSelection || $[12] !== displayText) {
495
+ t8 = /* @__PURE__ */ jsx(BlockTreeItemTrigger, {
493
496
  displayText,
494
497
  onClick: ctx.toggleSelection
495
498
  });
496
- $[10] = ctx.toggleSelection;
497
- $[11] = displayText;
498
- $[12] = t6;
499
- } else t6 = $[12];
500
- let t7;
501
- if ($[13] !== block || $[14] !== ctx.ellipsisPopoverOpen || $[15] !== ctx.setEllipsisPopoverOpen || $[16] !== isReadOnly || $[17] !== requireDraft) {
502
- t7 = isReadOnly ? /* @__PURE__ */ jsx(BlockTreeItemEllipsis, {
499
+ $[11] = ctx.toggleSelection;
500
+ $[12] = displayText;
501
+ $[13] = t8;
502
+ } else t8 = $[13];
503
+ let t9;
504
+ if ($[14] !== block || $[15] !== ctx.ellipsisPopoverOpen || $[16] !== ctx.setEllipsisPopoverOpen || $[17] !== derived || $[18] !== displayText || $[19] !== isReadOnly || $[20] !== requireDraft) {
505
+ t9 = derived ? /* @__PURE__ */ jsx(Button, {
506
+ variant: "ghost",
507
+ size: "icon-sm",
508
+ className: "text-muted-foreground hidden group-focus-within:flex group-hover:flex",
509
+ "aria-label": `Edit ${displayText} in form`,
510
+ onClick: () => {
511
+ if (!requireDraft()) return;
512
+ previewStore.send({
513
+ type: "openBlockContentSheet",
514
+ blockId: block.id
515
+ });
516
+ },
517
+ children: /* @__PURE__ */ jsx(Pencil, { className: "size-4" })
518
+ }) : isReadOnly ? /* @__PURE__ */ jsx(BlockTreeItemEllipsis, {
503
519
  open: false,
504
520
  onClick: (e) => {
505
521
  e.preventDefault();
@@ -514,45 +530,85 @@ const LayoutBlockItem = (t0) => {
514
530
  layoutPlacement: block.placement,
515
531
  children: /* @__PURE__ */ jsx(BlockTreeItemEllipsis, { open: ctx.ellipsisPopoverOpen })
516
532
  });
517
- $[13] = block;
518
- $[14] = ctx.ellipsisPopoverOpen;
519
- $[15] = ctx.setEllipsisPopoverOpen;
520
- $[16] = isReadOnly;
521
- $[17] = requireDraft;
522
- $[18] = t7;
523
- } else t7 = $[18];
524
- let t8;
525
- if ($[19] !== ctx.handleBlockMouseEnter || $[20] !== ctx.handleBlockMouseLeave || $[21] !== ctx.shouldShowActive || $[22] !== ctx.shouldShowHover || $[23] !== t5 || $[24] !== t6 || $[25] !== t7) {
526
- t8 = /* @__PURE__ */ jsxs(BlockTreeItemHeader, {
533
+ $[14] = block;
534
+ $[15] = ctx.ellipsisPopoverOpen;
535
+ $[16] = ctx.setEllipsisPopoverOpen;
536
+ $[17] = derived;
537
+ $[18] = displayText;
538
+ $[19] = isReadOnly;
539
+ $[20] = requireDraft;
540
+ $[21] = t9;
541
+ } else t9 = $[21];
542
+ let t10;
543
+ if ($[22] !== ctx.handleBlockMouseEnter || $[23] !== ctx.handleBlockMouseLeave || $[24] !== ctx.shouldShowActive || $[25] !== ctx.shouldShowHover || $[26] !== t7 || $[27] !== t8 || $[28] !== t9) {
544
+ t10 = /* @__PURE__ */ jsxs(BlockTreeItemHeader, {
527
545
  className: "group",
528
546
  shouldShowHover: ctx.shouldShowHover,
529
547
  shouldShowActive: ctx.shouldShowActive,
530
548
  onMouseEnter: ctx.handleBlockMouseEnter,
531
549
  onMouseLeave: ctx.handleBlockMouseLeave,
532
550
  children: [
533
- t5,
534
- t6,
535
- t7
551
+ t7,
552
+ t8,
553
+ t9
536
554
  ]
537
555
  });
538
- $[19] = ctx.handleBlockMouseEnter;
539
- $[20] = ctx.handleBlockMouseLeave;
540
- $[21] = ctx.shouldShowActive;
541
- $[22] = ctx.shouldShowHover;
542
- $[23] = t5;
543
- $[24] = t6;
544
- $[25] = t7;
545
- $[26] = t8;
546
- } else t8 = $[26];
547
- return t8;
556
+ $[22] = ctx.handleBlockMouseEnter;
557
+ $[23] = ctx.handleBlockMouseLeave;
558
+ $[24] = ctx.shouldShowActive;
559
+ $[25] = ctx.shouldShowHover;
560
+ $[26] = t7;
561
+ $[27] = t8;
562
+ $[28] = t9;
563
+ $[29] = t10;
564
+ } else t10 = $[29];
565
+ return t10;
566
+ };
567
+ const BlockInsertionIndicator = () => {
568
+ const $ = c(4);
569
+ if ($[0] !== "eb6753965d39814f517f29742d376441f9199b2f64da5f504a380a03bff336c8") {
570
+ for (let $i = 0; $i < 4; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
571
+ $[0] = "eb6753965d39814f517f29742d376441f9199b2f64da5f504a380a03bff336c8";
572
+ }
573
+ const ref = React.useRef(null);
574
+ let t0;
575
+ let t1;
576
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
577
+ t0 = () => {
578
+ ref.current?.scrollIntoView({ block: "nearest" });
579
+ };
580
+ t1 = [];
581
+ $[1] = t0;
582
+ $[2] = t1;
583
+ } else {
584
+ t0 = $[1];
585
+ t1 = $[2];
586
+ }
587
+ React.useEffect(t0, t1);
588
+ let t2;
589
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
590
+ t2 = /* @__PURE__ */ jsx("div", {
591
+ ref,
592
+ className: "pointer-events-none relative z-30 h-2 shrink-0",
593
+ "aria-hidden": "true",
594
+ children: /* @__PURE__ */ jsx("div", {
595
+ className: "bg-primary absolute inset-x-1 top-1/2 h-0.5 -translate-y-1/2 rounded-full motion-safe:animate-pulse",
596
+ children: /* @__PURE__ */ jsx("div", { className: "bg-primary absolute -top-0.5 -left-0.5 size-1.5 rounded-full" })
597
+ })
598
+ });
599
+ $[3] = t2;
600
+ } else t2 = $[3];
601
+ return t2;
548
602
  };
549
603
  const PageTree = () => {
550
- const $ = c(56);
551
- if ($[0] !== "e2e18e0d8166e0ab2847dfaad4af267e4cb38ede982af367ff19b699a6d19a10") {
552
- for (let $i = 0; $i < 56; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
553
- $[0] = "e2e18e0d8166e0ab2847dfaad4af267e4cb38ede982af367ff19b699a6d19a10";
604
+ const $ = c(71);
605
+ if ($[0] !== "eb6753965d39814f517f29742d376441f9199b2f64da5f504a380a03bff336c8") {
606
+ for (let $i = 0; $i < 71; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
607
+ $[0] = "eb6753965d39814f517f29742d376441f9199b2f64da5f504a380a03bff336c8";
554
608
  }
555
609
  const page = usePreviewedPage();
610
+ const isAddBlockSidebarOpen = useSelector(previewStore, _temp4);
611
+ const peekedBlockPosition = useSelector(previewStore, _temp5);
556
612
  const previewSource = usePreviewSource();
557
613
  const requireDraft = useRequireDraftSource();
558
614
  const isReadOnly = previewSource !== "draft";
@@ -642,52 +698,85 @@ const PageTree = () => {
642
698
  } else t5 = $[12];
643
699
  const layout = t5;
644
700
  let t6;
645
- if ($[13] !== layout?._internal || $[14] !== layoutBeforeBlocks) {
701
+ if ($[13] !== pageBlocks || $[14] !== peekedBlockPosition) {
646
702
  let t7;
647
- if ($[16] !== layout?._internal) {
648
- t7 = (block_1) => /* @__PURE__ */ jsx(LayoutBlockItem, {
649
- block: block_1,
650
- layoutName: layout?._internal.title ?? "Unknown"
651
- }, String(block_1.id));
652
- $[16] = layout?._internal;
703
+ if ($[16] !== peekedBlockPosition) {
704
+ t7 = (block_1) => peekedBlockPosition != null && block_1.position > peekedBlockPosition;
705
+ $[16] = peekedBlockPosition;
653
706
  $[17] = t7;
654
707
  } else t7 = $[17];
655
- t6 = layoutBeforeBlocks.map(t7);
656
- $[13] = layout?._internal;
657
- $[14] = layoutBeforeBlocks;
708
+ t6 = pageBlocks.findIndex(t7);
709
+ $[13] = pageBlocks;
710
+ $[14] = peekedBlockPosition;
658
711
  $[15] = t6;
659
712
  } else t6 = $[15];
713
+ const nextBlockIndex = t6;
714
+ const insertionIndex = peekedBlockPosition === "" ? 0 : nextBlockIndex === -1 ? pageBlocks.length : nextBlockIndex;
660
715
  let t7;
661
- if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
662
- t7 = [restrictToVerticalAxis];
663
- $[18] = t7;
664
- } else t7 = $[18];
716
+ if ($[18] !== layout?._internal || $[19] !== layoutBeforeBlocks) {
717
+ let t8;
718
+ if ($[21] !== layout?._internal) {
719
+ t8 = (block_2) => /* @__PURE__ */ jsx(LayoutBlockItem, {
720
+ block: block_2,
721
+ layoutName: layout?._internal.title ?? "Unknown"
722
+ }, String(block_2.id));
723
+ $[21] = layout?._internal;
724
+ $[22] = t8;
725
+ } else t8 = $[22];
726
+ t7 = layoutBeforeBlocks.map(t8);
727
+ $[18] = layout?._internal;
728
+ $[19] = layoutBeforeBlocks;
729
+ $[20] = t7;
730
+ } else t7 = $[20];
665
731
  let t8;
666
- if ($[19] !== pageBlocks) {
667
- t8 = pageBlocks.map(_temp4);
668
- $[19] = pageBlocks;
669
- $[20] = t8;
670
- } else t8 = $[20];
732
+ if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
733
+ t8 = [restrictToVerticalAxis];
734
+ $[23] = t8;
735
+ } else t8 = $[23];
671
736
  let t9;
672
- if ($[21] !== pageBlocks) {
673
- t9 = pageBlocks.map(_temp5);
674
- $[21] = pageBlocks;
675
- $[22] = t9;
676
- } else t9 = $[22];
737
+ if ($[24] !== pageBlocks) {
738
+ t9 = pageBlocks.map(_temp6);
739
+ $[24] = pageBlocks;
740
+ $[25] = t9;
741
+ } else t9 = $[25];
677
742
  let t10;
678
- if ($[23] !== t8 || $[24] !== t9) {
679
- t10 = /* @__PURE__ */ jsx(SortableContext, {
680
- items: t8,
743
+ if ($[26] !== insertionIndex || $[27] !== isAddBlockSidebarOpen || $[28] !== pageBlocks) {
744
+ let t11;
745
+ if ($[30] !== insertionIndex || $[31] !== isAddBlockSidebarOpen) {
746
+ t11 = (block_4, index) => /* @__PURE__ */ jsxs(React.Fragment, { children: [isAddBlockSidebarOpen && index === insertionIndex && /* @__PURE__ */ jsx(BlockInsertionIndicator, {}), /* @__PURE__ */ jsx(SortableBlock, { block: block_4 })] }, String(block_4.id));
747
+ $[30] = insertionIndex;
748
+ $[31] = isAddBlockSidebarOpen;
749
+ $[32] = t11;
750
+ } else t11 = $[32];
751
+ t10 = pageBlocks.map(t11);
752
+ $[26] = insertionIndex;
753
+ $[27] = isAddBlockSidebarOpen;
754
+ $[28] = pageBlocks;
755
+ $[29] = t10;
756
+ } else t10 = $[29];
757
+ let t11;
758
+ if ($[33] !== insertionIndex || $[34] !== isAddBlockSidebarOpen || $[35] !== pageBlocks.length) {
759
+ t11 = isAddBlockSidebarOpen && insertionIndex === pageBlocks.length && /* @__PURE__ */ jsx(BlockInsertionIndicator, {});
760
+ $[33] = insertionIndex;
761
+ $[34] = isAddBlockSidebarOpen;
762
+ $[35] = pageBlocks.length;
763
+ $[36] = t11;
764
+ } else t11 = $[36];
765
+ let t12;
766
+ if ($[37] !== t10 || $[38] !== t11 || $[39] !== t9) {
767
+ t12 = /* @__PURE__ */ jsxs(SortableContext, {
768
+ items: t9,
681
769
  strategy: verticalListSortingStrategy,
682
- children: t9
770
+ children: [t10, t11]
683
771
  });
684
- $[23] = t8;
685
- $[24] = t9;
686
- $[25] = t10;
687
- } else t10 = $[25];
688
- let t11;
689
- if ($[26] !== activeId || $[27] !== pageBlocks) {
690
- t11 = activeId ? (() => {
772
+ $[37] = t10;
773
+ $[38] = t11;
774
+ $[39] = t9;
775
+ $[40] = t12;
776
+ } else t12 = $[40];
777
+ let t13;
778
+ if ($[41] !== activeId || $[42] !== pageBlocks) {
779
+ t13 = activeId ? (() => {
691
780
  const activeBlock = pageBlocks.find((b) => String(b.id) === activeId);
692
781
  if (!activeBlock) return null;
693
782
  return /* @__PURE__ */ jsx("div", {
@@ -701,121 +790,124 @@ const PageTree = () => {
701
790
  })
702
791
  });
703
792
  })() : null;
704
- $[26] = activeId;
705
- $[27] = pageBlocks;
706
- $[28] = t11;
707
- } else t11 = $[28];
708
- let t12;
709
- if ($[29] !== t11) {
710
- t12 = /* @__PURE__ */ jsx(DragOverlay, {
793
+ $[41] = activeId;
794
+ $[42] = pageBlocks;
795
+ $[43] = t13;
796
+ } else t13 = $[43];
797
+ let t14;
798
+ if ($[44] !== t13) {
799
+ t14 = /* @__PURE__ */ jsx(DragOverlay, {
711
800
  dropAnimation: null,
712
- children: t11
801
+ children: t13
713
802
  });
714
- $[29] = t11;
715
- $[30] = t12;
716
- } else t12 = $[30];
717
- let t13;
718
- if ($[31] !== handleDragEnd || $[32] !== sensors || $[33] !== t10 || $[34] !== t12) {
719
- t13 = /* @__PURE__ */ jsxs(DndContext, {
803
+ $[44] = t13;
804
+ $[45] = t14;
805
+ } else t14 = $[45];
806
+ let t15;
807
+ if ($[46] !== handleDragEnd || $[47] !== sensors || $[48] !== t12 || $[49] !== t14) {
808
+ t15 = /* @__PURE__ */ jsxs(DndContext, {
720
809
  sensors,
721
810
  collisionDetection: closestCenter,
722
811
  onDragStart: handleDragStart,
723
812
  onDragEnd: handleDragEnd,
724
813
  onDragCancel: handleDragCancel,
725
- modifiers: t7,
726
- children: [t10, t12]
814
+ modifiers: t8,
815
+ children: [t12, t14]
727
816
  });
728
- $[31] = handleDragEnd;
729
- $[32] = sensors;
730
- $[33] = t10;
731
- $[34] = t12;
732
- $[35] = t13;
733
- } else t13 = $[35];
734
- let t14;
735
- if ($[36] !== layout?._internal || $[37] !== layoutAfterBlocks) {
736
- let t15;
737
- if ($[39] !== layout?._internal) {
738
- t15 = (block_4) => /* @__PURE__ */ jsx(LayoutBlockItem, {
739
- block: block_4,
817
+ $[46] = handleDragEnd;
818
+ $[47] = sensors;
819
+ $[48] = t12;
820
+ $[49] = t14;
821
+ $[50] = t15;
822
+ } else t15 = $[50];
823
+ let t16;
824
+ if ($[51] !== layout?._internal || $[52] !== layoutAfterBlocks) {
825
+ let t17;
826
+ if ($[54] !== layout?._internal) {
827
+ t17 = (block_5) => /* @__PURE__ */ jsx(LayoutBlockItem, {
828
+ block: block_5,
740
829
  layoutName: layout?._internal.title ?? "Unknown"
741
- }, String(block_4.id));
742
- $[39] = layout?._internal;
743
- $[40] = t15;
744
- } else t15 = $[40];
745
- t14 = layoutAfterBlocks.map(t15);
746
- $[36] = layout?._internal;
747
- $[37] = layoutAfterBlocks;
748
- $[38] = t14;
749
- } else t14 = $[38];
750
- let t15;
751
- if ($[41] !== t13 || $[42] !== t14 || $[43] !== t6) {
752
- t15 = /* @__PURE__ */ jsxs("div", {
830
+ }, String(block_5.id));
831
+ $[54] = layout?._internal;
832
+ $[55] = t17;
833
+ } else t17 = $[55];
834
+ t16 = layoutAfterBlocks.map(t17);
835
+ $[51] = layout?._internal;
836
+ $[52] = layoutAfterBlocks;
837
+ $[53] = t16;
838
+ } else t16 = $[53];
839
+ let t17;
840
+ if ($[56] !== t15 || $[57] !== t16 || $[58] !== t7) {
841
+ t17 = /* @__PURE__ */ jsxs("div", {
753
842
  className: "flex flex-col gap-0.5",
754
843
  children: [
755
- t6,
756
- t13,
757
- t14
844
+ t7,
845
+ t15,
846
+ t16
758
847
  ]
759
848
  });
760
- $[41] = t13;
761
- $[42] = t14;
762
- $[43] = t6;
763
- $[44] = t15;
764
- } else t15 = $[44];
765
- const t16 = isReadOnly && "opacity-50 cursor-not-allowed";
766
- let t17;
767
- if ($[45] !== t16) {
768
- t17 = cn(t16);
769
- $[45] = t16;
770
- $[46] = t17;
771
- } else t17 = $[46];
772
- let t18;
773
- if ($[47] !== requireDraft) {
774
- t18 = () => {
849
+ $[56] = t15;
850
+ $[57] = t16;
851
+ $[58] = t7;
852
+ $[59] = t17;
853
+ } else t17 = $[59];
854
+ const t18 = isReadOnly && "opacity-50 cursor-not-allowed";
855
+ let t19;
856
+ if ($[60] !== t18) {
857
+ t19 = cn(t18);
858
+ $[60] = t18;
859
+ $[61] = t19;
860
+ } else t19 = $[61];
861
+ let t20;
862
+ if ($[62] !== requireDraft) {
863
+ t20 = () => {
775
864
  if (!requireDraft()) return;
776
865
  previewStore.send({
777
866
  type: "openAddBlockSidebar",
778
867
  via: "page-tree"
779
868
  });
780
869
  };
781
- $[47] = requireDraft;
782
- $[48] = t18;
783
- } else t18 = $[48];
784
- let t19;
785
- if ($[49] === Symbol.for("react.memo_cache_sentinel")) {
786
- t19 = /* @__PURE__ */ jsx(Plus, {});
787
- $[49] = t19;
788
- } else t19 = $[49];
789
- let t20;
790
- if ($[50] !== t17 || $[51] !== t18) {
791
- t20 = /* @__PURE__ */ jsxs(Button, {
870
+ $[62] = requireDraft;
871
+ $[63] = t20;
872
+ } else t20 = $[63];
873
+ let t21;
874
+ if ($[64] === Symbol.for("react.memo_cache_sentinel")) {
875
+ t21 = /* @__PURE__ */ jsx(Plus, {});
876
+ $[64] = t21;
877
+ } else t21 = $[64];
878
+ let t22;
879
+ if ($[65] !== t19 || $[66] !== t20) {
880
+ t22 = /* @__PURE__ */ jsxs(Button, {
792
881
  variant: "secondary",
793
- className: t17,
794
- onClick: t18,
795
- children: [t19, "Add block"]
882
+ className: t19,
883
+ onClick: t20,
884
+ children: [t21, "Add block"]
796
885
  });
797
- $[50] = t17;
798
- $[51] = t18;
799
- $[52] = t20;
800
- } else t20 = $[52];
801
- let t21;
802
- if ($[53] !== t15 || $[54] !== t20) {
803
- t21 = /* @__PURE__ */ jsxs(Fragment, { children: [t15, t20] });
804
- $[53] = t15;
805
- $[54] = t20;
806
- $[55] = t21;
807
- } else t21 = $[55];
808
- return t21;
886
+ $[65] = t19;
887
+ $[66] = t20;
888
+ $[67] = t22;
889
+ } else t22 = $[67];
890
+ let t23;
891
+ if ($[68] !== t17 || $[69] !== t22) {
892
+ t23 = /* @__PURE__ */ jsxs(Fragment, { children: [t17, t22] });
893
+ $[68] = t17;
894
+ $[69] = t22;
895
+ $[70] = t23;
896
+ } else t23 = $[70];
897
+ return t23;
809
898
  };
810
899
  function _temp(state) {
811
900
  return state.context.previewSource;
812
901
  }
813
- function _temp4(block_2) {
814
- return String(block_2.id);
902
+ function _temp4(state) {
903
+ return state.context.isAddBlockSidebarOpen;
904
+ }
905
+ function _temp5(state_0) {
906
+ return state_0.context.peekedBlockPosition;
815
907
  }
816
- function _temp5(block_3) {
817
- return /* @__PURE__ */ jsx(SortableBlock, { block: block_3 }, String(block_3.id));
908
+ function _temp6(block_3) {
909
+ return String(block_3.id);
818
910
  }
819
911
 
820
912
  //#endregion
821
- export { PageTree };
913
+ export { LayoutBlockItem, PageTree };