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.
Files changed (77) hide show
  1. package/dist/core/createApp.d.ts +4 -103
  2. package/dist/core/createApp.js +3 -24
  3. package/dist/core/createBlock.d.ts +2 -2
  4. package/dist/core/createBlock.js +41 -185
  5. package/dist/core/createLayout.d.ts +6 -77
  6. package/dist/core/createLayout.js +12 -50
  7. package/dist/core/editing/createEditableBlock.d.ts +9 -75
  8. package/dist/core/editing/createEditableBlock.js +258 -640
  9. package/dist/core/hooks/useIsEditable.js +2 -2
  10. package/dist/core/lib/artifactData.js +8 -3
  11. package/dist/core/lib/contentType.d.ts +23 -38
  12. package/dist/core/lib/contentType.js +34 -62
  13. package/dist/core/lib/iconTypes.d.ts +0 -3
  14. package/dist/core/lib/icons.js +63 -51
  15. package/dist/core/lib/recordScope.js +1 -1
  16. package/dist/features/canvas/CanvasOverlays.js +94 -176
  17. package/dist/features/canvas/CanvasPageFrame.js +62 -68
  18. package/dist/features/canvas/CanvasPreviewPageSlot.js +1 -3
  19. package/dist/features/canvas/canvasOverlayGeometry.js +1 -7
  20. package/dist/features/canvas/sidebar/CuratedPageInspector.js +3 -21
  21. package/dist/features/canvas/sidebar/LayoutPageBlocks.js +1 -2
  22. package/dist/features/canvas/useCanvasCamera.js +1 -1
  23. package/dist/features/canvas/useCanvasFrame.js +1 -1
  24. package/dist/features/content/ContentCollection.js +2 -2
  25. package/dist/features/content/collection-form.js +6 -7
  26. package/dist/features/page/CuratedPageContent.js +15 -24
  27. package/dist/features/page/UnplacedBlockContent.js +1 -6
  28. package/dist/features/preview/CamoxPreview.js +30 -33
  29. package/dist/features/preview/EditablePageContent.js +131 -151
  30. package/dist/features/preview/components/BlockActionsPopover.js +43 -152
  31. package/dist/features/preview/components/CanvasPreview.js +2 -2
  32. package/dist/features/preview/components/Frame.js +3 -3
  33. package/dist/features/preview/components/IconFieldEditor.js +1 -1
  34. package/dist/features/preview/components/ItemFieldsEditor.js +1 -3
  35. package/dist/features/preview/components/Overlays.js +18 -84
  36. package/dist/features/preview/components/PageTree.js +57 -103
  37. package/dist/features/preview/components/PreviewPanel.js +8 -11
  38. package/dist/features/preview/components/RecordCombobox.js +65 -78
  39. package/dist/features/preview/components/ReferenceFieldEditor.js +1 -19
  40. package/dist/features/preview/components/ReferenceListFieldEditor.js +1 -19
  41. package/dist/features/preview/components/RemovedBlockPlaceholder.js +2 -2
  42. package/dist/features/preview/components/SelectionEditor.js +5 -4
  43. package/dist/features/preview/components/useRepeatableItemActions.js +18 -24
  44. package/dist/features/preview/components/useUpdateBlockPosition.js +1 -1
  45. package/dist/features/preview/overlayMessages.js +1 -4
  46. package/dist/features/preview/previewStore.js +3 -23
  47. package/dist/features/renderer/RendererApp.js +17 -141
  48. package/dist/features/renderer/definitionAnswers.js +1 -8
  49. package/dist/features/renderer/rendererHost.js +1 -31
  50. package/dist/features/renderer/studioConnection.js +1 -25
  51. package/dist/features/runtime/pageApp.js +1 -1
  52. package/dist/features/runtime/runtime.js +3 -3
  53. package/dist/features/studio/components/ThreadMessages.js +89 -22
  54. package/dist/features/vite/blockBoilerplate.js +1 -1
  55. package/dist/features/vite/definitionsSync.js +1 -8
  56. package/dist/lib/queries.js +0 -1
  57. package/dist/lib/studio-definitions.js +0 -2
  58. package/dist/lib/studio-reads.js +0 -5
  59. package/dist/lib/use-thread.js +196 -138
  60. package/dist/package.js +1 -1
  61. package/dist/studio-overlays.css +0 -29
  62. package/dist/studio.css +1 -1
  63. package/package.json +4 -4
  64. package/skills/camox/SKILL.md +1 -1
  65. package/skills/camox/references/artifacts.md +4 -4
  66. package/skills/camox/references/block-definitions.md +21 -25
  67. package/skills/camox/references/dom-integrations.md +1 -1
  68. package/skills/camox/references/layout-definitions.md +3 -12
  69. package/skills/camox/references/routed-layouts.md +2 -2
  70. package/skills/camox-expand/SKILL.md +5 -5
  71. package/skills/camoxify/SKILL.md +4 -4
  72. package/dist/features/canvas/canvasInsertionSeams.js +0 -44
  73. package/dist/features/preview/components/AddBlockSheet.js +0 -314
  74. package/dist/features/preview/components/BlockPeek.js +0 -66
  75. package/dist/features/preview/components/BlockThumbnail.js +0 -281
  76. package/dist/features/preview/components/blockGridNavigation.js +0 -15
  77. package/dist/features/preview/referencePickerFocus.js +0 -29
@@ -1,6 +1,6 @@
1
1
  import { artifactFrameProps, artifactPlaceholderProps, artifactStandInProps, isArtifactSource } from "../lib/artifact.js";
2
2
  import { artifactData } from "../lib/artifactData.js";
3
- import { resolveBlockFields, resolveToMarkdown, resolveToStructuredData, resolveToTitle } from "../lib/contentType.js";
3
+ import { placeholderImage, resolveBlockFields, resolveToMarkdown, resolveToStructuredData, resolveToTitle } from "../lib/contentType.js";
4
4
  import { useLocation, useNavigate } from "../../features/navigation/navigation.js";
5
5
  import { useOptionalCamoxApp } from "../../features/provider/components/CamoxAppContext.js";
6
6
  import { useProjectUuid } from "../../lib/auth.js";
@@ -12,7 +12,6 @@ import { renderImagePlaceholder } from "../lib/imagePlaceholder.js";
12
12
  import { buildImageSrcSet, getDefaultImageSizes, getDefaultImageWidth, transformImageUrl } from "../lib/imageTransform.js";
13
13
  import { markdownToReactNodes } from "../lib/lexicalReact.js";
14
14
  import { resolveReference, resolveReferenceList } from "../lib/reference.js";
15
- import { referencePickerFocus } from "../../features/preview/referencePickerFocus.js";
16
15
  import { selectionBlockId } from "../../features/preview/previewStore.js";
17
16
  import { overlayFieldId, recordPlacementId } from "../../features/preview/overlayMessages.js";
18
17
  import { useIsEditable } from "../hooks/useIsEditable.js";
@@ -29,9 +28,8 @@ import { useOverlayMessage } from "../hooks/useOverlayMessage.js";
29
28
  import { useOverlayState } from "../hooks/useOverlayState.js";
30
29
  import { c } from "react/compiler-runtime";
31
30
  import * as React from "react";
32
- import { isQueryBacked } from "@camox/api-contract";
31
+ import { emptyFieldValues, isQueryBacked } from "@camox/api-contract";
33
32
  import { Type } from "@sinclair/typebox";
34
- import { generateKeyBetween } from "fractional-indexing";
35
33
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
36
34
 
37
35
  //#region src/core/editing/createEditableBlock.tsx
@@ -67,97 +65,6 @@ const resolveLinkHref = (link, pages, currentPathname) => {
67
65
  if (!link.href || link.href.startsWith("#")) return `${currentPathname}${link.href ?? ""}`;
68
66
  return link.href;
69
67
  };
70
- /**
71
- * Recursively walks schema properties to generate RepeatableItemSeed objects.
72
- * Sets `_itemId` placeholder markers on `content` for each repeatable field,
73
- * and pushes seed objects into `allSeeds`.
74
- */
75
- function buildInitialSeeds(properties, parentTempId, content, allSeeds, counter) {
76
- for (const [fieldName, fieldSchema] of Object.entries(properties)) {
77
- if (fieldSchema.type !== "array" || !fieldSchema.items?.properties) continue;
78
- const ft = fieldSchema.fieldType;
79
- if (ft === "ImageList" || ft === "FileList") continue;
80
- const defaultCount = fieldSchema.defaultItems ?? fieldSchema.minItems ?? 0;
81
- if (defaultCount <= 0) continue;
82
- const itemProperties = fieldSchema.items.properties;
83
- const itemContent = {};
84
- for (const [propName, propSchema] of Object.entries(itemProperties)) {
85
- if (propSchema.type === "array" && propSchema.items?.properties) continue;
86
- if ("default" in propSchema) itemContent[propName] = propSchema.default;
87
- }
88
- const itemSettingsDefaults = fieldSchema.defaultItemSettings;
89
- const markers = [];
90
- let prevPosition = null;
91
- for (let i = 0; i < defaultCount; i++) {
92
- const tempId = `seed_${++counter.value}`;
93
- const position = generateKeyBetween(prevPosition, null);
94
- prevPosition = position;
95
- allSeeds.push({
96
- tempId,
97
- parentTempId,
98
- fieldName,
99
- content: { ...itemContent },
100
- settings: itemSettingsDefaults ? { ...itemSettingsDefaults } : void 0,
101
- position
102
- });
103
- markers.push({ _itemId: tempId });
104
- buildInitialSeeds(itemProperties, tempId, {}, allSeeds, counter);
105
- }
106
- content[fieldName] = markers;
107
- }
108
- }
109
- /**
110
- * Recursively walks schema properties to generate fake repeatable items for peek mode.
111
- * Sets `_itemId` markers on `content` for each repeatable field,
112
- * and pushes the corresponding fake items into `allItems`.
113
- */
114
- function buildPeekItems(properties, blockId, parentItemId, content, allItems, counter) {
115
- for (const [fieldName, fieldSchema] of Object.entries(properties)) {
116
- if (fieldSchema.type !== "array" || !fieldSchema.items?.properties) continue;
117
- if (fieldSchema.fieldType === "ImageList" || fieldSchema.fieldType === "FileList") continue;
118
- const defaultCount = fieldSchema.defaultItems ?? fieldSchema.minItems ?? 0;
119
- if (defaultCount <= 0) continue;
120
- const itemProperties = fieldSchema.items.properties;
121
- const itemContent = {};
122
- for (const [propName, propSchema] of Object.entries(itemProperties)) {
123
- if (propSchema.type === "array" && propSchema.items?.properties) continue;
124
- if ("default" in propSchema) itemContent[propName] = propSchema.default;
125
- }
126
- const itemSettingsDefaults = fieldSchema.defaultItemSettings;
127
- const markers = [];
128
- let prevPosition = null;
129
- for (let i = 0; i < defaultCount; i++) {
130
- const itemId = `peek_${++counter.value}`;
131
- const position = generateKeyBetween(prevPosition, null);
132
- prevPosition = position;
133
- allItems.push({
134
- id: itemId,
135
- blockId,
136
- parentItemId,
137
- fieldName,
138
- content: { ...itemContent },
139
- settings: itemSettingsDefaults ? { ...itemSettingsDefaults } : null,
140
- summary: "",
141
- title: "",
142
- position,
143
- createdAt: 0,
144
- updatedAt: 0,
145
- projectId: null,
146
- sharedContentType: null,
147
- references: {}
148
- });
149
- markers.push({ _itemId: itemId });
150
- const nestedContent = {};
151
- buildPeekItems(itemProperties, blockId, itemId, nestedContent, allItems, counter);
152
- const item = allItems.find((it) => it.id === itemId);
153
- item.content = {
154
- ...item.content,
155
- ...nestedContent
156
- };
157
- }
158
- content[fieldName] = markers;
159
- }
160
- }
161
68
  function createEditableBlock(options) {
162
69
  const fields = resolveBlockFields(options);
163
70
  const typeboxSchema = Type.Object(fields.content);
@@ -177,29 +84,8 @@ function createEditableBlock(options) {
177
84
  properties: settingsTypeboxSchema.properties,
178
85
  required: Object.keys(fields.settings)
179
86
  } : void 0;
180
- const contentDefaults = {};
181
- const contentDefaultsForStorage = {};
182
- for (const [key, prop] of Object.entries(typeboxSchema.properties)) if ("default" in prop) {
183
- contentDefaults[key] = prop.default;
184
- const ft = prop.fieldType;
185
- if (ft === "Image" || ft === "File" || ft === "ImageList" || ft === "FileList" || ft === "Repeater") continue;
186
- contentDefaultsForStorage[key] = prop.default;
187
- }
188
- const repeatableItemDefaults = {};
189
- const repeatableItemSettingsDefaults = {};
190
- for (const [key, prop] of Object.entries(typeboxSchema.properties)) {
191
- const p = prop;
192
- if (p.type === "array" && p.items?.properties) {
193
- const itemDefaults = {};
194
- for (const [itemKey, itemProp] of Object.entries(p.items.properties)) if (itemProp && typeof itemProp === "object" && "default" in itemProp) itemDefaults[itemKey] = itemProp.default;
195
- if (Object.keys(itemDefaults).length > 0) repeatableItemDefaults[key] = itemDefaults;
196
- if (p.defaultItemSettings && typeof p.defaultItemSettings === "object") repeatableItemSettingsDefaults[key] = p.defaultItemSettings;
197
- }
198
- }
199
- const settingsDefaults = {};
200
- if (settingsTypeboxSchema) {
201
- for (const [key, prop] of Object.entries(settingsTypeboxSchema.properties)) if ("default" in prop) settingsDefaults[key] = prop.default;
202
- }
87
+ const emptyContent = emptyFieldValues(typeboxSchema);
88
+ const emptySettings = emptyFieldValues(settingsTypeboxSchema);
203
89
  const ToReact = options.toReact;
204
90
  const Context = React.createContext(null);
205
91
  const RepeatableItemContext = React.createContext(null);
@@ -212,8 +98,8 @@ function createEditableBlock(options) {
212
98
  const selectTarget = usePreviewSelection();
213
99
  const blockContext = React.use(Context);
214
100
  if (!blockContext) throw new Error("Field must be used within a Block Component");
215
- const { blockId, content, mode } = blockContext;
216
- const isContentEditable = useIsEditable(mode);
101
+ const { blockId, content } = blockContext;
102
+ const isContentEditable = useIsEditable();
217
103
  const elementRef = React.useRef(null);
218
104
  const { window: iframeWindow } = useFrame();
219
105
  const pages = useEditorLinkPages();
@@ -414,7 +300,7 @@ function createEditableBlock(options) {
414
300
  const item = React.use(RepeatableItemContext);
415
301
  const selectTarget = usePreviewSelection();
416
302
  if (!block) throw new Error("Icon must be used within a Block Component");
417
- const editable = useIsEditable(block.mode);
303
+ const editable = useIsEditable();
418
304
  const fieldName = String(name);
419
305
  const value = item ? item.itemContent[name] : block.content[name];
420
306
  const t1 = item?.itemId;
@@ -521,8 +407,8 @@ function createEditableBlock(options) {
521
407
  const selectTarget = usePreviewSelection();
522
408
  const blockContext = React.use(Context);
523
409
  if (!blockContext) throw new Error("Embed must be used within a Block Component");
524
- const { blockId, content, mode } = blockContext;
525
- const isContentEditable = useIsEditable(mode);
410
+ const { blockId, content } = blockContext;
411
+ const isContentEditable = useIsEditable();
526
412
  const { window: iframeWindow } = useFrame();
527
413
  const repeaterContext = React.use(RepeatableItemContext);
528
414
  const fieldValue = repeaterContext ? repeaterContext.itemContent[name] : content[name];
@@ -690,8 +576,8 @@ function createEditableBlock(options) {
690
576
  const selectTarget = usePreviewSelection();
691
577
  const blockContext = React.use(Context);
692
578
  if (!blockContext) throw new Error("Artifact must be used within a Block Component");
693
- const { blockId, content, mode } = blockContext;
694
- const isContentEditable = useIsEditable(mode);
579
+ const { blockId, content } = blockContext;
580
+ const isContentEditable = useIsEditable();
695
581
  const { window: iframeWindow } = useFrame();
696
582
  const repeaterContext = React.use(RepeatableItemContext);
697
583
  const value = repeaterContext ? repeaterContext.itemContent[name] : content[name];
@@ -901,8 +787,8 @@ function createEditableBlock(options) {
901
787
  const selectTarget = usePreviewSelection();
902
788
  const blockContext = React.use(Context);
903
789
  if (!blockContext) throw new Error("Link must be used within a Block Component");
904
- const { blockId, content, mode } = blockContext;
905
- const isContentEditable = useIsEditable(mode);
790
+ const { blockId, content } = blockContext;
791
+ const isContentEditable = useIsEditable();
906
792
  const elementRef = React.useRef(null);
907
793
  const { window: iframeWindow } = useFrame();
908
794
  const repeaterContext = React.use(RepeatableItemContext);
@@ -1074,15 +960,15 @@ function createEditableBlock(options) {
1074
960
  const selectTarget = usePreviewSelection();
1075
961
  const blockContext = React.use(Context);
1076
962
  if (!blockContext) throw new Error("Image must be used within a Block Component");
1077
- const { blockId, content, mode } = blockContext;
1078
- const isContentEditable = useIsEditable(mode);
963
+ const { blockId, content } = blockContext;
964
+ const isContentEditable = useIsEditable();
1079
965
  const { window: iframeWindow } = useFrame();
1080
966
  const repeaterContext = React.use(RepeatableItemContext);
1081
967
  const { filesMap } = useNormalizedData();
1082
968
  const rawSource = repeaterContext ? repeaterContext.itemContent[name] : content[name];
1083
969
  const rawValue = resolveAssetValue(rawSource, filesMap);
1084
- const defaultValue = repeaterContext ? repeatableItemDefaults[repeaterContext.arrayFieldName]?.[String(name)] : contentDefaults[String(name)];
1085
- const fieldValue = rawValue ?? defaultValue;
970
+ const fieldSchema = repeaterContext ? repeaterContext.itemSchema?.[name] : (blockContext.sourceSchema ?? typeboxSchema.properties)[name];
971
+ const fieldValue = rawValue?.url ? rawValue : placeholderImage(fieldSchema?.title);
1086
972
  const isInlineArrayItem = repeaterContext != null && repeaterContext.itemId == null;
1087
973
  const overlayFieldName = isInlineArrayItem ? repeaterContext.arrayFieldName : String(name);
1088
974
  const overlayItemId = isInlineArrayItem ? repeaterContext.containerItemId : repeaterContext?.itemId;
@@ -1213,16 +1099,14 @@ function createEditableBlock(options) {
1213
1099
  const { name, children } = t0;
1214
1100
  const blockContext = React.use(Context);
1215
1101
  if (!blockContext) throw new Error("File must be used within a Block Component");
1216
- const { blockId, content, mode } = blockContext;
1217
- const isContentEditable = useIsEditable(mode);
1102
+ const { blockId, content } = blockContext;
1103
+ const isContentEditable = useIsEditable();
1218
1104
  const { window: iframeWindow } = useFrame();
1219
1105
  const repeaterContext = React.use(RepeatableItemContext);
1220
1106
  const reference = React.use(ReferenceContext);
1221
1107
  const { filesMap } = useNormalizedData();
1222
1108
  const rawSource = repeaterContext ? repeaterContext.itemContent[name] : content[name];
1223
- const rawValue = resolveAssetValue(rawSource, filesMap);
1224
- const defaultValue = repeaterContext ? repeatableItemDefaults[repeaterContext.arrayFieldName]?.[String(name)] : contentDefaults[String(name)];
1225
- const fieldValue = rawValue ?? defaultValue;
1109
+ const fieldValue = resolveAssetValue(rawSource, filesMap);
1226
1110
  const isInlineArrayItem = repeaterContext != null && repeaterContext.itemId == null;
1227
1111
  const overlayFieldName = isInlineArrayItem ? repeaterContext.arrayFieldName : String(name);
1228
1112
  const fieldId = getOverlayFieldId(blockId, overlayFieldName, { reference });
@@ -1236,6 +1120,7 @@ function createEditableBlock(options) {
1236
1120
  setPrevSidebarHover(isHoveredFromSidebar);
1237
1121
  setIsHovered(isHoveredFromSidebar);
1238
1122
  }
1123
+ if (!fieldValue?.url) return null;
1239
1124
  const linkProps = {
1240
1125
  href: fieldValue.url,
1241
1126
  download: fieldValue.filename
@@ -1269,17 +1154,10 @@ function createEditableBlock(options) {
1269
1154
  const parentRepeaterContext = React.use(RepeatableItemContext);
1270
1155
  const { filesMap } = useNormalizedData();
1271
1156
  const fieldName = String(name);
1272
- const fieldSchema = parentRepeaterContext ? typeboxSchema.properties[parentRepeaterContext.arrayFieldName]?.items?.properties?.[fieldName] : (blockContext.sourceSchema ?? typeboxSchema.properties)[fieldName];
1273
- const ft = fieldSchema?.fieldType;
1157
+ const ft = (parentRepeaterContext ? typeboxSchema.properties[parentRepeaterContext.arrayFieldName]?.items?.properties?.[fieldName] : (blockContext.sourceSchema ?? typeboxSchema.properties)[fieldName])?.fieldType;
1274
1158
  if (ft !== "ImageList" && ft !== "FileList") throw new Error(`"${fieldName}" is not an imageList or fileList field`);
1275
1159
  const source = parentRepeaterContext ? parentRepeaterContext.itemContent[fieldName] : blockContext.content[fieldName];
1276
- let arr = Array.isArray(source) ? source : [];
1277
- if (arr.length === 0) {
1278
- const defaultCount = fieldSchema.defaultItems ?? 0;
1279
- const itemDefault = fieldSchema.items?.default;
1280
- if (defaultCount > 0 && itemDefault) arr = Array.from({ length: defaultCount }, () => itemDefault);
1281
- }
1282
- const resolved = arr.map((v) => resolveAssetValue(v, filesMap)).filter((v) => v != null && typeof v === "object" && "url" in v);
1160
+ const resolved = (Array.isArray(source) ? source : []).map((v) => resolveAssetValue(v, filesMap)).filter((v) => v != null && typeof v === "object" && "url" in v);
1283
1161
  const Single = ft === "ImageList" ? Image : File;
1284
1162
  return /* @__PURE__ */ jsx(RepeaterHoverProvider, {
1285
1163
  blockId: blockContext.blockId,
@@ -1304,8 +1182,8 @@ function createEditableBlock(options) {
1304
1182
  const FileList = _AssetList;
1305
1183
  const RepeatableItemWrapper = (t0) => {
1306
1184
  const $ = c(21);
1307
- const { itemId, blockId, nesting, mode, children } = t0;
1308
- const isContentEditable = useIsEditable(mode);
1185
+ const { itemId, blockId, nesting, children } = t0;
1186
+ const isContentEditable = useIsEditable();
1309
1187
  const { window: iframeWindow } = useFrame();
1310
1188
  const fragmentRef = React.useRef(null);
1311
1189
  const registrationRef = React.useRef(null);
@@ -1429,7 +1307,7 @@ function createEditableBlock(options) {
1429
1307
  const RepeaterHoverProvider = (t0) => {
1430
1308
  const $ = c(6);
1431
1309
  const { blockId, fieldName, children } = t0;
1432
- const isContentEditable = useIsEditable("site");
1310
+ const isContentEditable = useIsEditable();
1433
1311
  const { window: iframeWindow } = useFrame();
1434
1312
  const hoverGroup = React.useId();
1435
1313
  const t1 = String(blockId);
@@ -1457,11 +1335,11 @@ function createEditableBlock(options) {
1457
1335
  return t4;
1458
1336
  };
1459
1337
  const RepeaterImpl = (t0) => {
1460
- const $ = c(29);
1338
+ const $ = c(19);
1461
1339
  const { name, children } = t0;
1462
1340
  const blockContext = React.use(Context);
1463
1341
  if (!blockContext) throw new Error("Repeater must be used within a Block Component");
1464
- const { blockId, content, mode } = blockContext;
1342
+ const { blockId, content } = blockContext;
1465
1343
  const parentRepeaterContext = React.use(RepeatableItemContext);
1466
1344
  const fieldName = String(name);
1467
1345
  const source = parentRepeaterContext ? parentRepeaterContext.itemContent[fieldName] : content[fieldName];
@@ -1478,120 +1356,107 @@ function createEditableBlock(options) {
1478
1356
  let t2;
1479
1357
  let t3;
1480
1358
  let t4;
1481
- if ($[2] !== blockId || $[3] !== children || $[4] !== fieldName || $[5] !== itemsMap || $[6] !== mode || $[7] !== parentRepeaterContext || $[8] !== storedValue) {
1359
+ if ($[2] !== blockId || $[3] !== children || $[4] !== fieldName || $[5] !== itemsMap || $[6] !== parentRepeaterContext || $[7] !== storedValue) {
1482
1360
  let t5;
1483
- if ($[13] !== itemsMap) {
1361
+ if ($[12] !== itemsMap) {
1484
1362
  t5 = (item) => {
1485
1363
  if (isItemMarker(item)) return itemsMap.get(item._itemId) ?? null;
1486
1364
  return item;
1487
1365
  };
1488
- $[13] = itemsMap;
1489
- $[14] = t5;
1490
- } else t5 = $[14];
1366
+ $[12] = itemsMap;
1367
+ $[13] = t5;
1368
+ } else t5 = $[13];
1491
1369
  const arrayValue = storedValue.map(t5).filter(Boolean);
1492
- const settingsDefaultsForField = repeatableItemSettingsDefaults[fieldName];
1493
- const itemSchema = (parentRepeaterContext ? parentRepeaterContext.itemSchema?.[fieldName] : typeboxSchema.properties[fieldName])?.items?.properties;
1370
+ const fieldSchema = parentRepeaterContext ? parentRepeaterContext.itemSchema?.[fieldName] : typeboxSchema.properties[fieldName];
1371
+ const itemSchema = fieldSchema?.items?.properties;
1372
+ const emptyItem = emptyFieldValues(fieldSchema?.items);
1373
+ const emptyItemSettings = emptyFieldValues(fieldSchema?.itemSettingsSchema);
1494
1374
  const nesting = parentRepeaterContext ? (parentRepeaterContext.nesting ?? 0) + 1 : 0;
1495
1375
  T0 = RepeaterHoverProvider;
1496
1376
  t2 = blockId;
1497
1377
  t3 = fieldName;
1498
- let t6;
1499
- if ($[15] !== blockId || $[16] !== children || $[17] !== fieldName || $[18] !== itemSchema || $[19] !== mode || $[20] !== nesting || $[21] !== parentRepeaterContext?.containerItemId || $[22] !== settingsDefaultsForField) {
1500
- t6 = (item_0, index) => {
1501
- const isDbItem = item_0.content !== void 0 && item_0.id != null;
1502
- const itemContent = {
1503
- ...repeatableItemDefaults[fieldName],
1504
- ...isDbItem ? item_0.content : item_0
1505
- };
1506
- const itemSettings = {
1507
- ...settingsDefaultsForField,
1508
- ...isDbItem ? item_0.settings : null
1509
- };
1510
- const itemId = isDbItem ? item_0.id : void 0;
1511
- const useItemSetting = (settingName) => itemSettings[settingName];
1512
- const itemApi = {
1513
- Field,
1514
- Link,
1515
- Icon,
1516
- Embed,
1517
- Artifact,
1518
- Image,
1519
- File,
1520
- ImageList: _AssetList,
1521
- FileList: _AssetList,
1522
- Repeater: RepeaterImpl,
1523
- Reference: ReferenceImpl,
1524
- ReferenceList: ReferenceListImpl,
1525
- useSetting: useItemSetting
1526
- };
1527
- return /* @__PURE__ */ jsx(RepeatableItemContext.Provider, {
1528
- value: {
1529
- arrayFieldName: fieldName,
1530
- itemIndex: index,
1531
- itemContent,
1532
- itemSettings,
1533
- itemId,
1534
- containerItemId: itemId ?? parentRepeaterContext?.containerItemId,
1535
- itemSchema,
1536
- nesting
1537
- },
1538
- children: /* @__PURE__ */ jsx(RepeatableItemWrapper, {
1539
- itemId,
1540
- blockId,
1541
- nesting,
1542
- mode,
1543
- children: children(itemApi, index)
1544
- })
1545
- }, itemId ?? index);
1378
+ t4 = arrayValue.map((item_0, index) => {
1379
+ const isDbItem = item_0.content !== void 0 && item_0.id != null;
1380
+ const itemContent = {
1381
+ ...emptyItem,
1382
+ ...isDbItem ? item_0.content : item_0
1383
+ };
1384
+ const itemSettings = {
1385
+ ...emptyItemSettings,
1386
+ ...isDbItem ? item_0.settings : null
1387
+ };
1388
+ const itemId = isDbItem ? item_0.id : void 0;
1389
+ const useItemSetting = (settingName) => itemSettings[settingName];
1390
+ const itemApi = {
1391
+ Field,
1392
+ Link,
1393
+ Icon,
1394
+ Embed,
1395
+ Artifact,
1396
+ Image,
1397
+ File,
1398
+ ImageList: _AssetList,
1399
+ FileList: _AssetList,
1400
+ Repeater: RepeaterImpl,
1401
+ Reference: ReferenceImpl,
1402
+ ReferenceList: ReferenceListImpl,
1403
+ useSetting: useItemSetting
1546
1404
  };
1547
- $[15] = blockId;
1548
- $[16] = children;
1549
- $[17] = fieldName;
1550
- $[18] = itemSchema;
1551
- $[19] = mode;
1552
- $[20] = nesting;
1553
- $[21] = parentRepeaterContext?.containerItemId;
1554
- $[22] = settingsDefaultsForField;
1555
- $[23] = t6;
1556
- } else t6 = $[23];
1557
- t4 = arrayValue.map(t6);
1405
+ return /* @__PURE__ */ jsx(RepeatableItemContext.Provider, {
1406
+ value: {
1407
+ arrayFieldName: fieldName,
1408
+ itemIndex: index,
1409
+ itemContent,
1410
+ itemSettings,
1411
+ itemId,
1412
+ containerItemId: itemId ?? parentRepeaterContext?.containerItemId,
1413
+ itemSchema,
1414
+ nesting
1415
+ },
1416
+ children: /* @__PURE__ */ jsx(RepeatableItemWrapper, {
1417
+ itemId,
1418
+ blockId,
1419
+ nesting,
1420
+ children: children(itemApi, index)
1421
+ })
1422
+ }, itemId ?? index);
1423
+ });
1558
1424
  $[2] = blockId;
1559
1425
  $[3] = children;
1560
1426
  $[4] = fieldName;
1561
1427
  $[5] = itemsMap;
1562
- $[6] = mode;
1563
- $[7] = parentRepeaterContext;
1564
- $[8] = storedValue;
1565
- $[9] = T0;
1566
- $[10] = t2;
1567
- $[11] = t3;
1568
- $[12] = t4;
1428
+ $[6] = parentRepeaterContext;
1429
+ $[7] = storedValue;
1430
+ $[8] = T0;
1431
+ $[9] = t2;
1432
+ $[10] = t3;
1433
+ $[11] = t4;
1569
1434
  } else {
1570
- T0 = $[9];
1571
- t2 = $[10];
1572
- t3 = $[11];
1573
- t4 = $[12];
1435
+ T0 = $[8];
1436
+ t2 = $[9];
1437
+ t3 = $[10];
1438
+ t4 = $[11];
1574
1439
  }
1575
1440
  let t5;
1576
- if ($[24] !== T0 || $[25] !== t2 || $[26] !== t3 || $[27] !== t4) {
1441
+ if ($[14] !== T0 || $[15] !== t2 || $[16] !== t3 || $[17] !== t4) {
1577
1442
  t5 = /* @__PURE__ */ jsx(T0, {
1578
1443
  blockId: t2,
1579
1444
  fieldName: t3,
1580
1445
  children: t4
1581
1446
  });
1582
- $[24] = T0;
1583
- $[25] = t2;
1584
- $[26] = t3;
1585
- $[27] = t4;
1586
- $[28] = t5;
1587
- } else t5 = $[28];
1447
+ $[14] = T0;
1448
+ $[15] = t2;
1449
+ $[16] = t3;
1450
+ $[17] = t4;
1451
+ $[18] = t5;
1452
+ } else t5 = $[18];
1588
1453
  return t5;
1589
1454
  };
1590
1455
  const Repeater = RepeaterImpl;
1591
1456
  const BlockComponent = (t0) => {
1592
- const $ = c(63);
1593
- const { blockData, mode, isFirstBlock, showAddBlockTop, showAddBlockBottom, addBlockAfterPosition } = t0;
1594
- const isContentEditable = useIsEditable(mode);
1457
+ const $ = c(48);
1458
+ const { blockData } = t0;
1459
+ const isContentEditable = useIsEditable();
1595
1460
  const { window: iframeWindow } = useFrame();
1596
1461
  const [isHovered, setIsHovered] = React.useState(false);
1597
1462
  const selection = usePreviewTargetSelection();
@@ -1663,7 +1528,7 @@ function createEditableBlock(options) {
1663
1528
  let t6;
1664
1529
  if ($[11] !== blockData.settings) {
1665
1530
  t6 = {
1666
- ...settingsDefaults,
1531
+ ...emptySettings,
1667
1532
  ...blockData.settings
1668
1533
  };
1669
1534
  $[11] = blockData.settings;
@@ -1672,7 +1537,10 @@ function createEditableBlock(options) {
1672
1537
  const blockSettings = t6;
1673
1538
  let result;
1674
1539
  if ($[13] !== blockData.content) {
1675
- result = { ...blockData.content };
1540
+ result = {
1541
+ ...emptyContent,
1542
+ ...blockData.content
1543
+ };
1676
1544
  for (const key in result) {
1677
1545
  const value = result[key];
1678
1546
  if (Array.isArray(value) && value.length > 0 && value[0]?.content !== void 0) result[key] = value.map(_temp7);
@@ -1720,136 +1588,92 @@ function createEditableBlock(options) {
1720
1588
  } else t9 = $[22];
1721
1589
  const handleMouseLeave = t9;
1722
1590
  const shouldShowOverlay = isContentEditable && (overlayState["data-camox-hovered"] || overlayState["data-camox-focused"]);
1723
- const t10 = blockData._id;
1724
- let t11;
1591
+ let t10;
1725
1592
  if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
1726
- t11 = {
1593
+ t10 = {
1727
1594
  position: "relative",
1728
1595
  scrollMargin: "5rem"
1729
1596
  };
1730
- $[23] = t11;
1731
- } else t11 = $[23];
1732
- const t12 = isContentEditable ? blockData._id : void 0;
1597
+ $[23] = t10;
1598
+ } else t10 = $[23];
1599
+ const t11 = isContentEditable ? blockData._id : void 0;
1600
+ let t12;
1601
+ if ($[24] !== overlayState || $[25] !== shouldShowOverlay) {
1602
+ t12 = shouldShowOverlay ? overlayState : {};
1603
+ $[24] = overlayState;
1604
+ $[25] = shouldShowOverlay;
1605
+ $[26] = t12;
1606
+ } else t12 = $[26];
1733
1607
  let t13;
1734
- if ($[24] !== addBlockAfterPosition || $[25] !== blockData.position || $[26] !== isContentEditable || $[27] !== isFirstBlock || $[28] !== mode || $[29] !== showAddBlockBottom || $[30] !== showAddBlockTop) {
1735
- t13 = isContentEditable ? JSON.stringify({
1736
- position: blockData.position,
1737
- before: showAddBlockTop ?? (mode !== "layout" && !isFirstBlock),
1738
- after: showAddBlockBottom ?? mode !== "layout",
1739
- ...addBlockAfterPosition !== void 0 ? { afterPosition: addBlockAfterPosition } : {}
1740
- }) : void 0;
1741
- $[24] = addBlockAfterPosition;
1742
- $[25] = blockData.position;
1743
- $[26] = isContentEditable;
1744
- $[27] = isFirstBlock;
1745
- $[28] = mode;
1746
- $[29] = showAddBlockBottom;
1747
- $[30] = showAddBlockTop;
1748
- $[31] = t13;
1749
- } else t13 = $[31];
1750
- let t14;
1751
- if ($[32] !== overlayState || $[33] !== shouldShowOverlay) {
1752
- t14 = shouldShowOverlay ? overlayState : {};
1753
- $[32] = overlayState;
1754
- $[33] = shouldShowOverlay;
1755
- $[34] = t14;
1756
- } else t14 = $[34];
1757
- const t15 = blockData._id;
1758
- let t16;
1759
- if ($[35] !== blockData.content) {
1760
- t16 = {
1761
- ...contentDefaults,
1608
+ if ($[27] !== blockData.content) {
1609
+ t13 = {
1610
+ ...emptyContent,
1762
1611
  ...blockData.content
1763
1612
  };
1764
- $[35] = blockData.content;
1765
- $[36] = t16;
1766
- } else t16 = $[36];
1767
- const merged = t16;
1768
- let overrides;
1769
- if ($[37] !== merged) {
1770
- overrides = {};
1771
- for (const key_0 in merged) {
1772
- const val = merged[key_0];
1773
- if (val && typeof val === "object" && "url" in val && !val.url && contentDefaults[key_0]) overrides[key_0] = contentDefaults[key_0];
1774
- }
1775
- $[37] = merged;
1776
- $[38] = overrides;
1777
- } else overrides = $[38];
1778
- let t17;
1779
- if ($[39] !== merged || $[40] !== overrides) {
1780
- t17 = {
1781
- ...merged,
1782
- ...overrides
1783
- };
1784
- $[39] = merged;
1785
- $[40] = overrides;
1786
- $[41] = t17;
1787
- } else t17 = $[41];
1788
- const t18 = t17;
1789
- let t19;
1790
- if ($[42] !== blockData || $[43] !== blockSettings || $[44] !== isHovered || $[45] !== mode || $[46] !== t18) {
1791
- t19 = {
1792
- blockId: t15,
1793
- content: t18,
1613
+ $[27] = blockData.content;
1614
+ $[28] = t13;
1615
+ } else t13 = $[28];
1616
+ const t14 = t13;
1617
+ let t15;
1618
+ if ($[29] !== blockData._id || $[30] !== blockSettings || $[31] !== isHovered || $[32] !== t14) {
1619
+ t15 = {
1620
+ blockId: blockData._id,
1621
+ content: t14,
1794
1622
  settings: blockSettings,
1795
- mode,
1796
1623
  isHovered,
1797
1624
  setIsHovered
1798
1625
  };
1799
- $[42] = blockData;
1800
- $[43] = blockSettings;
1801
- $[44] = isHovered;
1802
- $[45] = mode;
1803
- $[46] = t18;
1804
- $[47] = t19;
1805
- } else t19 = $[47];
1806
- let t20;
1807
- if ($[48] !== blockSettings || $[49] !== normalizedContent) {
1808
- t20 = /* @__PURE__ */ jsx(ToReact, {
1626
+ $[29] = blockData._id;
1627
+ $[30] = blockSettings;
1628
+ $[31] = isHovered;
1629
+ $[32] = t14;
1630
+ $[33] = t15;
1631
+ } else t15 = $[33];
1632
+ let t16;
1633
+ if ($[34] !== blockSettings || $[35] !== normalizedContent) {
1634
+ t16 = /* @__PURE__ */ jsx(ToReact, {
1809
1635
  content: normalizedContent,
1810
1636
  settings: blockSettings
1811
1637
  });
1812
- $[48] = blockSettings;
1813
- $[49] = normalizedContent;
1814
- $[50] = t20;
1815
- } else t20 = $[50];
1816
- let t21;
1817
- if ($[51] !== t19 || $[52] !== t20) {
1818
- t21 = /* @__PURE__ */ jsx(Context.Provider, {
1819
- value: t19,
1820
- children: t20
1638
+ $[34] = blockSettings;
1639
+ $[35] = normalizedContent;
1640
+ $[36] = t16;
1641
+ } else t16 = $[36];
1642
+ let t17;
1643
+ if ($[37] !== t15 || $[38] !== t16) {
1644
+ t17 = /* @__PURE__ */ jsx(Context.Provider, {
1645
+ value: t15,
1646
+ children: t16
1821
1647
  });
1822
- $[51] = t19;
1823
- $[52] = t20;
1824
- $[53] = t21;
1825
- } else t21 = $[53];
1826
- let t22;
1827
- if ($[54] !== blockData || $[55] !== handleClick || $[56] !== handleMouseEnter || $[57] !== handleMouseLeave || $[58] !== t12 || $[59] !== t13 || $[60] !== t14 || $[61] !== t21) {
1828
- t22 = /* @__PURE__ */ jsx("div", {
1648
+ $[37] = t15;
1649
+ $[38] = t16;
1650
+ $[39] = t17;
1651
+ } else t17 = $[39];
1652
+ let t18;
1653
+ if ($[40] !== blockData._id || $[41] !== handleClick || $[42] !== handleMouseEnter || $[43] !== handleMouseLeave || $[44] !== t11 || $[45] !== t12 || $[46] !== t17) {
1654
+ t18 = /* @__PURE__ */ jsx("div", {
1829
1655
  className: "group visual-editing-block",
1830
- "data-camox-viewport-block": t10,
1656
+ "data-camox-viewport-block": blockData._id,
1831
1657
  ref,
1832
- style: t11,
1833
- "data-camox-block-id": t12,
1834
- "data-camox-block-insertion": t13,
1835
- ...t14,
1658
+ style: t10,
1659
+ "data-camox-block-id": t11,
1660
+ ...t12,
1836
1661
  "data-camox-overlay-mode": options.synced ? "synced" : void 0,
1837
1662
  onClickCapture: handleClick,
1838
1663
  onMouseEnter: handleMouseEnter,
1839
1664
  onMouseLeave: handleMouseLeave,
1840
- children: t21
1665
+ children: t17
1841
1666
  });
1842
- $[54] = blockData;
1843
- $[55] = handleClick;
1844
- $[56] = handleMouseEnter;
1845
- $[57] = handleMouseLeave;
1846
- $[58] = t12;
1847
- $[59] = t13;
1848
- $[60] = t14;
1849
- $[61] = t21;
1850
- $[62] = t22;
1851
- } else t22 = $[62];
1852
- return t22;
1667
+ $[40] = blockData._id;
1668
+ $[41] = handleClick;
1669
+ $[42] = handleMouseEnter;
1670
+ $[43] = handleMouseLeave;
1671
+ $[44] = t11;
1672
+ $[45] = t12;
1673
+ $[46] = t17;
1674
+ $[47] = t18;
1675
+ } else t18 = $[47];
1676
+ return t18;
1853
1677
  };
1854
1678
  const useSetting = (name) => {
1855
1679
  const ctx = React.use(Context);
@@ -1970,7 +1794,7 @@ function createEditableBlock(options) {
1970
1794
  const applyEdit = useApplyContentEdit();
1971
1795
  const [error, setError] = React.useState(null);
1972
1796
  const [pointerHovered, setPointerHovered] = React.useState(false);
1973
- const editable = useIsEditable(block.mode);
1797
+ const editable = useIsEditable();
1974
1798
  let t0;
1975
1799
  if ($[0] !== block || $[1] !== fieldName || $[2] !== owner || $[3] !== record) {
1976
1800
  t0 = record ? placementOf(block, owner, fieldName, record.id) : null;
@@ -2170,19 +1994,6 @@ function createEditableBlock(options) {
2170
1994
  } else t5 = $[15];
2171
1995
  return t5;
2172
1996
  };
2173
- const useCollectionTitle = (fieldName, field) => {
2174
- const $ = c(4);
2175
- const camoxApp = useOptionalCamoxApp();
2176
- let t0;
2177
- if ($[0] !== camoxApp || $[1] !== field || $[2] !== fieldName) {
2178
- t0 = camoxApp?.getCollectionById(field.collectionId)?._internal.title ?? field.title ?? fieldName;
2179
- $[0] = camoxApp;
2180
- $[1] = field;
2181
- $[2] = fieldName;
2182
- $[3] = t0;
2183
- } else t0 = $[3];
2184
- return t0;
2185
- };
2186
1997
  const useReferenceField = (block, fieldName) => {
2187
1998
  const item = React.use(RepeatableItemContext);
2188
1999
  const outer = React.use(ReferenceContext)?.placement ?? null;
@@ -2193,129 +2004,57 @@ function createEditableBlock(options) {
2193
2004
  const fieldType = "Reference";
2194
2005
  const recordFieldSelected = useRecordSelection(outer, fieldName);
2195
2006
  const blockFieldSelected = useFieldSelection(block.blockId, fieldName, fieldType, owner.itemId);
2196
- const fieldSelection = outer ? {
2197
- type: "record-field",
2198
- ...outer,
2199
- recordFieldName: fieldName,
2200
- recordFieldType: fieldType
2201
- } : owner.itemId == null ? {
2202
- type: "block-field",
2203
- blockId: block.blockId,
2204
- fieldName,
2205
- fieldType
2206
- } : {
2207
- type: "item-field",
2208
- blockId: block.blockId,
2209
- itemId: owner.itemId,
2210
- fieldName,
2211
- fieldType
2212
- };
2213
2007
  return {
2214
2008
  owner,
2215
2009
  field: item ? item.itemSchema?.[fieldName] : (block.sourceSchema ?? typeboxSchema.properties)[fieldName],
2216
2010
  stored: item ? item.itemContent[fieldName] : block.content[fieldName],
2217
2011
  fieldId: outer ? overlayFieldId(block.blockId, fieldName, { placement: outer }) : overlayFieldId(block.blockId, fieldName, { itemId: owner.itemId }),
2218
- fieldSelection,
2219
2012
  fieldSelected: outer ? recordFieldSelected : blockFieldSelected
2220
2013
  };
2221
2014
  };
2222
- const ReferencePlaceholder = (t0) => {
2223
- const $ = c(13);
2224
- let children;
2225
- let fieldId;
2226
- let fieldSelection;
2227
- let props;
2228
- if ($[0] !== t0) {
2229
- ({fieldId, fieldSelection, children, ...props} = t0);
2230
- $[0] = t0;
2231
- $[1] = children;
2232
- $[2] = fieldId;
2233
- $[3] = fieldSelection;
2234
- $[4] = props;
2235
- } else {
2236
- children = $[1];
2237
- fieldId = $[2];
2238
- fieldSelection = $[3];
2239
- props = $[4];
2240
- }
2241
- const selectTarget = usePreviewSelection();
2242
- let t1;
2243
- if ($[5] !== fieldId || $[6] !== fieldSelection || $[7] !== selectTarget) {
2244
- t1 = () => {
2245
- selectTarget(fieldSelection);
2246
- referencePickerFocus.send({
2247
- type: "request",
2248
- fieldId
2249
- });
2250
- };
2251
- $[5] = fieldId;
2252
- $[6] = fieldSelection;
2253
- $[7] = selectTarget;
2254
- $[8] = t1;
2255
- } else t1 = $[8];
2256
- let t2;
2257
- if ($[9] !== children || $[10] !== props || $[11] !== t1) {
2258
- t2 = /* @__PURE__ */ jsx("button", {
2259
- type: "button",
2260
- "data-camox-reference-placeholder": "",
2261
- className: "camox-reference-placeholder",
2262
- ...props,
2263
- onClick: t1,
2264
- children
2265
- });
2266
- $[9] = children;
2267
- $[10] = props;
2268
- $[11] = t1;
2269
- $[12] = t2;
2270
- } else t2 = $[12];
2271
- return t2;
2272
- };
2273
2015
  const PlacedRecordWrapper = (t0) => {
2274
2016
  const $ = c(10);
2275
2017
  const { fieldId, record, placedRecord, overlay, children } = t0;
2276
- const t1 = record?.id;
2277
- const t2 = record?.title;
2278
- let t3;
2018
+ let t1;
2279
2019
  if ($[0] !== placedRecord.error) {
2280
- t3 = placedRecord.error && /* @__PURE__ */ jsxs("p", {
2020
+ t1 = placedRecord.error && /* @__PURE__ */ jsxs("p", {
2281
2021
  role: "alert",
2282
2022
  children: ["Could not save item. ", placedRecord.error]
2283
2023
  });
2284
2024
  $[0] = placedRecord.error;
2285
- $[1] = t3;
2286
- } else t3 = $[1];
2287
- let t4;
2288
- if ($[2] !== children || $[3] !== fieldId || $[4] !== overlay || $[5] !== placedRecord.wrapperProps || $[6] !== t1 || $[7] !== t2 || $[8] !== t3) {
2289
- t4 = /* @__PURE__ */ jsxs("div", {
2025
+ $[1] = t1;
2026
+ } else t1 = $[1];
2027
+ let t2;
2028
+ if ($[2] !== children || $[3] !== fieldId || $[4] !== overlay || $[5] !== placedRecord.wrapperProps || $[6] !== record.id || $[7] !== record.title || $[8] !== t1) {
2029
+ t2 = /* @__PURE__ */ jsxs("div", {
2290
2030
  "data-camox-field-id": fieldId,
2291
- "data-camox-collection-record-id": t1,
2292
- "data-camox-reference-label": t2,
2031
+ "data-camox-collection-record-id": record.id,
2032
+ "data-camox-reference-label": record.title,
2293
2033
  "data-camox-overlay-mode": "reference",
2294
2034
  ...overlay,
2295
2035
  ...placedRecord.wrapperProps,
2296
- children: [children, t3]
2036
+ children: [children, t1]
2297
2037
  });
2298
2038
  $[2] = children;
2299
2039
  $[3] = fieldId;
2300
2040
  $[4] = overlay;
2301
2041
  $[5] = placedRecord.wrapperProps;
2302
- $[6] = t1;
2303
- $[7] = t2;
2304
- $[8] = t3;
2305
- $[9] = t4;
2306
- } else t4 = $[9];
2307
- return t4;
2042
+ $[6] = record.id;
2043
+ $[7] = record.title;
2044
+ $[8] = t1;
2045
+ $[9] = t2;
2046
+ } else t2 = $[9];
2047
+ return t2;
2308
2048
  };
2309
2049
  const ReferenceImpl = (t0) => {
2310
- const $ = c(21);
2050
+ const $ = c(18);
2311
2051
  const { name, children } = t0;
2312
2052
  const block = React.use(Context);
2313
2053
  const { recordsMap } = useNormalizedData();
2314
2054
  const { window: iframeWindow } = useFrame();
2315
2055
  if (!block) throw new Error("Reference must be used within a Block Component");
2316
2056
  const fieldName = String(name);
2317
- const { owner, field, stored, fieldId, fieldSelection, fieldSelected } = useReferenceField(block, fieldName);
2318
- const collectionTitle = useCollectionTitle(fieldName, field);
2057
+ const { owner, field, stored, fieldId, fieldSelected } = useReferenceField(block, fieldName);
2319
2058
  let t1;
2320
2059
  if ($[0] !== field.collectionId || $[1] !== recordsMap || $[2] !== stored) {
2321
2060
  t1 = resolveReference(stored, field.collectionId, recordsMap);
@@ -2335,34 +2074,27 @@ function createEditableBlock(options) {
2335
2074
  } else t2 = $[5];
2336
2075
  const fieldHovered = useOverlayMessage(iframeWindow, editable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", t2);
2337
2076
  const overlay = useOverlayState(placedRecord.hovered || fieldHovered, fieldSelected || placedRecord.selected);
2338
- if (!record && !editable) return null;
2077
+ if (!record || !placedRecord.reference) return null;
2339
2078
  let t3;
2340
- if ($[6] !== block || $[7] !== children || $[8] !== collectionTitle || $[9] !== field || $[10] !== fieldId || $[11] !== fieldSelection || $[12] !== placedRecord.reference || $[13] !== record) {
2341
- t3 = record && placedRecord.reference ? /* @__PURE__ */ jsx(RecordScope, {
2079
+ if ($[6] !== block || $[7] !== children || $[8] !== field || $[9] !== placedRecord.reference || $[10] !== record) {
2080
+ t3 = /* @__PURE__ */ jsx(RecordScope, {
2342
2081
  block,
2343
2082
  field,
2344
2083
  record,
2345
2084
  reference: placedRecord.reference,
2346
2085
  children
2347
- }) : /* @__PURE__ */ jsxs(ReferencePlaceholder, {
2348
- fieldId,
2349
- fieldSelection,
2350
- children: ["Select ", collectionTitle]
2351
2086
  });
2352
2087
  $[6] = block;
2353
2088
  $[7] = children;
2354
- $[8] = collectionTitle;
2355
- $[9] = field;
2356
- $[10] = fieldId;
2357
- $[11] = fieldSelection;
2358
- $[12] = placedRecord.reference;
2359
- $[13] = record;
2360
- $[14] = t3;
2361
- } else t3 = $[14];
2089
+ $[8] = field;
2090
+ $[9] = placedRecord.reference;
2091
+ $[10] = record;
2092
+ $[11] = t3;
2093
+ } else t3 = $[11];
2362
2094
  const rendered = t3;
2363
2095
  if (!editable) return rendered;
2364
2096
  let t4;
2365
- if ($[15] !== fieldId || $[16] !== overlay || $[17] !== placedRecord || $[18] !== record || $[19] !== rendered) {
2097
+ if ($[12] !== fieldId || $[13] !== overlay || $[14] !== placedRecord || $[15] !== record || $[16] !== rendered) {
2366
2098
  t4 = /* @__PURE__ */ jsx(PlacedRecordWrapper, {
2367
2099
  fieldId,
2368
2100
  record,
@@ -2370,13 +2102,13 @@ function createEditableBlock(options) {
2370
2102
  overlay,
2371
2103
  children: rendered
2372
2104
  });
2373
- $[15] = fieldId;
2374
- $[16] = overlay;
2375
- $[17] = placedRecord;
2376
- $[18] = record;
2377
- $[19] = rendered;
2378
- $[20] = t4;
2379
- } else t4 = $[20];
2105
+ $[12] = fieldId;
2106
+ $[13] = overlay;
2107
+ $[14] = placedRecord;
2108
+ $[15] = record;
2109
+ $[16] = rendered;
2110
+ $[17] = t4;
2111
+ } else t4 = $[17];
2380
2112
  return t4;
2381
2113
  };
2382
2114
  const Reference = ReferenceImpl;
@@ -2445,8 +2177,7 @@ function createEditableBlock(options) {
2445
2177
  sourceSchema: properties,
2446
2178
  settings: t2,
2447
2179
  isHovered: false,
2448
- setIsHovered: _temp8,
2449
- mode: "layout"
2180
+ setIsHovered: _temp8
2450
2181
  };
2451
2182
  $[1] = properties;
2452
2183
  $[2] = t1;
@@ -2560,17 +2291,16 @@ function createEditableBlock(options) {
2560
2291
  return t3;
2561
2292
  };
2562
2293
  const ReferenceListImpl = (t0) => {
2563
- const $ = c(44);
2294
+ const $ = c(25);
2564
2295
  const { name, children } = t0;
2565
2296
  const block = React.use(Context);
2566
2297
  const normalizedData = useNormalizedData();
2567
2298
  const { recordsMap } = normalizedData;
2568
2299
  const { window: iframeWindow } = useFrame();
2569
2300
  if (!block) throw new Error("ReferenceList must be used within a Block Component");
2570
- const editable = useIsEditable(block.mode);
2301
+ const editable = useIsEditable();
2571
2302
  const fieldName = String(name);
2572
- const { owner, field, stored, fieldId, fieldSelection } = useReferenceField(block, fieldName);
2573
- const collectionTitle = useCollectionTitle(fieldName, field);
2303
+ const { owner, field, stored, fieldId } = useReferenceField(block, fieldName);
2574
2304
  let t1;
2575
2305
  if ($[0] !== fieldId) {
2576
2306
  t1 = { fieldId };
@@ -2578,119 +2308,55 @@ function createEditableBlock(options) {
2578
2308
  $[1] = t1;
2579
2309
  } else t1 = $[1];
2580
2310
  const listHovered = useOverlayMessage(iframeWindow, editable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", t1);
2581
- const placeholderOverlay = useOverlayState(listHovered);
2582
2311
  let t2;
2583
- if ($[2] !== field) {
2584
- t2 = isQueryBacked(field);
2585
- $[2] = field;
2586
- $[3] = t2;
2587
- } else t2 = $[3];
2588
- const queryBacked = t2;
2589
- let t3;
2590
- if ($[4] !== block.blockId || $[5] !== fieldName || $[6] !== normalizedData || $[7] !== owner || $[8] !== queryBacked || $[9] !== stored) {
2591
- t3 = queryBacked ? queryResultIds(normalizedData, {
2312
+ if ($[2] !== block || $[3] !== field || $[4] !== fieldName || $[5] !== normalizedData || $[6] !== owner || $[7] !== stored) {
2313
+ t2 = isQueryBacked(field) ? queryResultIds(normalizedData, {
2592
2314
  blockId: block.blockId,
2593
2315
  itemId: owner.itemId
2594
2316
  }, fieldName) : stored;
2595
- $[4] = block.blockId;
2596
- $[5] = fieldName;
2597
- $[6] = normalizedData;
2598
- $[7] = owner;
2599
- $[8] = queryBacked;
2600
- $[9] = stored;
2601
- $[10] = t3;
2602
- } else t3 = $[10];
2603
- const ids = t3;
2604
- let t4;
2605
- let t5;
2606
- if ($[11] !== block || $[12] !== children || $[13] !== collectionTitle || $[14] !== editable || $[15] !== field || $[16] !== fieldId || $[17] !== fieldName || $[18] !== fieldSelection || $[19] !== ids || $[20] !== listHovered || $[21] !== owner || $[22] !== placeholderOverlay || $[23] !== queryBacked || $[24] !== recordsMap) {
2607
- t5 = Symbol.for("react.early_return_sentinel");
2608
- bb0: {
2609
- const records = resolveReferenceList(ids, field.collectionId, recordsMap);
2610
- if (records.length === 0) {
2611
- if (!editable || queryBacked) {
2612
- t5 = null;
2613
- break bb0;
2614
- }
2615
- let t6;
2616
- if ($[27] !== fieldSelection.type) {
2617
- t6 = fieldSelection.type === "record-field" ? { recordFieldType: "ReferenceList" } : { fieldType: "ReferenceList" };
2618
- $[27] = fieldSelection.type;
2619
- $[28] = t6;
2620
- } else t6 = $[28];
2621
- let t7;
2622
- if ($[29] !== fieldSelection || $[30] !== t6) {
2623
- t7 = {
2624
- ...fieldSelection,
2625
- ...t6
2626
- };
2627
- $[29] = fieldSelection;
2628
- $[30] = t6;
2629
- $[31] = t7;
2630
- } else t7 = $[31];
2631
- const t8 = t7;
2632
- let t9;
2633
- if ($[32] !== collectionTitle || $[33] !== fieldId || $[34] !== placeholderOverlay || $[35] !== t8) {
2634
- t9 = /* @__PURE__ */ jsxs(ReferencePlaceholder, {
2635
- fieldId,
2636
- fieldSelection: t8,
2637
- "data-camox-field-id": fieldId,
2638
- "data-camox-overlay-mode": "reference",
2639
- ...placeholderOverlay,
2640
- children: ["Add ", collectionTitle]
2641
- });
2642
- $[32] = collectionTitle;
2643
- $[33] = fieldId;
2644
- $[34] = placeholderOverlay;
2645
- $[35] = t8;
2646
- $[36] = t9;
2647
- } else t9 = $[36];
2648
- t5 = t9;
2649
- break bb0;
2650
- }
2651
- let t6;
2652
- if ($[37] !== block || $[38] !== children || $[39] !== field || $[40] !== fieldName || $[41] !== listHovered || $[42] !== owner) {
2653
- t6 = (record) => /* @__PURE__ */ jsx(ListedRecord, {
2654
- block,
2655
- owner,
2656
- field,
2657
- fieldName,
2658
- record,
2659
- listHovered,
2660
- children
2661
- }, record.id);
2662
- $[37] = block;
2663
- $[38] = children;
2664
- $[39] = field;
2665
- $[40] = fieldName;
2666
- $[41] = listHovered;
2667
- $[42] = owner;
2668
- $[43] = t6;
2669
- } else t6 = $[43];
2670
- t4 = records.map(t6);
2671
- }
2672
- $[11] = block;
2673
- $[12] = children;
2674
- $[13] = collectionTitle;
2675
- $[14] = editable;
2676
- $[15] = field;
2677
- $[16] = fieldId;
2678
- $[17] = fieldName;
2679
- $[18] = fieldSelection;
2680
- $[19] = ids;
2681
- $[20] = listHovered;
2682
- $[21] = owner;
2683
- $[22] = placeholderOverlay;
2684
- $[23] = queryBacked;
2685
- $[24] = recordsMap;
2686
- $[25] = t4;
2687
- $[26] = t5;
2688
- } else {
2689
- t4 = $[25];
2690
- t5 = $[26];
2691
- }
2692
- if (t5 !== Symbol.for("react.early_return_sentinel")) return t5;
2693
- return t4;
2317
+ $[2] = block;
2318
+ $[3] = field;
2319
+ $[4] = fieldName;
2320
+ $[5] = normalizedData;
2321
+ $[6] = owner;
2322
+ $[7] = stored;
2323
+ $[8] = t2;
2324
+ } else t2 = $[8];
2325
+ const ids = t2;
2326
+ let t3;
2327
+ if ($[9] !== block || $[10] !== children || $[11] !== field || $[12] !== fieldName || $[13] !== ids || $[14] !== listHovered || $[15] !== owner || $[16] !== recordsMap) {
2328
+ const records = resolveReferenceList(ids, field.collectionId, recordsMap);
2329
+ let t4;
2330
+ if ($[18] !== block || $[19] !== children || $[20] !== field || $[21] !== fieldName || $[22] !== listHovered || $[23] !== owner) {
2331
+ t4 = (record) => /* @__PURE__ */ jsx(ListedRecord, {
2332
+ block,
2333
+ owner,
2334
+ field,
2335
+ fieldName,
2336
+ record,
2337
+ listHovered,
2338
+ children
2339
+ }, record.id);
2340
+ $[18] = block;
2341
+ $[19] = children;
2342
+ $[20] = field;
2343
+ $[21] = fieldName;
2344
+ $[22] = listHovered;
2345
+ $[23] = owner;
2346
+ $[24] = t4;
2347
+ } else t4 = $[24];
2348
+ t3 = records.map(t4);
2349
+ $[9] = block;
2350
+ $[10] = children;
2351
+ $[11] = field;
2352
+ $[12] = fieldName;
2353
+ $[13] = ids;
2354
+ $[14] = listHovered;
2355
+ $[15] = owner;
2356
+ $[16] = recordsMap;
2357
+ $[17] = t3;
2358
+ } else t3 = $[17];
2359
+ return t3;
2694
2360
  };
2695
2361
  const ReferenceList = ReferenceListImpl;
2696
2362
  const Detached = (t0) => {
@@ -2698,8 +2364,8 @@ function createEditableBlock(options) {
2698
2364
  const { children } = t0;
2699
2365
  const ctx = React.use(Context);
2700
2366
  if (!ctx) throw new Error("Detached must be used within a Block Component");
2701
- const { blockId, mode, isHovered, setIsHovered } = ctx;
2702
- const isContentEditable = useIsEditable(mode);
2367
+ const { blockId, isHovered, setIsHovered } = ctx;
2368
+ const isContentEditable = useIsEditable();
2703
2369
  const { window: iframeWindow } = useFrame();
2704
2370
  const selection = usePreviewTargetSelection();
2705
2371
  const selectTarget = usePreviewSelection();
@@ -2831,55 +2497,7 @@ function createEditableBlock(options) {
2831
2497
  contentSchema,
2832
2498
  settingsSchema,
2833
2499
  layoutOnly: options.layoutOnly ?? false,
2834
- synced: options.synced ?? false,
2835
- getInitialBundle: () => {
2836
- const counter = { value: 0 };
2837
- const allSeeds = [];
2838
- const content = { ...contentDefaults };
2839
- buildInitialSeeds(typeboxSchema.properties, null, content, allSeeds, counter);
2840
- const storageContent = {};
2841
- for (const [key, prop] of Object.entries(typeboxSchema.properties)) {
2842
- const ft = prop.fieldType;
2843
- if (ft === "Image" || ft === "File" || ft === "ImageList" || ft === "FileList" || ft === "Repeater") continue;
2844
- if ("default" in prop) storageContent[key] = prop.default;
2845
- }
2846
- return {
2847
- content: storageContent,
2848
- settings: { ...settingsDefaults },
2849
- repeatableItems: allSeeds
2850
- };
2851
- },
2852
- getInitialContent: () => {
2853
- return { ...contentDefaultsForStorage };
2854
- },
2855
- getInitialSettings: () => {
2856
- return { ...settingsDefaults };
2857
- },
2858
- getPeekBundle: () => {
2859
- const PEEK_BLOCK_ID = "peek";
2860
- const counter = { value: 0 };
2861
- const allItems = [];
2862
- const content = { ...contentDefaults };
2863
- buildPeekItems(typeboxSchema.properties, PEEK_BLOCK_ID, null, content, allItems, counter);
2864
- return {
2865
- block: {
2866
- id: PEEK_BLOCK_ID,
2867
- pageId: null,
2868
- layoutId: null,
2869
- type: options.id,
2870
- content,
2871
- settings: settingsDefaults,
2872
- slot: null,
2873
- summary: "",
2874
- title: "",
2875
- position: "",
2876
- createdAt: 0,
2877
- updatedAt: 0
2878
- },
2879
- repeatableItems: allItems,
2880
- files: []
2881
- };
2882
- }
2500
+ synced: options.synced ?? false
2883
2501
  }
2884
2502
  };
2885
2503
  }