camox 0.41.0 → 0.41.1
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 +2 -2
- package/dist/core/createBlock.js +11 -25
- package/dist/core/createLayout.d.ts +1 -1
- package/dist/core/editing/BlockEditingRuntime.js +4 -4
- package/dist/core/editing/CompleteBlockEditingRuntime.js +5 -5
- package/dist/core/editing/createEditableBlock.js +169 -306
- package/dist/core/hooks/useIsEditable.js +4 -7
- package/dist/core/hooks/useRequireDraftSource.js +7 -11
- package/dist/features/preview/CamoxPreview.js +59 -80
- package/dist/features/preview/DerivedPreview.js +6 -9
- package/dist/features/preview/components/BlockActionsPopover.js +8 -8
- package/dist/features/preview/components/DerivedLayoutSidebar.js +4 -7
- package/dist/features/preview/components/LinkFieldEditor.js +3 -4
- package/dist/features/preview/components/MobilePreviewDrawer.js +3 -3
- package/dist/features/preview/components/Overlays.js +6 -9
- package/dist/features/preview/components/PageEditorSidebar.js +194 -203
- package/dist/features/preview/components/PageTree.js +162 -228
- package/dist/features/preview/components/PreviewPanel.js +39 -41
- package/dist/features/preview/components/PreviewToolbar.js +15 -18
- package/dist/features/preview/components/PreviewToolbarSpacer.js +43 -0
- package/dist/features/preview/components/PublicationRow.js +11 -17
- package/dist/features/preview/previewStore.js +18 -29
- package/dist/features/provider/useAdminShortcuts.js +5 -4
- package/dist/features/runtime/RuntimeChrome.js +98 -86
- package/dist/features/studio/components/UserButton.js +4 -4
- package/package.json +4 -4
- package/dist/features/preview/components/DraftSwitchDialog.js +0 -66
|
@@ -98,7 +98,6 @@ const PageEditorSidebar = () => {
|
|
|
98
98
|
const requireDraft = useRequireDraftSource();
|
|
99
99
|
const selection = useSelector(previewStore, (state) => state.context.selection);
|
|
100
100
|
const iframeElement = useSelector(previewStore, (state_0) => state_0.context.iframeElement);
|
|
101
|
-
const isReadOnly = useSelector(previewStore, (state_1) => state_1.context.previewSource) !== "draft";
|
|
102
101
|
const postToIframe = React.useCallback((message) => {
|
|
103
102
|
if (!iframeElement?.contentWindow) return;
|
|
104
103
|
iframeElement.contentWindow.postMessage(message, "*");
|
|
@@ -359,213 +358,205 @@ const PageEditorSidebar = () => {
|
|
|
359
358
|
})
|
|
360
359
|
})
|
|
361
360
|
})
|
|
362
|
-
}), /* @__PURE__ */
|
|
361
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
363
362
|
className: "relative flex-1 overflow-auto",
|
|
364
|
-
children:
|
|
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
|
-
sessionDirtyRef.current = true;
|
|
395
|
-
updateSettings.mutate({
|
|
396
|
-
id: block.id,
|
|
397
|
-
settings: { [field.name]: newValue }
|
|
398
|
-
});
|
|
399
|
-
},
|
|
400
|
-
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
401
|
-
id: `setting-${field.name}`,
|
|
402
|
-
children: /* @__PURE__ */ jsx(SelectValue, {})
|
|
403
|
-
}), /* @__PURE__ */ jsx(SelectContent, { children: field.enumValues?.map((enumValue) => /* @__PURE__ */ jsx(SelectItem, {
|
|
404
|
-
value: enumValue,
|
|
405
|
-
children: field.enumLabels?.[enumValue] ?? enumValue
|
|
406
|
-
}, enumValue)) })]
|
|
407
|
-
})]
|
|
408
|
-
}, field.name);
|
|
409
|
-
}
|
|
410
|
-
if (field.fieldType === "Boolean") {
|
|
411
|
-
const checked = settingsValues[field.name] ?? (blockDef._internal.settingsSchema?.properties?.[field.name])?.default ?? false;
|
|
412
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
413
|
-
className: "flex items-center justify-between",
|
|
414
|
-
children: [/* @__PURE__ */ jsx(Label, {
|
|
415
|
-
htmlFor: `setting-${field.name}`,
|
|
416
|
-
children: label
|
|
417
|
-
}), /* @__PURE__ */ jsx(Switch, {
|
|
363
|
+
children: /* @__PURE__ */ jsx("div", { children: isItemLoading ? /* @__PURE__ */ jsx("div", {
|
|
364
|
+
className: "flex h-full items-center justify-center py-12",
|
|
365
|
+
children: /* @__PURE__ */ jsx(Spinner, {})
|
|
366
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
367
|
+
currentItemId == null && !fieldHasOwnView && settingsFields.length > 0 && /* @__PURE__ */ jsxs("div", {
|
|
368
|
+
className: "border-border space-y-4 border-b px-2 py-4",
|
|
369
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
370
|
+
className: "text-muted-foreground",
|
|
371
|
+
children: "Settings"
|
|
372
|
+
}), settingsFields.map((field) => {
|
|
373
|
+
const label = field.label ?? formatFieldName(field.name);
|
|
374
|
+
const settingsValues = block.settings ?? {};
|
|
375
|
+
if (field.fieldType === "Enum") {
|
|
376
|
+
const value_3 = settingsValues[field.name] ?? (blockDef._internal.settingsSchema?.properties?.[field.name])?.default ?? "";
|
|
377
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
378
|
+
className: "space-y-2",
|
|
379
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
380
|
+
htmlFor: `setting-${field.name}`,
|
|
381
|
+
children: label
|
|
382
|
+
}), /* @__PURE__ */ jsxs(Select, {
|
|
383
|
+
value: value_3,
|
|
384
|
+
onValueChange: (newValue) => {
|
|
385
|
+
if (!requireDraft()) return;
|
|
386
|
+
sessionDirtyRef.current = true;
|
|
387
|
+
updateSettings.mutate({
|
|
388
|
+
id: block.id,
|
|
389
|
+
settings: { [field.name]: newValue }
|
|
390
|
+
});
|
|
391
|
+
},
|
|
392
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
418
393
|
id: `setting-${field.name}`,
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
394
|
+
children: /* @__PURE__ */ jsx(SelectValue, {})
|
|
395
|
+
}), /* @__PURE__ */ jsx(SelectContent, { children: field.enumValues?.map((enumValue) => /* @__PURE__ */ jsx(SelectItem, {
|
|
396
|
+
value: enumValue,
|
|
397
|
+
children: field.enumLabels?.[enumValue] ?? enumValue
|
|
398
|
+
}, enumValue)) })]
|
|
399
|
+
})]
|
|
400
|
+
}, field.name);
|
|
401
|
+
}
|
|
402
|
+
if (field.fieldType === "Boolean") {
|
|
403
|
+
const checked = settingsValues[field.name] ?? (blockDef._internal.settingsSchema?.properties?.[field.name])?.default ?? false;
|
|
404
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
405
|
+
className: "flex items-center justify-between",
|
|
406
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
407
|
+
htmlFor: `setting-${field.name}`,
|
|
408
|
+
children: label
|
|
409
|
+
}), /* @__PURE__ */ jsx(Switch, {
|
|
410
|
+
id: `setting-${field.name}`,
|
|
411
|
+
checked,
|
|
412
|
+
onCheckedChange: (newValue_0) => {
|
|
413
|
+
if (!requireDraft()) return;
|
|
414
|
+
sessionDirtyRef.current = true;
|
|
415
|
+
updateSettings.mutate({
|
|
416
|
+
id: block.id,
|
|
417
|
+
settings: { [field.name]: newValue_0 }
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
})]
|
|
421
|
+
}, field.name);
|
|
422
|
+
}
|
|
423
|
+
return null;
|
|
424
|
+
})]
|
|
425
|
+
}),
|
|
426
|
+
currentItemId != null && !fieldHasOwnView && itemSettingsFields.length > 0 && /* @__PURE__ */ jsxs("div", {
|
|
427
|
+
className: "border-border space-y-4 border-b px-2 py-4",
|
|
428
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
429
|
+
className: "text-muted-foreground",
|
|
430
|
+
children: "Settings"
|
|
431
|
+
}), itemSettingsFields.map((field_0) => {
|
|
432
|
+
const label_0 = field_0.label ?? formatFieldName(field_0.name);
|
|
433
|
+
const itemSettingsValues = currentItem?.settings ?? {};
|
|
434
|
+
const itemSettingsSchemaProps = itemArraySchema?.itemSettingsSchema?.properties;
|
|
435
|
+
if (field_0.fieldType === "Enum") {
|
|
436
|
+
const value_4 = itemSettingsValues[field_0.name] ?? itemSettingsSchemaProps?.[field_0.name]?.default ?? "";
|
|
437
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
438
|
+
className: "space-y-2",
|
|
439
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
440
|
+
htmlFor: `item-setting-${field_0.name}`,
|
|
441
|
+
children: label_0
|
|
442
|
+
}), /* @__PURE__ */ jsxs(Select, {
|
|
443
|
+
value: value_4,
|
|
444
|
+
onValueChange: (newValue_1) => {
|
|
445
|
+
if (!requireDraft()) return;
|
|
446
|
+
sessionDirtyRef.current = true;
|
|
447
|
+
updateRepeatableSettings.mutate({
|
|
448
|
+
id: currentItemId,
|
|
449
|
+
settings: { [field_0.name]: newValue_1 }
|
|
450
|
+
});
|
|
451
|
+
},
|
|
452
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
478
453
|
id: `item-setting-${field_0.name}`,
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
454
|
+
children: /* @__PURE__ */ jsx(SelectValue, {})
|
|
455
|
+
}), /* @__PURE__ */ jsx(SelectContent, { children: field_0.enumValues?.map((enumValue_0) => /* @__PURE__ */ jsx(SelectItem, {
|
|
456
|
+
value: enumValue_0,
|
|
457
|
+
children: field_0.enumLabels?.[enumValue_0] ?? enumValue_0
|
|
458
|
+
}, enumValue_0)) })]
|
|
459
|
+
})]
|
|
460
|
+
}, field_0.name);
|
|
461
|
+
}
|
|
462
|
+
if (field_0.fieldType === "Boolean") {
|
|
463
|
+
const checked_0 = itemSettingsValues[field_0.name] ?? itemSettingsSchemaProps?.[field_0.name]?.default ?? false;
|
|
464
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
465
|
+
className: "flex items-center justify-between",
|
|
466
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
467
|
+
htmlFor: `item-setting-${field_0.name}`,
|
|
468
|
+
children: label_0
|
|
469
|
+
}), /* @__PURE__ */ jsx(Switch, {
|
|
470
|
+
id: `item-setting-${field_0.name}`,
|
|
471
|
+
checked: checked_0,
|
|
472
|
+
onCheckedChange: (newValue_2) => {
|
|
473
|
+
if (!requireDraft()) return;
|
|
474
|
+
sessionDirtyRef.current = true;
|
|
475
|
+
updateRepeatableSettings.mutate({
|
|
476
|
+
id: currentItemId,
|
|
477
|
+
settings: { [field_0.name]: newValue_2 }
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
})]
|
|
481
|
+
}, field_0.name);
|
|
482
|
+
}
|
|
483
|
+
return null;
|
|
484
|
+
})]
|
|
485
|
+
}),
|
|
486
|
+
isViewingAsset && assetFieldName && isMultipleAsset && /* @__PURE__ */ jsx(MultipleAssetFieldEditor, {
|
|
487
|
+
fieldName: assetFieldName,
|
|
488
|
+
assetType,
|
|
489
|
+
currentData,
|
|
490
|
+
onFieldChange: activeFieldChangeHandler
|
|
491
|
+
}),
|
|
492
|
+
isViewingAsset && assetFieldName && !isMultipleAsset && /* @__PURE__ */ jsx(SingleAssetFieldEditor, {
|
|
493
|
+
fieldName: assetFieldName,
|
|
494
|
+
assetType,
|
|
495
|
+
currentData,
|
|
496
|
+
onFieldChange: activeFieldChangeHandler
|
|
497
|
+
}),
|
|
498
|
+
!isViewingAsset && isViewingLink && linkFieldName && /* @__PURE__ */ jsx("div", {
|
|
499
|
+
className: "px-2 py-4",
|
|
500
|
+
children: /* @__PURE__ */ jsx(LinkFieldEditor, {
|
|
501
|
+
fieldName: linkFieldName,
|
|
502
|
+
linkValue: currentData[linkFieldName] ?? {
|
|
503
|
+
type: "external",
|
|
504
|
+
text: "",
|
|
505
|
+
href: "",
|
|
506
|
+
newTab: false
|
|
507
|
+
},
|
|
508
|
+
onSave: (fieldName_1, value_5) => {
|
|
509
|
+
activeFieldChangeHandler(fieldName_1, value_5);
|
|
510
|
+
}
|
|
511
|
+
})
|
|
512
|
+
}),
|
|
513
|
+
!isViewingAsset && !isViewingLink && (currentItemId == null || currentItem) && /* @__PURE__ */ jsx(ItemFieldsEditor, {
|
|
514
|
+
schema: currentSchema,
|
|
515
|
+
data: currentData,
|
|
516
|
+
blockId: block.id,
|
|
517
|
+
itemId: currentItemId ?? void 0,
|
|
518
|
+
onFieldChange: activeFieldChangeHandler,
|
|
519
|
+
postToIframe,
|
|
520
|
+
filesMap,
|
|
521
|
+
itemsMap,
|
|
522
|
+
fieldIdPrefix
|
|
523
|
+
}, currentItemId ?? `block-${block.id}`),
|
|
524
|
+
!isViewingAsset && !isViewingLink && currentItemId != null && currentItem && /* @__PURE__ */ jsxs("div", {
|
|
525
|
+
className: "border-border flex items-center gap-1 border-t px-2 py-4",
|
|
526
|
+
children: [
|
|
527
|
+
canAddSibling && /* @__PURE__ */ jsxs(Button, {
|
|
528
|
+
type: "button",
|
|
529
|
+
variant: "ghost",
|
|
530
|
+
size: "sm",
|
|
531
|
+
className: "text-muted-foreground justify-start",
|
|
532
|
+
onClick: () => {
|
|
533
|
+
if (!requireDraft()) return;
|
|
534
|
+
addSibling({ afterPosition: currentItem.position });
|
|
515
535
|
},
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
536
|
+
children: [/* @__PURE__ */ jsx(CirclePlus, { className: "h-4 w-4" }), "Add item"]
|
|
537
|
+
}),
|
|
538
|
+
canRemoveCurrent && /* @__PURE__ */ jsxs(Button, {
|
|
539
|
+
type: "button",
|
|
540
|
+
variant: "ghost",
|
|
541
|
+
size: "sm",
|
|
542
|
+
className: "text-muted-foreground justify-start",
|
|
543
|
+
onClick: () => {
|
|
544
|
+
if (!requireDraft()) return;
|
|
545
|
+
removeCurrent(currentItemId, { onSuccess: () => previewStore.send({ type: "selectParent" }) });
|
|
546
|
+
},
|
|
547
|
+
children: [/* @__PURE__ */ jsx(CircleMinus, { className: "h-4 w-4" }), "Remove item"]
|
|
548
|
+
}),
|
|
549
|
+
/* @__PURE__ */ jsxs(Button, {
|
|
550
|
+
type: "button",
|
|
551
|
+
variant: "ghost",
|
|
552
|
+
size: "sm",
|
|
553
|
+
className: "text-muted-foreground justify-start",
|
|
554
|
+
onClick: () => previewStore.send({ type: "selectParent" }),
|
|
555
|
+
children: [/* @__PURE__ */ jsx(CornerLeftUp, { className: "h-4 w-4" }), "Select parent"]
|
|
519
556
|
})
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
data: currentData,
|
|
524
|
-
blockId: block.id,
|
|
525
|
-
itemId: currentItemId ?? void 0,
|
|
526
|
-
onFieldChange: activeFieldChangeHandler,
|
|
527
|
-
postToIframe,
|
|
528
|
-
filesMap,
|
|
529
|
-
itemsMap,
|
|
530
|
-
fieldIdPrefix
|
|
531
|
-
}, currentItemId ?? `block-${block.id}`),
|
|
532
|
-
!isViewingAsset && !isViewingLink && currentItemId != null && currentItem && /* @__PURE__ */ jsxs("div", {
|
|
533
|
-
className: "border-border flex items-center gap-1 border-t px-2 py-4",
|
|
534
|
-
children: [
|
|
535
|
-
canAddSibling && /* @__PURE__ */ jsxs(Button, {
|
|
536
|
-
type: "button",
|
|
537
|
-
variant: "ghost",
|
|
538
|
-
size: "sm",
|
|
539
|
-
className: "text-muted-foreground justify-start",
|
|
540
|
-
onClick: () => {
|
|
541
|
-
if (!requireDraft()) return;
|
|
542
|
-
addSibling({ afterPosition: currentItem.position });
|
|
543
|
-
},
|
|
544
|
-
children: [/* @__PURE__ */ jsx(CirclePlus, { className: "h-4 w-4" }), "Add item"]
|
|
545
|
-
}),
|
|
546
|
-
canRemoveCurrent && /* @__PURE__ */ jsxs(Button, {
|
|
547
|
-
type: "button",
|
|
548
|
-
variant: "ghost",
|
|
549
|
-
size: "sm",
|
|
550
|
-
className: "text-muted-foreground justify-start",
|
|
551
|
-
onClick: () => {
|
|
552
|
-
if (!requireDraft()) return;
|
|
553
|
-
removeCurrent(currentItemId, { onSuccess: () => previewStore.send({ type: "selectParent" }) });
|
|
554
|
-
},
|
|
555
|
-
children: [/* @__PURE__ */ jsx(CircleMinus, { className: "h-4 w-4" }), "Remove item"]
|
|
556
|
-
}),
|
|
557
|
-
/* @__PURE__ */ jsxs(Button, {
|
|
558
|
-
type: "button",
|
|
559
|
-
variant: "ghost",
|
|
560
|
-
size: "sm",
|
|
561
|
-
className: "text-muted-foreground justify-start",
|
|
562
|
-
onClick: () => previewStore.send({ type: "selectParent" }),
|
|
563
|
-
children: [/* @__PURE__ */ jsx(CornerLeftUp, { className: "h-4 w-4" }), "Select parent"]
|
|
564
|
-
})
|
|
565
|
-
]
|
|
566
|
-
})
|
|
567
|
-
] })
|
|
568
|
-
})]
|
|
557
|
+
]
|
|
558
|
+
})
|
|
559
|
+
] }) })
|
|
569
560
|
})] });
|
|
570
561
|
};
|
|
571
562
|
|