camox 0.71.0 → 0.72.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/createApp.d.ts +4 -103
- package/dist/core/createApp.js +3 -24
- package/dist/core/createBlock.d.ts +2 -2
- package/dist/core/createBlock.js +41 -185
- package/dist/core/createLayout.d.ts +6 -77
- package/dist/core/createLayout.js +12 -50
- package/dist/core/editing/createEditableBlock.d.ts +9 -75
- package/dist/core/editing/createEditableBlock.js +258 -640
- package/dist/core/hooks/useIsEditable.js +2 -2
- package/dist/core/lib/artifactData.js +8 -3
- package/dist/core/lib/contentType.d.ts +23 -38
- package/dist/core/lib/contentType.js +34 -62
- package/dist/core/lib/iconTypes.d.ts +0 -3
- package/dist/core/lib/icons.js +63 -51
- package/dist/core/lib/recordScope.js +1 -1
- package/dist/features/canvas/CanvasOverlays.js +94 -176
- package/dist/features/canvas/CanvasPageFrame.js +62 -68
- package/dist/features/canvas/CanvasPreviewPageSlot.js +1 -3
- package/dist/features/canvas/canvasOverlayGeometry.js +1 -7
- package/dist/features/canvas/sidebar/CuratedPageInspector.js +3 -21
- package/dist/features/canvas/sidebar/LayoutPageBlocks.js +1 -2
- package/dist/features/canvas/useCanvasCamera.js +1 -1
- package/dist/features/canvas/useCanvasFrame.js +1 -1
- package/dist/features/content/ContentCollection.js +2 -2
- package/dist/features/content/collection-form.js +6 -7
- package/dist/features/page/CuratedPageContent.js +15 -24
- package/dist/features/page/UnplacedBlockContent.js +1 -6
- package/dist/features/preview/CamoxPreview.js +30 -33
- package/dist/features/preview/EditablePageContent.js +131 -151
- package/dist/features/preview/components/BlockActionsPopover.js +43 -152
- package/dist/features/preview/components/CanvasPreview.js +2 -2
- package/dist/features/preview/components/Frame.js +3 -3
- package/dist/features/preview/components/IconFieldEditor.js +1 -1
- package/dist/features/preview/components/ItemFieldsEditor.js +1 -3
- package/dist/features/preview/components/Overlays.js +18 -84
- package/dist/features/preview/components/PageTree.js +57 -103
- package/dist/features/preview/components/PreviewPanel.js +8 -11
- package/dist/features/preview/components/RecordCombobox.js +65 -78
- package/dist/features/preview/components/ReferenceFieldEditor.js +1 -19
- package/dist/features/preview/components/ReferenceListFieldEditor.js +1 -19
- package/dist/features/preview/components/RemovedBlockPlaceholder.js +2 -2
- package/dist/features/preview/components/SelectionEditor.js +5 -4
- package/dist/features/preview/components/useRepeatableItemActions.js +18 -24
- package/dist/features/preview/components/useUpdateBlockPosition.js +1 -1
- package/dist/features/preview/overlayMessages.js +1 -4
- package/dist/features/preview/previewStore.js +3 -23
- package/dist/features/renderer/RendererApp.js +17 -141
- package/dist/features/renderer/definitionAnswers.js +1 -8
- package/dist/features/renderer/rendererHost.js +1 -31
- package/dist/features/renderer/studioConnection.js +1 -25
- package/dist/features/runtime/pageApp.js +1 -1
- package/dist/features/runtime/runtime.js +3 -3
- package/dist/features/studio/components/ThreadMessages.js +89 -22
- package/dist/features/vite/blockBoilerplate.js +1 -1
- package/dist/features/vite/definitionsSync.js +1 -8
- package/dist/lib/queries.js +0 -1
- package/dist/lib/studio-definitions.js +0 -2
- package/dist/lib/studio-reads.js +0 -5
- package/dist/lib/use-thread.js +196 -138
- package/dist/package.js +1 -1
- package/dist/studio-overlays.css +0 -29
- package/dist/studio.css +1 -1
- package/package.json +4 -4
- package/skills/camox/SKILL.md +1 -1
- package/skills/camox/references/artifacts.md +4 -4
- package/skills/camox/references/block-definitions.md +21 -25
- package/skills/camox/references/dom-integrations.md +1 -1
- package/skills/camox/references/layout-definitions.md +3 -12
- package/skills/camox/references/routed-layouts.md +2 -2
- package/skills/camox-expand/SKILL.md +5 -5
- package/skills/camoxify/SKILL.md +4 -4
- package/dist/features/canvas/canvasInsertionSeams.js +0 -44
- package/dist/features/preview/components/AddBlockSheet.js +0 -314
- package/dist/features/preview/components/BlockPeek.js +0 -66
- package/dist/features/preview/components/BlockThumbnail.js +0 -281
- package/dist/features/preview/components/blockGridNavigation.js +0 -15
- package/dist/features/preview/referencePickerFocus.js +0 -29
|
@@ -18,7 +18,7 @@ import { Popover, PopoverContent, PopoverTrigger } from "@camox/ui/popover";
|
|
|
18
18
|
import { Command as Command$1, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut } from "@camox/ui/command";
|
|
19
19
|
|
|
20
20
|
//#region src/features/preview/components/BlockActionsPopover.tsx
|
|
21
|
-
const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "start"
|
|
21
|
+
const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "start" }) => {
|
|
22
22
|
const [blockToDelete, setBlockToDelete] = React.useState(null);
|
|
23
23
|
const page = usePreviewedPage();
|
|
24
24
|
const { pageBlocks } = usePageBlocks(page);
|
|
@@ -45,21 +45,6 @@ const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "sta
|
|
|
45
45
|
toast.error("Could not duplicate block");
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
const handleAddBlockAbove = (block) => {
|
|
49
|
-
if (!page) return;
|
|
50
|
-
const blockIndex = pageBlocks.findIndex((b) => b.id === block.id);
|
|
51
|
-
const afterPosition = blockIndex > 0 ? pageBlocks[blockIndex - 1].position : "";
|
|
52
|
-
previewStore.send({
|
|
53
|
-
type: "openAddBlockSheet",
|
|
54
|
-
afterPosition
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
const handleAddBlockBelow = (block) => {
|
|
58
|
-
previewStore.send({
|
|
59
|
-
type: "openAddBlockSheet",
|
|
60
|
-
afterPosition: block.position
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
48
|
const getBlocksAbove = (block) => {
|
|
64
49
|
if (!page) return [];
|
|
65
50
|
const blockIndex = pageBlocks.findIndex((b) => b.id === block.id);
|
|
@@ -101,97 +86,46 @@ const BlockActionsPopover = ({ block, children, open, onOpenChange, align = "sta
|
|
|
101
86
|
children: /* @__PURE__ */ jsxs(Command$1, { children: [/* @__PURE__ */ jsx(CommandInput, { placeholder: "Search actions..." }), /* @__PURE__ */ jsxs(CommandList, {
|
|
102
87
|
className: "max-h-[350px]",
|
|
103
88
|
children: [
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
previewStore.send({
|
|
107
|
-
type: "openAddBlockSheet",
|
|
108
|
-
afterPosition: ""
|
|
109
|
-
});
|
|
110
|
-
onOpenChange(false);
|
|
111
|
-
},
|
|
112
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
113
|
-
className: "flex items-center gap-2",
|
|
114
|
-
children: [/* @__PURE__ */ jsx("span", { className: "w-4" }), "Add block below"]
|
|
115
|
-
})
|
|
116
|
-
}) }) }),
|
|
117
|
-
isLayoutBlock && layoutSlot === "after" && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsx(CommandItem, {
|
|
89
|
+
/* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsxs(CommandItem, {
|
|
90
|
+
className: "justify-between",
|
|
118
91
|
onSelect: () => {
|
|
119
|
-
|
|
120
|
-
previewStore.send({
|
|
121
|
-
type: "openAddBlockSheet",
|
|
122
|
-
afterPosition: lastPageBlock?.position
|
|
123
|
-
});
|
|
92
|
+
handleDuplicateBlock(block);
|
|
124
93
|
onOpenChange(false);
|
|
125
94
|
},
|
|
126
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
95
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
127
96
|
className: "flex items-center gap-2",
|
|
128
|
-
children: [/* @__PURE__ */ jsx(
|
|
129
|
-
})
|
|
130
|
-
}) })
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
97
|
+
children: [/* @__PURE__ */ jsx(Copy, { className: "h-4 w-4" }), "Duplicate block"]
|
|
98
|
+
}), /* @__PURE__ */ jsx(CommandShortcut, { children: formatShortcut("Mod+D") })]
|
|
99
|
+
}) }),
|
|
100
|
+
/* @__PURE__ */ jsx(CommandSeparator, {}),
|
|
101
|
+
/* @__PURE__ */ jsxs(CommandGroup, { children: [
|
|
102
|
+
/* @__PURE__ */ jsxs(CommandItem, {
|
|
134
103
|
onSelect: () => {
|
|
135
|
-
|
|
104
|
+
handleDeleteBlocksAbove(block);
|
|
136
105
|
onOpenChange(false);
|
|
137
106
|
},
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}), /* @__PURE__ */ jsxs(CommandItem, {
|
|
143
|
-
className: "justify-between",
|
|
107
|
+
disabled: getBlocksAbove(block).length === 0,
|
|
108
|
+
children: [/* @__PURE__ */ jsx("span", { className: "w-4" }), "Delete blocks above"]
|
|
109
|
+
}),
|
|
110
|
+
/* @__PURE__ */ jsxs(CommandItem, {
|
|
144
111
|
onSelect: () => {
|
|
145
|
-
|
|
112
|
+
handleDeleteBlocksBelow(block);
|
|
146
113
|
onOpenChange(false);
|
|
147
114
|
},
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
})] }),
|
|
153
|
-
/* @__PURE__ */ jsx(CommandSeparator, {}),
|
|
154
|
-
/* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsxs(CommandItem, {
|
|
115
|
+
disabled: getBlocksBelow(block).length === 0,
|
|
116
|
+
children: [/* @__PURE__ */ jsx("span", { className: "w-4" }), "Delete blocks below"]
|
|
117
|
+
}),
|
|
118
|
+
/* @__PURE__ */ jsxs(CommandItem, {
|
|
155
119
|
className: "justify-between",
|
|
156
120
|
onSelect: () => {
|
|
157
|
-
|
|
121
|
+
handleDeleteBlock(block);
|
|
158
122
|
onOpenChange(false);
|
|
159
123
|
},
|
|
160
124
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
161
125
|
className: "flex items-center gap-2",
|
|
162
|
-
children: [/* @__PURE__ */ jsx(
|
|
163
|
-
}), /* @__PURE__ */ jsx(CommandShortcut, { children: formatShortcut("Mod+
|
|
164
|
-
})
|
|
165
|
-
/* @__PURE__ */ jsx(CommandSeparator, {}),
|
|
166
|
-
/* @__PURE__ */ jsxs(CommandGroup, { children: [
|
|
167
|
-
/* @__PURE__ */ jsxs(CommandItem, {
|
|
168
|
-
onSelect: () => {
|
|
169
|
-
handleDeleteBlocksAbove(block);
|
|
170
|
-
onOpenChange(false);
|
|
171
|
-
},
|
|
172
|
-
disabled: getBlocksAbove(block).length === 0,
|
|
173
|
-
children: [/* @__PURE__ */ jsx("span", { className: "w-4" }), "Delete blocks above"]
|
|
174
|
-
}),
|
|
175
|
-
/* @__PURE__ */ jsxs(CommandItem, {
|
|
176
|
-
onSelect: () => {
|
|
177
|
-
handleDeleteBlocksBelow(block);
|
|
178
|
-
onOpenChange(false);
|
|
179
|
-
},
|
|
180
|
-
disabled: getBlocksBelow(block).length === 0,
|
|
181
|
-
children: [/* @__PURE__ */ jsx("span", { className: "w-4" }), "Delete blocks below"]
|
|
182
|
-
}),
|
|
183
|
-
/* @__PURE__ */ jsxs(CommandItem, {
|
|
184
|
-
className: "justify-between",
|
|
185
|
-
onSelect: () => {
|
|
186
|
-
handleDeleteBlock(block);
|
|
187
|
-
onOpenChange(false);
|
|
188
|
-
},
|
|
189
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
190
|
-
className: "flex items-center gap-2",
|
|
191
|
-
children: [/* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" }), "Delete block"]
|
|
192
|
-
}), /* @__PURE__ */ jsx(CommandShortcut, { children: formatShortcut("Mod+Backspace") })]
|
|
193
|
-
})
|
|
194
|
-
] })
|
|
126
|
+
children: [/* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" }), "Delete block"]
|
|
127
|
+
}), /* @__PURE__ */ jsx(CommandShortcut, { children: formatShortcut("Mod+Backspace") })]
|
|
128
|
+
})
|
|
195
129
|
] })
|
|
196
130
|
]
|
|
197
131
|
})] })
|
|
@@ -293,12 +227,12 @@ function useBlockActionsShortcuts() {
|
|
|
293
227
|
if (!sel_0) return;
|
|
294
228
|
const itemId_0 = selectionItemId(sel_0);
|
|
295
229
|
if (itemId_0 != null) {
|
|
296
|
-
deleteRepeatableItem({ id: itemId_0 }).then(
|
|
230
|
+
deleteRepeatableItem({ id: itemId_0 }).then(_temp3, _temp4);
|
|
297
231
|
previewStore.send({ type: "selectParent" });
|
|
298
232
|
return;
|
|
299
233
|
}
|
|
300
234
|
const block_0 = pageBlocks.find((b_0) => b_0.id === sel_0.blockId);
|
|
301
|
-
deleteBlock({ id: sel_0.blockId }).then(() => toast.success(`Deleted "${block_0 ? entityName(block_0, block_0.type) : ""}" block`),
|
|
235
|
+
deleteBlock({ id: sel_0.blockId }).then(() => toast.success(`Deleted "${block_0 ? entityName(block_0, block_0.type) : ""}" block`), _temp5);
|
|
302
236
|
previewStore.send({ type: "clearSelection" });
|
|
303
237
|
}
|
|
304
238
|
},
|
|
@@ -320,11 +254,11 @@ function useBlockActionsShortcuts() {
|
|
|
320
254
|
if (!sel_2) return;
|
|
321
255
|
const itemId_1 = selectionItemId(sel_2);
|
|
322
256
|
if (itemId_1 != null) {
|
|
323
|
-
duplicateRepeatableItem({ id: itemId_1 }).then(
|
|
257
|
+
duplicateRepeatableItem({ id: itemId_1 }).then(_temp6, _temp7);
|
|
324
258
|
return;
|
|
325
259
|
}
|
|
326
260
|
const block_1 = pageBlocks.find((b_1) => b_1.id === sel_2.blockId);
|
|
327
|
-
duplicateBlock({ id: sel_2.blockId }).then(() => toast.success(`Duplicated "${block_1 ? entityName(block_1, block_1.type) : ""}" block`),
|
|
261
|
+
duplicateBlock({ id: sel_2.blockId }).then(() => toast.success(`Duplicated "${block_1 ? entityName(block_1, block_1.type) : ""}" block`), _temp8);
|
|
328
262
|
}
|
|
329
263
|
},
|
|
330
264
|
{
|
|
@@ -351,7 +285,7 @@ function useBlockActionsShortcuts() {
|
|
|
351
285
|
id: sel_4.blockId,
|
|
352
286
|
afterPosition,
|
|
353
287
|
beforePosition
|
|
354
|
-
}).then(
|
|
288
|
+
}).then(_temp9, _temp10);
|
|
355
289
|
}
|
|
356
290
|
},
|
|
357
291
|
{
|
|
@@ -379,50 +313,7 @@ function useBlockActionsShortcuts() {
|
|
|
379
313
|
id: sel_6.blockId,
|
|
380
314
|
afterPosition: afterPosition_0,
|
|
381
315
|
beforePosition: beforePosition_0
|
|
382
|
-
}).then(
|
|
383
|
-
}
|
|
384
|
-
},
|
|
385
|
-
{
|
|
386
|
-
id: "add-block-below",
|
|
387
|
-
label: "Add block below",
|
|
388
|
-
groupLabel: "Website",
|
|
389
|
-
shortcut: "O",
|
|
390
|
-
checkIfAvailable: () => {
|
|
391
|
-
const ctx_3 = previewStore.getSnapshot().context;
|
|
392
|
-
if (ctx_3.view !== "canvas") return false;
|
|
393
|
-
return blockSelectionForPage(ctx_3, page.page.id) !== null;
|
|
394
|
-
},
|
|
395
|
-
execute: () => {
|
|
396
|
-
const sel_7 = blockSelectionForPage(previewStore.getSnapshot().context, page.page.id);
|
|
397
|
-
if (!sel_7 || !page) return;
|
|
398
|
-
const block_2 = pageBlocks.find((b_6) => b_6.id === sel_7.blockId);
|
|
399
|
-
if (!block_2) return;
|
|
400
|
-
previewStore.send({
|
|
401
|
-
type: "openAddBlockSheet",
|
|
402
|
-
afterPosition: block_2.position
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
},
|
|
406
|
-
{
|
|
407
|
-
id: "add-block-above",
|
|
408
|
-
label: "Add block above",
|
|
409
|
-
groupLabel: "Website",
|
|
410
|
-
shortcut: "Shift+O",
|
|
411
|
-
checkIfAvailable: () => {
|
|
412
|
-
const ctx_4 = previewStore.getSnapshot().context;
|
|
413
|
-
if (ctx_4.view !== "canvas") return false;
|
|
414
|
-
return blockSelectionForPage(ctx_4, page.page.id) !== null;
|
|
415
|
-
},
|
|
416
|
-
execute: () => {
|
|
417
|
-
const sel_8 = blockSelectionForPage(previewStore.getSnapshot().context, page.page.id);
|
|
418
|
-
if (!sel_8 || !page) return;
|
|
419
|
-
const blockIndex = pageBlocks.findIndex((b_7) => b_7.id === sel_8.blockId);
|
|
420
|
-
if (blockIndex === -1) return;
|
|
421
|
-
const afterPosition_1 = blockIndex > 0 ? pageBlocks[blockIndex - 1].position : "";
|
|
422
|
-
previewStore.send({
|
|
423
|
-
type: "openAddBlockSheet",
|
|
424
|
-
afterPosition: afterPosition_1
|
|
425
|
-
});
|
|
316
|
+
}).then(_temp11, _temp12);
|
|
426
317
|
}
|
|
427
318
|
}
|
|
428
319
|
];
|
|
@@ -433,7 +324,7 @@ function useBlockActionsShortcuts() {
|
|
|
433
324
|
return () => {
|
|
434
325
|
actionsStore.send({
|
|
435
326
|
type: "unregisterManyActions",
|
|
436
|
-
ids: actions.map(
|
|
327
|
+
ids: actions.map(_temp13)
|
|
437
328
|
});
|
|
438
329
|
};
|
|
439
330
|
};
|
|
@@ -470,33 +361,33 @@ function useBlockActionsShortcuts() {
|
|
|
470
361
|
} else t6 = $[22];
|
|
471
362
|
React.useEffect(t5, t6);
|
|
472
363
|
}
|
|
473
|
-
function
|
|
364
|
+
function _temp13(a) {
|
|
474
365
|
return a.id;
|
|
475
366
|
}
|
|
476
|
-
function
|
|
367
|
+
function _temp12() {
|
|
477
368
|
return toast.error("Could not move block");
|
|
478
369
|
}
|
|
479
|
-
function
|
|
480
|
-
function
|
|
370
|
+
function _temp11() {}
|
|
371
|
+
function _temp10() {
|
|
481
372
|
return toast.error("Could not move block");
|
|
482
373
|
}
|
|
483
|
-
function
|
|
484
|
-
function
|
|
374
|
+
function _temp9() {}
|
|
375
|
+
function _temp8() {
|
|
485
376
|
return toast.error("Could not duplicate block");
|
|
486
377
|
}
|
|
487
|
-
function
|
|
378
|
+
function _temp7() {
|
|
488
379
|
return toast.error("Could not duplicate item");
|
|
489
380
|
}
|
|
490
|
-
function
|
|
381
|
+
function _temp6() {
|
|
491
382
|
return toast.success("Duplicated item");
|
|
492
383
|
}
|
|
493
|
-
function
|
|
384
|
+
function _temp5() {
|
|
494
385
|
return toast.error("Could not delete block");
|
|
495
386
|
}
|
|
496
|
-
function
|
|
387
|
+
function _temp4() {
|
|
497
388
|
return toast.error("Could not delete item");
|
|
498
389
|
}
|
|
499
|
-
function
|
|
390
|
+
function _temp3() {
|
|
500
391
|
return toast.success("Deleted item");
|
|
501
392
|
}
|
|
502
393
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CanvasLoadingScreen } from "../../canvas/CanvasLoadingScreen.js";
|
|
2
|
-
import { ViewportContinuity, ViewportContinuityContext } from "../viewportContinuity.js";
|
|
3
|
-
import { PreviewActivationContext } from "./PreviewActivation.js";
|
|
4
2
|
import { PreviewPageFrame, PreviewPageFrameContext } from "../previewPageFrame.js";
|
|
5
3
|
import { PreviewPreparationContext } from "../previewPreparation.js";
|
|
4
|
+
import { ViewportContinuity, ViewportContinuityContext } from "../viewportContinuity.js";
|
|
5
|
+
import { PreviewActivationContext } from "./PreviewActivation.js";
|
|
6
6
|
import { c } from "react/compiler-runtime";
|
|
7
7
|
import * as React from "react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useLocation, useNavigate } from "../../navigation/navigation.js";
|
|
2
2
|
import { cn } from "../../../lib/utils.js";
|
|
3
|
-
import { listenForLinkIntent } from "../../runtime/linkPrefetch.js";
|
|
4
|
-
import { PageViewportContext } from "../../runtime/pageViewport.js";
|
|
5
|
-
import { PreviewDocumentContext } from "../../runtime/PreviewDocumentContext.js";
|
|
6
3
|
import { ViewportContinuityContext, capturePreviewAnchor, restorePreviewAnchor } from "../viewportContinuity.js";
|
|
7
4
|
import { PreviewActivationContext } from "./PreviewActivation.js";
|
|
8
5
|
import { EMPTY_PREVIEW_DOCUMENT, isSiteStyle, restyle } from "./previewStyles.js";
|
|
6
|
+
import { listenForLinkIntent } from "../../runtime/linkPrefetch.js";
|
|
7
|
+
import { PageViewportContext } from "../../runtime/pageViewport.js";
|
|
8
|
+
import { PreviewDocumentContext } from "../../runtime/PreviewDocumentContext.js";
|
|
9
9
|
import { c } from "react/compiler-runtime";
|
|
10
10
|
import * as React from "react";
|
|
11
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -6,8 +6,8 @@ import { Button } from "@camox/ui/button";
|
|
|
6
6
|
import { ChevronsUpDown, SearchIcon } from "lucide-react";
|
|
7
7
|
import { Combobox } from "@base-ui/react/combobox";
|
|
8
8
|
import { Popover, PopoverContent, PopoverTrigger } from "@camox/ui/popover";
|
|
9
|
-
import { commandFilter } from "@camox/ui/command";
|
|
10
9
|
import { InputGroup, InputGroupAddon, InputGroupInput } from "@camox/ui/input-group";
|
|
10
|
+
import { commandFilter } from "@camox/ui/command";
|
|
11
11
|
import { defaultRangeExtractor, useVirtualizer } from "@tanstack/react-virtual";
|
|
12
12
|
|
|
13
13
|
//#region src/features/preview/components/IconFieldEditor.tsx
|
|
@@ -258,7 +258,6 @@ const ItemFieldsEditor = (t0) => {
|
|
|
258
258
|
const renderField = () => {
|
|
259
259
|
if (field_0.fieldType === "Reference" && field_0.collectionId) return /* @__PURE__ */ jsx(ReferenceFieldEditor, {
|
|
260
260
|
collectionId: field_0.collectionId,
|
|
261
|
-
fieldId: fieldId_1,
|
|
262
261
|
value: data[field_0.name],
|
|
263
262
|
required: field_0.required,
|
|
264
263
|
record: singleReference(references, field_0.name),
|
|
@@ -273,7 +272,6 @@ const ItemFieldsEditor = (t0) => {
|
|
|
273
272
|
}, field_0.name);
|
|
274
273
|
if (field_0.fieldType === "ReferenceList" && field_0.collectionId) return /* @__PURE__ */ jsx(ReferenceListFieldEditor, {
|
|
275
274
|
collectionId: field_0.collectionId,
|
|
276
|
-
fieldId: fieldId_1,
|
|
277
275
|
value: data[field_0.name],
|
|
278
276
|
maxItems: field_0.maxItems,
|
|
279
277
|
query: field_0.query,
|
|
@@ -358,7 +356,7 @@ const ItemFieldsEditor = (t0) => {
|
|
|
358
356
|
}, field_0.name);
|
|
359
357
|
}
|
|
360
358
|
if (field_0.fieldType === "Icon") return /* @__PURE__ */ jsx(IconFieldEditor, {
|
|
361
|
-
value:
|
|
359
|
+
value: typeof data[field_0.name] === "string" ? data[field_0.name] : "",
|
|
362
360
|
ids: field_0.enumValues ?? [],
|
|
363
361
|
onChange: (value_3) => onFieldChange(field_0.name, value_3)
|
|
364
362
|
}, field_0.name);
|
|
@@ -1,69 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { previewStore, selectIsCanvasShown, selectionForOwner } from "../previewStore.js";
|
|
1
|
+
import { previewStore, selectionForOwner } from "../previewStore.js";
|
|
3
2
|
import { useEditingFrame } from "../editingFrame.js";
|
|
4
|
-
import {
|
|
5
|
-
import { usePreviewedPage } from "../CamoxPreview.js";
|
|
3
|
+
import { overlayFieldId, recordFieldId } from "../overlayMessages.js";
|
|
6
4
|
import { c } from "react/compiler-runtime";
|
|
7
5
|
import * as React from "react";
|
|
8
|
-
import { jsx } from "react/jsx-runtime";
|
|
9
6
|
import { useSelector } from "@xstate/store-react";
|
|
10
7
|
|
|
11
8
|
//#region src/features/preview/components/Overlays.tsx
|
|
12
|
-
function CuratedAddBlockListener(t0) {
|
|
13
|
-
const $ = c(5);
|
|
14
|
-
const { frame } = t0;
|
|
15
|
-
const page = usePreviewedPage();
|
|
16
|
-
const { pageBlocks } = usePageBlocks(page);
|
|
17
|
-
const { document: editingDocument } = useEditingFrame();
|
|
18
|
-
const isEditingFrame = !!editingDocument && editingDocument === frame?.contentDocument;
|
|
19
|
-
let t1;
|
|
20
|
-
let t2;
|
|
21
|
-
if ($[0] !== isEditingFrame || $[1] !== page.page.id || $[2] !== pageBlocks) {
|
|
22
|
-
t1 = () => {
|
|
23
|
-
const handleMessage = (event) => {
|
|
24
|
-
if (!isOverlayMessage(event.data)) return;
|
|
25
|
-
const message = event.data;
|
|
26
|
-
if (message.type === "CAMOX_ADD_BLOCK_REQUEST") {
|
|
27
|
-
const snapshot = previewStore.getSnapshot();
|
|
28
|
-
if (!selectIsCanvasShown(snapshot)) return;
|
|
29
|
-
if (!isEditingFrame) return;
|
|
30
|
-
const owner = snapshot.context.editingContext;
|
|
31
|
-
if (owner?.kind !== "page" || owner.pageId !== page.page.id) return;
|
|
32
|
-
const { blockPosition, insertPosition } = message;
|
|
33
|
-
let afterPosition = null;
|
|
34
|
-
if (message.afterPosition !== void 0) afterPosition = message.afterPosition;
|
|
35
|
-
else if (insertPosition === "after") afterPosition = blockPosition;
|
|
36
|
-
else {
|
|
37
|
-
const blockIndex = pageBlocks.findIndex((b) => b.position === blockPosition);
|
|
38
|
-
if (blockIndex > 0) afterPosition = pageBlocks[blockIndex - 1].position ?? null;
|
|
39
|
-
else if (blockIndex === 0) afterPosition = "";
|
|
40
|
-
}
|
|
41
|
-
previewStore.send({
|
|
42
|
-
type: "openAddBlockSheet",
|
|
43
|
-
afterPosition
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
window.addEventListener("message", handleMessage);
|
|
48
|
-
return () => window.removeEventListener("message", handleMessage);
|
|
49
|
-
};
|
|
50
|
-
t2 = [
|
|
51
|
-
pageBlocks,
|
|
52
|
-
page.page.id,
|
|
53
|
-
isEditingFrame
|
|
54
|
-
];
|
|
55
|
-
$[0] = isEditingFrame;
|
|
56
|
-
$[1] = page.page.id;
|
|
57
|
-
$[2] = pageBlocks;
|
|
58
|
-
$[3] = t1;
|
|
59
|
-
$[4] = t2;
|
|
60
|
-
} else {
|
|
61
|
-
t1 = $[3];
|
|
62
|
-
t2 = $[4];
|
|
63
|
-
}
|
|
64
|
-
React.useEffect(t1, t2);
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
9
|
/** The field ID of a selected String field; only those are focused in the page. */
|
|
68
10
|
function stringFieldId(selection) {
|
|
69
11
|
if (!selection) return null;
|
|
@@ -75,22 +17,21 @@ function stringFieldId(selection) {
|
|
|
75
17
|
}
|
|
76
18
|
}
|
|
77
19
|
const Overlays = (t0) => {
|
|
78
|
-
const $ = c(
|
|
79
|
-
const { frame,
|
|
80
|
-
|
|
81
|
-
let t2;
|
|
20
|
+
const $ = c(7);
|
|
21
|
+
const { frame, owner } = t0;
|
|
22
|
+
let t1;
|
|
82
23
|
if ($[0] !== owner) {
|
|
83
|
-
|
|
24
|
+
t1 = (state) => selectionForOwner(state.context, owner);
|
|
84
25
|
$[0] = owner;
|
|
85
|
-
$[1] =
|
|
86
|
-
} else
|
|
87
|
-
const selection = useSelector(previewStore,
|
|
26
|
+
$[1] = t1;
|
|
27
|
+
} else t1 = $[1];
|
|
28
|
+
const selection = useSelector(previewStore, t1);
|
|
88
29
|
const { document: editingDocument, send } = useEditingFrame();
|
|
89
30
|
const isEditingFrame = !!editingDocument && editingDocument === frame?.contentDocument;
|
|
31
|
+
let t2;
|
|
90
32
|
let t3;
|
|
91
|
-
let t4;
|
|
92
33
|
if ($[2] !== isEditingFrame || $[3] !== selection || $[4] !== send) {
|
|
93
|
-
|
|
34
|
+
t2 = () => {
|
|
94
35
|
const fieldId = stringFieldId(selection);
|
|
95
36
|
if (!fieldId || !isEditingFrame) return;
|
|
96
37
|
send({
|
|
@@ -98,7 +39,7 @@ const Overlays = (t0) => {
|
|
|
98
39
|
fieldId
|
|
99
40
|
});
|
|
100
41
|
};
|
|
101
|
-
|
|
42
|
+
t3 = [
|
|
102
43
|
selection,
|
|
103
44
|
isEditingFrame,
|
|
104
45
|
send
|
|
@@ -106,21 +47,14 @@ const Overlays = (t0) => {
|
|
|
106
47
|
$[2] = isEditingFrame;
|
|
107
48
|
$[3] = selection;
|
|
108
49
|
$[4] = send;
|
|
109
|
-
$[5] =
|
|
110
|
-
$[6] =
|
|
50
|
+
$[5] = t2;
|
|
51
|
+
$[6] = t3;
|
|
111
52
|
} else {
|
|
112
|
-
|
|
113
|
-
|
|
53
|
+
t2 = $[5];
|
|
54
|
+
t3 = $[6];
|
|
114
55
|
}
|
|
115
|
-
React.useEffect(
|
|
116
|
-
|
|
117
|
-
if ($[7] !== canAddBlocks || $[8] !== frame) {
|
|
118
|
-
t5 = canAddBlocks ? /* @__PURE__ */ jsx(CuratedAddBlockListener, { frame }) : null;
|
|
119
|
-
$[7] = canAddBlocks;
|
|
120
|
-
$[8] = frame;
|
|
121
|
-
$[9] = t5;
|
|
122
|
-
} else t5 = $[9];
|
|
123
|
-
return t5;
|
|
56
|
+
React.useEffect(t2, t3);
|
|
57
|
+
return null;
|
|
124
58
|
};
|
|
125
59
|
|
|
126
60
|
//#endregion
|