camox 0.3.0 → 0.3.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/components/AuthGate.js +2 -1
- package/dist/core/components/AddBlockControlBar.js +117 -44
- package/dist/core/components/lexical/InlineContentEditable.js +37 -17
- package/dist/core/components/lexical/InlineLexicalEditor.js +84 -25
- package/dist/core/components/lexical/SelectionBroadcaster.js +84 -47
- package/dist/core/components/lexical/SidebarLexicalEditor.js +54 -19
- package/dist/core/createBlock.js +1172 -414
- package/dist/core/createLayout.js +48 -16
- package/dist/core/hooks/useFieldSelection.js +24 -13
- package/dist/core/hooks/useIsEditable.js +8 -2
- package/dist/core/hooks/useOverlayMessage.js +51 -20
- package/dist/features/content/CamoxContent.js +239 -107
- package/dist/features/content/components/AssetCard.js +78 -16
- package/dist/features/content/components/AssetCardSkeleton.js +11 -4
- package/dist/features/content/components/ContentSidebar.js +15 -8
- package/dist/features/content/components/UploadDropZone.js +77 -34
- package/dist/features/content/components/UploadProgressDrawer.js +201 -58
- package/dist/features/metadata/sitemap.js +15 -0
- package/dist/features/preview/CamoxPreview.js +447 -179
- package/dist/features/preview/components/AddBlockSheet.js +344 -167
- package/dist/features/preview/components/AgentChatSheet.js +32 -10
- package/dist/features/preview/components/AssetFieldEditor.js +185 -50
- package/dist/features/preview/components/AssetLightbox.js +60 -33
- package/dist/features/preview/components/AssetPickerGrid.js +203 -71
- package/dist/features/preview/components/BlockActionsPopover.js +295 -218
- package/dist/features/preview/components/CreatePageSheet.js +3 -3
- package/dist/features/preview/components/DebouncedFieldEditor.js +80 -23
- package/dist/features/preview/components/EditPageSheet.js +241 -86
- package/dist/features/preview/components/ItemFieldsEditor.js +209 -115
- package/dist/features/preview/components/LinkFieldEditor.js +351 -153
- package/dist/features/preview/components/MultipleAssetFieldEditor.js +245 -92
- package/dist/features/preview/components/OverlayTracker.js +58 -23
- package/dist/features/preview/components/Overlays.js +85 -43
- package/dist/features/preview/components/PageContentSheet.js +18 -18
- package/dist/features/preview/components/PageLocationFieldset.js +229 -63
- package/dist/features/preview/components/PagePicker.js +27 -27
- package/dist/features/preview/components/PageTree.js +921 -319
- package/dist/features/preview/components/PeekedBlock.js +173 -63
- package/dist/features/preview/components/PreviewPanel.js +271 -148
- package/dist/features/preview/components/PreviewSideSheet.js +44 -11
- package/dist/features/preview/components/PreviewToolbar.js +262 -59
- package/dist/features/preview/components/RepeatableItemsList.js +187 -78
- package/dist/features/preview/components/ShikiMarkdown.js +46 -20
- package/dist/features/preview/components/TextFormatToolbar.js +81 -23
- package/dist/features/preview/components/UnlinkAssetButton.js +161 -40
- package/dist/features/preview/components/useUpdateBlockPosition.js +64 -47
- package/dist/features/preview/previewStore.d.ts +2 -2
- package/dist/features/provider/CamoxProvider.js +69 -21
- package/dist/features/provider/actionsStore.d.ts +2 -2
- package/dist/features/provider/components/CamoxAppContext.js +15 -5
- package/dist/features/provider/components/CommandPalette.js +199 -92
- package/dist/features/provider/useAdminShortcuts.js +80 -64
- package/dist/features/routes/pageRoute.js +8 -1
- package/dist/features/studio/CamoxStudio.js +45 -9
- package/dist/features/studio/components/EnvironmentMenu.js +47 -12
- package/dist/features/studio/components/Navbar.js +163 -65
- package/dist/features/studio/components/ProjectMenu.js +263 -82
- package/dist/features/studio/components/UserButton.js +21 -6
- package/dist/features/studio/studioStore.d.ts +2 -2
- package/dist/features/studio/useTheme.js +128 -74
- package/dist/hooks/use-file-upload.js +11 -11
- package/dist/hooks/use-marquee-selection.js +121 -74
- package/dist/lib/auth.js +95 -51
- package/dist/lib/normalized-data.js +103 -30
- package/dist/lib/use-project-room.js +55 -22
- package/dist/studio.css +2 -2
- package/package.json +29 -26
- package/dist/lib/auth.d.ts +0 -2130
- package/dist/lib/auth.d.ts.map +0 -1
package/dist/core/createBlock.js
CHANGED
|
@@ -12,6 +12,7 @@ import { useIsEditable } from "./hooks/useIsEditable.js";
|
|
|
12
12
|
import { useOverlayMessage } from "./hooks/useOverlayMessage.js";
|
|
13
13
|
import { Type } from "./lib/contentType.js";
|
|
14
14
|
import { markdownToReactNodes } from "./lib/lexicalReact.js";
|
|
15
|
+
import { c } from "react/compiler-runtime";
|
|
15
16
|
import { useFrame } from "@camox/ui/frame";
|
|
16
17
|
import { Input } from "@camox/ui/input";
|
|
17
18
|
import { Kbd } from "@camox/ui/kbd";
|
|
@@ -261,7 +262,9 @@ function createBlock(options) {
|
|
|
261
262
|
}))
|
|
262
263
|
});
|
|
263
264
|
};
|
|
264
|
-
const Embed = (
|
|
265
|
+
const Embed = (t0) => {
|
|
266
|
+
const $ = c(55);
|
|
267
|
+
const { name, children } = t0;
|
|
265
268
|
const blockContext = React.use(Context);
|
|
266
269
|
if (!blockContext) throw new Error("Embed must be used within a Block Component");
|
|
267
270
|
const { blockId, content, mode } = blockContext;
|
|
@@ -270,89 +273,201 @@ function createBlock(options) {
|
|
|
270
273
|
const { window: iframeWindow } = useFrame();
|
|
271
274
|
const repeaterContext = React.use(RepeaterItemContext);
|
|
272
275
|
const fieldValue = repeaterContext ? repeaterContext.itemContent[name] : content[name];
|
|
273
|
-
const
|
|
276
|
+
const t1 = String(name);
|
|
277
|
+
let t2;
|
|
278
|
+
if ($[0] !== blockId || $[1] !== repeaterContext || $[2] !== t1) {
|
|
279
|
+
t2 = getOverlayFieldId(blockId, repeaterContext, t1);
|
|
280
|
+
$[0] = blockId;
|
|
281
|
+
$[1] = repeaterContext;
|
|
282
|
+
$[2] = t1;
|
|
283
|
+
$[3] = t2;
|
|
284
|
+
} else t2 = $[3];
|
|
285
|
+
const fieldId = t2;
|
|
274
286
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
275
287
|
const [urlValue, setUrlValue] = React.useState(fieldValue);
|
|
276
288
|
const [isHovered, setIsHovered] = React.useState(false);
|
|
277
289
|
const timerRef = React.useRef(null);
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
290
|
+
let t3;
|
|
291
|
+
if ($[4] !== fieldId) {
|
|
292
|
+
t3 = { fieldId };
|
|
293
|
+
$[4] = fieldId;
|
|
294
|
+
$[5] = t3;
|
|
295
|
+
} else t3 = $[5];
|
|
296
|
+
const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", t3);
|
|
297
|
+
let t4;
|
|
298
|
+
let t5;
|
|
299
|
+
if ($[6] !== isHoveredFromSidebar) {
|
|
300
|
+
t4 = () => {
|
|
301
|
+
setIsHovered(isHoveredFromSidebar);
|
|
302
|
+
};
|
|
303
|
+
t5 = [isHoveredFromSidebar];
|
|
304
|
+
$[6] = isHoveredFromSidebar;
|
|
305
|
+
$[7] = t4;
|
|
306
|
+
$[8] = t5;
|
|
307
|
+
} else {
|
|
308
|
+
t4 = $[7];
|
|
309
|
+
t5 = $[8];
|
|
310
|
+
}
|
|
311
|
+
React.useEffect(t4, t5);
|
|
312
|
+
let t6;
|
|
313
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
314
|
+
t6 = blockMutations.updateContent();
|
|
315
|
+
$[9] = t6;
|
|
316
|
+
} else t6 = $[9];
|
|
317
|
+
const updateBlockContent = useMutation(t6);
|
|
318
|
+
let t7;
|
|
319
|
+
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
320
|
+
t7 = repeatableItemMutations.updateContent();
|
|
321
|
+
$[10] = t7;
|
|
322
|
+
} else t7 = $[10];
|
|
323
|
+
const updateRepeatableContent = useMutation(t7);
|
|
324
|
+
let t8;
|
|
325
|
+
let t9;
|
|
326
|
+
if ($[11] !== fieldValue || $[12] !== isOpen) {
|
|
327
|
+
t8 = () => {
|
|
328
|
+
if (!isOpen) setUrlValue(fieldValue);
|
|
329
|
+
};
|
|
330
|
+
t9 = [fieldValue, isOpen];
|
|
331
|
+
$[11] = fieldValue;
|
|
332
|
+
$[12] = isOpen;
|
|
333
|
+
$[13] = t8;
|
|
334
|
+
$[14] = t9;
|
|
335
|
+
} else {
|
|
336
|
+
t8 = $[13];
|
|
337
|
+
t9 = $[14];
|
|
338
|
+
}
|
|
339
|
+
React.useEffect(t8, t9);
|
|
340
|
+
let t10;
|
|
341
|
+
let t11;
|
|
342
|
+
if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
|
|
343
|
+
t10 = () => () => {
|
|
289
344
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
290
345
|
};
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
346
|
+
t11 = [];
|
|
347
|
+
$[15] = t10;
|
|
348
|
+
$[16] = t11;
|
|
349
|
+
} else {
|
|
350
|
+
t10 = $[15];
|
|
351
|
+
t11 = $[16];
|
|
352
|
+
}
|
|
353
|
+
React.useEffect(t10, t11);
|
|
354
|
+
let t12;
|
|
355
|
+
if ($[17] !== blockId || $[18] !== name || $[19] !== repeaterContext || $[20] !== updateBlockContent || $[21] !== updateRepeatableContent) {
|
|
356
|
+
t12 = (e) => {
|
|
357
|
+
const newValue = e.target.value;
|
|
358
|
+
setUrlValue(newValue);
|
|
359
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
360
|
+
timerRef.current = window.setTimeout(() => {
|
|
361
|
+
if (repeaterContext?.itemId) updateRepeatableContent.mutate({
|
|
362
|
+
id: Number(repeaterContext.itemId),
|
|
363
|
+
content: { [name]: newValue }
|
|
364
|
+
});
|
|
365
|
+
else updateBlockContent.mutate({
|
|
366
|
+
id: Number(blockId),
|
|
367
|
+
content: { [name]: newValue }
|
|
368
|
+
});
|
|
369
|
+
}, 500);
|
|
370
|
+
};
|
|
371
|
+
$[17] = blockId;
|
|
372
|
+
$[18] = name;
|
|
373
|
+
$[19] = repeaterContext;
|
|
374
|
+
$[20] = updateBlockContent;
|
|
375
|
+
$[21] = updateRepeatableContent;
|
|
376
|
+
$[22] = t12;
|
|
377
|
+
} else t12 = $[22];
|
|
378
|
+
const handleUrlChange = t12;
|
|
379
|
+
let t13;
|
|
380
|
+
if ($[23] !== blockId || $[24] !== name || $[25] !== repeaterContext) {
|
|
381
|
+
t13 = (open) => {
|
|
382
|
+
setIsOpen(open);
|
|
383
|
+
if (open) if (repeaterContext?.itemId) previewStore.send({
|
|
384
|
+
type: "selectItemField",
|
|
385
|
+
blockId,
|
|
386
|
+
itemId: repeaterContext.itemId,
|
|
387
|
+
fieldName: name.toString(),
|
|
388
|
+
fieldType: "Embed"
|
|
300
389
|
});
|
|
301
|
-
else
|
|
302
|
-
|
|
303
|
-
|
|
390
|
+
else previewStore.send({
|
|
391
|
+
type: "selectBlockField",
|
|
392
|
+
blockId,
|
|
393
|
+
fieldName: name.toString(),
|
|
394
|
+
fieldType: "Embed"
|
|
304
395
|
});
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
396
|
+
};
|
|
397
|
+
$[23] = blockId;
|
|
398
|
+
$[24] = name;
|
|
399
|
+
$[25] = repeaterContext;
|
|
400
|
+
$[26] = t13;
|
|
401
|
+
} else t13 = $[26];
|
|
402
|
+
const handleOpenChange = t13;
|
|
403
|
+
const t14 = isContentEditable ? isOpen : false;
|
|
404
|
+
const t15 = isContentEditable ? handleOpenChange : void 0;
|
|
405
|
+
let t16;
|
|
406
|
+
if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
|
|
407
|
+
t16 = { position: "relative" };
|
|
408
|
+
$[27] = t16;
|
|
409
|
+
} else t16 = $[27];
|
|
410
|
+
let t17;
|
|
411
|
+
if ($[28] !== isContentEditable) {
|
|
412
|
+
t17 = isContentEditable ? () => setIsHovered(true) : void 0;
|
|
413
|
+
$[28] = isContentEditable;
|
|
414
|
+
$[29] = t17;
|
|
415
|
+
} else t17 = $[29];
|
|
416
|
+
let t18;
|
|
417
|
+
if ($[30] !== isContentEditable) {
|
|
418
|
+
t18 = isContentEditable ? () => setIsHovered(false) : void 0;
|
|
419
|
+
$[30] = isContentEditable;
|
|
420
|
+
$[31] = t18;
|
|
421
|
+
} else t18 = $[31];
|
|
422
|
+
let t19;
|
|
423
|
+
if ($[32] !== children || $[33] !== fieldValue) {
|
|
424
|
+
t19 = children(fieldValue);
|
|
425
|
+
$[32] = children;
|
|
426
|
+
$[33] = fieldValue;
|
|
427
|
+
$[34] = t19;
|
|
428
|
+
} else t19 = $[34];
|
|
429
|
+
let t20;
|
|
430
|
+
if ($[35] !== colors || $[36] !== isContentEditable || $[37] !== isHovered || $[38] !== isOpen) {
|
|
431
|
+
t20 = isContentEditable && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
432
|
+
style: {
|
|
433
|
+
position: "absolute",
|
|
434
|
+
inset: 0,
|
|
435
|
+
zIndex: 10
|
|
436
|
+
},
|
|
437
|
+
onClick: _temp
|
|
438
|
+
}), (isHovered || isOpen) && /* @__PURE__ */ jsx("div", { style: {
|
|
439
|
+
position: "absolute",
|
|
440
|
+
inset: isOpen ? OVERLAY_OFFSETS.blockSelected : OVERLAY_OFFSETS.blockHover,
|
|
441
|
+
border: `${isOpen ? OVERLAY_WIDTHS.selected : OVERLAY_WIDTHS.hover} solid ${isOpen ? colors.selected : colors.hover}`,
|
|
442
|
+
pointerEvents: "none",
|
|
443
|
+
zIndex: 11
|
|
444
|
+
} })] });
|
|
445
|
+
$[35] = colors;
|
|
446
|
+
$[36] = isContentEditable;
|
|
447
|
+
$[37] = isHovered;
|
|
448
|
+
$[38] = isOpen;
|
|
449
|
+
$[39] = t20;
|
|
450
|
+
} else t20 = $[39];
|
|
451
|
+
let t21;
|
|
452
|
+
if ($[40] !== t17 || $[41] !== t18 || $[42] !== t19 || $[43] !== t20) {
|
|
453
|
+
t21 = /* @__PURE__ */ jsx(PopoverTrigger, {
|
|
327
454
|
asChild: true,
|
|
328
455
|
children: /* @__PURE__ */ jsxs("div", {
|
|
329
|
-
style:
|
|
330
|
-
onMouseEnter:
|
|
331
|
-
onMouseLeave:
|
|
332
|
-
children: [
|
|
333
|
-
style: {
|
|
334
|
-
position: "absolute",
|
|
335
|
-
inset: 0,
|
|
336
|
-
zIndex: 10
|
|
337
|
-
},
|
|
338
|
-
onClick: () => {
|
|
339
|
-
if (hasShownEmbedLockToast) return;
|
|
340
|
-
hasShownEmbedLockToast = true;
|
|
341
|
-
toast(/* @__PURE__ */ jsxs("span", { children: [
|
|
342
|
-
"Hold ",
|
|
343
|
-
/* @__PURE__ */ jsx(Kbd, { children: "L" }),
|
|
344
|
-
" to interact with the embed content"
|
|
345
|
-
] }));
|
|
346
|
-
}
|
|
347
|
-
}), (isHovered || isOpen) && /* @__PURE__ */ jsx("div", { style: {
|
|
348
|
-
position: "absolute",
|
|
349
|
-
inset: isOpen ? OVERLAY_OFFSETS.blockSelected : OVERLAY_OFFSETS.blockHover,
|
|
350
|
-
border: `${isOpen ? OVERLAY_WIDTHS.selected : OVERLAY_WIDTHS.hover} solid ${isOpen ? colors.selected : colors.hover}`,
|
|
351
|
-
pointerEvents: "none",
|
|
352
|
-
zIndex: 11
|
|
353
|
-
} })] })]
|
|
456
|
+
style: t16,
|
|
457
|
+
onMouseEnter: t17,
|
|
458
|
+
onMouseLeave: t18,
|
|
459
|
+
children: [t19, t20]
|
|
354
460
|
})
|
|
355
|
-
})
|
|
461
|
+
});
|
|
462
|
+
$[40] = t17;
|
|
463
|
+
$[41] = t18;
|
|
464
|
+
$[42] = t19;
|
|
465
|
+
$[43] = t20;
|
|
466
|
+
$[44] = t21;
|
|
467
|
+
} else t21 = $[44];
|
|
468
|
+
let t22;
|
|
469
|
+
if ($[45] !== handleUrlChange || $[46] !== isContentEditable || $[47] !== name || $[48] !== urlValue) {
|
|
470
|
+
t22 = isContentEditable && /* @__PURE__ */ jsx(PopoverContent, {
|
|
356
471
|
className: "w-96 gap-2",
|
|
357
472
|
children: /* @__PURE__ */ jsxs("form", {
|
|
358
473
|
className: "grid gap-2",
|
|
@@ -366,10 +481,31 @@ function createBlock(options) {
|
|
|
366
481
|
onChange: handleUrlChange
|
|
367
482
|
})]
|
|
368
483
|
})
|
|
369
|
-
})
|
|
370
|
-
|
|
484
|
+
});
|
|
485
|
+
$[45] = handleUrlChange;
|
|
486
|
+
$[46] = isContentEditable;
|
|
487
|
+
$[47] = name;
|
|
488
|
+
$[48] = urlValue;
|
|
489
|
+
$[49] = t22;
|
|
490
|
+
} else t22 = $[49];
|
|
491
|
+
let t23;
|
|
492
|
+
if ($[50] !== t14 || $[51] !== t15 || $[52] !== t21 || $[53] !== t22) {
|
|
493
|
+
t23 = /* @__PURE__ */ jsxs(Popover, {
|
|
494
|
+
open: t14,
|
|
495
|
+
onOpenChange: t15,
|
|
496
|
+
children: [t21, t22]
|
|
497
|
+
});
|
|
498
|
+
$[50] = t14;
|
|
499
|
+
$[51] = t15;
|
|
500
|
+
$[52] = t21;
|
|
501
|
+
$[53] = t22;
|
|
502
|
+
$[54] = t23;
|
|
503
|
+
} else t23 = $[54];
|
|
504
|
+
return t23;
|
|
371
505
|
};
|
|
372
|
-
const Link = (
|
|
506
|
+
const Link = (t0) => {
|
|
507
|
+
const $ = c(63);
|
|
508
|
+
const { name, children } = t0;
|
|
373
509
|
const blockContext = React.use(Context);
|
|
374
510
|
if (!blockContext) throw new Error("Link must be used within a Block Component");
|
|
375
511
|
const { blockId, content, mode } = blockContext;
|
|
@@ -379,16 +515,55 @@ function createBlock(options) {
|
|
|
379
515
|
const { window: iframeWindow } = useFrame();
|
|
380
516
|
const repeaterContext = React.use(RepeaterItemContext);
|
|
381
517
|
const fieldValue = normalizeLinkValue(repeaterContext ? repeaterContext.itemContent[name] : content[name]);
|
|
382
|
-
|
|
383
|
-
|
|
518
|
+
let t1;
|
|
519
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
520
|
+
t1 = blockMutations.updateContent();
|
|
521
|
+
$[0] = t1;
|
|
522
|
+
} else t1 = $[0];
|
|
523
|
+
const updateBlockContent = useMutation(t1);
|
|
524
|
+
let t2;
|
|
525
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
526
|
+
t2 = repeatableItemMutations.updateContent();
|
|
527
|
+
$[1] = t2;
|
|
528
|
+
} else t2 = $[1];
|
|
529
|
+
const updateRepeatableContent = useMutation(t2);
|
|
384
530
|
const projectSlug = useProjectSlug();
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
531
|
+
let t3;
|
|
532
|
+
if ($[2] !== projectSlug) {
|
|
533
|
+
t3 = projectQueries.getBySlug(projectSlug);
|
|
534
|
+
$[2] = projectSlug;
|
|
535
|
+
$[3] = t3;
|
|
536
|
+
} else t3 = $[3];
|
|
537
|
+
const { data: project } = useQuery(t3);
|
|
538
|
+
let t4;
|
|
539
|
+
if ($[4] !== project?.id) {
|
|
540
|
+
t4 = pageQueries.list(project?.id ?? 0);
|
|
541
|
+
$[4] = project?.id;
|
|
542
|
+
$[5] = t4;
|
|
543
|
+
} else t4 = $[5];
|
|
544
|
+
const t5 = !!project;
|
|
545
|
+
let t6;
|
|
546
|
+
if ($[6] !== t4 || $[7] !== t5) {
|
|
547
|
+
t6 = {
|
|
548
|
+
...t4,
|
|
549
|
+
enabled: t5
|
|
550
|
+
};
|
|
551
|
+
$[6] = t4;
|
|
552
|
+
$[7] = t5;
|
|
553
|
+
$[8] = t6;
|
|
554
|
+
} else t6 = $[8];
|
|
555
|
+
const { data: pages } = useQuery(t6);
|
|
390
556
|
const resolvedHref = resolveLinkHref(fieldValue, pages);
|
|
391
|
-
const
|
|
557
|
+
const t7 = String(name);
|
|
558
|
+
let t8;
|
|
559
|
+
if ($[9] !== blockId || $[10] !== repeaterContext || $[11] !== t7) {
|
|
560
|
+
t8 = getOverlayFieldId(blockId, repeaterContext, t7);
|
|
561
|
+
$[9] = blockId;
|
|
562
|
+
$[10] = repeaterContext;
|
|
563
|
+
$[11] = t7;
|
|
564
|
+
$[12] = t8;
|
|
565
|
+
} else t8 = $[12];
|
|
566
|
+
const fieldId = t8;
|
|
392
567
|
const [isEditing, setIsEditing] = React.useState(false);
|
|
393
568
|
const [displayText, setDisplayText] = React.useState(fieldValue.text);
|
|
394
569
|
const [isHovered, setIsHovered] = React.useState(false);
|
|
@@ -398,20 +573,48 @@ function createBlock(options) {
|
|
|
398
573
|
React.useEffect(() => {
|
|
399
574
|
if (!isEditing) setDisplayText(fieldValue.text);
|
|
400
575
|
}, [fieldValue.text, isEditing]);
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}
|
|
414
|
-
|
|
576
|
+
let t9;
|
|
577
|
+
if ($[13] !== fieldId) {
|
|
578
|
+
t9 = { fieldId };
|
|
579
|
+
$[13] = fieldId;
|
|
580
|
+
$[14] = t9;
|
|
581
|
+
} else t9 = $[14];
|
|
582
|
+
const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", t9);
|
|
583
|
+
let t10;
|
|
584
|
+
let t11;
|
|
585
|
+
if ($[15] !== isHoveredFromSidebar) {
|
|
586
|
+
t10 = () => {
|
|
587
|
+
setIsHovered(isHoveredFromSidebar);
|
|
588
|
+
};
|
|
589
|
+
t11 = [isHoveredFromSidebar];
|
|
590
|
+
$[15] = isHoveredFromSidebar;
|
|
591
|
+
$[16] = t10;
|
|
592
|
+
$[17] = t11;
|
|
593
|
+
} else {
|
|
594
|
+
t10 = $[16];
|
|
595
|
+
t11 = $[17];
|
|
596
|
+
}
|
|
597
|
+
React.useEffect(t10, t11);
|
|
598
|
+
let t12;
|
|
599
|
+
if ($[18] !== blockId || $[19] !== name || $[20] !== repeaterContext || $[21] !== updateBlockContent || $[22] !== updateRepeatableContent) {
|
|
600
|
+
t12 = (newLinkValue) => {
|
|
601
|
+
if (repeaterContext?.itemId) updateRepeatableContent.mutate({
|
|
602
|
+
id: Number(repeaterContext.itemId),
|
|
603
|
+
content: { [name]: newLinkValue }
|
|
604
|
+
});
|
|
605
|
+
else updateBlockContent.mutate({
|
|
606
|
+
id: Number(blockId),
|
|
607
|
+
content: { [name]: newLinkValue }
|
|
608
|
+
});
|
|
609
|
+
};
|
|
610
|
+
$[18] = blockId;
|
|
611
|
+
$[19] = name;
|
|
612
|
+
$[20] = repeaterContext;
|
|
613
|
+
$[21] = updateBlockContent;
|
|
614
|
+
$[22] = updateRepeatableContent;
|
|
615
|
+
$[23] = t12;
|
|
616
|
+
} else t12 = $[23];
|
|
617
|
+
const saveLinkValue = t12;
|
|
415
618
|
const handleInput = (e) => {
|
|
416
619
|
const newText = e.target.textContent || "";
|
|
417
620
|
saveLinkValue({
|
|
@@ -419,77 +622,167 @@ function createBlock(options) {
|
|
|
419
622
|
text: newText
|
|
420
623
|
});
|
|
421
624
|
};
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
625
|
+
let t13;
|
|
626
|
+
if ($[24] !== blockId || $[25] !== name || $[26] !== repeaterContext) {
|
|
627
|
+
t13 = () => {
|
|
628
|
+
setIsEditing(true);
|
|
629
|
+
setIsEditorFocused(true);
|
|
630
|
+
if (repeaterContext?.itemId) previewStore.send({
|
|
631
|
+
type: "selectItemField",
|
|
632
|
+
blockId,
|
|
633
|
+
itemId: repeaterContext.itemId,
|
|
634
|
+
fieldName: String(name),
|
|
635
|
+
fieldType: "Link"
|
|
636
|
+
});
|
|
637
|
+
else previewStore.send({
|
|
638
|
+
type: "selectBlockField",
|
|
639
|
+
blockId,
|
|
640
|
+
fieldName: String(name),
|
|
641
|
+
fieldType: "Link"
|
|
642
|
+
});
|
|
643
|
+
};
|
|
644
|
+
$[24] = blockId;
|
|
645
|
+
$[25] = name;
|
|
646
|
+
$[26] = repeaterContext;
|
|
647
|
+
$[27] = t13;
|
|
648
|
+
} else t13 = $[27];
|
|
649
|
+
const handleFocus = t13;
|
|
650
|
+
let t14;
|
|
651
|
+
if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
|
|
652
|
+
t14 = () => {
|
|
653
|
+
setIsEditing(false);
|
|
654
|
+
setIsEditorFocused(false);
|
|
655
|
+
};
|
|
656
|
+
$[28] = t14;
|
|
657
|
+
} else t14 = $[28];
|
|
658
|
+
const handleBlur = t14;
|
|
659
|
+
let t15;
|
|
660
|
+
if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
|
|
661
|
+
t15 = (e_0) => {
|
|
662
|
+
e_0.stopPropagation();
|
|
663
|
+
previewStore.send({ type: "toggleContentSheet" });
|
|
664
|
+
setIsEditorFocused(false);
|
|
665
|
+
setIsEditing(false);
|
|
666
|
+
};
|
|
667
|
+
$[29] = t15;
|
|
668
|
+
} else t15 = $[29];
|
|
669
|
+
const handleEditLink = t15;
|
|
670
|
+
const T0 = Popover;
|
|
671
|
+
const t16 = isContentEditable && isEditorFocused;
|
|
672
|
+
const T1 = PopoverAnchor;
|
|
673
|
+
const t17 = true;
|
|
674
|
+
const T2 = Slot;
|
|
675
|
+
const t18 = isContentEditable ? fieldId : void 0;
|
|
676
|
+
const t19 = isContentEditable ? _temp2 : void 0;
|
|
677
|
+
let t20;
|
|
678
|
+
if ($[30] !== isContentEditable) {
|
|
679
|
+
t20 = isContentEditable ? () => setIsHovered(true) : void 0;
|
|
680
|
+
$[30] = isContentEditable;
|
|
681
|
+
$[31] = t20;
|
|
682
|
+
} else t20 = $[31];
|
|
683
|
+
let t21;
|
|
684
|
+
if ($[32] !== isContentEditable) {
|
|
685
|
+
t21 = isContentEditable ? () => setIsHovered(false) : void 0;
|
|
686
|
+
$[32] = isContentEditable;
|
|
687
|
+
$[33] = t21;
|
|
688
|
+
} else t21 = $[33];
|
|
689
|
+
const t22 = _temp3;
|
|
690
|
+
const t23 = false;
|
|
691
|
+
const t24 = true;
|
|
692
|
+
let t25;
|
|
693
|
+
if ($[34] !== colors || $[35] !== isContentEditable || $[36] !== isFocused || $[37] !== isHovered) {
|
|
694
|
+
t25 = isContentEditable && (isHovered || isFocused) ? {
|
|
695
|
+
outline: `${isFocused ? OVERLAY_WIDTHS.selected : OVERLAY_WIDTHS.hover} solid ${isFocused ? colors.selected : colors.hover}`,
|
|
696
|
+
outlineOffset: isFocused ? OVERLAY_OFFSETS.fieldSelected : OVERLAY_OFFSETS.fieldHover
|
|
697
|
+
} : void 0;
|
|
698
|
+
$[34] = colors;
|
|
699
|
+
$[35] = isContentEditable;
|
|
700
|
+
$[36] = isFocused;
|
|
701
|
+
$[37] = isHovered;
|
|
702
|
+
$[38] = t25;
|
|
703
|
+
} else t25 = $[38];
|
|
704
|
+
const t26 = children({
|
|
705
|
+
text: displayText,
|
|
706
|
+
href: resolvedHref,
|
|
707
|
+
newTab: fieldValue.newTab
|
|
708
|
+
});
|
|
709
|
+
let t27;
|
|
710
|
+
if ($[39] !== T2 || $[40] !== handleBlur || $[41] !== handleFocus || $[42] !== handleInput || $[43] !== isContentEditable || $[44] !== t18 || $[45] !== t19 || $[46] !== t20 || $[47] !== t21 || $[48] !== t22 || $[49] !== t25 || $[50] !== t26) {
|
|
711
|
+
t27 = /* @__PURE__ */ jsx(T2, {
|
|
712
|
+
ref: elementRef,
|
|
713
|
+
"data-camox-field-id": t18,
|
|
714
|
+
contentEditable: isContentEditable,
|
|
715
|
+
onClick: t19,
|
|
716
|
+
onInput: handleInput,
|
|
717
|
+
onFocus: handleFocus,
|
|
718
|
+
onBlur: handleBlur,
|
|
719
|
+
onMouseEnter: t20,
|
|
720
|
+
onMouseLeave: t21,
|
|
721
|
+
onKeyDown: t22,
|
|
722
|
+
spellCheck: t23,
|
|
723
|
+
suppressContentEditableWarning: t24,
|
|
724
|
+
style: t25,
|
|
725
|
+
children: t26
|
|
431
726
|
});
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
727
|
+
$[39] = T2;
|
|
728
|
+
$[40] = handleBlur;
|
|
729
|
+
$[41] = handleFocus;
|
|
730
|
+
$[42] = handleInput;
|
|
731
|
+
$[43] = isContentEditable;
|
|
732
|
+
$[44] = t18;
|
|
733
|
+
$[45] = t19;
|
|
734
|
+
$[46] = t20;
|
|
735
|
+
$[47] = t21;
|
|
736
|
+
$[48] = t22;
|
|
737
|
+
$[49] = t25;
|
|
738
|
+
$[50] = t26;
|
|
739
|
+
$[51] = t27;
|
|
740
|
+
} else t27 = $[51];
|
|
741
|
+
let t28;
|
|
742
|
+
if ($[52] !== T1 || $[53] !== t27) {
|
|
743
|
+
t28 = /* @__PURE__ */ jsx(T1, {
|
|
744
|
+
asChild: t17,
|
|
745
|
+
children: t27
|
|
437
746
|
});
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
previewStore.send({ type: "toggleContentSheet" });
|
|
446
|
-
setIsEditorFocused(false);
|
|
447
|
-
setIsEditing(false);
|
|
448
|
-
};
|
|
449
|
-
return /* @__PURE__ */ jsxs(Popover, {
|
|
450
|
-
open: isContentEditable && isEditorFocused,
|
|
451
|
-
children: [/* @__PURE__ */ jsx(PopoverAnchor, {
|
|
452
|
-
asChild: true,
|
|
453
|
-
children: /* @__PURE__ */ jsx(Slot, {
|
|
454
|
-
ref: elementRef,
|
|
455
|
-
"data-camox-field-id": isContentEditable ? fieldId : void 0,
|
|
456
|
-
contentEditable: isContentEditable,
|
|
457
|
-
onClick: isContentEditable ? (e) => e.preventDefault() : void 0,
|
|
458
|
-
onInput: handleInput,
|
|
459
|
-
onFocus: handleFocus,
|
|
460
|
-
onBlur: handleBlur,
|
|
461
|
-
onMouseEnter: isContentEditable ? () => setIsHovered(true) : void 0,
|
|
462
|
-
onMouseLeave: isContentEditable ? () => setIsHovered(false) : void 0,
|
|
463
|
-
onKeyDown: (e) => {
|
|
464
|
-
if (e.key === "Escape") e.target.blur();
|
|
465
|
-
},
|
|
466
|
-
spellCheck: false,
|
|
467
|
-
suppressContentEditableWarning: true,
|
|
468
|
-
style: isContentEditable && (isHovered || isFocused) ? {
|
|
469
|
-
outline: `${isFocused ? OVERLAY_WIDTHS.selected : OVERLAY_WIDTHS.hover} solid ${isFocused ? colors.selected : colors.hover}`,
|
|
470
|
-
outlineOffset: isFocused ? OVERLAY_OFFSETS.fieldSelected : OVERLAY_OFFSETS.fieldHover
|
|
471
|
-
} : void 0,
|
|
472
|
-
children: children({
|
|
473
|
-
text: displayText,
|
|
474
|
-
href: resolvedHref,
|
|
475
|
-
newTab: fieldValue.newTab
|
|
476
|
-
})
|
|
477
|
-
})
|
|
478
|
-
}), isContentEditable && /* @__PURE__ */ jsx(PopoverContent, {
|
|
747
|
+
$[52] = T1;
|
|
748
|
+
$[53] = t27;
|
|
749
|
+
$[54] = t28;
|
|
750
|
+
} else t28 = $[54];
|
|
751
|
+
let t29;
|
|
752
|
+
if ($[55] !== handleEditLink || $[56] !== isContentEditable) {
|
|
753
|
+
t29 = isContentEditable && /* @__PURE__ */ jsx(PopoverContent, {
|
|
479
754
|
className: "w-auto p-2",
|
|
480
|
-
onOpenAutoFocus:
|
|
755
|
+
onOpenAutoFocus: _temp4,
|
|
481
756
|
align: "end",
|
|
482
757
|
children: /* @__PURE__ */ jsx("button", {
|
|
483
758
|
type: "button",
|
|
484
759
|
className: "hover:bg-accent flex items-center gap-1.5 rounded-md px-2 py-1 text-sm transition-colors",
|
|
485
|
-
onMouseDown:
|
|
760
|
+
onMouseDown: _temp5,
|
|
486
761
|
onClick: handleEditLink,
|
|
487
762
|
children: "Edit link"
|
|
488
763
|
})
|
|
489
|
-
})
|
|
490
|
-
|
|
764
|
+
});
|
|
765
|
+
$[55] = handleEditLink;
|
|
766
|
+
$[56] = isContentEditable;
|
|
767
|
+
$[57] = t29;
|
|
768
|
+
} else t29 = $[57];
|
|
769
|
+
let t30;
|
|
770
|
+
if ($[58] !== T0 || $[59] !== t16 || $[60] !== t28 || $[61] !== t29) {
|
|
771
|
+
t30 = /* @__PURE__ */ jsxs(T0, {
|
|
772
|
+
open: t16,
|
|
773
|
+
children: [t28, t29]
|
|
774
|
+
});
|
|
775
|
+
$[58] = T0;
|
|
776
|
+
$[59] = t16;
|
|
777
|
+
$[60] = t28;
|
|
778
|
+
$[61] = t29;
|
|
779
|
+
$[62] = t30;
|
|
780
|
+
} else t30 = $[62];
|
|
781
|
+
return t30;
|
|
491
782
|
};
|
|
492
|
-
const Image = (
|
|
783
|
+
const Image = (t0) => {
|
|
784
|
+
const $ = c(37);
|
|
785
|
+
const { name, children } = t0;
|
|
493
786
|
const blockContext = React.use(Context);
|
|
494
787
|
if (!blockContext) throw new Error("Image must be used within a Block Component");
|
|
495
788
|
const { blockId, content, mode } = blockContext;
|
|
@@ -499,93 +792,262 @@ function createBlock(options) {
|
|
|
499
792
|
const repeaterContext = React.use(RepeaterItemContext);
|
|
500
793
|
const { filesMap } = useNormalizedData();
|
|
501
794
|
const rawSource = repeaterContext ? repeaterContext.itemContent[name] : content[name];
|
|
502
|
-
|
|
503
|
-
|
|
795
|
+
let t1;
|
|
796
|
+
if ($[0] !== filesMap || $[1] !== rawSource) {
|
|
797
|
+
t1 = isFileMarker(rawSource) ? resolveFileMarker(rawSource, filesMap) : rawSource;
|
|
798
|
+
$[0] = filesMap;
|
|
799
|
+
$[1] = rawSource;
|
|
800
|
+
$[2] = t1;
|
|
801
|
+
} else t1 = $[2];
|
|
802
|
+
const fieldValue = t1 ?? contentDefaults[String(name)];
|
|
803
|
+
const t2 = String(name);
|
|
804
|
+
let t3;
|
|
805
|
+
if ($[3] !== blockId || $[4] !== repeaterContext || $[5] !== t2) {
|
|
806
|
+
t3 = getOverlayFieldId(blockId, repeaterContext, t2);
|
|
807
|
+
$[3] = blockId;
|
|
808
|
+
$[4] = repeaterContext;
|
|
809
|
+
$[5] = t2;
|
|
810
|
+
$[6] = t3;
|
|
811
|
+
} else t3 = $[6];
|
|
812
|
+
const fieldId = t3;
|
|
504
813
|
const [isHovered, setIsHovered] = React.useState(false);
|
|
505
814
|
const isFocused = useFieldSelection(blockId, String(name), "Image", repeaterContext?.itemId);
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
815
|
+
let t4;
|
|
816
|
+
if ($[7] !== fieldId) {
|
|
817
|
+
t4 = { fieldId };
|
|
818
|
+
$[7] = fieldId;
|
|
819
|
+
$[8] = t4;
|
|
820
|
+
} else t4 = $[8];
|
|
821
|
+
const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", t4);
|
|
822
|
+
let t5;
|
|
823
|
+
let t6;
|
|
824
|
+
if ($[9] !== isHoveredFromSidebar) {
|
|
825
|
+
t5 = () => {
|
|
826
|
+
setIsHovered(isHoveredFromSidebar);
|
|
827
|
+
};
|
|
828
|
+
t6 = [isHoveredFromSidebar];
|
|
829
|
+
$[9] = isHoveredFromSidebar;
|
|
830
|
+
$[10] = t5;
|
|
831
|
+
$[11] = t6;
|
|
832
|
+
} else {
|
|
833
|
+
t5 = $[10];
|
|
834
|
+
t6 = $[11];
|
|
835
|
+
}
|
|
836
|
+
React.useEffect(t5, t6);
|
|
837
|
+
let t7;
|
|
838
|
+
if ($[12] !== blockId || $[13] !== isContentEditable || $[14] !== name || $[15] !== repeaterContext) {
|
|
839
|
+
t7 = () => {
|
|
840
|
+
if (!isContentEditable) return;
|
|
841
|
+
const imageFieldName = repeaterContext && !repeaterContext.itemId ? repeaterContext.arrayFieldName : String(name);
|
|
842
|
+
if (repeaterContext?.itemId) previewStore.send({
|
|
843
|
+
type: "selectItemField",
|
|
844
|
+
blockId,
|
|
845
|
+
itemId: repeaterContext.itemId,
|
|
846
|
+
fieldName: imageFieldName,
|
|
847
|
+
fieldType: "Image"
|
|
848
|
+
});
|
|
849
|
+
else previewStore.send({
|
|
850
|
+
type: "selectBlockField",
|
|
851
|
+
blockId,
|
|
852
|
+
fieldName: imageFieldName,
|
|
853
|
+
fieldType: "Image"
|
|
854
|
+
});
|
|
855
|
+
previewStore.send({ type: "toggleContentSheet" });
|
|
856
|
+
};
|
|
857
|
+
$[12] = blockId;
|
|
858
|
+
$[13] = isContentEditable;
|
|
859
|
+
$[14] = name;
|
|
860
|
+
$[15] = repeaterContext;
|
|
861
|
+
$[16] = t7;
|
|
862
|
+
} else t7 = $[16];
|
|
863
|
+
const handleClick = t7;
|
|
864
|
+
if (!isContentEditable) {
|
|
865
|
+
let t8;
|
|
866
|
+
if ($[17] !== children || $[18] !== fieldValue) {
|
|
867
|
+
t8 = children(fieldValue);
|
|
868
|
+
$[17] = children;
|
|
869
|
+
$[18] = fieldValue;
|
|
870
|
+
$[19] = t8;
|
|
871
|
+
} else t8 = $[19];
|
|
872
|
+
let t9;
|
|
873
|
+
if ($[20] !== t8) {
|
|
874
|
+
t9 = /* @__PURE__ */ jsx(Fragment, { children: t8 });
|
|
875
|
+
$[20] = t8;
|
|
876
|
+
$[21] = t9;
|
|
877
|
+
} else t9 = $[21];
|
|
878
|
+
return t9;
|
|
879
|
+
}
|
|
529
880
|
const showOverlay = isHovered || isFocused;
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
"
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
881
|
+
let t8;
|
|
882
|
+
if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
|
|
883
|
+
t8 = { position: "relative" };
|
|
884
|
+
$[22] = t8;
|
|
885
|
+
} else t8 = $[22];
|
|
886
|
+
let t10;
|
|
887
|
+
let t9;
|
|
888
|
+
if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
|
|
889
|
+
t9 = () => setIsHovered(true);
|
|
890
|
+
t10 = () => setIsHovered(false);
|
|
891
|
+
$[23] = t10;
|
|
892
|
+
$[24] = t9;
|
|
893
|
+
} else {
|
|
894
|
+
t10 = $[23];
|
|
895
|
+
t9 = $[24];
|
|
896
|
+
}
|
|
897
|
+
let t11;
|
|
898
|
+
if ($[25] !== children || $[26] !== fieldValue) {
|
|
899
|
+
t11 = children(fieldValue);
|
|
900
|
+
$[25] = children;
|
|
901
|
+
$[26] = fieldValue;
|
|
902
|
+
$[27] = t11;
|
|
903
|
+
} else t11 = $[27];
|
|
904
|
+
let t12;
|
|
905
|
+
if ($[28] !== colors || $[29] !== isFocused || $[30] !== showOverlay) {
|
|
906
|
+
t12 = showOverlay && /* @__PURE__ */ jsx("div", { style: {
|
|
537
907
|
position: "absolute",
|
|
538
908
|
inset: isFocused ? OVERLAY_OFFSETS.blockSelected : OVERLAY_OFFSETS.blockHover,
|
|
539
909
|
border: `${isFocused ? OVERLAY_WIDTHS.selected : OVERLAY_WIDTHS.hover} solid ${isFocused ? colors.selected : colors.hover}`,
|
|
540
910
|
pointerEvents: "none",
|
|
541
911
|
zIndex: 10
|
|
542
|
-
} })
|
|
543
|
-
|
|
912
|
+
} });
|
|
913
|
+
$[28] = colors;
|
|
914
|
+
$[29] = isFocused;
|
|
915
|
+
$[30] = showOverlay;
|
|
916
|
+
$[31] = t12;
|
|
917
|
+
} else t12 = $[31];
|
|
918
|
+
let t13;
|
|
919
|
+
if ($[32] !== fieldId || $[33] !== handleClick || $[34] !== t11 || $[35] !== t12) {
|
|
920
|
+
t13 = /* @__PURE__ */ jsxs("div", {
|
|
921
|
+
style: t8,
|
|
922
|
+
"data-camox-field-id": fieldId,
|
|
923
|
+
onMouseEnter: t9,
|
|
924
|
+
onMouseLeave: t10,
|
|
925
|
+
onClick: handleClick,
|
|
926
|
+
children: [t11, t12]
|
|
927
|
+
});
|
|
928
|
+
$[32] = fieldId;
|
|
929
|
+
$[33] = handleClick;
|
|
930
|
+
$[34] = t11;
|
|
931
|
+
$[35] = t12;
|
|
932
|
+
$[36] = t13;
|
|
933
|
+
} else t13 = $[36];
|
|
934
|
+
return t13;
|
|
544
935
|
};
|
|
545
|
-
const File = (
|
|
936
|
+
const File = (t0) => {
|
|
937
|
+
const $ = c(8);
|
|
938
|
+
const { name, children } = t0;
|
|
546
939
|
const blockContext = React.use(Context);
|
|
547
940
|
if (!blockContext) throw new Error("File must be used within a Block Component");
|
|
548
941
|
const { content } = blockContext;
|
|
549
942
|
const repeaterContext = React.use(RepeaterItemContext);
|
|
550
943
|
const { filesMap } = useNormalizedData();
|
|
551
944
|
const rawSource = repeaterContext ? repeaterContext.itemContent[name] : content[name];
|
|
552
|
-
|
|
945
|
+
let t1;
|
|
946
|
+
if ($[0] !== filesMap || $[1] !== rawSource) {
|
|
947
|
+
t1 = isFileMarker(rawSource) ? resolveFileMarker(rawSource, filesMap) : rawSource;
|
|
948
|
+
$[0] = filesMap;
|
|
949
|
+
$[1] = rawSource;
|
|
950
|
+
$[2] = t1;
|
|
951
|
+
} else t1 = $[2];
|
|
952
|
+
const fieldValue = t1 ?? contentDefaults[String(name)];
|
|
953
|
+
let t2;
|
|
954
|
+
if ($[3] !== children || $[4] !== fieldValue) {
|
|
955
|
+
t2 = children(fieldValue);
|
|
956
|
+
$[3] = children;
|
|
957
|
+
$[4] = fieldValue;
|
|
958
|
+
$[5] = t2;
|
|
959
|
+
} else t2 = $[5];
|
|
960
|
+
let t3;
|
|
961
|
+
if ($[6] !== t2) {
|
|
962
|
+
t3 = /* @__PURE__ */ jsx(Fragment, { children: t2 });
|
|
963
|
+
$[6] = t2;
|
|
964
|
+
$[7] = t3;
|
|
965
|
+
} else t3 = $[7];
|
|
966
|
+
return t3;
|
|
553
967
|
};
|
|
554
|
-
const RepeaterItemWrapper = (
|
|
968
|
+
const RepeaterItemWrapper = (t0) => {
|
|
969
|
+
const $ = c(11);
|
|
970
|
+
const { itemId, blockId, mode, children } = t0;
|
|
555
971
|
const isContentEditable = useIsEditable(mode);
|
|
556
972
|
const colors = mode === "layout" ? LAYOUT_OVERLAY_COLORS : OVERLAY_COLORS;
|
|
557
973
|
const { window: iframeWindow } = useFrame();
|
|
558
974
|
const isRepeaterHovered = React.useContext(RepeaterHoverContext);
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
975
|
+
let t1;
|
|
976
|
+
if ($[0] !== blockId || $[1] !== itemId) {
|
|
977
|
+
t1 = {
|
|
978
|
+
blockId,
|
|
979
|
+
itemId
|
|
980
|
+
};
|
|
981
|
+
$[0] = blockId;
|
|
982
|
+
$[1] = itemId;
|
|
983
|
+
$[2] = t1;
|
|
984
|
+
} else t1 = $[2];
|
|
985
|
+
const isHovered = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_REPEATER_ITEM", "CAMOX_HOVER_REPEATER_ITEM_END", t1);
|
|
563
986
|
const showOverlay = isContentEditable && (isHovered || isRepeaterHovered);
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
987
|
+
let t2;
|
|
988
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
989
|
+
t2 = { position: "relative" };
|
|
990
|
+
$[3] = t2;
|
|
991
|
+
} else t2 = $[3];
|
|
992
|
+
const t3 = isContentEditable ? itemId : void 0;
|
|
993
|
+
let t4;
|
|
994
|
+
if ($[4] !== colors || $[5] !== showOverlay) {
|
|
995
|
+
t4 = showOverlay && /* @__PURE__ */ jsx("div", { style: {
|
|
568
996
|
position: "absolute",
|
|
569
997
|
inset: OVERLAY_OFFSETS.blockHover,
|
|
570
998
|
border: `${OVERLAY_WIDTHS.hover} solid ${colors.hover}`,
|
|
571
999
|
pointerEvents: "none",
|
|
572
1000
|
zIndex: 10
|
|
573
|
-
} })
|
|
574
|
-
|
|
1001
|
+
} });
|
|
1002
|
+
$[4] = colors;
|
|
1003
|
+
$[5] = showOverlay;
|
|
1004
|
+
$[6] = t4;
|
|
1005
|
+
} else t4 = $[6];
|
|
1006
|
+
let t5;
|
|
1007
|
+
if ($[7] !== children || $[8] !== t3 || $[9] !== t4) {
|
|
1008
|
+
t5 = /* @__PURE__ */ jsxs("div", {
|
|
1009
|
+
style: t2,
|
|
1010
|
+
"data-camox-repeater-item-id": t3,
|
|
1011
|
+
children: [children, t4]
|
|
1012
|
+
});
|
|
1013
|
+
$[7] = children;
|
|
1014
|
+
$[8] = t3;
|
|
1015
|
+
$[9] = t4;
|
|
1016
|
+
$[10] = t5;
|
|
1017
|
+
} else t5 = $[10];
|
|
1018
|
+
return t5;
|
|
575
1019
|
};
|
|
576
|
-
const RepeaterHoverProvider = (
|
|
1020
|
+
const RepeaterHoverProvider = (t0) => {
|
|
1021
|
+
const $ = c(6);
|
|
1022
|
+
const { blockId, fieldName, children } = t0;
|
|
577
1023
|
const isContentEditable = useIsEditable("site");
|
|
578
1024
|
const { window: iframeWindow } = useFrame();
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
1025
|
+
let t1;
|
|
1026
|
+
if ($[0] !== blockId || $[1] !== fieldName) {
|
|
1027
|
+
t1 = {
|
|
1028
|
+
blockId,
|
|
1029
|
+
fieldName
|
|
1030
|
+
};
|
|
1031
|
+
$[0] = blockId;
|
|
1032
|
+
$[1] = fieldName;
|
|
1033
|
+
$[2] = t1;
|
|
1034
|
+
} else t1 = $[2];
|
|
1035
|
+
const isHovered = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_REPEATER", "CAMOX_HOVER_REPEATER_END", t1);
|
|
1036
|
+
let t2;
|
|
1037
|
+
if ($[3] !== children || $[4] !== isHovered) {
|
|
1038
|
+
t2 = /* @__PURE__ */ jsx(RepeaterHoverContext.Provider, {
|
|
1039
|
+
value: isHovered,
|
|
1040
|
+
children
|
|
1041
|
+
});
|
|
1042
|
+
$[3] = children;
|
|
1043
|
+
$[4] = isHovered;
|
|
1044
|
+
$[5] = t2;
|
|
1045
|
+
} else t2 = $[5];
|
|
1046
|
+
return t2;
|
|
587
1047
|
};
|
|
588
|
-
const Repeater = (
|
|
1048
|
+
const Repeater = (t0) => {
|
|
1049
|
+
const $ = c(10);
|
|
1050
|
+
const { name, children } = t0;
|
|
589
1051
|
const blockContext = React.use(Context);
|
|
590
1052
|
if (!blockContext) throw new Error("Repeater must be used within a Block Component");
|
|
591
1053
|
const { blockId, content, mode } = blockContext;
|
|
@@ -603,10 +1065,16 @@ function createBlock(options) {
|
|
|
603
1065
|
const { itemsMap } = useNormalizedData();
|
|
604
1066
|
let arrayValue = source ?? [];
|
|
605
1067
|
if (!Array.isArray(arrayValue)) throw new Error(`Field "${String(name)}" is not an array`);
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
1068
|
+
let t1;
|
|
1069
|
+
if ($[0] !== itemsMap) {
|
|
1070
|
+
t1 = (item) => {
|
|
1071
|
+
if (isItemMarker(item)) return itemsMap.get(item._itemId) ?? null;
|
|
1072
|
+
return item;
|
|
1073
|
+
};
|
|
1074
|
+
$[0] = itemsMap;
|
|
1075
|
+
$[1] = t1;
|
|
1076
|
+
} else t1 = $[1];
|
|
1077
|
+
arrayValue = arrayValue.map(t1).filter(Boolean);
|
|
610
1078
|
if (arrayValue.length === 0) {
|
|
611
1079
|
const fieldSchema = parentRepeaterContext ? typeboxSchema.properties[parentRepeaterContext.arrayFieldName]?.items?.properties?.[fieldName] : typeboxSchema.properties[fieldName];
|
|
612
1080
|
const ait = fieldSchema?.arrayItemType;
|
|
@@ -614,177 +1082,357 @@ function createBlock(options) {
|
|
|
614
1082
|
const defaultCount = fieldSchema.defaultItems ?? 0;
|
|
615
1083
|
const itemProps = fieldSchema.items?.properties;
|
|
616
1084
|
if (defaultCount > 0 && itemProps) {
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
1085
|
+
let t2;
|
|
1086
|
+
if ($[2] !== defaultCount || $[3] !== itemProps) {
|
|
1087
|
+
const itemContent = {};
|
|
1088
|
+
for (const [propName, propSchema] of Object.entries(itemProps)) if (propSchema && typeof propSchema === "object" && "default" in propSchema) itemContent[propName] = propSchema.default;
|
|
1089
|
+
t2 = Array.from({ length: defaultCount }, () => ({ ...itemContent }));
|
|
1090
|
+
$[2] = defaultCount;
|
|
1091
|
+
$[3] = itemProps;
|
|
1092
|
+
$[4] = t2;
|
|
1093
|
+
} else t2 = $[4];
|
|
1094
|
+
arrayValue = t2;
|
|
620
1095
|
}
|
|
621
1096
|
}
|
|
622
1097
|
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
})
|
|
646
|
-
}, itemId || index);
|
|
647
|
-
})
|
|
1098
|
+
const T0 = RepeaterHoverProvider;
|
|
1099
|
+
const t2 = arrayValue.map((item_0, index) => {
|
|
1100
|
+
const isDbItem = item_0.content !== void 0 && item_0.id != null;
|
|
1101
|
+
const itemContent_0 = {
|
|
1102
|
+
...repeatableItemDefaults[fieldName],
|
|
1103
|
+
...isDbItem ? item_0.content : item_0
|
|
1104
|
+
};
|
|
1105
|
+
const itemId = isDbItem ? String(item_0.id) : void 0;
|
|
1106
|
+
return /* @__PURE__ */ jsx(RepeaterItemContext.Provider, {
|
|
1107
|
+
value: {
|
|
1108
|
+
arrayFieldName: fieldName,
|
|
1109
|
+
itemIndex: index,
|
|
1110
|
+
itemContent: itemContent_0,
|
|
1111
|
+
itemId
|
|
1112
|
+
},
|
|
1113
|
+
children: /* @__PURE__ */ jsx(RepeaterItemWrapper, {
|
|
1114
|
+
itemId,
|
|
1115
|
+
blockId,
|
|
1116
|
+
mode,
|
|
1117
|
+
children: children(itemComponents, index)
|
|
1118
|
+
})
|
|
1119
|
+
}, itemId || index);
|
|
648
1120
|
});
|
|
1121
|
+
let t3;
|
|
1122
|
+
if ($[5] !== T0 || $[6] !== blockId || $[7] !== fieldName || $[8] !== t2) {
|
|
1123
|
+
t3 = /* @__PURE__ */ jsx(T0, {
|
|
1124
|
+
blockId,
|
|
1125
|
+
fieldName,
|
|
1126
|
+
children: t2
|
|
1127
|
+
});
|
|
1128
|
+
$[5] = T0;
|
|
1129
|
+
$[6] = blockId;
|
|
1130
|
+
$[7] = fieldName;
|
|
1131
|
+
$[8] = t2;
|
|
1132
|
+
$[9] = t3;
|
|
1133
|
+
} else t3 = $[9];
|
|
1134
|
+
return t3;
|
|
649
1135
|
};
|
|
650
|
-
const BlockComponent = (
|
|
1136
|
+
const BlockComponent = (t0) => {
|
|
1137
|
+
const $ = c(67);
|
|
1138
|
+
const { blockData, mode, isFirstBlock, showAddBlockTop, showAddBlockBottom, addBlockAfterPosition } = t0;
|
|
651
1139
|
const isContentEditable = useIsEditable(mode);
|
|
652
1140
|
const { window: iframeWindow } = useFrame();
|
|
653
1141
|
const [isHovered, setIsHovered] = React.useState(false);
|
|
654
|
-
const selection = useSelector(previewStore,
|
|
655
|
-
const isPageContentSheetOpen = useSelector(previewStore,
|
|
656
|
-
const isAddBlockSheetOpen = useSelector(previewStore,
|
|
1142
|
+
const selection = useSelector(previewStore, _temp6);
|
|
1143
|
+
const isPageContentSheetOpen = useSelector(previewStore, _temp7);
|
|
1144
|
+
const isAddBlockSheetOpen = useSelector(previewStore, _temp8);
|
|
657
1145
|
const isAnySideSheetOpen = useIsPreviewSheetOpen();
|
|
658
1146
|
const isBlockSelected = selection?.blockId === blockData._id;
|
|
659
1147
|
const ref = React.useRef(null);
|
|
660
1148
|
const [isFirstRender, setIsFirstRender] = React.useState(true);
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
React.useEffect(
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
1149
|
+
let t1;
|
|
1150
|
+
let t2;
|
|
1151
|
+
if ($[0] !== isFirstRender) {
|
|
1152
|
+
t1 = () => {
|
|
1153
|
+
if (isFirstRender) setIsFirstRender(false);
|
|
1154
|
+
};
|
|
1155
|
+
t2 = [isFirstRender];
|
|
1156
|
+
$[0] = isFirstRender;
|
|
1157
|
+
$[1] = t1;
|
|
1158
|
+
$[2] = t2;
|
|
1159
|
+
} else {
|
|
1160
|
+
t1 = $[1];
|
|
1161
|
+
t2 = $[2];
|
|
1162
|
+
}
|
|
1163
|
+
React.useEffect(t1, t2);
|
|
1164
|
+
let t3;
|
|
1165
|
+
if ($[3] !== isBlockSelected || $[4] !== isFirstRender) {
|
|
1166
|
+
t3 = () => {
|
|
1167
|
+
if (isBlockSelected && ref.current) ref.current.scrollIntoView({
|
|
1168
|
+
behavior: isFirstRender ? "instant" : "smooth",
|
|
1169
|
+
block: isFirstRender ? "start" : "nearest"
|
|
1170
|
+
});
|
|
1171
|
+
};
|
|
1172
|
+
$[3] = isBlockSelected;
|
|
1173
|
+
$[4] = isFirstRender;
|
|
1174
|
+
$[5] = t3;
|
|
1175
|
+
} else t3 = $[5];
|
|
1176
|
+
let t4;
|
|
1177
|
+
if ($[6] !== isBlockSelected || $[7] !== isFirstRender || $[8] !== isPageContentSheetOpen) {
|
|
1178
|
+
t4 = [
|
|
1179
|
+
isBlockSelected,
|
|
1180
|
+
isFirstRender,
|
|
1181
|
+
isPageContentSheetOpen
|
|
1182
|
+
];
|
|
1183
|
+
$[6] = isBlockSelected;
|
|
1184
|
+
$[7] = isFirstRender;
|
|
1185
|
+
$[8] = isPageContentSheetOpen;
|
|
1186
|
+
$[9] = t4;
|
|
1187
|
+
} else t4 = $[9];
|
|
1188
|
+
React.useEffect(t3, t4);
|
|
1189
|
+
let t5;
|
|
1190
|
+
if ($[10] !== blockData._id) {
|
|
1191
|
+
t5 = { blockId: blockData._id };
|
|
1192
|
+
$[10] = blockData._id;
|
|
1193
|
+
$[11] = t5;
|
|
1194
|
+
} else t5 = $[11];
|
|
1195
|
+
const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_BLOCK", "CAMOX_HOVER_BLOCK_END", t5);
|
|
1196
|
+
let t6;
|
|
1197
|
+
let t7;
|
|
1198
|
+
if ($[12] !== isHoveredFromSidebar) {
|
|
1199
|
+
t6 = () => {
|
|
1200
|
+
setIsHovered(isHoveredFromSidebar);
|
|
1201
|
+
};
|
|
1202
|
+
t7 = [isHoveredFromSidebar];
|
|
1203
|
+
$[12] = isHoveredFromSidebar;
|
|
1204
|
+
$[13] = t6;
|
|
1205
|
+
$[14] = t7;
|
|
1206
|
+
} else {
|
|
1207
|
+
t6 = $[13];
|
|
1208
|
+
t7 = $[14];
|
|
1209
|
+
}
|
|
1210
|
+
React.useEffect(t6, t7);
|
|
1211
|
+
let result;
|
|
1212
|
+
if ($[15] !== blockData.content) {
|
|
1213
|
+
result = { ...blockData.content };
|
|
680
1214
|
for (const key in result) {
|
|
681
1215
|
const value = result[key];
|
|
682
|
-
if (Array.isArray(value) && value.length > 0 && value[0]?.content !== void 0) result[key] = value.map(
|
|
1216
|
+
if (Array.isArray(value) && value.length > 0 && value[0]?.content !== void 0) result[key] = value.map(_temp9);
|
|
683
1217
|
}
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
1218
|
+
$[15] = blockData.content;
|
|
1219
|
+
$[16] = result;
|
|
1220
|
+
} else result = $[16];
|
|
1221
|
+
const normalizedContent = result;
|
|
1222
|
+
let t8;
|
|
1223
|
+
if ($[17] !== blockData._id || $[18] !== isContentEditable) {
|
|
1224
|
+
t8 = (e) => {
|
|
1225
|
+
if (!isContentEditable) return;
|
|
1226
|
+
if (e.target.closest("[data-camox-field-id]")) return;
|
|
1227
|
+
previewStore.send({
|
|
1228
|
+
type: "setFocusedBlock",
|
|
1229
|
+
blockId: blockData._id
|
|
1230
|
+
});
|
|
1231
|
+
};
|
|
1232
|
+
$[17] = blockData._id;
|
|
1233
|
+
$[18] = isContentEditable;
|
|
1234
|
+
$[19] = t8;
|
|
1235
|
+
} else t8 = $[19];
|
|
1236
|
+
const handleClick = t8;
|
|
1237
|
+
let t9;
|
|
1238
|
+
if ($[20] !== isContentEditable) {
|
|
1239
|
+
t9 = () => {
|
|
1240
|
+
if (isContentEditable) setIsHovered(true);
|
|
1241
|
+
};
|
|
1242
|
+
$[20] = isContentEditable;
|
|
1243
|
+
$[21] = t9;
|
|
1244
|
+
} else t9 = $[21];
|
|
1245
|
+
const handleMouseEnter = t9;
|
|
1246
|
+
let t10;
|
|
1247
|
+
if ($[22] !== isContentEditable) {
|
|
1248
|
+
t10 = () => {
|
|
1249
|
+
if (isContentEditable) setIsHovered(false);
|
|
1250
|
+
};
|
|
1251
|
+
$[22] = isContentEditable;
|
|
1252
|
+
$[23] = t10;
|
|
1253
|
+
} else t10 = $[23];
|
|
1254
|
+
const handleMouseLeave = t10;
|
|
1255
|
+
let t11;
|
|
1256
|
+
if ($[24] !== addBlockAfterPosition || $[25] !== blockData.position) {
|
|
1257
|
+
t11 = (insertPosition) => {
|
|
1258
|
+
postOverlayMessage({
|
|
1259
|
+
type: "CAMOX_ADD_BLOCK_REQUEST",
|
|
1260
|
+
blockPosition: blockData.position,
|
|
1261
|
+
insertPosition,
|
|
1262
|
+
...addBlockAfterPosition !== void 0 && { afterPosition: addBlockAfterPosition }
|
|
1263
|
+
});
|
|
1264
|
+
};
|
|
1265
|
+
$[24] = addBlockAfterPosition;
|
|
1266
|
+
$[25] = blockData.position;
|
|
1267
|
+
$[26] = t11;
|
|
1268
|
+
} else t11 = $[26];
|
|
1269
|
+
const handleAddBlockClick = t11;
|
|
708
1270
|
const shouldShowOverlay = isContentEditable && (isHovered || isBlockSelected) && !isAddBlockSheetOpen;
|
|
709
1271
|
const shouldShowSheetOverlay = isAddBlockSheetOpen && mode !== "peek" || isPageContentSheetOpen && !isBlockSelected;
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
style: {
|
|
1272
|
+
let t12;
|
|
1273
|
+
if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1274
|
+
t12 = {
|
|
714
1275
|
position: "relative",
|
|
715
1276
|
scrollMargin: "5rem",
|
|
716
1277
|
background: "var(--background)"
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
1278
|
+
};
|
|
1279
|
+
$[27] = t12;
|
|
1280
|
+
} else t12 = $[27];
|
|
1281
|
+
const t13 = isContentEditable ? blockData._id : void 0;
|
|
1282
|
+
const t14 = blockData._id;
|
|
1283
|
+
let t15;
|
|
1284
|
+
if ($[28] !== blockData.content) {
|
|
1285
|
+
t15 = {
|
|
1286
|
+
...contentDefaults,
|
|
1287
|
+
...blockData.content
|
|
1288
|
+
};
|
|
1289
|
+
$[28] = blockData.content;
|
|
1290
|
+
$[29] = t15;
|
|
1291
|
+
} else t15 = $[29];
|
|
1292
|
+
const merged = t15;
|
|
1293
|
+
let overrides;
|
|
1294
|
+
if ($[30] !== merged) {
|
|
1295
|
+
overrides = {};
|
|
1296
|
+
for (const key_0 in merged) {
|
|
1297
|
+
const val = merged[key_0];
|
|
1298
|
+
if (val && typeof val === "object" && "url" in val && !val.url && contentDefaults[key_0]) overrides[key_0] = contentDefaults[key_0];
|
|
1299
|
+
}
|
|
1300
|
+
$[30] = merged;
|
|
1301
|
+
$[31] = overrides;
|
|
1302
|
+
} else overrides = $[31];
|
|
1303
|
+
let t16;
|
|
1304
|
+
if ($[32] !== merged || $[33] !== overrides) {
|
|
1305
|
+
t16 = {
|
|
1306
|
+
...merged,
|
|
1307
|
+
...overrides
|
|
1308
|
+
};
|
|
1309
|
+
$[32] = merged;
|
|
1310
|
+
$[33] = overrides;
|
|
1311
|
+
$[34] = t16;
|
|
1312
|
+
} else t16 = $[34];
|
|
1313
|
+
const t17 = t16;
|
|
1314
|
+
let t18;
|
|
1315
|
+
if ($[35] !== blockData.settings) {
|
|
1316
|
+
t18 = {
|
|
1317
|
+
...settingsDefaults,
|
|
1318
|
+
...blockData.settings
|
|
1319
|
+
};
|
|
1320
|
+
$[35] = blockData.settings;
|
|
1321
|
+
$[36] = t18;
|
|
1322
|
+
} else t18 = $[36];
|
|
1323
|
+
const t19 = t18;
|
|
1324
|
+
let t20;
|
|
1325
|
+
if ($[37] !== blockData._id || $[38] !== isHovered || $[39] !== mode || $[40] !== t17 || $[41] !== t19) {
|
|
1326
|
+
t20 = {
|
|
1327
|
+
blockId: t14,
|
|
1328
|
+
content: t17,
|
|
1329
|
+
settings: t19,
|
|
1330
|
+
mode,
|
|
1331
|
+
isHovered,
|
|
1332
|
+
setIsHovered
|
|
1333
|
+
};
|
|
1334
|
+
$[37] = blockData._id;
|
|
1335
|
+
$[38] = isHovered;
|
|
1336
|
+
$[39] = mode;
|
|
1337
|
+
$[40] = t17;
|
|
1338
|
+
$[41] = t19;
|
|
1339
|
+
$[42] = t20;
|
|
1340
|
+
} else t20 = $[42];
|
|
1341
|
+
let t21;
|
|
1342
|
+
if ($[43] !== normalizedContent) {
|
|
1343
|
+
t21 = /* @__PURE__ */ jsx(options.component, { content: normalizedContent });
|
|
1344
|
+
$[43] = normalizedContent;
|
|
1345
|
+
$[44] = t21;
|
|
1346
|
+
} else t21 = $[44];
|
|
1347
|
+
let t22;
|
|
1348
|
+
if ($[45] !== t20 || $[46] !== t21) {
|
|
1349
|
+
t22 = /* @__PURE__ */ jsx(Context.Provider, {
|
|
1350
|
+
value: t20,
|
|
1351
|
+
children: t21
|
|
1352
|
+
});
|
|
1353
|
+
$[45] = t20;
|
|
1354
|
+
$[46] = t21;
|
|
1355
|
+
$[47] = t22;
|
|
1356
|
+
} else t22 = $[47];
|
|
1357
|
+
const t23 = shouldShowSheetOverlay ? .6 : 0;
|
|
1358
|
+
let t24;
|
|
1359
|
+
if ($[48] !== t23) {
|
|
1360
|
+
t24 = /* @__PURE__ */ jsx("div", {
|
|
1361
|
+
style: {
|
|
1362
|
+
position: "absolute",
|
|
1363
|
+
width: "100%",
|
|
1364
|
+
height: "100%",
|
|
1365
|
+
top: 0,
|
|
1366
|
+
left: 0,
|
|
1367
|
+
background: "#000",
|
|
1368
|
+
opacity: t23,
|
|
1369
|
+
transition: "opacity 0.3s ease-in-out",
|
|
1370
|
+
pointerEvents: "none",
|
|
1371
|
+
zIndex: 20
|
|
1372
|
+
},
|
|
1373
|
+
id: "hello"
|
|
1374
|
+
});
|
|
1375
|
+
$[48] = t23;
|
|
1376
|
+
$[49] = t24;
|
|
1377
|
+
} else t24 = $[49];
|
|
1378
|
+
let t25;
|
|
1379
|
+
if ($[50] !== handleAddBlockClick || $[51] !== isAnySideSheetOpen || $[52] !== isBlockSelected || $[53] !== isFirstBlock || $[54] !== mode || $[55] !== shouldShowOverlay || $[56] !== showAddBlockBottom || $[57] !== showAddBlockTop) {
|
|
1380
|
+
t25 = shouldShowOverlay && (() => {
|
|
1381
|
+
const colors = mode === "layout" ? LAYOUT_OVERLAY_COLORS : OVERLAY_COLORS;
|
|
1382
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", { style: {
|
|
1383
|
+
position: "absolute",
|
|
1384
|
+
inset: isBlockSelected ? OVERLAY_OFFSETS.blockSelected : OVERLAY_OFFSETS.blockHover,
|
|
1385
|
+
border: `${isBlockSelected ? OVERLAY_WIDTHS.selected : OVERLAY_WIDTHS.hover} solid ${isBlockSelected ? colors.selected : colors.hover}`,
|
|
1386
|
+
pointerEvents: "none",
|
|
1387
|
+
zIndex: 10
|
|
1388
|
+
} }), /* @__PURE__ */ jsxs(Fragment, { children: [(showAddBlockTop ?? (mode !== "layout" && !isFirstBlock)) && /* @__PURE__ */ jsx(AddBlockControlBar, {
|
|
1389
|
+
position: "top",
|
|
1390
|
+
hidden: isAnySideSheetOpen,
|
|
1391
|
+
onMouseLeave: () => setIsHovered(false),
|
|
1392
|
+
onClick: () => handleAddBlockClick("before")
|
|
1393
|
+
}), (showAddBlockBottom ?? mode !== "layout") && /* @__PURE__ */ jsx(AddBlockControlBar, {
|
|
1394
|
+
position: "bottom",
|
|
1395
|
+
hidden: isAnySideSheetOpen,
|
|
1396
|
+
onMouseLeave: () => setIsHovered(false),
|
|
1397
|
+
onClick: () => handleAddBlockClick("after")
|
|
1398
|
+
})] })] });
|
|
1399
|
+
})();
|
|
1400
|
+
$[50] = handleAddBlockClick;
|
|
1401
|
+
$[51] = isAnySideSheetOpen;
|
|
1402
|
+
$[52] = isBlockSelected;
|
|
1403
|
+
$[53] = isFirstBlock;
|
|
1404
|
+
$[54] = mode;
|
|
1405
|
+
$[55] = shouldShowOverlay;
|
|
1406
|
+
$[56] = showAddBlockBottom;
|
|
1407
|
+
$[57] = showAddBlockTop;
|
|
1408
|
+
$[58] = t25;
|
|
1409
|
+
} else t25 = $[58];
|
|
1410
|
+
let t26;
|
|
1411
|
+
if ($[59] !== handleClick || $[60] !== handleMouseEnter || $[61] !== handleMouseLeave || $[62] !== t13 || $[63] !== t22 || $[64] !== t24 || $[65] !== t25) {
|
|
1412
|
+
t26 = /* @__PURE__ */ jsxs("div", {
|
|
1413
|
+
className: "group visual-editing-block",
|
|
1414
|
+
ref,
|
|
1415
|
+
style: t12,
|
|
1416
|
+
"data-camox-block-id": t13,
|
|
1417
|
+
onClick: handleClick,
|
|
1418
|
+
onMouseEnter: handleMouseEnter,
|
|
1419
|
+
onMouseLeave: handleMouseLeave,
|
|
1420
|
+
children: [
|
|
1421
|
+
t22,
|
|
1422
|
+
t24,
|
|
1423
|
+
t25
|
|
1424
|
+
]
|
|
1425
|
+
});
|
|
1426
|
+
$[59] = handleClick;
|
|
1427
|
+
$[60] = handleMouseEnter;
|
|
1428
|
+
$[61] = handleMouseLeave;
|
|
1429
|
+
$[62] = t13;
|
|
1430
|
+
$[63] = t22;
|
|
1431
|
+
$[64] = t24;
|
|
1432
|
+
$[65] = t25;
|
|
1433
|
+
$[66] = t26;
|
|
1434
|
+
} else t26 = $[66];
|
|
1435
|
+
return t26;
|
|
788
1436
|
};
|
|
789
1437
|
const useSetting = (name) => {
|
|
790
1438
|
const ctx = React.use(Context);
|
|
@@ -795,61 +1443,129 @@ function createBlock(options) {
|
|
|
795
1443
|
* Wraps block content that renders outside the block's visual bounds (fixed navbars, modals, portals, etc.).
|
|
796
1444
|
* Provides the same hover, selection, and sheet overlays as the main BlockComponent.
|
|
797
1445
|
*/
|
|
798
|
-
const Detached = (
|
|
1446
|
+
const Detached = (t0) => {
|
|
1447
|
+
const $ = c(29);
|
|
1448
|
+
const { children } = t0;
|
|
799
1449
|
const ctx = React.use(Context);
|
|
800
1450
|
if (!ctx) throw new Error("Detached must be used within a Block Component");
|
|
801
1451
|
const { blockId, mode, isHovered, setIsHovered } = ctx;
|
|
802
1452
|
const isContentEditable = useIsEditable(mode);
|
|
803
1453
|
const { window: iframeWindow } = useFrame();
|
|
804
|
-
const selection = useSelector(previewStore,
|
|
805
|
-
const isAddBlockSheetOpen = useSelector(previewStore,
|
|
806
|
-
const isPageContentSheetOpen = useSelector(previewStore,
|
|
1454
|
+
const selection = useSelector(previewStore, _temp0);
|
|
1455
|
+
const isAddBlockSheetOpen = useSelector(previewStore, _temp1);
|
|
1456
|
+
const isPageContentSheetOpen = useSelector(previewStore, _temp10);
|
|
807
1457
|
const isBlockSelected = selection?.blockId === blockId;
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
1458
|
+
let t1;
|
|
1459
|
+
if ($[0] !== blockId) {
|
|
1460
|
+
t1 = { blockId };
|
|
1461
|
+
$[0] = blockId;
|
|
1462
|
+
$[1] = t1;
|
|
1463
|
+
} else t1 = $[1];
|
|
1464
|
+
const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_BLOCK", "CAMOX_HOVER_BLOCK_END", t1);
|
|
1465
|
+
let t2;
|
|
1466
|
+
let t3;
|
|
1467
|
+
if ($[2] !== isHoveredFromSidebar || $[3] !== setIsHovered) {
|
|
1468
|
+
t2 = () => {
|
|
1469
|
+
setIsHovered(isHoveredFromSidebar);
|
|
1470
|
+
};
|
|
1471
|
+
t3 = [isHoveredFromSidebar, setIsHovered];
|
|
1472
|
+
$[2] = isHoveredFromSidebar;
|
|
1473
|
+
$[3] = setIsHovered;
|
|
1474
|
+
$[4] = t2;
|
|
1475
|
+
$[5] = t3;
|
|
1476
|
+
} else {
|
|
1477
|
+
t2 = $[4];
|
|
1478
|
+
t3 = $[5];
|
|
1479
|
+
}
|
|
1480
|
+
React.useEffect(t2, t3);
|
|
812
1481
|
const shouldShowOverlay = isContentEditable && (isHovered || isBlockSelected) && !isAddBlockSheetOpen;
|
|
813
1482
|
const shouldShowSheetOverlay = isAddBlockSheetOpen && mode !== "peek" || isPageContentSheetOpen && !isBlockSelected;
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
e
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
};
|
|
1483
|
+
let t4;
|
|
1484
|
+
if ($[6] !== blockId || $[7] !== isContentEditable) {
|
|
1485
|
+
t4 = (e) => {
|
|
1486
|
+
if (!isContentEditable) return;
|
|
1487
|
+
e.stopPropagation();
|
|
1488
|
+
previewStore.send({
|
|
1489
|
+
type: "setFocusedBlock",
|
|
1490
|
+
blockId
|
|
1491
|
+
});
|
|
1492
|
+
};
|
|
1493
|
+
$[6] = blockId;
|
|
1494
|
+
$[7] = isContentEditable;
|
|
1495
|
+
$[8] = t4;
|
|
1496
|
+
} else t4 = $[8];
|
|
1497
|
+
const handleClick = t4;
|
|
1498
|
+
let t5;
|
|
1499
|
+
if ($[9] !== isContentEditable || $[10] !== setIsHovered) {
|
|
1500
|
+
t5 = () => {
|
|
1501
|
+
if (isContentEditable) setIsHovered(true);
|
|
1502
|
+
};
|
|
1503
|
+
$[9] = isContentEditable;
|
|
1504
|
+
$[10] = setIsHovered;
|
|
1505
|
+
$[11] = t5;
|
|
1506
|
+
} else t5 = $[11];
|
|
1507
|
+
const handleMouseEnter = t5;
|
|
1508
|
+
let t6;
|
|
1509
|
+
if ($[12] !== isContentEditable || $[13] !== setIsHovered) {
|
|
1510
|
+
t6 = () => {
|
|
1511
|
+
if (isContentEditable) setIsHovered(false);
|
|
1512
|
+
};
|
|
1513
|
+
$[12] = isContentEditable;
|
|
1514
|
+
$[13] = setIsHovered;
|
|
1515
|
+
$[14] = t6;
|
|
1516
|
+
} else t6 = $[14];
|
|
1517
|
+
const handleMouseLeave = t6;
|
|
828
1518
|
const [container, setContainer] = React.useState(null);
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
|
|
1519
|
+
let t7;
|
|
1520
|
+
if ($[15] !== children || $[16] !== handleClick || $[17] !== handleMouseEnter || $[18] !== handleMouseLeave) {
|
|
1521
|
+
t7 = /* @__PURE__ */ jsx(Slot, {
|
|
1522
|
+
ref: setContainer,
|
|
1523
|
+
onClick: handleClick,
|
|
1524
|
+
onMouseEnter: handleMouseEnter,
|
|
1525
|
+
onMouseLeave: handleMouseLeave,
|
|
1526
|
+
children
|
|
1527
|
+
});
|
|
1528
|
+
$[15] = children;
|
|
1529
|
+
$[16] = handleClick;
|
|
1530
|
+
$[17] = handleMouseEnter;
|
|
1531
|
+
$[18] = handleMouseLeave;
|
|
1532
|
+
$[19] = t7;
|
|
1533
|
+
} else t7 = $[19];
|
|
1534
|
+
let t8;
|
|
1535
|
+
if ($[20] !== container || $[21] !== isBlockSelected || $[22] !== mode || $[23] !== shouldShowOverlay || $[24] !== shouldShowSheetOverlay) {
|
|
1536
|
+
t8 = container && createPortal(/* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", { style: {
|
|
846
1537
|
position: "absolute",
|
|
847
|
-
inset:
|
|
848
|
-
|
|
1538
|
+
inset: 0,
|
|
1539
|
+
background: "#000",
|
|
1540
|
+
opacity: shouldShowSheetOverlay ? .6 : 0,
|
|
1541
|
+
transition: "opacity 0.3s ease-in-out",
|
|
849
1542
|
pointerEvents: "none",
|
|
850
|
-
zIndex:
|
|
851
|
-
} })
|
|
852
|
-
|
|
1543
|
+
zIndex: 20
|
|
1544
|
+
} }), shouldShowOverlay && (() => {
|
|
1545
|
+
const colors = mode === "layout" ? LAYOUT_OVERLAY_COLORS : OVERLAY_COLORS;
|
|
1546
|
+
return /* @__PURE__ */ jsx("div", { style: {
|
|
1547
|
+
position: "absolute",
|
|
1548
|
+
inset: isBlockSelected ? OVERLAY_OFFSETS.blockSelected : OVERLAY_OFFSETS.blockHover,
|
|
1549
|
+
border: `${isBlockSelected ? OVERLAY_WIDTHS.selected : OVERLAY_WIDTHS.hover} solid ${isBlockSelected ? colors.selected : colors.hover}`,
|
|
1550
|
+
pointerEvents: "none",
|
|
1551
|
+
zIndex: 10
|
|
1552
|
+
} });
|
|
1553
|
+
})()] }), container);
|
|
1554
|
+
$[20] = container;
|
|
1555
|
+
$[21] = isBlockSelected;
|
|
1556
|
+
$[22] = mode;
|
|
1557
|
+
$[23] = shouldShowOverlay;
|
|
1558
|
+
$[24] = shouldShowSheetOverlay;
|
|
1559
|
+
$[25] = t8;
|
|
1560
|
+
} else t8 = $[25];
|
|
1561
|
+
let t9;
|
|
1562
|
+
if ($[26] !== t7 || $[27] !== t8) {
|
|
1563
|
+
t9 = /* @__PURE__ */ jsxs(Fragment, { children: [t7, t8] });
|
|
1564
|
+
$[26] = t7;
|
|
1565
|
+
$[27] = t8;
|
|
1566
|
+
$[28] = t9;
|
|
1567
|
+
} else t9 = $[28];
|
|
1568
|
+
return t9;
|
|
853
1569
|
};
|
|
854
1570
|
return {
|
|
855
1571
|
Component: BlockComponent,
|
|
@@ -917,5 +1633,47 @@ function createBlock(options) {
|
|
|
917
1633
|
layoutOnly: options.layoutOnly ?? false
|
|
918
1634
|
};
|
|
919
1635
|
}
|
|
1636
|
+
function _temp() {
|
|
1637
|
+
if (hasShownEmbedLockToast) return;
|
|
1638
|
+
hasShownEmbedLockToast = true;
|
|
1639
|
+
toast(/* @__PURE__ */ jsxs("span", { children: [
|
|
1640
|
+
"Hold ",
|
|
1641
|
+
/* @__PURE__ */ jsx(Kbd, { children: "L" }),
|
|
1642
|
+
" to interact with the embed content"
|
|
1643
|
+
] }));
|
|
1644
|
+
}
|
|
1645
|
+
function _temp2(e_1) {
|
|
1646
|
+
return e_1.preventDefault();
|
|
1647
|
+
}
|
|
1648
|
+
function _temp3(e_2) {
|
|
1649
|
+
if (e_2.key === "Escape") e_2.target.blur();
|
|
1650
|
+
}
|
|
1651
|
+
function _temp4(e_3) {
|
|
1652
|
+
return e_3.preventDefault();
|
|
1653
|
+
}
|
|
1654
|
+
function _temp5(e_4) {
|
|
1655
|
+
return e_4.preventDefault();
|
|
1656
|
+
}
|
|
1657
|
+
function _temp6(state) {
|
|
1658
|
+
return state.context.selection;
|
|
1659
|
+
}
|
|
1660
|
+
function _temp7(state_0) {
|
|
1661
|
+
return state_0.context.isPageContentSheetOpen;
|
|
1662
|
+
}
|
|
1663
|
+
function _temp8(state_1) {
|
|
1664
|
+
return state_1.context.isAddBlockSheetOpen;
|
|
1665
|
+
}
|
|
1666
|
+
function _temp9(item) {
|
|
1667
|
+
return item.content;
|
|
1668
|
+
}
|
|
1669
|
+
function _temp0(state) {
|
|
1670
|
+
return state.context.selection;
|
|
1671
|
+
}
|
|
1672
|
+
function _temp1(state_0) {
|
|
1673
|
+
return state_0.context.isAddBlockSheetOpen;
|
|
1674
|
+
}
|
|
1675
|
+
function _temp10(state_1) {
|
|
1676
|
+
return state_1.context.isPageContentSheetOpen;
|
|
1677
|
+
}
|
|
920
1678
|
//#endregion
|
|
921
1679
|
export { Type, createBlock };
|