camox 0.24.1 → 0.26.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 (26) hide show
  1. package/dist/core/hooks/useRequireDraftSource.js +27 -0
  2. package/dist/features/preview/CamoxPreview.d.ts +4 -0
  3. package/dist/features/preview/CamoxPreview.js +454 -181
  4. package/dist/features/preview/components/AddBlockSheet.js +79 -75
  5. package/dist/features/preview/components/AssetLightbox.js +1 -1
  6. package/dist/features/preview/components/BlockActionsPopover.js +39 -22
  7. package/dist/features/preview/components/DraftSwitchDialog.js +66 -0
  8. package/dist/features/preview/components/EditPageModal.js +9 -9
  9. package/dist/features/preview/components/LinkFieldEditor.js +1 -1
  10. package/dist/features/preview/components/Overlays.js +6 -2
  11. package/dist/features/preview/components/PageContentSheet.js +222 -190
  12. package/dist/features/preview/components/PagePicker.js +81 -3
  13. package/dist/features/preview/components/PageTree.js +418 -327
  14. package/dist/features/preview/components/PreviewToolbar.js +172 -158
  15. package/dist/features/preview/components/PublishDialog.js +111 -0
  16. package/dist/features/preview/components/useRepeatableItemActions.js +26 -20
  17. package/dist/features/preview/components/useUpdateBlockPosition.js +10 -9
  18. package/dist/features/preview/previewStore.js +38 -1
  19. package/dist/features/provider/useAdminShortcuts.js +7 -2
  20. package/dist/features/routes/pageRoute.d.ts +6 -2
  21. package/dist/features/routes/pageRoute.js +10 -6
  22. package/dist/features/vite/vite.js +6 -5
  23. package/dist/lib/normalized-data.js +87 -88
  24. package/dist/lib/queries.js +12 -6
  25. package/dist/studio.css +1 -1
  26. package/package.json +4 -4
@@ -3,6 +3,7 @@ import { blockQueries } from "../../../lib/queries.js";
3
3
  import { cn } from "../../../lib/utils.js";
4
4
  import { usePageBlocks } from "../../../lib/normalized-data.js";
5
5
  import { useCamoxApp } from "../../provider/components/CamoxAppContext.js";
6
+ import { useRequireDraftSource } from "../../../core/hooks/useRequireDraftSource.js";
6
7
  import { fieldTypesDictionary } from "../../../core/lib/fieldTypes.js";
7
8
  import { useUpdateBlockPosition } from "./useUpdateBlockPosition.js";
8
9
  import { BlockActionsPopover } from "./BlockActionsPopover.js";
@@ -22,11 +23,19 @@ import { CSS } from "@dnd-kit/utilities";
22
23
  import { Accordion } from "@base-ui/react/accordion";
23
24
 
24
25
  //#region src/features/preview/components/PageTree.tsx
26
+ const usePreviewSource = () => {
27
+ const $ = c(1);
28
+ if ($[0] !== "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7") {
29
+ for (let $i = 0; $i < 1; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
30
+ $[0] = "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7";
31
+ }
32
+ return useSelector(previewStore, _temp);
33
+ };
25
34
  function useEmbedTitle(url) {
26
35
  const $ = c(4);
27
- if ($[0] !== "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87") {
36
+ if ($[0] !== "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7") {
28
37
  for (let $i = 0; $i < 4; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
29
- $[0] = "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87";
38
+ $[0] = "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7";
30
39
  }
31
40
  const [title, setTitle] = React.useState(null);
32
41
  let t0;
@@ -36,10 +45,10 @@ function useEmbedTitle(url) {
36
45
  if (!url) return;
37
46
  setTitle(null);
38
47
  const controller = new AbortController();
39
- fetch(url, { signal: controller.signal }).then(_temp).then((html) => {
48
+ fetch(url, { signal: controller.signal }).then(_temp2).then((html) => {
40
49
  const match = html.match(/<title[^>]*>([^<]*)<\/title>/i);
41
50
  if (match?.[1]) setTitle(match[1].trim());
42
- }).catch(_temp2);
51
+ }).catch(_temp3);
43
52
  return () => controller.abort();
44
53
  };
45
54
  t1 = [url];
@@ -53,15 +62,15 @@ function useEmbedTitle(url) {
53
62
  React.useEffect(t0, t1);
54
63
  return title;
55
64
  }
56
- function _temp2() {}
57
- function _temp(res) {
65
+ function _temp3() {}
66
+ function _temp2(res) {
58
67
  return res.text();
59
68
  }
60
69
  const FieldItem = (t0) => {
61
70
  const $ = c(29);
62
- if ($[0] !== "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87") {
71
+ if ($[0] !== "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7") {
63
72
  for (let $i = 0; $i < 29; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
64
- $[0] = "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87";
73
+ $[0] = "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7";
65
74
  }
66
75
  const { fieldName, value, fieldType, schemaTitle, isSelected, onFieldClick, onFieldDoubleClick, onMouseEnter, onMouseLeave } = t0;
67
76
  const fetchedEmbedTitle = useEmbedTitle(fieldType === "Embed" ? value : null);
@@ -146,26 +155,28 @@ const FieldItem = (t0) => {
146
155
  return t9;
147
156
  };
148
157
  const BlockFields = (t0) => {
149
- const $ = c(5);
150
- if ($[0] !== "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87") {
151
- for (let $i = 0; $i < 5; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
152
- $[0] = "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87";
158
+ const $ = c(6);
159
+ if ($[0] !== "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7") {
160
+ for (let $i = 0; $i < 6; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
161
+ $[0] = "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7";
153
162
  }
154
163
  const { block } = t0;
155
164
  const schemaProperties = useCamoxApp().getBlockById(block.type)?._internal.contentSchema.properties;
156
- const selection = useSelector(previewStore, _temp3);
157
- const iframeElement = useSelector(previewStore, _temp4);
165
+ const selection = useSelector(previewStore, _temp4);
166
+ const iframeElement = useSelector(previewStore, _temp5);
167
+ const previewSource = usePreviewSource();
158
168
  let t1;
159
- if ($[1] !== block.id) {
160
- t1 = blockQueries.get(block.id);
169
+ if ($[1] !== block.id || $[2] !== previewSource) {
170
+ t1 = blockQueries.get(block.id, previewSource);
161
171
  $[1] = block.id;
162
- $[2] = t1;
163
- } else t1 = $[2];
172
+ $[2] = previewSource;
173
+ $[3] = t1;
174
+ } else t1 = $[3];
164
175
  const { data: blockBundle } = useQuery(t1);
165
176
  let selectedFieldName = null;
166
177
  if (selection?.type === "block-field" && selection.blockId === block.id) selectedFieldName = selection.fieldName;
167
178
  else if ((selection?.type === "item" || selection?.type === "item-field") && selection.blockId === block.id && blockBundle) {
168
- const itemsById = new Map(blockBundle.repeatableItems.map(_temp5));
179
+ const itemsById = new Map(blockBundle.repeatableItems.map(_temp6));
169
180
  let current = itemsById.get(selection.itemId);
170
181
  while (current?.parentItemId != null) current = itemsById.get(current.parentItemId);
171
182
  selectedFieldName = current?.fieldName ?? null;
@@ -238,26 +249,26 @@ const BlockFields = (t0) => {
238
249
  }, fieldName_3);
239
250
  });
240
251
  let t4;
241
- if ($[3] !== t3) {
252
+ if ($[4] !== t3) {
242
253
  t4 = /* @__PURE__ */ jsx("ul", {
243
254
  className: t2,
244
255
  children: t3
245
256
  });
246
- $[3] = t3;
247
- $[4] = t4;
248
- } else t4 = $[4];
257
+ $[4] = t3;
258
+ $[5] = t4;
259
+ } else t4 = $[5];
249
260
  return t4;
250
261
  };
251
262
  function useBlockTreeItem(block, t0) {
252
263
  const $ = c(17);
253
- if ($[0] !== "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87") {
264
+ if ($[0] !== "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7") {
254
265
  for (let $i = 0; $i < 17; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
255
- $[0] = "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87";
266
+ $[0] = "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7";
256
267
  }
257
268
  const isDragging = t0 === void 0 ? false : t0;
258
269
  const [ellipsisPopoverOpen, setEllipsisPopoverOpen] = React.useState(false);
259
- const selection = useSelector(previewStore, _temp6);
260
- const iframeElement = useSelector(previewStore, _temp7);
270
+ const selection = useSelector(previewStore, _temp7);
271
+ const iframeElement = useSelector(previewStore, _temp8);
261
272
  const isBlockSelected = selection?.type === "block" && selection.blockId === block.id;
262
273
  const shouldShowHover = !isDragging && !isBlockSelected;
263
274
  const shouldShowActive = isDragging || isBlockSelected;
@@ -326,17 +337,17 @@ function useBlockTreeItem(block, t0) {
326
337
  } else t4 = $[16];
327
338
  return t4;
328
339
  }
329
- function _temp7(state_0) {
340
+ function _temp8(state_0) {
330
341
  return state_0.context.iframeElement;
331
342
  }
332
- function _temp6(state) {
343
+ function _temp7(state) {
333
344
  return state.context.selection;
334
345
  }
335
346
  const BlockTreeItemHeader = (t0) => {
336
347
  const $ = c(17);
337
- if ($[0] !== "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87") {
348
+ if ($[0] !== "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7") {
338
349
  for (let $i = 0; $i < 17; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
339
- $[0] = "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87";
350
+ $[0] = "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7";
340
351
  }
341
352
  let children;
342
353
  let className;
@@ -389,9 +400,9 @@ const BlockTreeItemHeader = (t0) => {
389
400
  };
390
401
  const BlockTreeItemTrigger = (t0) => {
391
402
  const $ = c(5);
392
- if ($[0] !== "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87") {
403
+ if ($[0] !== "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7") {
393
404
  for (let $i = 0; $i < 5; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
394
- $[0] = "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87";
405
+ $[0] = "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7";
395
406
  }
396
407
  const { displayText, onClick } = t0;
397
408
  let t1;
@@ -418,9 +429,9 @@ const BlockTreeItemTrigger = (t0) => {
418
429
  };
419
430
  const BlockTreeItemEllipsis = (t0) => {
420
431
  const $ = c(12);
421
- if ($[0] !== "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87") {
432
+ if ($[0] !== "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7") {
422
433
  for (let $i = 0; $i < 12; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
423
- $[0] = "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87";
434
+ $[0] = "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7";
424
435
  }
425
436
  let className;
426
437
  let open;
@@ -466,9 +477,9 @@ const BlockTreeItemEllipsis = (t0) => {
466
477
  };
467
478
  const BlockTreeItemContent = (t0) => {
468
479
  const $ = c(3);
469
- if ($[0] !== "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87") {
480
+ if ($[0] !== "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7") {
470
481
  for (let $i = 0; $i < 3; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
471
- $[0] = "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87";
482
+ $[0] = "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7";
472
483
  }
473
484
  const { block } = t0;
474
485
  let t1;
@@ -488,201 +499,245 @@ const animateLayoutChanges = (args) => {
488
499
  return defaultAnimateLayoutChanges(args);
489
500
  };
490
501
  const SortableBlock = (t0) => {
491
- const $ = c(53);
492
- if ($[0] !== "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87") {
493
- for (let $i = 0; $i < 53; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
494
- $[0] = "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87";
502
+ const $ = c(67);
503
+ if ($[0] !== "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7") {
504
+ for (let $i = 0; $i < 67; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
505
+ $[0] = "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7";
495
506
  }
496
507
  const { block } = t0;
497
508
  const [gripPopoverOpen, setGripPopoverOpen] = React.useState(false);
509
+ const previewSource = usePreviewSource();
510
+ const requireDraft = useRequireDraftSource();
511
+ const isReadOnly = previewSource !== "draft";
498
512
  const t1 = String(block.id);
499
513
  let t2;
500
- if ($[1] !== t1) {
514
+ if ($[1] !== isReadOnly || $[2] !== t1) {
501
515
  t2 = {
502
516
  id: t1,
503
- animateLayoutChanges
517
+ animateLayoutChanges,
518
+ disabled: isReadOnly
504
519
  };
505
- $[1] = t1;
506
- $[2] = t2;
507
- } else t2 = $[2];
520
+ $[1] = isReadOnly;
521
+ $[2] = t1;
522
+ $[3] = t2;
523
+ } else t2 = $[3];
508
524
  const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable(t2);
509
525
  let t3;
510
- if ($[3] !== transform) {
526
+ if ($[4] !== transform) {
511
527
  t3 = CSS.Transform.toString(transform);
512
- $[3] = transform;
513
- $[4] = t3;
514
- } else t3 = $[4];
528
+ $[4] = transform;
529
+ $[5] = t3;
530
+ } else t3 = $[5];
515
531
  const t4 = isDragging ? 0 : 1;
516
532
  let t5;
517
- if ($[5] !== t3 || $[6] !== t4 || $[7] !== transition) {
533
+ if ($[6] !== t3 || $[7] !== t4 || $[8] !== transition) {
518
534
  t5 = {
519
535
  transform: t3,
520
536
  transition,
521
537
  opacity: t4
522
538
  };
523
- $[5] = t3;
524
- $[6] = t4;
525
- $[7] = transition;
526
- $[8] = t5;
527
- } else t5 = $[8];
539
+ $[6] = t3;
540
+ $[7] = t4;
541
+ $[8] = transition;
542
+ $[9] = t5;
543
+ } else t5 = $[9];
528
544
  const style = t5;
529
545
  const ctx = useBlockTreeItem(block, isDragging);
530
546
  let t6;
531
- if ($[9] !== block.id) {
547
+ if ($[10] !== block.id) {
532
548
  t6 = (state) => state.context.selection?.blockId === block.id;
533
- $[9] = block.id;
534
- $[10] = t6;
535
- } else t6 = $[10];
549
+ $[10] = block.id;
550
+ $[11] = t6;
551
+ } else t6 = $[11];
536
552
  const isBlockFocused = useSelector(previewStore, t6);
537
- let t7;
538
- if ($[11] !== block.id || $[12] !== isBlockFocused) {
539
- t7 = isBlockFocused ? [String(block.id)] : [];
540
- $[11] = block.id;
541
- $[12] = isBlockFocused;
542
- $[13] = t7;
543
- } else t7 = $[13];
544
- const t8 = String(block.id);
553
+ const t7 = isReadOnly ? "cursor-not-allowed opacity-50" : "cursor-grab active:cursor-grabbing";
554
+ let t8;
555
+ if ($[12] !== t7) {
556
+ t8 = cn("text-muted-foreground hover:text-foreground flex", t7);
557
+ $[12] = t7;
558
+ $[13] = t8;
559
+ } else t8 = $[13];
545
560
  let t9;
546
- if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
547
- t9 = /* @__PURE__ */ jsx("div", {});
548
- $[14] = t9;
549
- } else t9 = $[14];
561
+ if ($[14] !== attributes || $[15] !== isReadOnly) {
562
+ t9 = isReadOnly ? {} : attributes;
563
+ $[14] = attributes;
564
+ $[15] = isReadOnly;
565
+ $[16] = t9;
566
+ } else t9 = $[16];
550
567
  let t10;
568
+ if ($[17] !== isReadOnly || $[18] !== listeners) {
569
+ t10 = isReadOnly ? {} : listeners;
570
+ $[17] = isReadOnly;
571
+ $[18] = listeners;
572
+ $[19] = t10;
573
+ } else t10 = $[19];
551
574
  let t11;
552
- if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
553
- t10 = /* @__PURE__ */ jsx("span", {
575
+ if ($[20] !== isReadOnly || $[21] !== requireDraft) {
576
+ t11 = isReadOnly ? (e) => {
577
+ e.preventDefault();
578
+ e.stopPropagation();
579
+ requireDraft();
580
+ } : void 0;
581
+ $[20] = isReadOnly;
582
+ $[21] = requireDraft;
583
+ $[22] = t11;
584
+ } else t11 = $[22];
585
+ let t12;
586
+ let t13;
587
+ if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
588
+ t12 = /* @__PURE__ */ jsx("span", {
554
589
  className: "sr-only",
555
590
  children: "Click and use arrow keys to reorder"
556
591
  });
557
- t11 = /* @__PURE__ */ jsx(GripVertical, { className: "h-4 w-4" });
558
- $[15] = t10;
559
- $[16] = t11;
592
+ t13 = /* @__PURE__ */ jsx(GripVertical, { className: "h-4 w-4" });
593
+ $[23] = t12;
594
+ $[24] = t13;
560
595
  } else {
561
- t10 = $[15];
562
- t11 = $[16];
596
+ t12 = $[23];
597
+ t13 = $[24];
563
598
  }
564
- let t12;
565
- if ($[17] !== attributes || $[18] !== listeners) {
566
- t12 = /* @__PURE__ */ jsxs(Button, {
599
+ let t14;
600
+ if ($[25] !== t10 || $[26] !== t11 || $[27] !== t8 || $[28] !== t9) {
601
+ t14 = /* @__PURE__ */ jsxs(Button, {
567
602
  variant: "ghost",
568
603
  size: "icon-sm",
569
- className: "text-muted-foreground hover:text-foreground flex cursor-grab active:cursor-grabbing",
570
- ...attributes,
571
- ...listeners,
572
- children: [t10, t11]
604
+ className: t8,
605
+ ...t9,
606
+ ...t10,
607
+ onClick: t11,
608
+ children: [t12, t13]
573
609
  });
574
- $[17] = attributes;
575
- $[18] = listeners;
576
- $[19] = t12;
577
- } else t12 = $[19];
578
- let t13;
579
- if ($[20] !== block || $[21] !== gripPopoverOpen || $[22] !== t12) {
580
- t13 = /* @__PURE__ */ jsx(BlockActionsPopover, {
610
+ $[25] = t10;
611
+ $[26] = t11;
612
+ $[27] = t8;
613
+ $[28] = t9;
614
+ $[29] = t14;
615
+ } else t14 = $[29];
616
+ const gripButton = t14;
617
+ let t15;
618
+ if ($[30] !== block.id || $[31] !== isBlockFocused) {
619
+ t15 = isBlockFocused ? [String(block.id)] : [];
620
+ $[30] = block.id;
621
+ $[31] = isBlockFocused;
622
+ $[32] = t15;
623
+ } else t15 = $[32];
624
+ const t16 = String(block.id);
625
+ let t17;
626
+ if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
627
+ t17 = /* @__PURE__ */ jsx("div", {});
628
+ $[33] = t17;
629
+ } else t17 = $[33];
630
+ let t18;
631
+ if ($[34] !== block || $[35] !== gripButton || $[36] !== gripPopoverOpen || $[37] !== isReadOnly) {
632
+ t18 = isReadOnly ? gripButton : /* @__PURE__ */ jsx(BlockActionsPopover, {
581
633
  block,
582
634
  open: gripPopoverOpen,
583
635
  onOpenChange: setGripPopoverOpen,
584
- children: t12
636
+ children: gripButton
585
637
  });
586
- $[20] = block;
587
- $[21] = gripPopoverOpen;
588
- $[22] = t12;
589
- $[23] = t13;
590
- } else t13 = $[23];
591
- const t14 = block.summary || block.type;
592
- let t15;
593
- if ($[24] !== ctx.toggleSelection || $[25] !== t14) {
594
- t15 = /* @__PURE__ */ jsx(BlockTreeItemTrigger, {
595
- displayText: t14,
638
+ $[34] = block;
639
+ $[35] = gripButton;
640
+ $[36] = gripPopoverOpen;
641
+ $[37] = isReadOnly;
642
+ $[38] = t18;
643
+ } else t18 = $[38];
644
+ const t19 = block.summary || block.type;
645
+ let t20;
646
+ if ($[39] !== ctx.toggleSelection || $[40] !== t19) {
647
+ t20 = /* @__PURE__ */ jsx(BlockTreeItemTrigger, {
648
+ displayText: t19,
596
649
  onClick: ctx.toggleSelection
597
650
  });
598
- $[24] = ctx.toggleSelection;
599
- $[25] = t14;
600
- $[26] = t15;
601
- } else t15 = $[26];
602
- let t16;
603
- if ($[27] !== ctx.ellipsisPopoverOpen) {
604
- t16 = /* @__PURE__ */ jsx(BlockTreeItemEllipsis, { open: ctx.ellipsisPopoverOpen });
605
- $[27] = ctx.ellipsisPopoverOpen;
606
- $[28] = t16;
607
- } else t16 = $[28];
608
- let t17;
609
- if ($[29] !== block || $[30] !== ctx.ellipsisPopoverOpen || $[31] !== ctx.setEllipsisPopoverOpen || $[32] !== t16) {
610
- t17 = /* @__PURE__ */ jsx(BlockActionsPopover, {
651
+ $[39] = ctx.toggleSelection;
652
+ $[40] = t19;
653
+ $[41] = t20;
654
+ } else t20 = $[41];
655
+ let t21;
656
+ if ($[42] !== block || $[43] !== ctx.ellipsisPopoverOpen || $[44] !== ctx.setEllipsisPopoverOpen || $[45] !== isReadOnly || $[46] !== requireDraft) {
657
+ t21 = isReadOnly ? /* @__PURE__ */ jsx(BlockTreeItemEllipsis, {
658
+ open: false,
659
+ onClick: (e_0) => {
660
+ e_0.preventDefault();
661
+ e_0.stopPropagation();
662
+ requireDraft();
663
+ }
664
+ }) : /* @__PURE__ */ jsx(BlockActionsPopover, {
611
665
  block,
612
666
  open: ctx.ellipsisPopoverOpen,
613
667
  onOpenChange: ctx.setEllipsisPopoverOpen,
614
- children: t16
668
+ children: /* @__PURE__ */ jsx(BlockTreeItemEllipsis, { open: ctx.ellipsisPopoverOpen })
615
669
  });
616
- $[29] = block;
617
- $[30] = ctx.ellipsisPopoverOpen;
618
- $[31] = ctx.setEllipsisPopoverOpen;
619
- $[32] = t16;
620
- $[33] = t17;
621
- } else t17 = $[33];
622
- let t18;
623
- if ($[34] !== ctx.shouldShowActive || $[35] !== ctx.shouldShowHover || $[36] !== t13 || $[37] !== t15 || $[38] !== t17) {
624
- t18 = /* @__PURE__ */ jsx(Accordion.Header, {
625
- render: t9,
670
+ $[42] = block;
671
+ $[43] = ctx.ellipsisPopoverOpen;
672
+ $[44] = ctx.setEllipsisPopoverOpen;
673
+ $[45] = isReadOnly;
674
+ $[46] = requireDraft;
675
+ $[47] = t21;
676
+ } else t21 = $[47];
677
+ let t22;
678
+ if ($[48] !== ctx.shouldShowActive || $[49] !== ctx.shouldShowHover || $[50] !== t18 || $[51] !== t20 || $[52] !== t21) {
679
+ t22 = /* @__PURE__ */ jsx(Accordion.Header, {
680
+ render: t17,
626
681
  children: /* @__PURE__ */ jsxs(BlockTreeItemHeader, {
627
682
  shouldShowHover: ctx.shouldShowHover,
628
683
  shouldShowActive: ctx.shouldShowActive,
629
684
  children: [
630
- t13,
631
- t15,
632
- t17
685
+ t18,
686
+ t20,
687
+ t21
633
688
  ]
634
689
  })
635
690
  });
636
- $[34] = ctx.shouldShowActive;
637
- $[35] = ctx.shouldShowHover;
638
- $[36] = t13;
639
- $[37] = t15;
640
- $[38] = t17;
641
- $[39] = t18;
642
- } else t18 = $[39];
643
- let t19;
644
- if ($[40] !== block) {
645
- t19 = /* @__PURE__ */ jsx(BlockTreeItemContent, { block });
646
- $[40] = block;
647
- $[41] = t19;
648
- } else t19 = $[41];
649
- let t20;
650
- if ($[42] !== ctx.handleBlockMouseEnter || $[43] !== ctx.handleBlockMouseLeave || $[44] !== setNodeRef || $[45] !== style || $[46] !== t18 || $[47] !== t19 || $[48] !== t8) {
651
- t20 = /* @__PURE__ */ jsxs(Accordion.Item, {
652
- value: t8,
691
+ $[48] = ctx.shouldShowActive;
692
+ $[49] = ctx.shouldShowHover;
693
+ $[50] = t18;
694
+ $[51] = t20;
695
+ $[52] = t21;
696
+ $[53] = t22;
697
+ } else t22 = $[53];
698
+ let t23;
699
+ if ($[54] !== block) {
700
+ t23 = /* @__PURE__ */ jsx(BlockTreeItemContent, { block });
701
+ $[54] = block;
702
+ $[55] = t23;
703
+ } else t23 = $[55];
704
+ let t24;
705
+ if ($[56] !== ctx.handleBlockMouseEnter || $[57] !== ctx.handleBlockMouseLeave || $[58] !== setNodeRef || $[59] !== style || $[60] !== t16 || $[61] !== t22 || $[62] !== t23) {
706
+ t24 = /* @__PURE__ */ jsxs(Accordion.Item, {
707
+ value: t16,
653
708
  ref: setNodeRef,
654
709
  style,
655
710
  className: "group",
656
711
  onMouseEnter: ctx.handleBlockMouseEnter,
657
712
  onMouseLeave: ctx.handleBlockMouseLeave,
658
- children: [t18, t19]
713
+ children: [t22, t23]
659
714
  });
660
- $[42] = ctx.handleBlockMouseEnter;
661
- $[43] = ctx.handleBlockMouseLeave;
662
- $[44] = setNodeRef;
663
- $[45] = style;
664
- $[46] = t18;
665
- $[47] = t19;
666
- $[48] = t8;
667
- $[49] = t20;
668
- } else t20 = $[49];
669
- let t21;
670
- if ($[50] !== t20 || $[51] !== t7) {
671
- t21 = /* @__PURE__ */ jsx(Accordion.Root, {
672
- value: t7,
673
- children: t20
715
+ $[56] = ctx.handleBlockMouseEnter;
716
+ $[57] = ctx.handleBlockMouseLeave;
717
+ $[58] = setNodeRef;
718
+ $[59] = style;
719
+ $[60] = t16;
720
+ $[61] = t22;
721
+ $[62] = t23;
722
+ $[63] = t24;
723
+ } else t24 = $[63];
724
+ let t25;
725
+ if ($[64] !== t15 || $[65] !== t24) {
726
+ t25 = /* @__PURE__ */ jsx(Accordion.Root, {
727
+ value: t15,
728
+ children: t24
674
729
  });
675
- $[50] = t20;
676
- $[51] = t7;
677
- $[52] = t21;
678
- } else t21 = $[52];
679
- return t21;
730
+ $[64] = t15;
731
+ $[65] = t24;
732
+ $[66] = t25;
733
+ } else t25 = $[66];
734
+ return t25;
680
735
  };
681
736
  const LayoutBlockItem = (t0) => {
682
- const $ = c(44);
683
- if ($[0] !== "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87") {
684
- for (let $i = 0; $i < 44; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
685
- $[0] = "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87";
737
+ const $ = c(42);
738
+ if ($[0] !== "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7") {
739
+ for (let $i = 0; $i < 42; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
740
+ $[0] = "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7";
686
741
  }
687
742
  const { block, layoutName } = t0;
688
743
  const camoxApp = useCamoxApp();
@@ -695,6 +750,9 @@ const LayoutBlockItem = (t0) => {
695
750
  } else t1 = $[3];
696
751
  const blockDef = t1;
697
752
  const ctx = useBlockTreeItem(block);
753
+ const previewSource = usePreviewSource();
754
+ const requireDraft = useRequireDraftSource();
755
+ const isReadOnly = previewSource !== "draft";
698
756
  const displayText = blockDef?._internal.title ?? block.type;
699
757
  let t2;
700
758
  if ($[4] !== block.id) {
@@ -738,7 +796,7 @@ const LayoutBlockItem = (t0) => {
738
796
  let t9;
739
797
  if ($[14] !== t7) {
740
798
  t9 = /* @__PURE__ */ jsx("div", {
741
- className: "text-muted-foreground flex size-7 shrink-0 items-center justify-center",
799
+ className: "text-muted-foreground flex size-8 shrink-0 items-center justify-center",
742
800
  children: /* @__PURE__ */ jsxs(Tooltip, { children: [t6, /* @__PURE__ */ jsxs(TooltipContent, { children: [
743
801
  "From ",
744
802
  t7,
@@ -760,33 +818,33 @@ const LayoutBlockItem = (t0) => {
760
818
  $[17] = displayText;
761
819
  $[18] = t10;
762
820
  } else t10 = $[18];
763
- const t11 = block.placement;
764
- let t12;
765
- if ($[19] !== ctx.ellipsisPopoverOpen) {
766
- t12 = /* @__PURE__ */ jsx(BlockTreeItemEllipsis, { open: ctx.ellipsisPopoverOpen });
767
- $[19] = ctx.ellipsisPopoverOpen;
768
- $[20] = t12;
769
- } else t12 = $[20];
770
- let t13;
771
- if ($[21] !== block || $[22] !== ctx.ellipsisPopoverOpen || $[23] !== ctx.setEllipsisPopoverOpen || $[24] !== t11 || $[25] !== t12) {
772
- t13 = /* @__PURE__ */ jsx(BlockActionsPopover, {
821
+ let t11;
822
+ if ($[19] !== block || $[20] !== ctx.ellipsisPopoverOpen || $[21] !== ctx.setEllipsisPopoverOpen || $[22] !== isReadOnly || $[23] !== requireDraft) {
823
+ t11 = isReadOnly ? /* @__PURE__ */ jsx(BlockTreeItemEllipsis, {
824
+ open: false,
825
+ onClick: (e) => {
826
+ e.preventDefault();
827
+ e.stopPropagation();
828
+ requireDraft();
829
+ }
830
+ }) : /* @__PURE__ */ jsx(BlockActionsPopover, {
773
831
  block,
774
832
  open: ctx.ellipsisPopoverOpen,
775
833
  onOpenChange: ctx.setEllipsisPopoverOpen,
776
834
  isLayoutBlock: true,
777
- layoutPlacement: t11,
778
- children: t12
835
+ layoutPlacement: block.placement,
836
+ children: /* @__PURE__ */ jsx(BlockTreeItemEllipsis, { open: ctx.ellipsisPopoverOpen })
779
837
  });
780
- $[21] = block;
781
- $[22] = ctx.ellipsisPopoverOpen;
782
- $[23] = ctx.setEllipsisPopoverOpen;
838
+ $[19] = block;
839
+ $[20] = ctx.ellipsisPopoverOpen;
840
+ $[21] = ctx.setEllipsisPopoverOpen;
841
+ $[22] = isReadOnly;
842
+ $[23] = requireDraft;
783
843
  $[24] = t11;
784
- $[25] = t12;
785
- $[26] = t13;
786
- } else t13 = $[26];
787
- let t14;
788
- if ($[27] !== ctx.shouldShowActive || $[28] !== ctx.shouldShowHover || $[29] !== t10 || $[30] !== t13 || $[31] !== t9) {
789
- t14 = /* @__PURE__ */ jsx(Accordion.Header, {
844
+ } else t11 = $[24];
845
+ let t12;
846
+ if ($[25] !== ctx.shouldShowActive || $[26] !== ctx.shouldShowHover || $[27] !== t10 || $[28] !== t11 || $[29] !== t9) {
847
+ t12 = /* @__PURE__ */ jsx(Accordion.Header, {
790
848
  render: t5,
791
849
  children: /* @__PURE__ */ jsxs(BlockTreeItemHeader, {
792
850
  shouldShowHover: ctx.shouldShowHover,
@@ -794,59 +852,62 @@ const LayoutBlockItem = (t0) => {
794
852
  children: [
795
853
  t9,
796
854
  t10,
797
- t13
855
+ t11
798
856
  ]
799
857
  })
800
858
  });
801
- $[27] = ctx.shouldShowActive;
802
- $[28] = ctx.shouldShowHover;
803
- $[29] = t10;
804
- $[30] = t13;
805
- $[31] = t9;
806
- $[32] = t14;
807
- } else t14 = $[32];
808
- let t15;
809
- if ($[33] !== block) {
810
- t15 = /* @__PURE__ */ jsx(BlockTreeItemContent, { block });
811
- $[33] = block;
812
- $[34] = t15;
813
- } else t15 = $[34];
814
- let t16;
815
- if ($[35] !== ctx.handleBlockMouseEnter || $[36] !== ctx.handleBlockMouseLeave || $[37] !== t14 || $[38] !== t15 || $[39] !== t4) {
816
- t16 = /* @__PURE__ */ jsxs(Accordion.Item, {
859
+ $[25] = ctx.shouldShowActive;
860
+ $[26] = ctx.shouldShowHover;
861
+ $[27] = t10;
862
+ $[28] = t11;
863
+ $[29] = t9;
864
+ $[30] = t12;
865
+ } else t12 = $[30];
866
+ let t13;
867
+ if ($[31] !== block) {
868
+ t13 = /* @__PURE__ */ jsx(BlockTreeItemContent, { block });
869
+ $[31] = block;
870
+ $[32] = t13;
871
+ } else t13 = $[32];
872
+ let t14;
873
+ if ($[33] !== ctx.handleBlockMouseEnter || $[34] !== ctx.handleBlockMouseLeave || $[35] !== t12 || $[36] !== t13 || $[37] !== t4) {
874
+ t14 = /* @__PURE__ */ jsxs(Accordion.Item, {
817
875
  value: t4,
818
876
  className: "group",
819
877
  onMouseEnter: ctx.handleBlockMouseEnter,
820
878
  onMouseLeave: ctx.handleBlockMouseLeave,
821
- children: [t14, t15]
879
+ children: [t12, t13]
822
880
  });
823
- $[35] = ctx.handleBlockMouseEnter;
824
- $[36] = ctx.handleBlockMouseLeave;
825
- $[37] = t14;
826
- $[38] = t15;
827
- $[39] = t4;
828
- $[40] = t16;
829
- } else t16 = $[40];
830
- let t17;
831
- if ($[41] !== t16 || $[42] !== t3) {
832
- t17 = /* @__PURE__ */ jsx(Accordion.Root, {
881
+ $[33] = ctx.handleBlockMouseEnter;
882
+ $[34] = ctx.handleBlockMouseLeave;
883
+ $[35] = t12;
884
+ $[36] = t13;
885
+ $[37] = t4;
886
+ $[38] = t14;
887
+ } else t14 = $[38];
888
+ let t15;
889
+ if ($[39] !== t14 || $[40] !== t3) {
890
+ t15 = /* @__PURE__ */ jsx(Accordion.Root, {
833
891
  value: t3,
834
- children: t16
892
+ children: t14
835
893
  });
836
- $[41] = t16;
837
- $[42] = t3;
838
- $[43] = t17;
839
- } else t17 = $[43];
840
- return t17;
894
+ $[39] = t14;
895
+ $[40] = t3;
896
+ $[41] = t15;
897
+ } else t15 = $[41];
898
+ return t15;
841
899
  };
842
900
  const PageTree = () => {
843
- const $ = c(47);
844
- if ($[0] !== "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87") {
845
- for (let $i = 0; $i < 47; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
846
- $[0] = "93644338051da8a2fc7d6bcaeba79afa786571ac097e7be02bb6bea0e96d3c87";
901
+ const $ = c(56);
902
+ if ($[0] !== "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7") {
903
+ for (let $i = 0; $i < 56; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
904
+ $[0] = "4252672317e9d976c47102ba1a26a55d6393ec9a518eb0503aaa3be0355ffab7";
847
905
  }
848
906
  const page = usePreviewedPage();
849
- const { pageBlocks, beforeBlocks: layoutBeforeBlocks, afterBlocks: layoutAfterBlocks } = usePageBlocks(page);
907
+ const previewSource = usePreviewSource();
908
+ const requireDraft = useRequireDraftSource();
909
+ const isReadOnly = previewSource !== "draft";
910
+ const { pageBlocks, beforeBlocks: layoutBeforeBlocks, afterBlocks: layoutAfterBlocks } = usePageBlocks(page, previewSource);
850
911
  const camoxApp = useCamoxApp();
851
912
  const updatePosition = useUpdateBlockPosition();
852
913
  const [activeId, setActiveId] = React.useState(null);
@@ -874,13 +935,17 @@ const PageTree = () => {
874
935
  } else t2 = $[3];
875
936
  const handleDragStart = t2;
876
937
  let t3;
877
- if ($[4] !== page || $[5] !== pageBlocks || $[6] !== updatePosition) {
938
+ if ($[4] !== page || $[5] !== pageBlocks || $[6] !== requireDraft || $[7] !== updatePosition) {
878
939
  t3 = (event_0) => {
879
940
  const { active, over } = event_0;
880
941
  if (!over || active.id === over.id || !page) {
881
942
  setActiveId(null);
882
943
  return;
883
944
  }
945
+ if (!requireDraft()) {
946
+ setActiveId(null);
947
+ return;
948
+ }
884
949
  const oldIndex = pageBlocks.findIndex((block) => String(block.id) === active.id);
885
950
  const newIndex = pageBlocks.findIndex((block_0) => String(block_0.id) === over.id);
886
951
  if (oldIndex === -1 || newIndex === -1) {
@@ -905,73 +970,74 @@ const PageTree = () => {
905
970
  };
906
971
  $[4] = page;
907
972
  $[5] = pageBlocks;
908
- $[6] = updatePosition;
909
- $[7] = t3;
910
- } else t3 = $[7];
973
+ $[6] = requireDraft;
974
+ $[7] = updatePosition;
975
+ $[8] = t3;
976
+ } else t3 = $[8];
911
977
  const handleDragEnd = t3;
912
978
  let t4;
913
- if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
979
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
914
980
  t4 = () => {
915
981
  setActiveId(null);
916
982
  };
917
- $[8] = t4;
918
- } else t4 = $[8];
983
+ $[9] = t4;
984
+ } else t4 = $[9];
919
985
  const handleDragCancel = t4;
920
986
  if (!page) return null;
921
987
  let t5;
922
- if ($[9] !== camoxApp || $[10] !== page.layout) {
988
+ if ($[10] !== camoxApp || $[11] !== page.layout) {
923
989
  t5 = page.layout ? camoxApp.getLayoutById(page.layout.layoutId) : void 0;
924
- $[9] = camoxApp;
925
- $[10] = page.layout;
926
- $[11] = t5;
927
- } else t5 = $[11];
990
+ $[10] = camoxApp;
991
+ $[11] = page.layout;
992
+ $[12] = t5;
993
+ } else t5 = $[12];
928
994
  const layout = t5;
929
995
  let t6;
930
- if ($[12] !== layout?._internal || $[13] !== layoutBeforeBlocks) {
996
+ if ($[13] !== layout?._internal || $[14] !== layoutBeforeBlocks) {
931
997
  let t7;
932
- if ($[15] !== layout?._internal) {
998
+ if ($[16] !== layout?._internal) {
933
999
  t7 = (block_1) => /* @__PURE__ */ jsx(LayoutBlockItem, {
934
1000
  block: block_1,
935
1001
  layoutName: layout?._internal.title ?? "Unknown"
936
1002
  }, String(block_1.id));
937
- $[15] = layout?._internal;
938
- $[16] = t7;
939
- } else t7 = $[16];
1003
+ $[16] = layout?._internal;
1004
+ $[17] = t7;
1005
+ } else t7 = $[17];
940
1006
  t6 = layoutBeforeBlocks.map(t7);
941
- $[12] = layout?._internal;
942
- $[13] = layoutBeforeBlocks;
943
- $[14] = t6;
944
- } else t6 = $[14];
1007
+ $[13] = layout?._internal;
1008
+ $[14] = layoutBeforeBlocks;
1009
+ $[15] = t6;
1010
+ } else t6 = $[15];
945
1011
  let t7;
946
- if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
1012
+ if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
947
1013
  t7 = [restrictToVerticalAxis];
948
- $[17] = t7;
949
- } else t7 = $[17];
1014
+ $[18] = t7;
1015
+ } else t7 = $[18];
950
1016
  let t8;
951
- if ($[18] !== pageBlocks) {
952
- t8 = pageBlocks.map(_temp8);
953
- $[18] = pageBlocks;
954
- $[19] = t8;
955
- } else t8 = $[19];
1017
+ if ($[19] !== pageBlocks) {
1018
+ t8 = pageBlocks.map(_temp9);
1019
+ $[19] = pageBlocks;
1020
+ $[20] = t8;
1021
+ } else t8 = $[20];
956
1022
  let t9;
957
- if ($[20] !== pageBlocks) {
958
- t9 = pageBlocks.map(_temp9);
959
- $[20] = pageBlocks;
960
- $[21] = t9;
961
- } else t9 = $[21];
1023
+ if ($[21] !== pageBlocks) {
1024
+ t9 = pageBlocks.map(_temp0);
1025
+ $[21] = pageBlocks;
1026
+ $[22] = t9;
1027
+ } else t9 = $[22];
962
1028
  let t10;
963
- if ($[22] !== t8 || $[23] !== t9) {
1029
+ if ($[23] !== t8 || $[24] !== t9) {
964
1030
  t10 = /* @__PURE__ */ jsx(SortableContext, {
965
1031
  items: t8,
966
1032
  strategy: verticalListSortingStrategy,
967
1033
  children: t9
968
1034
  });
969
- $[22] = t8;
970
- $[23] = t9;
971
- $[24] = t10;
972
- } else t10 = $[24];
1035
+ $[23] = t8;
1036
+ $[24] = t9;
1037
+ $[25] = t10;
1038
+ } else t10 = $[25];
973
1039
  let t11;
974
- if ($[25] !== activeId || $[26] !== pageBlocks) {
1040
+ if ($[26] !== activeId || $[27] !== pageBlocks) {
975
1041
  t11 = activeId ? (() => {
976
1042
  const activeBlock = pageBlocks.find((b) => String(b.id) === activeId);
977
1043
  if (!activeBlock) return null;
@@ -986,21 +1052,21 @@ const PageTree = () => {
986
1052
  })
987
1053
  });
988
1054
  })() : null;
989
- $[25] = activeId;
990
- $[26] = pageBlocks;
991
- $[27] = t11;
992
- } else t11 = $[27];
1055
+ $[26] = activeId;
1056
+ $[27] = pageBlocks;
1057
+ $[28] = t11;
1058
+ } else t11 = $[28];
993
1059
  let t12;
994
- if ($[28] !== t11) {
1060
+ if ($[29] !== t11) {
995
1061
  t12 = /* @__PURE__ */ jsx(DragOverlay, {
996
1062
  dropAnimation: null,
997
1063
  children: t11
998
1064
  });
999
- $[28] = t11;
1000
- $[29] = t12;
1001
- } else t12 = $[29];
1065
+ $[29] = t11;
1066
+ $[30] = t12;
1067
+ } else t12 = $[30];
1002
1068
  let t13;
1003
- if ($[30] !== handleDragEnd || $[31] !== sensors || $[32] !== t10 || $[33] !== t12) {
1069
+ if ($[31] !== handleDragEnd || $[32] !== sensors || $[33] !== t10 || $[34] !== t12) {
1004
1070
  t13 = /* @__PURE__ */ jsxs(DndContext, {
1005
1071
  sensors,
1006
1072
  collisionDetection: closestCenter,
@@ -1010,30 +1076,30 @@ const PageTree = () => {
1010
1076
  modifiers: t7,
1011
1077
  children: [t10, t12]
1012
1078
  });
1013
- $[30] = handleDragEnd;
1014
- $[31] = sensors;
1015
- $[32] = t10;
1016
- $[33] = t12;
1017
- $[34] = t13;
1018
- } else t13 = $[34];
1079
+ $[31] = handleDragEnd;
1080
+ $[32] = sensors;
1081
+ $[33] = t10;
1082
+ $[34] = t12;
1083
+ $[35] = t13;
1084
+ } else t13 = $[35];
1019
1085
  let t14;
1020
- if ($[35] !== layout?._internal || $[36] !== layoutAfterBlocks) {
1086
+ if ($[36] !== layout?._internal || $[37] !== layoutAfterBlocks) {
1021
1087
  let t15;
1022
- if ($[38] !== layout?._internal) {
1088
+ if ($[39] !== layout?._internal) {
1023
1089
  t15 = (block_4) => /* @__PURE__ */ jsx(LayoutBlockItem, {
1024
1090
  block: block_4,
1025
1091
  layoutName: layout?._internal.title ?? "Unknown"
1026
1092
  }, String(block_4.id));
1027
- $[38] = layout?._internal;
1028
- $[39] = t15;
1029
- } else t15 = $[39];
1093
+ $[39] = layout?._internal;
1094
+ $[40] = t15;
1095
+ } else t15 = $[40];
1030
1096
  t14 = layoutAfterBlocks.map(t15);
1031
- $[35] = layout?._internal;
1032
- $[36] = layoutAfterBlocks;
1033
- $[37] = t14;
1034
- } else t14 = $[37];
1097
+ $[36] = layout?._internal;
1098
+ $[37] = layoutAfterBlocks;
1099
+ $[38] = t14;
1100
+ } else t14 = $[38];
1035
1101
  let t15;
1036
- if ($[40] !== t13 || $[41] !== t14 || $[42] !== t6) {
1102
+ if ($[41] !== t13 || $[42] !== t14 || $[43] !== t6) {
1037
1103
  t15 = /* @__PURE__ */ jsxs("div", {
1038
1104
  className: "flex flex-col gap-0.5",
1039
1105
  children: [
@@ -1042,49 +1108,74 @@ const PageTree = () => {
1042
1108
  t14
1043
1109
  ]
1044
1110
  });
1045
- $[40] = t13;
1046
- $[41] = t14;
1047
- $[42] = t6;
1048
- $[43] = t15;
1049
- } else t15 = $[43];
1050
- let t16;
1051
- if ($[44] === Symbol.for("react.memo_cache_sentinel")) {
1052
- t16 = /* @__PURE__ */ jsxs(Button, {
1053
- variant: "secondary",
1054
- onClick: _temp0,
1055
- children: [/* @__PURE__ */ jsx(Plus, {}), "Add block"]
1056
- });
1057
- $[44] = t16;
1058
- } else t16 = $[44];
1111
+ $[41] = t13;
1112
+ $[42] = t14;
1113
+ $[43] = t6;
1114
+ $[44] = t15;
1115
+ } else t15 = $[44];
1116
+ const t16 = isReadOnly && "opacity-50 cursor-not-allowed";
1059
1117
  let t17;
1060
- if ($[45] !== t15) {
1061
- t17 = /* @__PURE__ */ jsxs(Fragment, { children: [t15, t16] });
1062
- $[45] = t15;
1118
+ if ($[45] !== t16) {
1119
+ t17 = cn(t16);
1120
+ $[45] = t16;
1063
1121
  $[46] = t17;
1064
1122
  } else t17 = $[46];
1065
- return t17;
1123
+ let t18;
1124
+ if ($[47] !== requireDraft) {
1125
+ t18 = () => {
1126
+ if (!requireDraft()) return;
1127
+ previewStore.send({
1128
+ type: "openAddBlockSheet",
1129
+ via: "page-tree"
1130
+ });
1131
+ };
1132
+ $[47] = requireDraft;
1133
+ $[48] = t18;
1134
+ } else t18 = $[48];
1135
+ let t19;
1136
+ if ($[49] === Symbol.for("react.memo_cache_sentinel")) {
1137
+ t19 = /* @__PURE__ */ jsx(Plus, {});
1138
+ $[49] = t19;
1139
+ } else t19 = $[49];
1140
+ let t20;
1141
+ if ($[50] !== t17 || $[51] !== t18) {
1142
+ t20 = /* @__PURE__ */ jsxs(Button, {
1143
+ variant: "secondary",
1144
+ className: t17,
1145
+ onClick: t18,
1146
+ children: [t19, "Add block"]
1147
+ });
1148
+ $[50] = t17;
1149
+ $[51] = t18;
1150
+ $[52] = t20;
1151
+ } else t20 = $[52];
1152
+ let t21;
1153
+ if ($[53] !== t15 || $[54] !== t20) {
1154
+ t21 = /* @__PURE__ */ jsxs(Fragment, { children: [t15, t20] });
1155
+ $[53] = t15;
1156
+ $[54] = t20;
1157
+ $[55] = t21;
1158
+ } else t21 = $[55];
1159
+ return t21;
1066
1160
  };
1067
- function _temp3(state) {
1161
+ function _temp(state) {
1162
+ return state.context.previewSource;
1163
+ }
1164
+ function _temp4(state) {
1068
1165
  return state.context.selection;
1069
1166
  }
1070
- function _temp4(state_0) {
1167
+ function _temp5(state_0) {
1071
1168
  return state_0.context.iframeElement;
1072
1169
  }
1073
- function _temp5(i) {
1170
+ function _temp6(i) {
1074
1171
  return [i.id, i];
1075
1172
  }
1076
- function _temp8(block_2) {
1173
+ function _temp9(block_2) {
1077
1174
  return String(block_2.id);
1078
1175
  }
1079
- function _temp9(block_3) {
1176
+ function _temp0(block_3) {
1080
1177
  return /* @__PURE__ */ jsx(SortableBlock, { block: block_3 }, String(block_3.id));
1081
1178
  }
1082
- function _temp0() {
1083
- return previewStore.send({
1084
- type: "openAddBlockSheet",
1085
- via: "page-tree"
1086
- });
1087
- }
1088
1179
 
1089
1180
  //#endregion
1090
1181
  export { PageTree };