camox 0.24.0 → 0.25.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/core/hooks/useRequireDraftSource.js +27 -0
- package/dist/features/preview/CamoxPreview.d.ts +4 -0
- package/dist/features/preview/CamoxPreview.js +454 -181
- package/dist/features/preview/components/AddBlockSheet.js +79 -75
- package/dist/features/preview/components/AssetLightbox.js +1 -1
- package/dist/features/preview/components/BlockActionsPopover.js +39 -22
- package/dist/features/preview/components/DraftSwitchDialog.js +66 -0
- package/dist/features/preview/components/EditPageModal.js +9 -9
- package/dist/features/preview/components/LinkFieldEditor.js +1 -1
- package/dist/features/preview/components/Overlays.js +6 -2
- package/dist/features/preview/components/PageContentSheet.js +222 -190
- package/dist/features/preview/components/PagePicker.js +81 -3
- package/dist/features/preview/components/PageTree.js +418 -327
- package/dist/features/preview/components/PreviewToolbar.js +172 -158
- package/dist/features/preview/components/PublishDialog.js +111 -0
- package/dist/features/preview/components/useRepeatableItemActions.js +26 -20
- package/dist/features/preview/components/useUpdateBlockPosition.js +10 -9
- package/dist/features/preview/previewStore.js +38 -1
- package/dist/features/provider/useAdminShortcuts.js +7 -2
- package/dist/features/routes/pageRoute.d.ts +6 -2
- package/dist/features/routes/pageRoute.js +10 -6
- package/dist/features/vite/vite.js +6 -5
- package/dist/lib/normalized-data.js +87 -88
- package/dist/lib/queries.js +12 -6
- package/dist/studio.css +1 -1
- package/package.json +4 -4
- package/skills/camox-cli/SKILL.md +23 -0
|
@@ -5,6 +5,7 @@ import { useProjectSlug } from "../../../lib/auth.js";
|
|
|
5
5
|
import { blockMutations, blockQueries, projectQueries } from "../../../lib/queries.js";
|
|
6
6
|
import { usePageBlocks } from "../../../lib/normalized-data.js";
|
|
7
7
|
import { useCamoxApp } from "../../provider/components/CamoxAppContext.js";
|
|
8
|
+
import { useRequireDraftSource } from "../../../core/hooks/useRequireDraftSource.js";
|
|
8
9
|
import { usePreviewedPage } from "../CamoxPreview.js";
|
|
9
10
|
import { c } from "react/compiler-runtime";
|
|
10
11
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
@@ -18,15 +19,16 @@ import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, Command
|
|
|
18
19
|
|
|
19
20
|
//#region src/features/preview/components/AddBlockSheet.tsx
|
|
20
21
|
const AddBlockSheet = () => {
|
|
21
|
-
const $ = c(
|
|
22
|
-
if ($[0] !== "
|
|
23
|
-
for (let $i = 0; $i <
|
|
24
|
-
$[0] = "
|
|
22
|
+
const $ = c(61);
|
|
23
|
+
if ($[0] !== "0320621570f40e4a7e82d65adec2727cd3960491c9729ac51b93474f1e682d5a") {
|
|
24
|
+
for (let $i = 0; $i < 61; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
25
|
+
$[0] = "0320621570f40e4a7e82d65adec2727cd3960491c9729ac51b93474f1e682d5a";
|
|
25
26
|
}
|
|
26
27
|
const [highlightedValue, setHighlightedValue] = React.useState("");
|
|
27
28
|
const queryClient = useQueryClient();
|
|
28
29
|
const { pathname } = useLocation();
|
|
29
30
|
const pagePathname = useSelector(previewStore, _temp) ?? pathname;
|
|
31
|
+
const requireDraft = useRequireDraftSource();
|
|
30
32
|
let t0;
|
|
31
33
|
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
32
34
|
t0 = blockMutations.create();
|
|
@@ -37,11 +39,11 @@ const AddBlockSheet = () => {
|
|
|
37
39
|
t1 = {
|
|
38
40
|
...t0,
|
|
39
41
|
onMutate: (variables) => {
|
|
40
|
-
const pageQueryKey = queryKeys.pages.getByPath(pagePathname);
|
|
42
|
+
const pageQueryKey = queryKeys.pages.getByPath(pagePathname, "draft");
|
|
41
43
|
const previousPage = queryClient.getQueryData(pageQueryKey);
|
|
42
44
|
if (!previousPage) return {};
|
|
43
45
|
const blockIds = previousPage.page.blockIds;
|
|
44
|
-
const pageBlocks = blockIds.map((id) => queryClient.getQueryData(queryKeys.blocks.get(id))?.block).filter(_temp2);
|
|
46
|
+
const pageBlocks = blockIds.map((id) => queryClient.getQueryData(queryKeys.blocks.get(id, "draft"))?.block).filter(_temp2);
|
|
45
47
|
const { afterPosition } = variables;
|
|
46
48
|
let position;
|
|
47
49
|
if (afterPosition == null) {
|
|
@@ -74,7 +76,7 @@ const AddBlockSheet = () => {
|
|
|
74
76
|
createdAt: now,
|
|
75
77
|
updatedAt: now
|
|
76
78
|
};
|
|
77
|
-
queryClient.setQueryData(queryKeys.blocks.get(optimisticId), {
|
|
79
|
+
queryClient.setQueryData(queryKeys.blocks.get(optimisticId, "draft"), {
|
|
78
80
|
block: optimisticBlock,
|
|
79
81
|
repeatableItems: [],
|
|
80
82
|
files: []
|
|
@@ -97,11 +99,11 @@ const AddBlockSheet = () => {
|
|
|
97
99
|
};
|
|
98
100
|
},
|
|
99
101
|
onError: (_error, _variables, context) => {
|
|
100
|
-
if (context?.previousPage) queryClient.setQueryData(queryKeys.pages.getByPath(pagePathname), context.previousPage);
|
|
101
|
-
if (context?.optimisticId) queryClient.removeQueries({ queryKey: queryKeys.blocks.get(context.optimisticId) });
|
|
102
|
+
if (context?.previousPage) queryClient.setQueryData(queryKeys.pages.getByPath(pagePathname, "draft"), context.previousPage);
|
|
103
|
+
if (context?.optimisticId) queryClient.removeQueries({ queryKey: queryKeys.blocks.get(context.optimisticId, "draft") });
|
|
102
104
|
},
|
|
103
105
|
onSettled: () => {
|
|
104
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.pages.getByPath(pagePathname) });
|
|
106
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.pages.getByPath(pagePathname, "draft") });
|
|
105
107
|
}
|
|
106
108
|
};
|
|
107
109
|
$[2] = pagePathname;
|
|
@@ -165,9 +167,10 @@ const AddBlockSheet = () => {
|
|
|
165
167
|
const peekedBlockPosition = useSelector(previewStore, _temp5);
|
|
166
168
|
const addBlockSource = useSelector(previewStore, _temp6);
|
|
167
169
|
let t9;
|
|
168
|
-
if ($[17] !== addBlockSource || $[18] !== createBlock || $[19] !== page || $[20] !== pageBlocks_0 || $[21] !== peekedBlockPosition) {
|
|
170
|
+
if ($[17] !== addBlockSource || $[18] !== createBlock || $[19] !== page || $[20] !== pageBlocks_0 || $[21] !== peekedBlockPosition || $[22] !== requireDraft) {
|
|
169
171
|
t9 = async (block_0) => {
|
|
170
172
|
if (!page) return;
|
|
173
|
+
if (!requireDraft()) return;
|
|
171
174
|
const afterPosition_0 = peekedBlockPosition === "" ? "" : peekedBlockPosition ?? pageBlocks_0[pageBlocks_0.length - 1]?.position;
|
|
172
175
|
const bundle = block_0._internal.getInitialBundle();
|
|
173
176
|
const { id: blockId } = await createBlock.mutateAsync({
|
|
@@ -193,11 +196,12 @@ const AddBlockSheet = () => {
|
|
|
193
196
|
$[19] = page;
|
|
194
197
|
$[20] = pageBlocks_0;
|
|
195
198
|
$[21] = peekedBlockPosition;
|
|
196
|
-
$[22] =
|
|
197
|
-
|
|
199
|
+
$[22] = requireDraft;
|
|
200
|
+
$[23] = t9;
|
|
201
|
+
} else t9 = $[23];
|
|
198
202
|
const handleAddBlock = t9;
|
|
199
203
|
let t10;
|
|
200
|
-
if ($[
|
|
204
|
+
if ($[24] !== pageBlocks_0 || $[25] !== peekedBlockPosition) {
|
|
201
205
|
t10 = (block_1) => {
|
|
202
206
|
const afterPosition_1 = peekedBlockPosition === "" ? "" : peekedBlockPosition ?? pageBlocks_0[pageBlocks_0.length - 1]?.position;
|
|
203
207
|
previewStore.send({
|
|
@@ -206,10 +210,10 @@ const AddBlockSheet = () => {
|
|
|
206
210
|
afterPosition: afterPosition_1
|
|
207
211
|
});
|
|
208
212
|
};
|
|
209
|
-
$[
|
|
210
|
-
$[
|
|
211
|
-
$[
|
|
212
|
-
} else t10 = $[
|
|
213
|
+
$[24] = pageBlocks_0;
|
|
214
|
+
$[25] = peekedBlockPosition;
|
|
215
|
+
$[26] = t10;
|
|
216
|
+
} else t10 = $[26];
|
|
213
217
|
const handlePreviewBlock = t10;
|
|
214
218
|
const handleValueChange = (value) => {
|
|
215
219
|
setHighlightedValue(value);
|
|
@@ -220,70 +224,70 @@ const AddBlockSheet = () => {
|
|
|
220
224
|
const handleOpenChange = _temp7;
|
|
221
225
|
let t11;
|
|
222
226
|
let t12;
|
|
223
|
-
if ($[
|
|
227
|
+
if ($[27] !== isOpen) {
|
|
224
228
|
t11 = () => {
|
|
225
229
|
if (isOpen) setHighlightedValue("");
|
|
226
230
|
};
|
|
227
231
|
t12 = [isOpen];
|
|
228
|
-
$[
|
|
229
|
-
$[
|
|
230
|
-
$[
|
|
232
|
+
$[27] = isOpen;
|
|
233
|
+
$[28] = t11;
|
|
234
|
+
$[29] = t12;
|
|
231
235
|
} else {
|
|
232
|
-
t11 = $[
|
|
233
|
-
t12 = $[
|
|
236
|
+
t11 = $[28];
|
|
237
|
+
t12 = $[29];
|
|
234
238
|
}
|
|
235
239
|
React.useEffect(t11, t12);
|
|
236
240
|
let t13;
|
|
237
|
-
if ($[
|
|
241
|
+
if ($[30] !== pageCounts || $[31] !== totalCounts) {
|
|
238
242
|
t13 = (blockId_0) => {
|
|
239
243
|
const total = totalCounts[blockId_0] ?? 0;
|
|
240
244
|
if (total === 0) return "Never used";
|
|
241
245
|
const page_0 = pageCounts[blockId_0] ?? "none";
|
|
242
246
|
return `${total} use${total > 1 ? "s" : ""} (${page_0} here)`;
|
|
243
247
|
};
|
|
244
|
-
$[
|
|
245
|
-
$[
|
|
246
|
-
$[
|
|
247
|
-
} else t13 = $[
|
|
248
|
+
$[30] = pageCounts;
|
|
249
|
+
$[31] = totalCounts;
|
|
250
|
+
$[32] = t13;
|
|
251
|
+
} else t13 = $[32];
|
|
248
252
|
const displayCount = t13;
|
|
249
253
|
const T0 = PreviewSideSheet;
|
|
250
254
|
const t14 = "flex flex-col gap-0";
|
|
251
255
|
let t15;
|
|
252
|
-
if ($[
|
|
256
|
+
if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
|
|
253
257
|
t15 = /* @__PURE__ */ jsxs(Sheet.SheetHeader, {
|
|
254
258
|
className: "border-border border-b",
|
|
255
259
|
children: [/* @__PURE__ */ jsx(Sheet.SheetTitle, { children: "Add new block" }), /* @__PURE__ */ jsx(Sheet.SheetDescription, { children: "Search and select a block to add to the page." })]
|
|
256
260
|
});
|
|
257
|
-
$[
|
|
258
|
-
} else t15 = $[
|
|
261
|
+
$[33] = t15;
|
|
262
|
+
} else t15 = $[33];
|
|
259
263
|
const t16 = "flex-1 overflow-auto p-2";
|
|
260
264
|
const T1 = Command;
|
|
261
265
|
const t17 = "overflow-visible";
|
|
262
266
|
const t18 = _temp8;
|
|
263
267
|
let t19;
|
|
264
|
-
if ($[
|
|
268
|
+
if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
|
|
265
269
|
t19 = /* @__PURE__ */ jsx(CommandInput, {
|
|
266
270
|
placeholder: "Search blocks...",
|
|
267
271
|
autoFocus: true
|
|
268
272
|
});
|
|
269
|
-
$[
|
|
270
|
-
} else t19 = $[
|
|
273
|
+
$[34] = t19;
|
|
274
|
+
} else t19 = $[34];
|
|
271
275
|
const T2 = CommandList;
|
|
272
276
|
const t20 = "mt-1 max-h-full";
|
|
273
277
|
let t21;
|
|
274
|
-
if ($[
|
|
278
|
+
if ($[35] === Symbol.for("react.memo_cache_sentinel")) {
|
|
275
279
|
t21 = /* @__PURE__ */ jsx(CommandEmpty, { children: "No blocks found." });
|
|
276
|
-
$[
|
|
277
|
-
} else t21 = $[
|
|
280
|
+
$[35] = t21;
|
|
281
|
+
} else t21 = $[35];
|
|
278
282
|
const T3 = CommandGroup;
|
|
279
283
|
let t22;
|
|
280
|
-
if ($[
|
|
284
|
+
if ($[36] !== totalCounts) {
|
|
281
285
|
t22 = (a, b_3) => (totalCounts[b_3._internal.id] ?? 0) - (totalCounts[a._internal.id] ?? 0);
|
|
282
|
-
$[
|
|
283
|
-
$[
|
|
284
|
-
} else t22 = $[
|
|
286
|
+
$[36] = totalCounts;
|
|
287
|
+
$[37] = t22;
|
|
288
|
+
} else t22 = $[37];
|
|
285
289
|
let t23;
|
|
286
|
-
if ($[
|
|
290
|
+
if ($[38] !== displayCount || $[39] !== handleAddBlock) {
|
|
287
291
|
t23 = (block_3) => /* @__PURE__ */ jsx(CommandItem, {
|
|
288
292
|
value: block_3._internal.title,
|
|
289
293
|
onSelect: () => {
|
|
@@ -298,31 +302,31 @@ const AddBlockSheet = () => {
|
|
|
298
302
|
})]
|
|
299
303
|
})
|
|
300
304
|
}, block_3._internal.id);
|
|
301
|
-
$[
|
|
302
|
-
$[
|
|
303
|
-
$[
|
|
304
|
-
} else t23 = $[
|
|
305
|
+
$[38] = displayCount;
|
|
306
|
+
$[39] = handleAddBlock;
|
|
307
|
+
$[40] = t23;
|
|
308
|
+
} else t23 = $[40];
|
|
305
309
|
const t24 = availableBlocks.sort(t22).map(t23);
|
|
306
310
|
let t25;
|
|
307
|
-
if ($[
|
|
311
|
+
if ($[41] !== T3 || $[42] !== t24) {
|
|
308
312
|
t25 = /* @__PURE__ */ jsx(T3, { children: t24 });
|
|
309
|
-
$[
|
|
310
|
-
$[
|
|
311
|
-
$[
|
|
312
|
-
} else t25 = $[
|
|
313
|
+
$[41] = T3;
|
|
314
|
+
$[42] = t24;
|
|
315
|
+
$[43] = t25;
|
|
316
|
+
} else t25 = $[43];
|
|
313
317
|
let t26;
|
|
314
|
-
if ($[
|
|
318
|
+
if ($[44] !== T2 || $[45] !== t21 || $[46] !== t25) {
|
|
315
319
|
t26 = /* @__PURE__ */ jsxs(T2, {
|
|
316
320
|
className: t20,
|
|
317
321
|
children: [t21, t25]
|
|
318
322
|
});
|
|
319
|
-
$[
|
|
320
|
-
$[
|
|
321
|
-
$[
|
|
322
|
-
$[
|
|
323
|
-
} else t26 = $[
|
|
323
|
+
$[44] = T2;
|
|
324
|
+
$[45] = t21;
|
|
325
|
+
$[46] = t25;
|
|
326
|
+
$[47] = t26;
|
|
327
|
+
} else t26 = $[47];
|
|
324
328
|
let t27;
|
|
325
|
-
if ($[
|
|
329
|
+
if ($[48] !== T1 || $[49] !== handleValueChange || $[50] !== highlightedValue || $[51] !== t18 || $[52] !== t19 || $[53] !== t26) {
|
|
326
330
|
t27 = /* @__PURE__ */ jsx("div", {
|
|
327
331
|
className: t16,
|
|
328
332
|
children: /* @__PURE__ */ jsxs(T1, {
|
|
@@ -333,29 +337,29 @@ const AddBlockSheet = () => {
|
|
|
333
337
|
children: [t19, t26]
|
|
334
338
|
})
|
|
335
339
|
});
|
|
336
|
-
$[
|
|
337
|
-
$[
|
|
338
|
-
$[
|
|
339
|
-
$[
|
|
340
|
-
$[
|
|
341
|
-
$[
|
|
342
|
-
$[
|
|
343
|
-
} else t27 = $[
|
|
340
|
+
$[48] = T1;
|
|
341
|
+
$[49] = handleValueChange;
|
|
342
|
+
$[50] = highlightedValue;
|
|
343
|
+
$[51] = t18;
|
|
344
|
+
$[52] = t19;
|
|
345
|
+
$[53] = t26;
|
|
346
|
+
$[54] = t27;
|
|
347
|
+
} else t27 = $[54];
|
|
344
348
|
let t28;
|
|
345
|
-
if ($[
|
|
349
|
+
if ($[55] !== T0 || $[56] !== handleOpenChange || $[57] !== isOpen || $[58] !== t15 || $[59] !== t27) {
|
|
346
350
|
t28 = /* @__PURE__ */ jsxs(T0, {
|
|
347
351
|
open: isOpen,
|
|
348
352
|
onOpenChange: handleOpenChange,
|
|
349
353
|
className: t14,
|
|
350
354
|
children: [t15, t27]
|
|
351
355
|
});
|
|
352
|
-
$[
|
|
353
|
-
$[
|
|
354
|
-
$[
|
|
355
|
-
$[
|
|
356
|
-
$[
|
|
357
|
-
$[
|
|
358
|
-
} else t28 = $[
|
|
356
|
+
$[55] = T0;
|
|
357
|
+
$[56] = handleOpenChange;
|
|
358
|
+
$[57] = isOpen;
|
|
359
|
+
$[58] = t15;
|
|
360
|
+
$[59] = t27;
|
|
361
|
+
$[60] = t28;
|
|
362
|
+
} else t28 = $[60];
|
|
359
363
|
return t28;
|
|
360
364
|
};
|
|
361
365
|
function _temp(state) {
|
|
@@ -12,10 +12,10 @@ import { useMutation, useQuery } from "@tanstack/react-query";
|
|
|
12
12
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
13
13
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { Button } from "@camox/ui/button";
|
|
15
|
+
import { Switch } from "@camox/ui/switch";
|
|
15
16
|
import { Tooltip, TooltipContent, TooltipTrigger } from "@camox/ui/tooltip";
|
|
16
17
|
import { Check, Download, FileIcon, Info, Link, Loader2, Trash2, X } from "lucide-react";
|
|
17
18
|
import { Dialog, DialogContent, DialogTitle } from "@camox/ui/dialog";
|
|
18
|
-
import { Switch } from "@camox/ui/switch";
|
|
19
19
|
import { ButtonGroup } from "@camox/ui/button-group";
|
|
20
20
|
|
|
21
21
|
//#region src/features/preview/components/AssetLightbox.tsx
|
|
@@ -5,6 +5,7 @@ import { blockMutations, repeatableItemMutations } from "../../../lib/queries.js
|
|
|
5
5
|
import { formatShortcut } from "../../../lib/utils.js";
|
|
6
6
|
import { usePageBlocks } from "../../../lib/normalized-data.js";
|
|
7
7
|
import { useCamoxApp } from "../../provider/components/CamoxAppContext.js";
|
|
8
|
+
import { useRequireDraftSource } from "../../../core/hooks/useRequireDraftSource.js";
|
|
8
9
|
import { useUpdateBlockPosition } from "./useUpdateBlockPosition.js";
|
|
9
10
|
import { usePreviewedPage } from "../CamoxPreview.js";
|
|
10
11
|
import { c } from "react/compiler-runtime";
|
|
@@ -277,15 +278,16 @@ function isLayoutBlockId(page, blockId) {
|
|
|
277
278
|
return new Set([...page.layout.beforeBlockIds, ...page.layout.afterBlockIds]).has(blockId);
|
|
278
279
|
}
|
|
279
280
|
function useBlockActionsShortcuts() {
|
|
280
|
-
const $ = c(
|
|
281
|
-
if ($[0] !== "
|
|
282
|
-
for (let $i = 0; $i <
|
|
283
|
-
$[0] = "
|
|
281
|
+
const $ = c(20);
|
|
282
|
+
if ($[0] !== "040883a85a53eb481b8e8bc8c871b7bd284c1089502a38f1dfd9b09fbc6d8c28") {
|
|
283
|
+
for (let $i = 0; $i < 20; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
284
|
+
$[0] = "040883a85a53eb481b8e8bc8c871b7bd284c1089502a38f1dfd9b09fbc6d8c28";
|
|
284
285
|
}
|
|
285
286
|
const camoxApp = useCamoxApp();
|
|
286
287
|
const page = usePreviewedPage();
|
|
287
288
|
const { pageBlocks } = usePageBlocks(page);
|
|
288
289
|
const selection = useSelector(previewStore, _temp);
|
|
290
|
+
const requireDraft = useRequireDraftSource();
|
|
289
291
|
let t0;
|
|
290
292
|
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
291
293
|
t0 = blockMutations.delete();
|
|
@@ -312,7 +314,7 @@ function useBlockActionsShortcuts() {
|
|
|
312
314
|
} else t3 = $[4];
|
|
313
315
|
const duplicateRepeatableItem = useMutation(t3);
|
|
314
316
|
let t4;
|
|
315
|
-
if ($[5] !== deleteBlockMutation || $[6] !== deleteRepeatableItem || $[7] !== duplicateBlockMutation || $[8] !== duplicateRepeatableItem || $[9] !== page || $[10] !== pageBlocks || $[11] !== updatePositionMutation) {
|
|
317
|
+
if ($[5] !== deleteBlockMutation || $[6] !== deleteRepeatableItem || $[7] !== duplicateBlockMutation || $[8] !== duplicateRepeatableItem || $[9] !== page || $[10] !== pageBlocks || $[11] !== requireDraft || $[12] !== updatePositionMutation) {
|
|
316
318
|
t4 = () => {
|
|
317
319
|
const actions = [
|
|
318
320
|
{
|
|
@@ -325,7 +327,8 @@ function useBlockActionsShortcuts() {
|
|
|
325
327
|
},
|
|
326
328
|
checkIfAvailable: () => {
|
|
327
329
|
const ctx = previewStore.getSnapshot().context;
|
|
328
|
-
if (ctx.isContentLocked
|
|
330
|
+
if (ctx.isContentLocked && ctx.previewSource === "draft") return false;
|
|
331
|
+
if (ctx.isPresentationMode) return false;
|
|
329
332
|
const sel = ctx.selection;
|
|
330
333
|
if (!sel) return false;
|
|
331
334
|
if (isLayoutBlockId(page, sel.blockId)) return false;
|
|
@@ -343,6 +346,7 @@ function useBlockActionsShortcuts() {
|
|
|
343
346
|
return pageBlocks.length > 1;
|
|
344
347
|
},
|
|
345
348
|
execute: () => {
|
|
349
|
+
if (!requireDraft()) return;
|
|
346
350
|
const sel_0 = previewStore.getSnapshot().context.selection;
|
|
347
351
|
if (!sel_0) return;
|
|
348
352
|
const itemId_0 = selectionItemId(sel_0);
|
|
@@ -366,13 +370,15 @@ function useBlockActionsShortcuts() {
|
|
|
366
370
|
},
|
|
367
371
|
checkIfAvailable: () => {
|
|
368
372
|
const ctx_0 = previewStore.getSnapshot().context;
|
|
369
|
-
if (ctx_0.isContentLocked
|
|
373
|
+
if (ctx_0.isContentLocked && ctx_0.previewSource === "draft") return false;
|
|
374
|
+
if (ctx_0.isPresentationMode) return false;
|
|
370
375
|
const sel_1 = ctx_0.selection;
|
|
371
376
|
if (!sel_1) return false;
|
|
372
377
|
if (isLayoutBlockId(page, sel_1.blockId)) return false;
|
|
373
378
|
return true;
|
|
374
379
|
},
|
|
375
380
|
execute: () => {
|
|
381
|
+
if (!requireDraft()) return;
|
|
376
382
|
const sel_2 = previewStore.getSnapshot().context.selection;
|
|
377
383
|
if (!sel_2) return;
|
|
378
384
|
const itemId_1 = selectionItemId(sel_2);
|
|
@@ -394,13 +400,15 @@ function useBlockActionsShortcuts() {
|
|
|
394
400
|
},
|
|
395
401
|
checkIfAvailable: () => {
|
|
396
402
|
const ctx_1 = previewStore.getSnapshot().context;
|
|
397
|
-
if (ctx_1.isContentLocked
|
|
403
|
+
if (ctx_1.isContentLocked && ctx_1.previewSource === "draft") return false;
|
|
404
|
+
if (ctx_1.isPresentationMode) return false;
|
|
398
405
|
const sel_3 = ctx_1.selection;
|
|
399
406
|
if (!sel_3 || !page) return false;
|
|
400
407
|
if (isLayoutBlockId(page, sel_3.blockId)) return false;
|
|
401
408
|
return pageBlocks.findIndex((b_2) => b_2.id === sel_3.blockId) > 0;
|
|
402
409
|
},
|
|
403
410
|
execute: () => {
|
|
411
|
+
if (!requireDraft()) return;
|
|
404
412
|
const sel_4 = previewStore.getSnapshot().context.selection;
|
|
405
413
|
if (!sel_4 || !page) return;
|
|
406
414
|
const index_0 = pageBlocks.findIndex((b_3) => b_3.id === sel_4.blockId);
|
|
@@ -424,7 +432,8 @@ function useBlockActionsShortcuts() {
|
|
|
424
432
|
},
|
|
425
433
|
checkIfAvailable: () => {
|
|
426
434
|
const ctx_2 = previewStore.getSnapshot().context;
|
|
427
|
-
if (ctx_2.isContentLocked
|
|
435
|
+
if (ctx_2.isContentLocked && ctx_2.previewSource === "draft") return false;
|
|
436
|
+
if (ctx_2.isPresentationMode) return false;
|
|
428
437
|
const sel_5 = ctx_2.selection;
|
|
429
438
|
if (!sel_5 || !page) return false;
|
|
430
439
|
if (isLayoutBlockId(page, sel_5.blockId)) return false;
|
|
@@ -432,6 +441,7 @@ function useBlockActionsShortcuts() {
|
|
|
432
441
|
return index_1 !== -1 && index_1 < pageBlocks.length - 1;
|
|
433
442
|
},
|
|
434
443
|
execute: () => {
|
|
444
|
+
if (!requireDraft()) return;
|
|
435
445
|
const sel_6 = previewStore.getSnapshot().context.selection;
|
|
436
446
|
if (!sel_6 || !page) return;
|
|
437
447
|
const index_2 = pageBlocks.findIndex((b_5) => b_5.id === sel_6.blockId);
|
|
@@ -452,6 +462,7 @@ function useBlockActionsShortcuts() {
|
|
|
452
462
|
shortcut: { key: "o" },
|
|
453
463
|
checkIfAvailable: _temp10,
|
|
454
464
|
execute: () => {
|
|
465
|
+
if (!requireDraft()) return;
|
|
455
466
|
const sel_7 = previewStore.getSnapshot().context.selection;
|
|
456
467
|
if (!sel_7 || !page) return;
|
|
457
468
|
const block_2 = pageBlocks.find((b_6) => b_6.id === sel_7.blockId);
|
|
@@ -473,6 +484,7 @@ function useBlockActionsShortcuts() {
|
|
|
473
484
|
},
|
|
474
485
|
checkIfAvailable: _temp11,
|
|
475
486
|
execute: () => {
|
|
487
|
+
if (!requireDraft()) return;
|
|
476
488
|
const sel_8 = previewStore.getSnapshot().context.selection;
|
|
477
489
|
if (!sel_8 || !page) return;
|
|
478
490
|
const blockIndex = pageBlocks.findIndex((b_7) => b_7.id === sel_8.blockId);
|
|
@@ -503,23 +515,26 @@ function useBlockActionsShortcuts() {
|
|
|
503
515
|
$[8] = duplicateRepeatableItem;
|
|
504
516
|
$[9] = page;
|
|
505
517
|
$[10] = pageBlocks;
|
|
506
|
-
$[11] =
|
|
507
|
-
$[12] =
|
|
508
|
-
|
|
518
|
+
$[11] = requireDraft;
|
|
519
|
+
$[12] = updatePositionMutation;
|
|
520
|
+
$[13] = t4;
|
|
521
|
+
} else t4 = $[13];
|
|
509
522
|
let t5;
|
|
510
|
-
if ($[
|
|
523
|
+
if ($[14] !== camoxApp || $[15] !== page || $[16] !== pageBlocks || $[17] !== requireDraft || $[18] !== selection) {
|
|
511
524
|
t5 = [
|
|
512
525
|
selection,
|
|
513
526
|
page,
|
|
514
527
|
pageBlocks,
|
|
515
|
-
camoxApp
|
|
528
|
+
camoxApp,
|
|
529
|
+
requireDraft
|
|
516
530
|
];
|
|
517
|
-
$[
|
|
518
|
-
$[
|
|
519
|
-
$[
|
|
520
|
-
$[
|
|
521
|
-
$[
|
|
522
|
-
|
|
531
|
+
$[14] = camoxApp;
|
|
532
|
+
$[15] = page;
|
|
533
|
+
$[16] = pageBlocks;
|
|
534
|
+
$[17] = requireDraft;
|
|
535
|
+
$[18] = selection;
|
|
536
|
+
$[19] = t5;
|
|
537
|
+
} else t5 = $[19];
|
|
523
538
|
React.useEffect(t4, t5);
|
|
524
539
|
}
|
|
525
540
|
function _temp12(a) {
|
|
@@ -527,12 +542,14 @@ function _temp12(a) {
|
|
|
527
542
|
}
|
|
528
543
|
function _temp11() {
|
|
529
544
|
const ctx_4 = previewStore.getSnapshot().context;
|
|
530
|
-
if (ctx_4.isContentLocked
|
|
545
|
+
if (ctx_4.isContentLocked && ctx_4.previewSource === "draft") return false;
|
|
546
|
+
if (ctx_4.isPresentationMode) return false;
|
|
531
547
|
return ctx_4.selection !== null;
|
|
532
548
|
}
|
|
533
549
|
function _temp10() {
|
|
534
550
|
const ctx_3 = previewStore.getSnapshot().context;
|
|
535
|
-
if (ctx_3.isContentLocked
|
|
551
|
+
if (ctx_3.isContentLocked && ctx_3.previewSource === "draft") return false;
|
|
552
|
+
if (ctx_3.isPresentationMode) return false;
|
|
536
553
|
return ctx_3.selection !== null;
|
|
537
554
|
}
|
|
538
555
|
function _temp1() {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { previewStore } from "../previewStore.js";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useSelector } from "@xstate/store-react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
|
|
6
|
+
|
|
7
|
+
//#region src/features/preview/components/DraftSwitchDialog.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Global confirmation that the user wants to leave a non-draft preview
|
|
10
|
+
* before editing. The CTA only flips `previewSource` to `'draft'` — the
|
|
11
|
+
* original edit attempt is intentionally NOT replayed; the user re-issues it
|
|
12
|
+
* once back on draft. This keeps the action explicit and avoids "magical"
|
|
13
|
+
* delayed edits the user might no longer want.
|
|
14
|
+
*/
|
|
15
|
+
function DraftSwitchDialog() {
|
|
16
|
+
const $ = c(5);
|
|
17
|
+
if ($[0] !== "3be875184f6abab2ae16a64fbececa2389b1e6a2f4ea614823966b8277e4826b") {
|
|
18
|
+
for (let $i = 0; $i < 5; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
19
|
+
$[0] = "3be875184f6abab2ae16a64fbececa2389b1e6a2f4ea614823966b8277e4826b";
|
|
20
|
+
}
|
|
21
|
+
const open = useSelector(previewStore, _temp);
|
|
22
|
+
let t0;
|
|
23
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
24
|
+
t0 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: "Switch to draft to edit?" }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: "You're previewing the live version. Switch to the draft to make changes." })] });
|
|
25
|
+
$[1] = t0;
|
|
26
|
+
} else t0 = $[1];
|
|
27
|
+
let t1;
|
|
28
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
29
|
+
t1 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t0, /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [/* @__PURE__ */ jsx(AlertDialogCancel, {
|
|
30
|
+
variant: "outline",
|
|
31
|
+
size: "default",
|
|
32
|
+
children: "Cancel"
|
|
33
|
+
}), /* @__PURE__ */ jsx(AlertDialogAction, {
|
|
34
|
+
onClick: _temp3,
|
|
35
|
+
children: "Switch to draft"
|
|
36
|
+
})] })] });
|
|
37
|
+
$[2] = t1;
|
|
38
|
+
} else t1 = $[2];
|
|
39
|
+
let t2;
|
|
40
|
+
if ($[3] !== open) {
|
|
41
|
+
t2 = /* @__PURE__ */ jsx(AlertDialog, {
|
|
42
|
+
open,
|
|
43
|
+
onOpenChange: _temp2,
|
|
44
|
+
children: t1
|
|
45
|
+
});
|
|
46
|
+
$[3] = open;
|
|
47
|
+
$[4] = t2;
|
|
48
|
+
} else t2 = $[4];
|
|
49
|
+
return t2;
|
|
50
|
+
}
|
|
51
|
+
function _temp3() {
|
|
52
|
+
previewStore.send({
|
|
53
|
+
type: "setPreviewSource",
|
|
54
|
+
source: "draft"
|
|
55
|
+
});
|
|
56
|
+
previewStore.send({ type: "dismissDraftSwitch" });
|
|
57
|
+
}
|
|
58
|
+
function _temp2(next) {
|
|
59
|
+
if (!next) previewStore.send({ type: "dismissDraftSwitch" });
|
|
60
|
+
}
|
|
61
|
+
function _temp(state) {
|
|
62
|
+
return state.context.isDraftSwitchDialogOpen;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
export { DraftSwitchDialog };
|
|
@@ -17,6 +17,7 @@ import { useSelector } from "@xstate/store-react";
|
|
|
17
17
|
import * as React from "react";
|
|
18
18
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
19
19
|
import { Button } from "@camox/ui/button";
|
|
20
|
+
import { Switch } from "@camox/ui/switch";
|
|
20
21
|
import { Tooltip, TooltipContent, TooltipTrigger } from "@camox/ui/tooltip";
|
|
21
22
|
import { Globe, Info, Trash2, Upload } from "lucide-react";
|
|
22
23
|
import { Spinner } from "@camox/ui/spinner";
|
|
@@ -24,14 +25,13 @@ import { Alert, AlertDescription, AlertTitle } from "@camox/ui/alert";
|
|
|
24
25
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@camox/ui/dialog";
|
|
25
26
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@camox/ui/select";
|
|
26
27
|
import { useForm } from "@tanstack/react-form";
|
|
27
|
-
import { Switch } from "@camox/ui/switch";
|
|
28
28
|
|
|
29
29
|
//#region src/features/preview/components/EditPageModal.tsx
|
|
30
30
|
const EditPageModal = () => {
|
|
31
31
|
const $ = c(3);
|
|
32
|
-
if ($[0] !== "
|
|
32
|
+
if ($[0] !== "dfed49772fc493ebb158f0892caae2776e9f3903bcc54115d8f549c2a9beee89") {
|
|
33
33
|
for (let $i = 0; $i < 3; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
34
|
-
$[0] = "
|
|
34
|
+
$[0] = "dfed49772fc493ebb158f0892caae2776e9f3903bcc54115d8f549c2a9beee89";
|
|
35
35
|
}
|
|
36
36
|
const editingPageId = useSelector(previewStore, _temp);
|
|
37
37
|
let t0;
|
|
@@ -303,9 +303,9 @@ function truncateText(text, maxLen) {
|
|
|
303
303
|
}
|
|
304
304
|
const SearchEnginePreview = (t0) => {
|
|
305
305
|
const $ = c(17);
|
|
306
|
-
if ($[0] !== "
|
|
306
|
+
if ($[0] !== "dfed49772fc493ebb158f0892caae2776e9f3903bcc54115d8f549c2a9beee89") {
|
|
307
307
|
for (let $i = 0; $i < 17; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
308
|
-
$[0] = "
|
|
308
|
+
$[0] = "dfed49772fc493ebb158f0892caae2776e9f3903bcc54115d8f549c2a9beee89";
|
|
309
309
|
}
|
|
310
310
|
const { page, metaTitle, metaDescription } = t0;
|
|
311
311
|
const url = `${typeof window !== "undefined" ? window.location.origin : ""}${page.fullPath}`;
|
|
@@ -388,9 +388,9 @@ const SearchEnginePreview = (t0) => {
|
|
|
388
388
|
};
|
|
389
389
|
const SocialPreviewSection = (t0) => {
|
|
390
390
|
const $ = c(60);
|
|
391
|
-
if ($[0] !== "
|
|
391
|
+
if ($[0] !== "dfed49772fc493ebb158f0892caae2776e9f3903bcc54115d8f549c2a9beee89") {
|
|
392
392
|
for (let $i = 0; $i < 60; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
393
|
-
$[0] = "
|
|
393
|
+
$[0] = "dfed49772fc493ebb158f0892caae2776e9f3903bcc54115d8f549c2a9beee89";
|
|
394
394
|
}
|
|
395
395
|
const { page, metaTitle, metaDescription, layoutId, projectName } = t0;
|
|
396
396
|
const pageMetaTitle = page.metaTitle ?? page.pathSegment;
|
|
@@ -664,9 +664,9 @@ const SocialPreviewSection = (t0) => {
|
|
|
664
664
|
};
|
|
665
665
|
const PageMarkdownPreview = (t0) => {
|
|
666
666
|
const $ = c(9);
|
|
667
|
-
if ($[0] !== "
|
|
667
|
+
if ($[0] !== "dfed49772fc493ebb158f0892caae2776e9f3903bcc54115d8f549c2a9beee89") {
|
|
668
668
|
for (let $i = 0; $i < 9; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
669
|
-
$[0] = "
|
|
669
|
+
$[0] = "dfed49772fc493ebb158f0892caae2776e9f3903bcc54115d8f549c2a9beee89";
|
|
670
670
|
}
|
|
671
671
|
const { pageId, metaTitle, metaDescription } = t0;
|
|
672
672
|
let t1;
|
|
@@ -10,9 +10,9 @@ import { useQuery } from "@tanstack/react-query";
|
|
|
10
10
|
import * as React from "react";
|
|
11
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
12
|
import { Button } from "@camox/ui/button";
|
|
13
|
+
import { Switch } from "@camox/ui/switch";
|
|
13
14
|
import { Check, ChevronsUpDown } from "lucide-react";
|
|
14
15
|
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@camox/ui/command";
|
|
15
|
-
import { Switch } from "@camox/ui/switch";
|
|
16
16
|
import { Tabs, TabsList, TabsTrigger } from "@camox/ui/tabs";
|
|
17
17
|
|
|
18
18
|
//#region src/features/preview/components/LinkFieldEditor.tsx
|
|
@@ -9,9 +9,9 @@ import * as React from "react";
|
|
|
9
9
|
//#region src/features/preview/components/Overlays.tsx
|
|
10
10
|
const Overlays = (t0) => {
|
|
11
11
|
const $ = c(15);
|
|
12
|
-
if ($[0] !== "
|
|
12
|
+
if ($[0] !== "6b8884e7d682d7edd8d7ea97e0dfb6a690c2fd0b3e00f8e55354ffd5d743702c") {
|
|
13
13
|
for (let $i = 0; $i < 15; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
14
|
-
$[0] = "
|
|
14
|
+
$[0] = "6b8884e7d682d7edd8d7ea97e0dfb6a690c2fd0b3e00f8e55354ffd5d743702c";
|
|
15
15
|
}
|
|
16
16
|
const { iframeElement } = t0;
|
|
17
17
|
const isPageContentSheetOpen = useSelector(previewStore, _temp);
|
|
@@ -26,6 +26,10 @@ const Overlays = (t0) => {
|
|
|
26
26
|
if (!isOverlayMessage(event.data)) return;
|
|
27
27
|
const message = event.data;
|
|
28
28
|
if (message.type === "CAMOX_ADD_BLOCK_REQUEST") {
|
|
29
|
+
if (previewStore.getSnapshot().context.previewSource !== "draft") {
|
|
30
|
+
previewStore.send({ type: "requestDraftSwitch" });
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
29
33
|
const { blockPosition, insertPosition } = message;
|
|
30
34
|
let afterPosition = null;
|
|
31
35
|
if (message.afterPosition !== void 0) afterPosition = message.afterPosition;
|