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.
- package/dist/components/AuthGate.js +2 -1
- package/dist/core/components/AddBlockControlBar.js +117 -44
- package/dist/core/components/lexical/InlineContentEditable.js +37 -17
- package/dist/core/components/lexical/InlineLexicalEditor.js +84 -25
- package/dist/core/components/lexical/SelectionBroadcaster.js +84 -47
- package/dist/core/components/lexical/SidebarLexicalEditor.js +54 -19
- package/dist/core/createBlock.js +1172 -414
- package/dist/core/createLayout.js +48 -16
- package/dist/core/hooks/useFieldSelection.js +24 -13
- package/dist/core/hooks/useIsEditable.js +8 -2
- package/dist/core/hooks/useOverlayMessage.js +51 -20
- package/dist/features/content/CamoxContent.js +239 -107
- package/dist/features/content/components/AssetCard.js +78 -16
- package/dist/features/content/components/AssetCardSkeleton.js +11 -4
- package/dist/features/content/components/ContentSidebar.js +15 -8
- package/dist/features/content/components/UploadDropZone.js +77 -34
- package/dist/features/content/components/UploadProgressDrawer.js +201 -58
- package/dist/features/metadata/sitemap.js +15 -0
- package/dist/features/preview/CamoxPreview.js +447 -179
- package/dist/features/preview/components/AddBlockSheet.js +344 -167
- package/dist/features/preview/components/AgentChatSheet.js +32 -10
- package/dist/features/preview/components/AssetFieldEditor.js +185 -50
- package/dist/features/preview/components/AssetLightbox.js +60 -33
- package/dist/features/preview/components/AssetPickerGrid.js +203 -71
- package/dist/features/preview/components/BlockActionsPopover.js +295 -218
- package/dist/features/preview/components/CreatePageSheet.js +3 -3
- package/dist/features/preview/components/DebouncedFieldEditor.js +80 -23
- package/dist/features/preview/components/EditPageSheet.js +241 -86
- package/dist/features/preview/components/ItemFieldsEditor.js +209 -115
- package/dist/features/preview/components/LinkFieldEditor.js +351 -153
- package/dist/features/preview/components/MultipleAssetFieldEditor.js +245 -92
- package/dist/features/preview/components/OverlayTracker.js +58 -23
- package/dist/features/preview/components/Overlays.js +85 -43
- package/dist/features/preview/components/PageContentSheet.js +18 -18
- package/dist/features/preview/components/PageLocationFieldset.js +229 -63
- package/dist/features/preview/components/PagePicker.js +27 -27
- package/dist/features/preview/components/PageTree.js +921 -319
- package/dist/features/preview/components/PeekedBlock.js +173 -63
- package/dist/features/preview/components/PreviewPanel.js +271 -148
- package/dist/features/preview/components/PreviewSideSheet.js +44 -11
- package/dist/features/preview/components/PreviewToolbar.js +262 -59
- package/dist/features/preview/components/RepeatableItemsList.js +187 -78
- package/dist/features/preview/components/ShikiMarkdown.js +46 -20
- package/dist/features/preview/components/TextFormatToolbar.js +81 -23
- package/dist/features/preview/components/UnlinkAssetButton.js +161 -40
- package/dist/features/preview/components/useUpdateBlockPosition.js +64 -47
- package/dist/features/preview/previewStore.d.ts +2 -2
- package/dist/features/provider/CamoxProvider.js +69 -21
- package/dist/features/provider/actionsStore.d.ts +2 -2
- package/dist/features/provider/components/CamoxAppContext.js +15 -5
- package/dist/features/provider/components/CommandPalette.js +199 -92
- package/dist/features/provider/useAdminShortcuts.js +80 -64
- package/dist/features/routes/pageRoute.js +8 -1
- package/dist/features/studio/CamoxStudio.js +45 -9
- package/dist/features/studio/components/EnvironmentMenu.js +47 -12
- package/dist/features/studio/components/Navbar.js +163 -65
- package/dist/features/studio/components/ProjectMenu.d.ts.map +1 -1
- package/dist/features/studio/components/ProjectMenu.js +284 -83
- package/dist/features/studio/components/UserButton.js +21 -6
- package/dist/features/studio/studioStore.d.ts +2 -2
- package/dist/features/studio/useTheme.js +128 -74
- package/dist/features/vite/definitionsSync.d.ts +7 -12
- package/dist/features/vite/definitionsSync.d.ts.map +1 -1
- package/dist/features/vite/definitionsSync.js +5 -16
- package/dist/features/vite/vite.d.ts +0 -3
- package/dist/features/vite/vite.d.ts.map +1 -1
- package/dist/features/vite/vite.js +1 -2
- package/dist/hooks/use-file-upload.js +11 -11
- package/dist/hooks/use-marquee-selection.js +121 -74
- package/dist/lib/auth.js +95 -51
- package/dist/lib/normalized-data.js +103 -30
- package/dist/lib/use-project-room.js +55 -22
- package/dist/studio.css +2 -2
- package/package.json +29 -26
- package/dist/lib/auth.d.ts +0 -2130
- 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 (
|
|
30
|
+
const handleDeleteBlock = async (block_0) => {
|
|
30
31
|
try {
|
|
31
|
-
await deleteBlock.mutateAsync({ id:
|
|
32
|
+
await deleteBlock.mutateAsync({ id: block_0.id });
|
|
32
33
|
trackClientEvent("block_deleted", {
|
|
33
34
|
projectId: page?.page.projectId,
|
|
34
|
-
blockType:
|
|
35
|
+
blockType: block_0.type
|
|
35
36
|
});
|
|
36
|
-
toast.success(`Deleted "${
|
|
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 (
|
|
45
|
+
const handleDuplicateBlock = async (block_1) => {
|
|
45
46
|
try {
|
|
46
|
-
await duplicateBlock.mutateAsync({ id:
|
|
47
|
+
await duplicateBlock.mutateAsync({ id: block_1.id });
|
|
47
48
|
trackClientEvent("block_duplicated", {
|
|
48
49
|
projectId: page?.page.projectId,
|
|
49
|
-
blockType:
|
|
50
|
+
blockType: block_1.type
|
|
50
51
|
});
|
|
51
|
-
toast.success(`Duplicated "${
|
|
52
|
-
} catch (
|
|
53
|
-
console.error("Failed to duplicate block:",
|
|
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 = (
|
|
58
|
+
const handleAddBlockAbove = (block_2) => {
|
|
58
59
|
if (!page) return;
|
|
59
|
-
const blockIndex = pageBlocks.findIndex((b) => String(b.id) === String(
|
|
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 = (
|
|
67
|
+
const handleAddBlockBelow = (block_3) => {
|
|
67
68
|
previewStore.send({
|
|
68
69
|
type: "openAddBlockSheet",
|
|
69
|
-
afterPosition:
|
|
70
|
+
afterPosition: block_3.position
|
|
70
71
|
});
|
|
71
72
|
};
|
|
72
|
-
const getBlocksAbove = (
|
|
73
|
+
const getBlocksAbove = (block_4) => {
|
|
73
74
|
if (!page) return [];
|
|
74
|
-
const
|
|
75
|
-
return pageBlocks.slice(0,
|
|
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 = (
|
|
78
|
+
const getBlocksBelow = (block_5) => {
|
|
78
79
|
if (!page) return [];
|
|
79
|
-
const
|
|
80
|
-
return pageBlocks.slice(
|
|
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 (
|
|
83
|
-
const blocksAbove = getBlocksAbove(
|
|
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((
|
|
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 (
|
|
89
|
-
console.error("Failed to delete blocks above:",
|
|
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 (
|
|
94
|
-
const blocksBelow = getBlocksBelow(
|
|
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((
|
|
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 (
|
|
100
|
-
console.error("Failed to delete blocks below:",
|
|
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: (
|
|
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,
|
|
281
|
-
|
|
282
|
-
|
|
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
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
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
|
-
|
|
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
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
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
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
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
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
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
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
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: "
|
|
472
|
-
|
|
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
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
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: (
|
|
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:
|
|
142
|
-
onChange: (
|
|
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", {
|