camox 0.3.0 → 0.4.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 (76) hide show
  1. package/dist/components/AuthGate.js +2 -1
  2. package/dist/core/components/AddBlockControlBar.js +117 -44
  3. package/dist/core/components/lexical/InlineContentEditable.js +37 -17
  4. package/dist/core/components/lexical/InlineLexicalEditor.js +84 -25
  5. package/dist/core/components/lexical/SelectionBroadcaster.js +84 -47
  6. package/dist/core/components/lexical/SidebarLexicalEditor.js +54 -19
  7. package/dist/core/createBlock.js +1172 -414
  8. package/dist/core/createLayout.js +48 -16
  9. package/dist/core/hooks/useFieldSelection.js +24 -13
  10. package/dist/core/hooks/useIsEditable.js +8 -2
  11. package/dist/core/hooks/useOverlayMessage.js +51 -20
  12. package/dist/features/content/CamoxContent.js +239 -107
  13. package/dist/features/content/components/AssetCard.js +78 -16
  14. package/dist/features/content/components/AssetCardSkeleton.js +11 -4
  15. package/dist/features/content/components/ContentSidebar.js +15 -8
  16. package/dist/features/content/components/UploadDropZone.js +77 -34
  17. package/dist/features/content/components/UploadProgressDrawer.js +201 -58
  18. package/dist/features/metadata/sitemap.js +15 -0
  19. package/dist/features/preview/CamoxPreview.js +447 -179
  20. package/dist/features/preview/components/AddBlockSheet.js +344 -167
  21. package/dist/features/preview/components/AgentChatSheet.js +32 -10
  22. package/dist/features/preview/components/AssetFieldEditor.js +185 -50
  23. package/dist/features/preview/components/AssetLightbox.js +60 -33
  24. package/dist/features/preview/components/AssetPickerGrid.js +203 -71
  25. package/dist/features/preview/components/BlockActionsPopover.js +295 -218
  26. package/dist/features/preview/components/CreatePageSheet.js +3 -3
  27. package/dist/features/preview/components/DebouncedFieldEditor.js +80 -23
  28. package/dist/features/preview/components/EditPageSheet.js +241 -86
  29. package/dist/features/preview/components/ItemFieldsEditor.js +209 -115
  30. package/dist/features/preview/components/LinkFieldEditor.js +351 -153
  31. package/dist/features/preview/components/MultipleAssetFieldEditor.js +245 -92
  32. package/dist/features/preview/components/OverlayTracker.js +58 -23
  33. package/dist/features/preview/components/Overlays.js +85 -43
  34. package/dist/features/preview/components/PageContentSheet.js +18 -18
  35. package/dist/features/preview/components/PageLocationFieldset.js +229 -63
  36. package/dist/features/preview/components/PagePicker.js +27 -27
  37. package/dist/features/preview/components/PageTree.js +921 -319
  38. package/dist/features/preview/components/PeekedBlock.js +173 -63
  39. package/dist/features/preview/components/PreviewPanel.js +271 -148
  40. package/dist/features/preview/components/PreviewSideSheet.js +44 -11
  41. package/dist/features/preview/components/PreviewToolbar.js +262 -59
  42. package/dist/features/preview/components/RepeatableItemsList.js +187 -78
  43. package/dist/features/preview/components/ShikiMarkdown.js +46 -20
  44. package/dist/features/preview/components/TextFormatToolbar.js +81 -23
  45. package/dist/features/preview/components/UnlinkAssetButton.js +161 -40
  46. package/dist/features/preview/components/useUpdateBlockPosition.js +64 -47
  47. package/dist/features/preview/previewStore.d.ts +2 -2
  48. package/dist/features/provider/CamoxProvider.js +69 -21
  49. package/dist/features/provider/actionsStore.d.ts +2 -2
  50. package/dist/features/provider/components/CamoxAppContext.js +15 -5
  51. package/dist/features/provider/components/CommandPalette.js +199 -92
  52. package/dist/features/provider/useAdminShortcuts.js +80 -64
  53. package/dist/features/routes/pageRoute.js +8 -1
  54. package/dist/features/studio/CamoxStudio.js +45 -9
  55. package/dist/features/studio/components/EnvironmentMenu.js +47 -12
  56. package/dist/features/studio/components/Navbar.js +163 -65
  57. package/dist/features/studio/components/ProjectMenu.d.ts.map +1 -1
  58. package/dist/features/studio/components/ProjectMenu.js +284 -83
  59. package/dist/features/studio/components/UserButton.js +21 -6
  60. package/dist/features/studio/studioStore.d.ts +2 -2
  61. package/dist/features/studio/useTheme.js +128 -74
  62. package/dist/features/vite/definitionsSync.d.ts +7 -12
  63. package/dist/features/vite/definitionsSync.d.ts.map +1 -1
  64. package/dist/features/vite/definitionsSync.js +5 -16
  65. package/dist/features/vite/vite.d.ts +0 -3
  66. package/dist/features/vite/vite.d.ts.map +1 -1
  67. package/dist/features/vite/vite.js +1 -2
  68. package/dist/hooks/use-file-upload.js +11 -11
  69. package/dist/hooks/use-marquee-selection.js +121 -74
  70. package/dist/lib/auth.js +95 -51
  71. package/dist/lib/normalized-data.js +103 -30
  72. package/dist/lib/use-project-room.js +55 -22
  73. package/dist/studio.css +2 -2
  74. package/package.json +29 -26
  75. package/dist/lib/auth.d.ts +0 -2130
  76. package/dist/lib/auth.d.ts.map +0 -1
@@ -7,6 +7,7 @@ import { useCamoxApp } from "../../provider/components/CamoxAppContext.js";
7
7
  import { trackClientEvent } from "../../../lib/analytics-client.js";
8
8
  import { useUpdateBlockPosition } from "./useUpdateBlockPosition.js";
9
9
  import { usePreviewedPage } from "../CamoxPreview.js";
10
+ import { c } from "react/compiler-runtime";
10
11
  import { Popover, PopoverContent, PopoverTrigger } from "@camox/ui/popover";
11
12
  import { toast } from "@camox/ui/toaster";
12
13
  import { useMutation } from "@tanstack/react-query";
@@ -26,14 +27,14 @@ var BlockActionsPopover = ({ block, children, open, onOpenChange, align = "start
26
27
  const deleteBlock = useMutation(blockMutations.delete());
27
28
  const duplicateBlock = useMutation(blockMutations.duplicate());
28
29
  const deleteManyBlocks = useMutation(blockMutations.deleteMany());
29
- const handleDeleteBlock = async (block) => {
30
+ const handleDeleteBlock = async (block_0) => {
30
31
  try {
31
- await deleteBlock.mutateAsync({ id: block.id });
32
+ await deleteBlock.mutateAsync({ id: block_0.id });
32
33
  trackClientEvent("block_deleted", {
33
34
  projectId: page?.page.projectId,
34
- blockType: block.type
35
+ blockType: block_0.type
35
36
  });
36
- toast.success(`Deleted "${block.summary || block.type}" block`);
37
+ toast.success(`Deleted "${block_0.summary || block_0.type}" block`);
37
38
  } catch (error) {
38
39
  console.error("Failed to delete block:", error);
39
40
  toast.error("Could not delete block");
@@ -41,63 +42,63 @@ var BlockActionsPopover = ({ block, children, open, onOpenChange, align = "start
41
42
  setBlockToDelete(null);
42
43
  }
43
44
  };
44
- const handleDuplicateBlock = async (block) => {
45
+ const handleDuplicateBlock = async (block_1) => {
45
46
  try {
46
- await duplicateBlock.mutateAsync({ id: block.id });
47
+ await duplicateBlock.mutateAsync({ id: block_1.id });
47
48
  trackClientEvent("block_duplicated", {
48
49
  projectId: page?.page.projectId,
49
- blockType: block.type
50
+ blockType: block_1.type
50
51
  });
51
- toast.success(`Duplicated "${block.summary}" block`);
52
- } catch (error) {
53
- console.error("Failed to duplicate block:", error);
52
+ toast.success(`Duplicated "${block_1.summary}" block`);
53
+ } catch (error_0) {
54
+ console.error("Failed to duplicate block:", error_0);
54
55
  toast.error("Could not duplicate block");
55
56
  }
56
57
  };
57
- const handleAddBlockAbove = (block) => {
58
+ const handleAddBlockAbove = (block_2) => {
58
59
  if (!page) return;
59
- const blockIndex = pageBlocks.findIndex((b) => String(b.id) === String(block.id));
60
+ const blockIndex = pageBlocks.findIndex((b) => String(b.id) === String(block_2.id));
60
61
  const afterPosition = blockIndex > 0 ? pageBlocks[blockIndex - 1].position : "";
61
62
  previewStore.send({
62
63
  type: "openAddBlockSheet",
63
64
  afterPosition
64
65
  });
65
66
  };
66
- const handleAddBlockBelow = (block) => {
67
+ const handleAddBlockBelow = (block_3) => {
67
68
  previewStore.send({
68
69
  type: "openAddBlockSheet",
69
- afterPosition: block.position
70
+ afterPosition: block_3.position
70
71
  });
71
72
  };
72
- const getBlocksAbove = (block) => {
73
+ const getBlocksAbove = (block_4) => {
73
74
  if (!page) return [];
74
- const blockIndex = pageBlocks.findIndex((b) => String(b.id) === String(block.id));
75
- return pageBlocks.slice(0, blockIndex);
75
+ const blockIndex_0 = pageBlocks.findIndex((b_0) => String(b_0.id) === String(block_4.id));
76
+ return pageBlocks.slice(0, blockIndex_0);
76
77
  };
77
- const getBlocksBelow = (block) => {
78
+ const getBlocksBelow = (block_5) => {
78
79
  if (!page) return [];
79
- const blockIndex = pageBlocks.findIndex((b) => String(b.id) === String(block.id));
80
- return pageBlocks.slice(blockIndex + 1);
80
+ const blockIndex_1 = pageBlocks.findIndex((b_1) => String(b_1.id) === String(block_5.id));
81
+ return pageBlocks.slice(blockIndex_1 + 1);
81
82
  };
82
- const handleDeleteBlocksAbove = async (block) => {
83
- const blocksAbove = getBlocksAbove(block);
83
+ const handleDeleteBlocksAbove = async (block_6) => {
84
+ const blocksAbove = getBlocksAbove(block_6);
84
85
  if (blocksAbove.length === 0) return;
85
86
  try {
86
- await deleteManyBlocks.mutateAsync({ blockIds: blocksAbove.map((b) => b.id) });
87
+ await deleteManyBlocks.mutateAsync({ blockIds: blocksAbove.map((b_2) => b_2.id) });
87
88
  toast.success(`Deleted ${blocksAbove.length} block${blocksAbove.length === 1 ? "" : "s"}`);
88
- } catch (error) {
89
- console.error("Failed to delete blocks above:", error);
89
+ } catch (error_1) {
90
+ console.error("Failed to delete blocks above:", error_1);
90
91
  toast.error("Could not delete blocks");
91
92
  }
92
93
  };
93
- const handleDeleteBlocksBelow = async (block) => {
94
- const blocksBelow = getBlocksBelow(block);
94
+ const handleDeleteBlocksBelow = async (block_7) => {
95
+ const blocksBelow = getBlocksBelow(block_7);
95
96
  if (blocksBelow.length === 0) return;
96
97
  try {
97
- await deleteManyBlocks.mutateAsync({ blockIds: blocksBelow.map((b) => b.id) });
98
+ await deleteManyBlocks.mutateAsync({ blockIds: blocksBelow.map((b_3) => b_3.id) });
98
99
  toast.success(`Deleted ${blocksBelow.length} block${blocksBelow.length === 1 ? "" : "s"}`);
99
- } catch (error) {
100
- console.error("Failed to delete blocks below:", error);
100
+ } catch (error_2) {
101
+ console.error("Failed to delete blocks below:", error_2);
101
102
  toast.error("Could not delete blocks");
102
103
  }
103
104
  };
@@ -254,7 +255,7 @@ var BlockActionsPopover = ({ block, children, open, onOpenChange, align = "start
254
255
  })]
255
256
  }), /* @__PURE__ */ jsx(AlertDialog, {
256
257
  open: !!blockToDelete,
257
- onOpenChange: (open) => !open && setBlockToDelete(null),
258
+ onOpenChange: (open_0) => !open_0 && setBlockToDelete(null),
258
259
  children: /* @__PURE__ */ jsxs(AlertDialogContent, { children: [/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: "Delete block" }), /* @__PURE__ */ jsxs(AlertDialogDescription, { children: [
259
260
  "Are you sure you want to delete ",
260
261
  /* @__PURE__ */ jsx("strong", { children: blockToDelete?.summary }),
@@ -274,210 +275,286 @@ function isLayoutBlockId(page, blockId) {
274
275
  return new Set([...page.layout.beforeBlockIds, ...page.layout.afterBlockIds]).has(Number(blockId));
275
276
  }
276
277
  function useBlockActionsShortcuts() {
278
+ const $ = c(17);
277
279
  const camoxApp = useCamoxApp();
278
280
  const page = usePreviewedPage();
279
281
  const { pageBlocks } = usePageBlocks(page);
280
- const selection = useSelector(previewStore, (state) => state.context.selection);
281
- const deleteBlockMutation = useMutation(blockMutations.delete());
282
- const duplicateBlockMutation = useMutation(blockMutations.duplicate());
282
+ const selection = useSelector(previewStore, _temp);
283
+ let t0;
284
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
285
+ t0 = blockMutations.delete();
286
+ $[0] = t0;
287
+ } else t0 = $[0];
288
+ const deleteBlockMutation = useMutation(t0);
289
+ let t1;
290
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
291
+ t1 = blockMutations.duplicate();
292
+ $[1] = t1;
293
+ } else t1 = $[1];
294
+ const duplicateBlockMutation = useMutation(t1);
283
295
  const updatePositionMutation = useUpdateBlockPosition();
284
- const deleteRepeatableItem = useMutation(repeatableItemMutations.delete());
285
- const duplicateRepeatableItem = useMutation(repeatableItemMutations.duplicate());
286
- React.useEffect(() => {
287
- const actions = [
288
- {
289
- id: "delete-selected",
290
- label: "Delete selected",
291
- groupLabel: "Preview",
292
- shortcut: {
293
- key: "Backspace",
294
- withMeta: true
295
- },
296
- checkIfAvailable: () => {
297
- const ctx = previewStore.getSnapshot().context;
298
- if (ctx.isContentLocked || ctx.isPresentationMode) return false;
299
- const sel = ctx.selection;
300
- if (!sel) return false;
301
- if (isLayoutBlockId(page, sel.blockId)) return false;
302
- const itemId = selectionItemId(sel);
303
- if (itemId) {
304
- if (!page) return false;
305
- const block = pageBlocks.find((b) => String(b.id) === sel.blockId);
306
- if (!block) return false;
307
- for (const [, value] of Object.entries(block.content)) {
308
- if (!Array.isArray(value)) continue;
309
- if (value.some((i) => i?._itemId != null && String(i._itemId) === itemId)) return value.length > 1;
296
+ let t2;
297
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
298
+ t2 = repeatableItemMutations.delete();
299
+ $[2] = t2;
300
+ } else t2 = $[2];
301
+ const deleteRepeatableItem = useMutation(t2);
302
+ let t3;
303
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
304
+ t3 = repeatableItemMutations.duplicate();
305
+ $[3] = t3;
306
+ } else t3 = $[3];
307
+ const duplicateRepeatableItem = useMutation(t3);
308
+ let t4;
309
+ if ($[4] !== deleteBlockMutation || $[5] !== deleteRepeatableItem || $[6] !== duplicateBlockMutation || $[7] !== duplicateRepeatableItem || $[8] !== page || $[9] !== pageBlocks || $[10] !== updatePositionMutation) {
310
+ t4 = () => {
311
+ const actions = [
312
+ {
313
+ id: "delete-selected",
314
+ label: "Delete selected",
315
+ groupLabel: "Preview",
316
+ shortcut: {
317
+ key: "Backspace",
318
+ withMeta: true
319
+ },
320
+ checkIfAvailable: () => {
321
+ const ctx = previewStore.getSnapshot().context;
322
+ if (ctx.isContentLocked || ctx.isPresentationMode) return false;
323
+ const sel = ctx.selection;
324
+ if (!sel) return false;
325
+ if (isLayoutBlockId(page, sel.blockId)) return false;
326
+ const itemId = selectionItemId(sel);
327
+ if (itemId) {
328
+ if (!page) return false;
329
+ const block = pageBlocks.find((b) => String(b.id) === sel.blockId);
330
+ if (!block) return false;
331
+ for (const [, value] of Object.entries(block.content)) {
332
+ if (!Array.isArray(value)) continue;
333
+ if (value.some((i) => i?._itemId != null && String(i._itemId) === itemId)) return value.length > 1;
334
+ }
335
+ return false;
336
+ }
337
+ return pageBlocks.length > 1;
338
+ },
339
+ execute: () => {
340
+ const sel_0 = previewStore.getSnapshot().context.selection;
341
+ if (!sel_0) return;
342
+ const itemId_0 = selectionItemId(sel_0);
343
+ if (itemId_0) {
344
+ deleteRepeatableItem.mutateAsync({ id: Number(itemId_0) }).then(_temp2, _temp3);
345
+ previewStore.send({ type: "selectParent" });
346
+ return;
310
347
  }
311
- return false;
348
+ const block_0 = pageBlocks.find((b_0) => String(b_0.id) === sel_0.blockId);
349
+ deleteBlockMutation.mutateAsync({ id: Number(sel_0.blockId) }).then(() => toast.success(`Deleted "${block_0?.summary || block_0?.type}" block`), _temp4);
350
+ previewStore.send({ type: "clearSelection" });
312
351
  }
313
- return pageBlocks.length > 1;
314
352
  },
315
- execute: () => {
316
- const sel = previewStore.getSnapshot().context.selection;
317
- if (!sel) return;
318
- const itemId = selectionItemId(sel);
319
- if (itemId) {
320
- deleteRepeatableItem.mutateAsync({ id: Number(itemId) }).then(() => toast.success("Deleted item"), () => toast.error("Could not delete item"));
321
- previewStore.send({ type: "selectParent" });
322
- return;
353
+ {
354
+ id: "duplicate-selected",
355
+ label: "Duplicate selected",
356
+ groupLabel: "Preview",
357
+ shortcut: {
358
+ key: "d",
359
+ withMeta: true
360
+ },
361
+ checkIfAvailable: () => {
362
+ const ctx_0 = previewStore.getSnapshot().context;
363
+ if (ctx_0.isContentLocked || ctx_0.isPresentationMode) return false;
364
+ const sel_1 = ctx_0.selection;
365
+ if (!sel_1) return false;
366
+ if (isLayoutBlockId(page, sel_1.blockId)) return false;
367
+ return true;
368
+ },
369
+ execute: () => {
370
+ const sel_2 = previewStore.getSnapshot().context.selection;
371
+ if (!sel_2) return;
372
+ const itemId_1 = selectionItemId(sel_2);
373
+ if (itemId_1) {
374
+ duplicateRepeatableItem.mutateAsync({ id: Number(itemId_1) }).then(_temp5, _temp6);
375
+ return;
376
+ }
377
+ const block_1 = pageBlocks.find((b_1) => String(b_1.id) === sel_2.blockId);
378
+ duplicateBlockMutation.mutateAsync({ id: Number(sel_2.blockId) }).then(() => toast.success(`Duplicated "${block_1?.summary}" block`), _temp7);
323
379
  }
324
- const block = pageBlocks.find((b) => String(b.id) === sel.blockId);
325
- deleteBlockMutation.mutateAsync({ id: Number(sel.blockId) }).then(() => toast.success(`Deleted "${block?.summary || block?.type}" block`), () => toast.error("Could not delete block"));
326
- previewStore.send({ type: "clearSelection" });
327
- }
328
- },
329
- {
330
- id: "duplicate-selected",
331
- label: "Duplicate selected",
332
- groupLabel: "Preview",
333
- shortcut: {
334
- key: "d",
335
- withMeta: true
336
380
  },
337
- checkIfAvailable: () => {
338
- const ctx = previewStore.getSnapshot().context;
339
- if (ctx.isContentLocked || ctx.isPresentationMode) return false;
340
- const sel = ctx.selection;
341
- if (!sel) return false;
342
- if (isLayoutBlockId(page, sel.blockId)) return false;
343
- return true;
344
- },
345
- execute: () => {
346
- const sel = previewStore.getSnapshot().context.selection;
347
- if (!sel) return;
348
- const itemId = selectionItemId(sel);
349
- if (itemId) {
350
- duplicateRepeatableItem.mutateAsync({ id: Number(itemId) }).then(() => toast.success("Duplicated item"), () => toast.error("Could not duplicate item"));
351
- return;
381
+ {
382
+ id: "move-block-up",
383
+ label: "Move block up",
384
+ groupLabel: "Preview",
385
+ shortcut: {
386
+ key: "ArrowUp",
387
+ withAlt: true
388
+ },
389
+ checkIfAvailable: () => {
390
+ const ctx_1 = previewStore.getSnapshot().context;
391
+ if (ctx_1.isContentLocked || ctx_1.isPresentationMode) return false;
392
+ const sel_3 = ctx_1.selection;
393
+ if (!sel_3 || !page) return false;
394
+ if (isLayoutBlockId(page, sel_3.blockId)) return false;
395
+ return pageBlocks.findIndex((b_2) => String(b_2.id) === sel_3.blockId) > 0;
396
+ },
397
+ execute: () => {
398
+ const sel_4 = previewStore.getSnapshot().context.selection;
399
+ if (!sel_4 || !page) return;
400
+ const index_0 = pageBlocks.findIndex((b_3) => String(b_3.id) === sel_4.blockId);
401
+ if (index_0 <= 0) return;
402
+ const afterPosition = index_0 > 1 ? pageBlocks[index_0 - 2].position : void 0;
403
+ const beforePosition = pageBlocks[index_0 - 1].position;
404
+ updatePositionMutation.mutateAsync({
405
+ id: Number(sel_4.blockId),
406
+ afterPosition,
407
+ beforePosition
408
+ }).then(_temp8, _temp9);
352
409
  }
353
- const block = pageBlocks.find((b) => String(b.id) === sel.blockId);
354
- duplicateBlockMutation.mutateAsync({ id: Number(sel.blockId) }).then(() => toast.success(`Duplicated "${block?.summary}" block`), () => toast.error("Could not duplicate block"));
355
- }
356
- },
357
- {
358
- id: "move-block-up",
359
- label: "Move block up",
360
- groupLabel: "Preview",
361
- shortcut: {
362
- key: "ArrowUp",
363
- withAlt: true
364
410
  },
365
- checkIfAvailable: () => {
366
- const ctx = previewStore.getSnapshot().context;
367
- if (ctx.isContentLocked || ctx.isPresentationMode) return false;
368
- const sel = ctx.selection;
369
- if (!sel || !page) return false;
370
- if (isLayoutBlockId(page, sel.blockId)) return false;
371
- return pageBlocks.findIndex((b) => String(b.id) === sel.blockId) > 0;
372
- },
373
- execute: () => {
374
- const sel = previewStore.getSnapshot().context.selection;
375
- if (!sel || !page) return;
376
- const index = pageBlocks.findIndex((b) => String(b.id) === sel.blockId);
377
- if (index <= 0) return;
378
- const afterPosition = index > 1 ? pageBlocks[index - 2].position : void 0;
379
- const beforePosition = pageBlocks[index - 1].position;
380
- updatePositionMutation.mutateAsync({
381
- id: Number(sel.blockId),
382
- afterPosition,
383
- beforePosition
384
- }).then(() => {}, () => toast.error("Could not move block"));
385
- }
386
- },
387
- {
388
- id: "move-block-down",
389
- label: "Move block down",
390
- groupLabel: "Preview",
391
- shortcut: {
392
- key: "ArrowDown",
393
- withAlt: true
394
- },
395
- checkIfAvailable: () => {
396
- const ctx = previewStore.getSnapshot().context;
397
- if (ctx.isContentLocked || ctx.isPresentationMode) return false;
398
- const sel = ctx.selection;
399
- if (!sel || !page) return false;
400
- if (isLayoutBlockId(page, sel.blockId)) return false;
401
- const index = pageBlocks.findIndex((b) => String(b.id) === sel.blockId);
402
- return index !== -1 && index < pageBlocks.length - 1;
403
- },
404
- execute: () => {
405
- const sel = previewStore.getSnapshot().context.selection;
406
- if (!sel || !page) return;
407
- const index = pageBlocks.findIndex((b) => String(b.id) === sel.blockId);
408
- if (index === -1 || index >= pageBlocks.length - 1) return;
409
- const afterPosition = pageBlocks[index + 1].position;
410
- const beforePosition = index + 2 < pageBlocks.length ? pageBlocks[index + 2].position : void 0;
411
- updatePositionMutation.mutateAsync({
412
- id: Number(sel.blockId),
413
- afterPosition,
414
- beforePosition
415
- }).then(() => {}, () => toast.error("Could not move block"));
416
- }
417
- },
418
- {
419
- id: "add-block-below",
420
- label: "Add block below",
421
- groupLabel: "Preview",
422
- shortcut: { key: "o" },
423
- checkIfAvailable: () => {
424
- const ctx = previewStore.getSnapshot().context;
425
- if (ctx.isContentLocked || ctx.isPresentationMode) return false;
426
- return ctx.selection !== null;
427
- },
428
- execute: () => {
429
- const sel = previewStore.getSnapshot().context.selection;
430
- if (!sel || !page) return;
431
- const block = pageBlocks.find((b) => String(b.id) === sel.blockId);
432
- if (!block) return;
433
- previewStore.send({
434
- type: "openAddBlockSheet",
435
- afterPosition: block.position
436
- });
437
- }
438
- },
439
- {
440
- id: "add-block-above",
441
- label: "Add block above",
442
- groupLabel: "Preview",
443
- shortcut: {
444
- key: "o",
445
- withShift: true
411
+ {
412
+ id: "move-block-down",
413
+ label: "Move block down",
414
+ groupLabel: "Preview",
415
+ shortcut: {
416
+ key: "ArrowDown",
417
+ withAlt: true
418
+ },
419
+ checkIfAvailable: () => {
420
+ const ctx_2 = previewStore.getSnapshot().context;
421
+ if (ctx_2.isContentLocked || ctx_2.isPresentationMode) return false;
422
+ const sel_5 = ctx_2.selection;
423
+ if (!sel_5 || !page) return false;
424
+ if (isLayoutBlockId(page, sel_5.blockId)) return false;
425
+ const index_1 = pageBlocks.findIndex((b_4) => String(b_4.id) === sel_5.blockId);
426
+ return index_1 !== -1 && index_1 < pageBlocks.length - 1;
427
+ },
428
+ execute: () => {
429
+ const sel_6 = previewStore.getSnapshot().context.selection;
430
+ if (!sel_6 || !page) return;
431
+ const index_2 = pageBlocks.findIndex((b_5) => String(b_5.id) === sel_6.blockId);
432
+ if (index_2 === -1 || index_2 >= pageBlocks.length - 1) return;
433
+ const afterPosition_0 = pageBlocks[index_2 + 1].position;
434
+ const beforePosition_0 = index_2 + 2 < pageBlocks.length ? pageBlocks[index_2 + 2].position : void 0;
435
+ updatePositionMutation.mutateAsync({
436
+ id: Number(sel_6.blockId),
437
+ afterPosition: afterPosition_0,
438
+ beforePosition: beforePosition_0
439
+ }).then(_temp0, _temp1);
440
+ }
446
441
  },
447
- checkIfAvailable: () => {
448
- const ctx = previewStore.getSnapshot().context;
449
- if (ctx.isContentLocked || ctx.isPresentationMode) return false;
450
- return ctx.selection !== null;
442
+ {
443
+ id: "add-block-below",
444
+ label: "Add block below",
445
+ groupLabel: "Preview",
446
+ shortcut: { key: "o" },
447
+ checkIfAvailable: _temp10,
448
+ execute: () => {
449
+ const sel_7 = previewStore.getSnapshot().context.selection;
450
+ if (!sel_7 || !page) return;
451
+ const block_2 = pageBlocks.find((b_6) => String(b_6.id) === sel_7.blockId);
452
+ if (!block_2) return;
453
+ previewStore.send({
454
+ type: "openAddBlockSheet",
455
+ afterPosition: block_2.position
456
+ });
457
+ }
451
458
  },
452
- execute: () => {
453
- const sel = previewStore.getSnapshot().context.selection;
454
- if (!sel || !page) return;
455
- const blockIndex = pageBlocks.findIndex((b) => String(b.id) === sel.blockId);
456
- if (blockIndex === -1) return;
457
- const afterPosition = blockIndex > 0 ? pageBlocks[blockIndex - 1].position : "";
458
- previewStore.send({
459
- type: "openAddBlockSheet",
460
- afterPosition
461
- });
459
+ {
460
+ id: "add-block-above",
461
+ label: "Add block above",
462
+ groupLabel: "Preview",
463
+ shortcut: {
464
+ key: "o",
465
+ withShift: true
466
+ },
467
+ checkIfAvailable: _temp11,
468
+ execute: () => {
469
+ const sel_8 = previewStore.getSnapshot().context.selection;
470
+ if (!sel_8 || !page) return;
471
+ const blockIndex = pageBlocks.findIndex((b_7) => String(b_7.id) === sel_8.blockId);
472
+ if (blockIndex === -1) return;
473
+ const afterPosition_1 = blockIndex > 0 ? pageBlocks[blockIndex - 1].position : "";
474
+ previewStore.send({
475
+ type: "openAddBlockSheet",
476
+ afterPosition: afterPosition_1
477
+ });
478
+ }
462
479
  }
463
- }
464
- ];
465
- actionsStore.send({
466
- type: "registerManyActions",
467
- actions
468
- });
469
- return () => {
480
+ ];
470
481
  actionsStore.send({
471
- type: "unregisterManyActions",
472
- ids: actions.map((a) => a.id)
482
+ type: "registerManyActions",
483
+ actions
473
484
  });
485
+ return () => {
486
+ actionsStore.send({
487
+ type: "unregisterManyActions",
488
+ ids: actions.map(_temp12)
489
+ });
490
+ };
474
491
  };
475
- }, [
476
- selection,
477
- page,
478
- pageBlocks,
479
- camoxApp
480
- ]);
492
+ $[4] = deleteBlockMutation;
493
+ $[5] = deleteRepeatableItem;
494
+ $[6] = duplicateBlockMutation;
495
+ $[7] = duplicateRepeatableItem;
496
+ $[8] = page;
497
+ $[9] = pageBlocks;
498
+ $[10] = updatePositionMutation;
499
+ $[11] = t4;
500
+ } else t4 = $[11];
501
+ let t5;
502
+ if ($[12] !== camoxApp || $[13] !== page || $[14] !== pageBlocks || $[15] !== selection) {
503
+ t5 = [
504
+ selection,
505
+ page,
506
+ pageBlocks,
507
+ camoxApp
508
+ ];
509
+ $[12] = camoxApp;
510
+ $[13] = page;
511
+ $[14] = pageBlocks;
512
+ $[15] = selection;
513
+ $[16] = t5;
514
+ } else t5 = $[16];
515
+ React.useEffect(t4, t5);
516
+ }
517
+ function _temp12(a) {
518
+ return a.id;
519
+ }
520
+ function _temp11() {
521
+ const ctx_4 = previewStore.getSnapshot().context;
522
+ if (ctx_4.isContentLocked || ctx_4.isPresentationMode) return false;
523
+ return ctx_4.selection !== null;
524
+ }
525
+ function _temp10() {
526
+ const ctx_3 = previewStore.getSnapshot().context;
527
+ if (ctx_3.isContentLocked || ctx_3.isPresentationMode) return false;
528
+ return ctx_3.selection !== null;
529
+ }
530
+ function _temp1() {
531
+ return toast.error("Could not move block");
532
+ }
533
+ function _temp0() {}
534
+ function _temp9() {
535
+ return toast.error("Could not move block");
536
+ }
537
+ function _temp8() {}
538
+ function _temp7() {
539
+ return toast.error("Could not duplicate block");
540
+ }
541
+ function _temp6() {
542
+ return toast.error("Could not duplicate item");
543
+ }
544
+ function _temp5() {
545
+ return toast.success("Duplicated item");
546
+ }
547
+ function _temp4() {
548
+ return toast.error("Could not delete block");
549
+ }
550
+ function _temp3() {
551
+ return toast.error("Could not delete item");
552
+ }
553
+ function _temp2() {
554
+ return toast.success("Deleted item");
555
+ }
556
+ function _temp(state) {
557
+ return state.context.selection;
481
558
  }
482
559
  //#endregion
483
560
  export { BlockActionsPopover, useBlockActionsShortcuts };
@@ -129,7 +129,7 @@ var CreatePageSheet = () => {
129
129
  }),
130
130
  /* @__PURE__ */ jsx(form.Field, {
131
131
  name: "contentDescription",
132
- children: (field) => /* @__PURE__ */ jsxs("div", {
132
+ children: (field_0) => /* @__PURE__ */ jsxs("div", {
133
133
  className: "space-y-2",
134
134
  children: [
135
135
  /* @__PURE__ */ jsx(Label, {
@@ -138,8 +138,8 @@ var CreatePageSheet = () => {
138
138
  }),
139
139
  /* @__PURE__ */ jsx(Textarea, {
140
140
  id: "contentDescription",
141
- value: field.state.value,
142
- onChange: (e) => field.handleChange(e.target.value),
141
+ value: field_0.state.value,
142
+ onChange: (e_0) => field_0.handleChange(e_0.target.value),
143
143
  placeholder: "What your page will be about"
144
144
  }),
145
145
  /* @__PURE__ */ jsx("p", {