camox 0.41.1 → 0.43.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 (93) hide show
  1. package/dist/core/components/lexical/{GradientNode.js → HighlightNode.js} +34 -34
  2. package/dist/core/components/lexical/InlineLexicalEditor.js +14 -14
  3. package/dist/core/components/lexical/InlineStylesPlugin.js +6 -6
  4. package/dist/core/components/lexical/SelectionBroadcaster.js +5 -5
  5. package/dist/core/components/lexical/SidebarLexicalEditor.js +52 -49
  6. package/dist/core/components/lexical/TextLinkPopover.js +191 -208
  7. package/dist/core/components/lexical/editorConfig.js +2 -2
  8. package/dist/core/createApp.d.ts +19 -4
  9. package/dist/core/createApp.js +2 -1
  10. package/dist/core/createLayout.d.ts +16 -3
  11. package/dist/core/createLayout.js +15 -15
  12. package/dist/core/derivedRoutes.js +1 -1
  13. package/dist/core/dom.d.ts +17 -0
  14. package/dist/core/dom.js +22 -0
  15. package/dist/core/editing/createEditableBlock.d.ts +8 -1
  16. package/dist/core/editing/createEditableBlock.js +636 -459
  17. package/dist/core/hooks/useOverlayState.js +11 -0
  18. package/dist/core/lib/fieldTypes.js +5 -5
  19. package/dist/core/lib/lexicalReact.js +4 -4
  20. package/dist/core/lib/lexicalState.js +20 -4
  21. package/dist/core/lib/modifierFormats.js +1 -1
  22. package/dist/core/lib/textLinks.js +5 -2
  23. package/dist/core/lib/textStyles.d.ts +2 -2
  24. package/dist/core/lib/textStyles.js +6 -11
  25. package/dist/core/pageDestinations.js +37 -0
  26. package/dist/features/og/imageResponse.node.js +11 -9
  27. package/dist/features/preview/CamoxPreview.js +108 -124
  28. package/dist/features/preview/commentsEnabled.js +8 -0
  29. package/dist/features/preview/components/AddBlockSidebar.js +80 -90
  30. package/dist/features/preview/components/AssetLightbox.js +4 -11
  31. package/dist/features/preview/components/AttachedComments.js +194 -0
  32. package/dist/features/preview/components/BlockActionsPopover.js +14 -65
  33. package/dist/features/preview/components/CommentHeader.js +122 -0
  34. package/dist/features/preview/components/CommentSidebar.js +29 -0
  35. package/dist/features/preview/components/CommentTargetQuote.js +166 -0
  36. package/dist/features/preview/components/CreatePageModal.js +4 -10
  37. package/dist/features/preview/components/DerivedLayoutSidebar.js +45 -26
  38. package/dist/features/preview/components/DerivedPageInfoSidebar.js +38 -26
  39. package/dist/features/preview/components/FieldToolbar.js +7 -7
  40. package/dist/features/preview/components/ItemFieldsEditor.js +275 -204
  41. package/dist/features/preview/components/LeftSidebar.js +18 -18
  42. package/dist/features/preview/components/LinkFieldEditor.js +212 -209
  43. package/dist/features/preview/components/OverlayTracker.js +14 -20
  44. package/dist/features/preview/components/Overlays.js +26 -35
  45. package/dist/features/preview/components/PageEditorSidebar.js +90 -91
  46. package/dist/features/preview/components/PageInfoSidebar.js +128 -159
  47. package/dist/features/preview/components/PagePicker.js +29 -24
  48. package/dist/features/preview/components/PageTree.js +159 -157
  49. package/dist/features/preview/components/PreviewComments.js +56 -0
  50. package/dist/features/preview/components/PreviewPanel.js +122 -78
  51. package/dist/features/preview/components/PreviewToolbar.js +280 -231
  52. package/dist/features/preview/components/PublicationRow.js +8 -11
  53. package/dist/features/preview/components/RightSidebar.js +14 -11
  54. package/dist/features/preview/components/SidebarSection.js +121 -0
  55. package/dist/features/preview/components/useRepeatableItemActions.js +1 -1
  56. package/dist/features/preview/previewCommentsStore.js +115 -0
  57. package/dist/features/preview/previewSelection.js +75 -0
  58. package/dist/features/preview/previewStore.js +19 -39
  59. package/dist/features/preview/publication.js +10 -0
  60. package/dist/features/provider/AuthenticatedCamoxProvider.js +46 -34
  61. package/dist/features/provider/CoreCamoxProvider.js +1 -1
  62. package/dist/features/provider/components/CommandPalette.js +142 -58
  63. package/dist/features/provider/useAdminShortcuts.js +19 -8
  64. package/dist/features/routes/pageRuntime.js +0 -6
  65. package/dist/features/runtime/RuntimeChrome.js +40 -37
  66. package/dist/features/runtime/runtime.js +20 -21
  67. package/dist/features/studio/CamoxStudio.js +30 -50
  68. package/dist/features/studio/components/EnvironmentMenu.js +3 -2
  69. package/dist/features/studio/components/Navbar.js +53 -80
  70. package/dist/features/vite/layoutGeneration.js +7 -3
  71. package/dist/features/vite/runtimeDev.js +4 -1
  72. package/dist/features/vite/vite.d.ts +3 -2
  73. package/dist/features/vite/vite.js +14 -6
  74. package/dist/hooks/use-file-upload.js +0 -2
  75. package/dist/hooks/use-page-destinations.js +53 -0
  76. package/dist/lib/auth.js +11 -14
  77. package/dist/lib/server-auth-cookie.js +21 -0
  78. package/dist/studio.css +1 -1
  79. package/package.json +9 -7
  80. package/skills/camox/SKILL.md +32 -9
  81. package/skills/camox/references/block-definitions.md +84 -290
  82. package/skills/camox/references/cli-common.md +2 -4
  83. package/skills/camox/references/cli-content.md +147 -0
  84. package/skills/camox/references/cli-environments.md +1 -1
  85. package/skills/camox/references/dom-integrations.md +93 -0
  86. package/skills/camox/references/field-styling.md +50 -0
  87. package/skills/camox/references/layout-definitions.md +33 -147
  88. package/skills/camox/references/routed-layouts.md +71 -0
  89. package/skills/camoxify/SKILL.md +52 -0
  90. package/dist/lib/telemetry-client.js +0 -66
  91. package/dist/lib/telemetry.js +0 -26
  92. package/skills/camox/references/cli-blocks.md +0 -78
  93. package/skills/camox/references/cli-pages.md +0 -53
@@ -5,8 +5,8 @@ import { Type as Type$1, resolveToMarkdown } from "../lib/contentType.js";
5
5
  import { buildImageSrcSet, getDefaultImageSizes, getDefaultImageWidth, transformImageUrl } from "../lib/imageTransform.js";
6
6
  import { markdownToReactNodes } from "../lib/lexicalReact.js";
7
7
  import { blockMutations, pageQueries, projectQueries, repeatableItemMutations } from "../../lib/queries.js";
8
- import { trackClientEvent } from "../../lib/telemetry-client.js";
9
- import { previewStore } from "../../features/preview/previewStore.js";
8
+ import { previewStore, selectIsCommentMode } from "../../features/preview/previewStore.js";
9
+ import { usePreviewSelection } from "../../features/preview/previewSelection.js";
10
10
  import { postOverlayMessage } from "../../features/preview/overlayMessages.js";
11
11
  import { useFrame } from "../../features/preview/components/Frame.js";
12
12
  import { AddBlockControlBar } from "../components/AddBlockControlBar.js";
@@ -14,6 +14,7 @@ import { InlineLexicalEditor } from "../components/lexical/InlineLexicalEditor.j
14
14
  import { useFieldSelection } from "../hooks/useFieldSelection.js";
15
15
  import { useIsEditable } from "../hooks/useIsEditable.js";
16
16
  import { useOverlayMessage } from "../hooks/useOverlayMessage.js";
17
+ import { useOverlayState } from "../hooks/useOverlayState.js";
17
18
  import { c } from "react/compiler-runtime";
18
19
  import { Type } from "@sinclair/typebox";
19
20
  import { useMutation, useQuery } from "@tanstack/react-query";
@@ -182,7 +183,15 @@ function createEditableBlock(options) {
182
183
  if (repeaterContext?.itemId != null) return `${blockId}__${repeaterContext.itemId}__${fieldName}`;
183
184
  return `${blockId}__${fieldName}`;
184
185
  };
185
- const Field = ({ name, textStyle, linkStyle, children }) => {
186
+ const Field = (t0) => {
187
+ const $ = c(34);
188
+ if ($[0] !== "9390cfa3e0bf4e772e82a3d1352a7d56d8ae67f112d215b6d45231db17c01883") {
189
+ for (let $i = 0; $i < 34; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
190
+ $[0] = "9390cfa3e0bf4e772e82a3d1352a7d56d8ae67f112d215b6d45231db17c01883";
191
+ }
192
+ const { name, textStyle, linkStyle, children } = t0;
193
+ const selectTarget = usePreviewSelection();
194
+ const isCommentMode = useSelector(previewStore, selectIsCommentMode);
186
195
  const blockContext = React.use(Context);
187
196
  if (!blockContext) throw new Error("Field must be used within a Block Component");
188
197
  const { blockId, content, mode } = blockContext;
@@ -190,77 +199,154 @@ function createEditableBlock(options) {
190
199
  const elementRef = React.useRef(null);
191
200
  const { window: iframeWindow } = useFrame();
192
201
  const projectSlug = useProjectSlug();
193
- const { data: project } = useQuery(projectQueries.getBySlug(projectSlug));
194
- const { data: pages } = useQuery({
195
- ...pageQueries.list(project?.id ?? 0),
196
- enabled: !!project
197
- });
198
- const currentPathname = useLocation({ select: (l) => l.pathname });
202
+ let t1;
203
+ if ($[1] !== projectSlug) {
204
+ t1 = projectQueries.getBySlug(projectSlug);
205
+ $[1] = projectSlug;
206
+ $[2] = t1;
207
+ } else t1 = $[2];
208
+ const { data: project } = useQuery(t1);
209
+ let t2;
210
+ if ($[3] !== project?.id) {
211
+ t2 = pageQueries.list(project?.id ?? 0);
212
+ $[3] = project?.id;
213
+ $[4] = t2;
214
+ } else t2 = $[4];
215
+ const t3 = !!project;
216
+ let t4;
217
+ if ($[5] !== t2 || $[6] !== t3) {
218
+ t4 = {
219
+ ...t2,
220
+ enabled: t3
221
+ };
222
+ $[5] = t2;
223
+ $[6] = t3;
224
+ $[7] = t4;
225
+ } else t4 = $[7];
226
+ const { data: pages } = useQuery(t4);
227
+ let t5;
228
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
229
+ t5 = { select: _temp };
230
+ $[8] = t5;
231
+ } else t5 = $[8];
232
+ const currentPathname = useLocation(t5);
199
233
  const repeaterContext = React.use(RepeaterItemContext);
200
234
  const fieldId = getOverlayFieldId(blockId, repeaterContext, String(name));
201
235
  const fieldValue = repeaterContext ? repeaterContext.itemContent[name] : content[name];
202
236
  const [isHovered, setIsHovered] = React.useState(false);
203
237
  const [isEditorFocused, setIsEditorFocused] = React.useState(false);
204
238
  const isSelectedFromSelection = useFieldSelection(blockId, String(name), "String", repeaterContext?.itemId);
205
- const isFocused = isEditorFocused || isSelectedFromSelection;
239
+ const overlayState = useOverlayState(isHovered, isEditorFocused || isSelectedFromSelection);
206
240
  const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", { fieldId });
207
- React.useEffect(() => {
208
- setIsHovered(isHoveredFromSidebar);
209
- }, [isHoveredFromSidebar]);
210
- const updateBlockContent = useMutation(blockMutations.updateContent());
211
- const updateRepeatableContent = useMutation(repeatableItemMutations.updateContent());
212
- const handleChange = React.useCallback((newValue) => {
213
- if (repeaterContext) {
214
- const { itemId } = repeaterContext;
215
- if (itemId != null) updateRepeatableContent.mutate({
216
- id: itemId,
241
+ let t6;
242
+ let t7;
243
+ if ($[9] !== isHoveredFromSidebar) {
244
+ t6 = () => {
245
+ setIsHovered(isHoveredFromSidebar);
246
+ };
247
+ t7 = [isHoveredFromSidebar];
248
+ $[9] = isHoveredFromSidebar;
249
+ $[10] = t6;
250
+ $[11] = t7;
251
+ } else {
252
+ t6 = $[10];
253
+ t7 = $[11];
254
+ }
255
+ React.useEffect(t6, t7);
256
+ let t8;
257
+ if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
258
+ t8 = blockMutations.updateContent();
259
+ $[12] = t8;
260
+ } else t8 = $[12];
261
+ const updateBlockContent = useMutation(t8);
262
+ let t9;
263
+ if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
264
+ t9 = repeatableItemMutations.updateContent();
265
+ $[13] = t9;
266
+ } else t9 = $[13];
267
+ const updateRepeatableContent = useMutation(t9);
268
+ let t10;
269
+ if ($[14] !== blockId || $[15] !== name || $[16] !== repeaterContext || $[17] !== updateBlockContent || $[18] !== updateRepeatableContent) {
270
+ t10 = (newValue) => {
271
+ if (repeaterContext) {
272
+ const { itemId } = repeaterContext;
273
+ if (itemId != null) updateRepeatableContent.mutate({
274
+ id: itemId,
275
+ content: { [name]: newValue }
276
+ });
277
+ } else updateBlockContent.mutate({
278
+ id: blockId,
217
279
  content: { [name]: newValue }
218
280
  });
219
- } else updateBlockContent.mutate({
220
- id: blockId,
221
- content: { [name]: newValue }
222
- });
223
- }, [
224
- blockId,
225
- name,
226
- repeaterContext,
227
- updateBlockContent,
228
- updateRepeatableContent
229
- ]);
230
- const handleFocus = React.useCallback(() => {
231
- setIsEditorFocused(true);
232
- if (repeaterContext?.itemId != null) previewStore.send({
233
- type: "selectItemField",
234
- blockId,
235
- itemId: repeaterContext.itemId,
236
- fieldName: name.toString(),
237
- fieldType: "String"
238
- });
239
- else previewStore.send({
240
- type: "selectBlockField",
241
- blockId,
242
- fieldName: name.toString(),
243
- fieldType: "String"
244
- });
245
- }, [
246
- blockId,
247
- name,
248
- repeaterContext?.itemId
249
- ]);
250
- const handleBlur = React.useCallback((wasEdited) => {
251
- setIsEditorFocused(false);
252
- if (wasEdited) trackClientEvent("block_edited", {
253
- via: "inline-lexical",
254
- blockType: options.id,
255
- field: String(name)
256
- });
257
- }, [name]);
258
- const handleMouseEnter = () => {
259
- if (isContentEditable) setIsHovered(true);
260
- };
261
- const handleMouseLeave = () => {
262
- if (isContentEditable) setIsHovered(false);
263
- };
281
+ };
282
+ $[14] = blockId;
283
+ $[15] = name;
284
+ $[16] = repeaterContext;
285
+ $[17] = updateBlockContent;
286
+ $[18] = updateRepeatableContent;
287
+ $[19] = t10;
288
+ } else t10 = $[19];
289
+ const handleChange = t10;
290
+ let t11;
291
+ if ($[20] !== blockId || $[21] !== name || $[22] !== repeaterContext || $[23] !== selectTarget) {
292
+ t11 = (event) => {
293
+ selectTarget(repeaterContext?.itemId != null ? {
294
+ type: "item-field",
295
+ blockId,
296
+ itemId: repeaterContext.itemId,
297
+ fieldName: String(name),
298
+ fieldType: "String"
299
+ } : {
300
+ type: "block-field",
301
+ blockId,
302
+ fieldName: String(name),
303
+ fieldType: "String"
304
+ }, event);
305
+ };
306
+ $[20] = blockId;
307
+ $[21] = name;
308
+ $[22] = repeaterContext;
309
+ $[23] = selectTarget;
310
+ $[24] = t11;
311
+ } else t11 = $[24];
312
+ const selectField = t11;
313
+ let t12;
314
+ if ($[25] !== selectField) {
315
+ t12 = () => {
316
+ if (selectIsCommentMode(previewStore.getSnapshot())) return;
317
+ setIsEditorFocused(true);
318
+ selectField();
319
+ };
320
+ $[25] = selectField;
321
+ $[26] = t12;
322
+ } else t12 = $[26];
323
+ const handleFocus = t12;
324
+ let t13;
325
+ if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
326
+ t13 = () => {
327
+ setIsEditorFocused(false);
328
+ };
329
+ $[27] = t13;
330
+ } else t13 = $[27];
331
+ const handleBlur = t13;
332
+ let t14;
333
+ if ($[28] !== isContentEditable) {
334
+ t14 = () => {
335
+ if (isContentEditable) setIsHovered(true);
336
+ };
337
+ $[28] = isContentEditable;
338
+ $[29] = t14;
339
+ } else t14 = $[29];
340
+ const handleMouseEnter = t14;
341
+ let t15;
342
+ if ($[30] !== isContentEditable) {
343
+ t15 = () => {
344
+ if (isContentEditable) setIsHovered(false);
345
+ };
346
+ $[30] = isContentEditable;
347
+ $[31] = t15;
348
+ } else t15 = $[31];
349
+ const handleMouseLeave = t15;
264
350
  const fieldData = { text: fieldValue };
265
351
  if (!isContentEditable) return /* @__PURE__ */ jsx(Fragment, { children: children({ children: markdownToReactNodes(fieldValue, {
266
352
  pages,
@@ -268,15 +354,20 @@ function createEditableBlock(options) {
268
354
  textStyle,
269
355
  linkStyle
270
356
  }) }, fieldData) });
271
- return /* @__PURE__ */ jsx(Fragment, { children: children({
357
+ const t16 = children({
272
358
  ref: elementRef,
273
359
  "data-camox-field-id": fieldId,
274
- "data-camox-hovered": isHovered || void 0,
275
- "data-camox-focused": isFocused || void 0,
360
+ ...overlayState,
276
361
  "data-camox-overlay-mode": options.synced ? "synced" : void 0,
277
362
  onMouseEnter: handleMouseEnter,
278
363
  onMouseLeave: handleMouseLeave,
279
- children: /* @__PURE__ */ jsx(InlineLexicalEditor, {
364
+ onClickCapture: selectField,
365
+ children: isCommentMode ? markdownToReactNodes(fieldValue, {
366
+ pages,
367
+ fallbackHref: currentPathname,
368
+ textStyle,
369
+ linkStyle
370
+ }) : /* @__PURE__ */ jsx(InlineLexicalEditor, {
280
371
  textStyle,
281
372
  linkStyle,
282
373
  pages,
@@ -287,15 +378,23 @@ function createEditableBlock(options) {
287
378
  onFocus: handleFocus,
288
379
  onBlur: handleBlur
289
380
  })
290
- }, fieldData) });
381
+ }, fieldData);
382
+ let t17;
383
+ if ($[32] !== t16) {
384
+ t17 = /* @__PURE__ */ jsx(Fragment, { children: t16 });
385
+ $[32] = t16;
386
+ $[33] = t17;
387
+ } else t17 = $[33];
388
+ return t17;
291
389
  };
292
390
  const Embed = (t0) => {
293
- const $ = c(35);
294
- if ($[0] !== "d6c181312c1800a4e5ae8a8c97d5ce89a20fae6d141b3bb8b9dd5c16e3c88316") {
295
- for (let $i = 0; $i < 35; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
296
- $[0] = "d6c181312c1800a4e5ae8a8c97d5ce89a20fae6d141b3bb8b9dd5c16e3c88316";
391
+ const $ = c(39);
392
+ if ($[0] !== "9390cfa3e0bf4e772e82a3d1352a7d56d8ae67f112d215b6d45231db17c01883") {
393
+ for (let $i = 0; $i < 39; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
394
+ $[0] = "9390cfa3e0bf4e772e82a3d1352a7d56d8ae67f112d215b6d45231db17c01883";
297
395
  }
298
396
  const { name, children } = t0;
397
+ const selectTarget = usePreviewSelection();
299
398
  const blockContext = React.use(Context);
300
399
  if (!blockContext) throw new Error("Embed must be used within a Block Component");
301
400
  const { blockId, content, mode } = blockContext;
@@ -314,39 +413,37 @@ function createEditableBlock(options) {
314
413
  } else t2 = $[4];
315
414
  const fieldId = t2;
316
415
  const [isHovered, setIsHovered] = React.useState(false);
416
+ const overlayState = useOverlayState(isHovered);
317
417
  const embedRef = React.useRef(null);
318
418
  const itemId = repeaterContext?.itemId;
319
419
  let t3;
320
- if ($[5] !== blockId || $[6] !== isContentEditable || $[7] !== itemId || $[8] !== name) {
321
- t3 = () => {
420
+ if ($[5] !== blockId || $[6] !== isContentEditable || $[7] !== itemId || $[8] !== name || $[9] !== selectTarget) {
421
+ t3 = (event) => {
322
422
  if (!isContentEditable) return;
323
- if (itemId != null) {
324
- previewStore.send({
325
- type: "selectItemField",
326
- blockId,
327
- itemId,
328
- fieldName: String(name),
329
- fieldType: "Embed"
330
- });
331
- return;
332
- }
333
- previewStore.send({
334
- type: "selectBlockField",
423
+ selectTarget(itemId != null ? {
424
+ type: "item-field",
335
425
  blockId,
426
+ itemId,
336
427
  fieldName: String(name),
337
428
  fieldType: "Embed"
338
- });
429
+ } : {
430
+ type: "block-field",
431
+ blockId,
432
+ fieldName: String(name),
433
+ fieldType: "Embed"
434
+ }, event);
339
435
  };
340
436
  $[5] = blockId;
341
437
  $[6] = isContentEditable;
342
438
  $[7] = itemId;
343
439
  $[8] = name;
344
- $[9] = t3;
345
- } else t3 = $[9];
440
+ $[9] = selectTarget;
441
+ $[10] = t3;
442
+ } else t3 = $[10];
346
443
  const selectField = t3;
347
444
  let t4;
348
445
  let t5;
349
- if ($[10] !== iframeWindow || $[11] !== isContentEditable || $[12] !== selectField) {
446
+ if ($[11] !== iframeWindow || $[12] !== isContentEditable || $[13] !== selectField) {
350
447
  t4 = () => {
351
448
  if (!isContentEditable || !iframeWindow) return;
352
449
  let timer;
@@ -355,7 +452,12 @@ function createEditableBlock(options) {
355
452
  timer = iframeWindow.setTimeout(() => {
356
453
  const activeElement = iframeWindow.document.activeElement;
357
454
  if (activeElement?.tagName !== "IFRAME") return;
358
- if (embedRef.current?.contains(activeElement)) selectField();
455
+ if (!embedRef.current?.contains(activeElement)) return;
456
+ selectField({
457
+ currentTarget: embedRef.current,
458
+ preventDefault() {},
459
+ stopPropagation() {}
460
+ });
359
461
  }, 0);
360
462
  };
361
463
  iframeWindow.addEventListener("blur", handleBlur);
@@ -369,91 +471,99 @@ function createEditableBlock(options) {
369
471
  iframeWindow,
370
472
  selectField
371
473
  ];
372
- $[10] = iframeWindow;
373
- $[11] = isContentEditable;
374
- $[12] = selectField;
375
- $[13] = t4;
376
- $[14] = t5;
474
+ $[11] = iframeWindow;
475
+ $[12] = isContentEditable;
476
+ $[13] = selectField;
477
+ $[14] = t4;
478
+ $[15] = t5;
377
479
  } else {
378
- t4 = $[13];
379
- t5 = $[14];
480
+ t4 = $[14];
481
+ t5 = $[15];
380
482
  }
381
483
  React.useEffect(t4, t5);
382
484
  let t6;
383
- if ($[15] !== fieldId) {
485
+ if ($[16] !== fieldId) {
384
486
  t6 = { fieldId };
385
- $[15] = fieldId;
386
- $[16] = t6;
387
- } else t6 = $[16];
487
+ $[16] = fieldId;
488
+ $[17] = t6;
489
+ } else t6 = $[17];
388
490
  const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_FIELD", "CAMOX_HOVER_FIELD_END", t6);
389
491
  let t7;
390
492
  let t8;
391
- if ($[17] !== isHoveredFromSidebar) {
493
+ if ($[18] !== isHoveredFromSidebar) {
392
494
  t7 = () => {
393
495
  setIsHovered(isHoveredFromSidebar);
394
496
  };
395
497
  t8 = [isHoveredFromSidebar];
396
- $[17] = isHoveredFromSidebar;
397
- $[18] = t7;
398
- $[19] = t8;
498
+ $[18] = isHoveredFromSidebar;
499
+ $[19] = t7;
500
+ $[20] = t8;
399
501
  } else {
400
- t7 = $[18];
401
- t8 = $[19];
502
+ t7 = $[19];
503
+ t8 = $[20];
402
504
  }
403
505
  React.useEffect(t7, t8);
404
506
  const t9 = isContentEditable ? fieldId : void 0;
405
507
  const t10 = isContentEditable ? "embed" : void 0;
406
- const t11 = isContentEditable && isHovered || void 0;
508
+ let t11;
509
+ if ($[21] !== isContentEditable || $[22] !== overlayState) {
510
+ t11 = isContentEditable ? overlayState : {};
511
+ $[21] = isContentEditable;
512
+ $[22] = overlayState;
513
+ $[23] = t11;
514
+ } else t11 = $[23];
407
515
  let t12;
408
- if ($[20] !== isContentEditable) {
516
+ if ($[24] !== isContentEditable) {
409
517
  t12 = isContentEditable ? () => setIsHovered(true) : void 0;
410
- $[20] = isContentEditable;
411
- $[21] = t12;
412
- } else t12 = $[21];
518
+ $[24] = isContentEditable;
519
+ $[25] = t12;
520
+ } else t12 = $[25];
413
521
  let t13;
414
- if ($[22] !== isContentEditable) {
522
+ if ($[26] !== isContentEditable) {
415
523
  t13 = isContentEditable ? () => setIsHovered(false) : void 0;
416
- $[22] = isContentEditable;
417
- $[23] = t13;
418
- } else t13 = $[23];
524
+ $[26] = isContentEditable;
525
+ $[27] = t13;
526
+ } else t13 = $[27];
419
527
  let t14;
420
- if ($[24] !== children || $[25] !== fieldValue) {
528
+ if ($[28] !== children || $[29] !== fieldValue) {
421
529
  t14 = children({ src: fieldValue }, { url: fieldValue });
422
- $[24] = children;
423
- $[25] = fieldValue;
424
- $[26] = t14;
425
- } else t14 = $[26];
530
+ $[28] = children;
531
+ $[29] = fieldValue;
532
+ $[30] = t14;
533
+ } else t14 = $[30];
426
534
  let t15;
427
- if ($[27] !== selectField || $[28] !== t10 || $[29] !== t11 || $[30] !== t12 || $[31] !== t13 || $[32] !== t14 || $[33] !== t9) {
535
+ if ($[31] !== selectField || $[32] !== t10 || $[33] !== t11 || $[34] !== t12 || $[35] !== t13 || $[36] !== t14 || $[37] !== t9) {
428
536
  t15 = /* @__PURE__ */ jsx("div", {
429
537
  ref: embedRef,
430
538
  onClickCapture: selectField,
431
539
  "data-camox-field-id": t9,
432
540
  "data-camox-field-type": t10,
433
- "data-camox-hovered": t11,
541
+ ...t11,
434
542
  "data-camox-overlay-mode": options.synced ? "synced" : void 0,
435
543
  onMouseEnter: t12,
436
544
  onMouseLeave: t13,
437
545
  children: t14
438
546
  });
439
- $[27] = selectField;
440
- $[28] = t10;
441
- $[29] = t11;
442
- $[30] = t12;
443
- $[31] = t13;
444
- $[32] = t14;
445
- $[33] = t9;
446
- $[34] = t15;
447
- } else t15 = $[34];
547
+ $[31] = selectField;
548
+ $[32] = t10;
549
+ $[33] = t11;
550
+ $[34] = t12;
551
+ $[35] = t13;
552
+ $[36] = t14;
553
+ $[37] = t9;
554
+ $[38] = t15;
555
+ } else t15 = $[38];
448
556
  return t15;
449
557
  };
450
558
  const Link = (t0) => {
451
- const $ = c(29);
452
- if ($[0] !== "d6c181312c1800a4e5ae8a8c97d5ce89a20fae6d141b3bb8b9dd5c16e3c88316") {
453
- for (let $i = 0; $i < 29; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
454
- $[0] = "d6c181312c1800a4e5ae8a8c97d5ce89a20fae6d141b3bb8b9dd5c16e3c88316";
559
+ const $ = c(32);
560
+ if ($[0] !== "9390cfa3e0bf4e772e82a3d1352a7d56d8ae67f112d215b6d45231db17c01883") {
561
+ for (let $i = 0; $i < 32; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
562
+ $[0] = "9390cfa3e0bf4e772e82a3d1352a7d56d8ae67f112d215b6d45231db17c01883";
455
563
  }
456
564
  const { name, children } = t0;
565
+ const selectTarget = usePreviewSelection();
566
+ const isCommentMode = useSelector(previewStore, selectIsCommentMode);
457
567
  const blockContext = React.use(Context);
458
568
  if (!blockContext) throw new Error("Link must be used within a Block Component");
459
569
  const { blockId, content, mode } = blockContext;
@@ -502,7 +612,7 @@ function createEditableBlock(options) {
502
612
  const { data: pages } = useQuery(t6);
503
613
  let t7;
504
614
  if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
505
- t7 = { select: _temp };
615
+ t7 = { select: _temp2 };
506
616
  $[10] = t7;
507
617
  } else t7 = $[10];
508
618
  const resolvedHref = resolveLinkHref(fieldValue, pages, useLocation(t7));
@@ -512,7 +622,7 @@ function createEditableBlock(options) {
512
622
  const [isHovered, setIsHovered] = React.useState(false);
513
623
  const [isEditorFocused, setIsEditorFocused] = React.useState(false);
514
624
  const isSelectedFromSelection = useFieldSelection(blockId, String(name), "Link", repeaterContext?.itemId);
515
- const isFocused = isEditorFocused || isSelectedFromSelection;
625
+ const overlayState = useOverlayState(isHovered, isEditorFocused || isSelectedFromSelection);
516
626
  React.useEffect(() => {
517
627
  if (!isEditing) setDisplayText(fieldValue.text);
518
628
  }, [fieldValue.text, isEditing]);
@@ -560,39 +670,49 @@ function createEditableBlock(options) {
560
670
  });
561
671
  };
562
672
  let t11;
563
- if ($[20] !== blockId || $[21] !== name || $[22] !== repeaterContext) {
564
- t11 = () => {
565
- setIsEditing(true);
566
- setIsEditorFocused(true);
567
- if (repeaterContext?.itemId != null) previewStore.send({
568
- type: "selectItemField",
673
+ if ($[20] !== blockId || $[21] !== name || $[22] !== repeaterContext || $[23] !== selectTarget) {
674
+ t11 = (event) => {
675
+ selectTarget(repeaterContext?.itemId != null ? {
676
+ type: "item-field",
569
677
  blockId,
570
678
  itemId: repeaterContext.itemId,
571
679
  fieldName: String(name),
572
680
  fieldType: "Link"
573
- });
574
- else previewStore.send({
575
- type: "selectBlockField",
681
+ } : {
682
+ type: "block-field",
576
683
  blockId,
577
684
  fieldName: String(name),
578
685
  fieldType: "Link"
579
- });
686
+ }, event);
580
687
  };
581
688
  $[20] = blockId;
582
689
  $[21] = name;
583
690
  $[22] = repeaterContext;
584
- $[23] = t11;
585
- } else t11 = $[23];
586
- const handleFocus = t11;
691
+ $[23] = selectTarget;
692
+ $[24] = t11;
693
+ } else t11 = $[24];
694
+ const selectField = t11;
587
695
  let t12;
588
- if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
696
+ if ($[25] !== selectField) {
589
697
  t12 = () => {
698
+ if (selectIsCommentMode(previewStore.getSnapshot())) return;
699
+ setIsEditing(true);
700
+ setIsEditorFocused(true);
701
+ selectField();
702
+ };
703
+ $[25] = selectField;
704
+ $[26] = t12;
705
+ } else t12 = $[26];
706
+ const handleFocus = t12;
707
+ let t13;
708
+ if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
709
+ t13 = () => {
590
710
  setIsEditing(false);
591
711
  setIsEditorFocused(false);
592
712
  };
593
- $[24] = t12;
594
- } else t12 = $[24];
595
- const handleBlur = t12;
713
+ $[27] = t13;
714
+ } else t13 = $[27];
715
+ const handleBlur = t13;
596
716
  const linkData = {
597
717
  text: displayText,
598
718
  href: resolvedHref,
@@ -604,53 +724,54 @@ function createEditableBlock(options) {
604
724
  rel: fieldValue.newTab ? "noreferrer" : void 0,
605
725
  children: fieldValue.text
606
726
  }, linkData) });
607
- let t13;
608
727
  let t14;
609
- if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
610
- t13 = () => setIsHovered(true);
611
- t14 = () => setIsHovered(false);
612
- $[25] = t13;
613
- $[26] = t14;
728
+ let t15;
729
+ if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
730
+ t14 = () => setIsHovered(true);
731
+ t15 = () => setIsHovered(false);
732
+ $[28] = t14;
733
+ $[29] = t15;
614
734
  } else {
615
- t13 = $[25];
616
- t14 = $[26];
735
+ t14 = $[28];
736
+ t15 = $[29];
617
737
  }
618
- const t15 = children({
738
+ const t16 = children({
619
739
  ref: elementRef,
620
740
  to: resolvedHref,
621
741
  target: fieldValue.newTab ? "_blank" : void 0,
622
742
  rel: fieldValue.newTab ? "noreferrer" : void 0,
623
743
  children: displayText,
624
744
  "data-camox-field-id": fieldId,
625
- "data-camox-hovered": isHovered || void 0,
626
- "data-camox-focused": isFocused || void 0,
745
+ ...overlayState,
627
746
  "data-camox-overlay-mode": options.synced ? "synced" : void 0,
628
- contentEditable: true,
629
- onClick: _temp2,
747
+ contentEditable: !isCommentMode,
748
+ onClickCapture: selectField,
749
+ onClick: _temp3,
630
750
  onInput: handleInput,
631
751
  onFocus: handleFocus,
632
752
  onBlur: handleBlur,
633
- onMouseEnter: t13,
634
- onMouseLeave: t14,
635
- onKeyDown: _temp3,
753
+ onMouseEnter: t14,
754
+ onMouseLeave: t15,
755
+ onKeyDown: _temp4,
636
756
  spellCheck: false,
637
757
  suppressContentEditableWarning: true
638
758
  }, linkData);
639
- let t16;
640
- if ($[27] !== t15) {
641
- t16 = /* @__PURE__ */ jsx(Fragment, { children: t15 });
642
- $[27] = t15;
643
- $[28] = t16;
644
- } else t16 = $[28];
645
- return t16;
759
+ let t17;
760
+ if ($[30] !== t16) {
761
+ t17 = /* @__PURE__ */ jsx(Fragment, { children: t16 });
762
+ $[30] = t16;
763
+ $[31] = t17;
764
+ } else t17 = $[31];
765
+ return t17;
646
766
  };
647
767
  const Image = (t0) => {
648
768
  const $ = c(22);
649
- if ($[0] !== "d6c181312c1800a4e5ae8a8c97d5ce89a20fae6d141b3bb8b9dd5c16e3c88316") {
769
+ if ($[0] !== "9390cfa3e0bf4e772e82a3d1352a7d56d8ae67f112d215b6d45231db17c01883") {
650
770
  for (let $i = 0; $i < 22; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
651
- $[0] = "d6c181312c1800a4e5ae8a8c97d5ce89a20fae6d141b3bb8b9dd5c16e3c88316";
771
+ $[0] = "9390cfa3e0bf4e772e82a3d1352a7d56d8ae67f112d215b6d45231db17c01883";
652
772
  }
653
773
  const { name, children } = t0;
774
+ const selectTarget = usePreviewSelection();
654
775
  const blockContext = React.use(Context);
655
776
  if (!blockContext) throw new Error("Image must be used within a Block Component");
656
777
  const { blockId, content, mode } = blockContext;
@@ -667,7 +788,7 @@ function createEditableBlock(options) {
667
788
  const overlayItemId = isInlineArrayItem ? repeaterContext.containerItemId : repeaterContext?.itemId;
668
789
  const fieldId = overlayItemId != null ? `${blockId}__${overlayItemId}__${overlayFieldName}` : `${blockId}__${overlayFieldName}`;
669
790
  const [isHovered, setIsHovered] = React.useState(false);
670
- const isFocused = useFieldSelection(blockId, overlayFieldName, "Image", overlayItemId);
791
+ const overlayState = useOverlayState(isHovered, useFieldSelection(blockId, overlayFieldName, "Image", overlayItemId));
671
792
  let t1;
672
793
  if ($[1] !== fieldId) {
673
794
  t1 = { fieldId };
@@ -691,30 +812,29 @@ function createEditableBlock(options) {
691
812
  }
692
813
  React.useEffect(t2, t3);
693
814
  let t4;
694
- if ($[6] !== blockId || $[7] !== isContentEditable || $[8] !== overlayFieldName || $[9] !== overlayItemId) {
695
- t4 = () => {
815
+ if ($[6] !== blockId || $[7] !== isContentEditable || $[8] !== overlayFieldName || $[9] !== overlayItemId || $[10] !== selectTarget) {
816
+ t4 = (event) => {
696
817
  if (!isContentEditable) return;
697
- if (overlayItemId != null) previewStore.send({
698
- type: "selectItemField",
818
+ selectTarget(overlayItemId != null ? {
819
+ type: "item-field",
699
820
  blockId,
700
821
  itemId: overlayItemId,
701
822
  fieldName: overlayFieldName,
702
823
  fieldType: "Image"
703
- });
704
- else previewStore.send({
705
- type: "selectBlockField",
824
+ } : {
825
+ type: "block-field",
706
826
  blockId,
707
827
  fieldName: overlayFieldName,
708
828
  fieldType: "Image"
709
- });
710
- previewStore.send({ type: "toggleContentSheet" });
829
+ }, event);
711
830
  };
712
831
  $[6] = blockId;
713
832
  $[7] = isContentEditable;
714
833
  $[8] = overlayFieldName;
715
834
  $[9] = overlayItemId;
716
- $[10] = t4;
717
- } else t4 = $[10];
835
+ $[10] = selectTarget;
836
+ $[11] = t4;
837
+ } else t4 = $[11];
718
838
  const handleClick = t4;
719
839
  const imageProps = {
720
840
  src: transformImageUrl(fieldValue.url, {
@@ -728,51 +848,47 @@ function createEditableBlock(options) {
728
848
  };
729
849
  if (!isContentEditable) return /* @__PURE__ */ jsx(Fragment, { children: children(imageProps, fieldValue) });
730
850
  const t5 = "image";
731
- const t6 = isHovered || void 0;
732
- const t7 = isFocused || void 0;
733
- const t8 = options.synced ? "synced" : void 0;
734
- let t10;
735
- let t9;
736
- if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
737
- t9 = () => setIsHovered(true);
738
- t10 = () => setIsHovered(false);
739
- $[11] = t10;
740
- $[12] = t9;
851
+ const t6 = options.synced ? "synced" : void 0;
852
+ let t7;
853
+ let t8;
854
+ if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
855
+ t7 = () => setIsHovered(true);
856
+ t8 = () => setIsHovered(false);
857
+ $[12] = t7;
858
+ $[13] = t8;
741
859
  } else {
742
- t10 = $[11];
743
- t9 = $[12];
860
+ t7 = $[12];
861
+ t8 = $[13];
744
862
  }
745
- const t11 = children(imageProps, fieldValue);
746
- let t12;
747
- if ($[13] !== fieldId || $[14] !== handleClick || $[15] !== t10 || $[16] !== t11 || $[17] !== t6 || $[18] !== t7 || $[19] !== t8 || $[20] !== t9) {
748
- t12 = /* @__PURE__ */ jsx("div", {
863
+ const t9 = children(imageProps, fieldValue);
864
+ let t10;
865
+ if ($[14] !== fieldId || $[15] !== handleClick || $[16] !== overlayState || $[17] !== t6 || $[18] !== t7 || $[19] !== t8 || $[20] !== t9) {
866
+ t10 = /* @__PURE__ */ jsx("div", {
749
867
  "data-camox-field-id": fieldId,
750
868
  "data-camox-field-type": t5,
751
- "data-camox-hovered": t6,
752
- "data-camox-focused": t7,
753
- "data-camox-overlay-mode": t8,
754
- onMouseEnter: t9,
755
- onMouseLeave: t10,
756
- onClick: handleClick,
757
- children: t11
869
+ ...overlayState,
870
+ "data-camox-overlay-mode": t6,
871
+ onMouseEnter: t7,
872
+ onMouseLeave: t8,
873
+ onClickCapture: handleClick,
874
+ children: t9
758
875
  });
759
- $[13] = fieldId;
760
- $[14] = handleClick;
761
- $[15] = t10;
762
- $[16] = t11;
876
+ $[14] = fieldId;
877
+ $[15] = handleClick;
878
+ $[16] = overlayState;
763
879
  $[17] = t6;
764
880
  $[18] = t7;
765
881
  $[19] = t8;
766
882
  $[20] = t9;
767
- $[21] = t12;
768
- } else t12 = $[21];
769
- return t12;
883
+ $[21] = t10;
884
+ } else t10 = $[21];
885
+ return t10;
770
886
  };
771
887
  const File = (t0) => {
772
888
  const $ = c(9);
773
- if ($[0] !== "d6c181312c1800a4e5ae8a8c97d5ce89a20fae6d141b3bb8b9dd5c16e3c88316") {
889
+ if ($[0] !== "9390cfa3e0bf4e772e82a3d1352a7d56d8ae67f112d215b6d45231db17c01883") {
774
890
  for (let $i = 0; $i < 9; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
775
- $[0] = "d6c181312c1800a4e5ae8a8c97d5ce89a20fae6d141b3bb8b9dd5c16e3c88316";
891
+ $[0] = "9390cfa3e0bf4e772e82a3d1352a7d56d8ae67f112d215b6d45231db17c01883";
776
892
  }
777
893
  const { name, children } = t0;
778
894
  const blockContext = React.use(Context);
@@ -846,14 +962,17 @@ function createEditableBlock(options) {
846
962
  const ImageList = _AssetList;
847
963
  const FileList = _AssetList;
848
964
  const RepeaterItemWrapper = (t0) => {
849
- const $ = c(8);
850
- if ($[0] !== "d6c181312c1800a4e5ae8a8c97d5ce89a20fae6d141b3bb8b9dd5c16e3c88316") {
851
- for (let $i = 0; $i < 8; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
852
- $[0] = "d6c181312c1800a4e5ae8a8c97d5ce89a20fae6d141b3bb8b9dd5c16e3c88316";
965
+ const $ = c(20);
966
+ if ($[0] !== "9390cfa3e0bf4e772e82a3d1352a7d56d8ae67f112d215b6d45231db17c01883") {
967
+ for (let $i = 0; $i < 20; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
968
+ $[0] = "9390cfa3e0bf4e772e82a3d1352a7d56d8ae67f112d215b6d45231db17c01883";
853
969
  }
854
970
  const { itemId, blockId, mode, children } = t0;
855
971
  const isContentEditable = useIsEditable(mode);
856
972
  const { window: iframeWindow } = useFrame();
973
+ const selectTarget = usePreviewSelection();
974
+ const isCommentMode = useSelector(previewStore, selectIsCommentMode);
975
+ const [isLocallyHovered, setIsLocallyHovered] = React.useState(false);
857
976
  const isRepeaterHovered = React.useContext(RepeaterHoverContext);
858
977
  const t1 = String(blockId);
859
978
  const t2 = String(itemId);
@@ -867,30 +986,71 @@ function createEditableBlock(options) {
867
986
  $[2] = t2;
868
987
  $[3] = t3;
869
988
  } else t3 = $[3];
870
- const isHovered = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_REPEATER_ITEM", "CAMOX_HOVER_REPEATER_ITEM_END", t3);
871
- const showOverlay = isContentEditable && (isHovered || isRepeaterHovered);
872
- const t4 = isContentEditable ? itemId : void 0;
873
- const t5 = showOverlay || void 0;
989
+ const overlayState = useOverlayState(useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_REPEATER_ITEM", "CAMOX_HOVER_REPEATER_ITEM_END", t3) || isRepeaterHovered || isCommentMode && isLocallyHovered);
990
+ let t4;
991
+ if ($[4] !== blockId || $[5] !== isCommentMode || $[6] !== isContentEditable || $[7] !== itemId || $[8] !== selectTarget) {
992
+ t4 = (event) => {
993
+ if (!isContentEditable || !isCommentMode || itemId == null) return;
994
+ const target = event.target;
995
+ if (target.closest("[data-camox-field-id]")) return;
996
+ if (target.closest("[data-camox-repeater-item-id], [data-camox-block-id], [data-camox-comment-block-id]") !== event.currentTarget) return;
997
+ selectTarget({
998
+ type: "item",
999
+ blockId,
1000
+ itemId
1001
+ }, event);
1002
+ };
1003
+ $[4] = blockId;
1004
+ $[5] = isCommentMode;
1005
+ $[6] = isContentEditable;
1006
+ $[7] = itemId;
1007
+ $[8] = selectTarget;
1008
+ $[9] = t4;
1009
+ } else t4 = $[9];
1010
+ const handleClick = t4;
1011
+ const t5 = isContentEditable ? itemId : void 0;
874
1012
  let t6;
875
- if ($[4] !== children || $[5] !== t4 || $[6] !== t5) {
876
- t6 = /* @__PURE__ */ jsx("div", {
877
- "data-camox-repeater-item-id": t4,
878
- "data-camox-hovered": t5,
1013
+ let t7;
1014
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
1015
+ t6 = () => setIsLocallyHovered(true);
1016
+ t7 = () => setIsLocallyHovered(false);
1017
+ $[10] = t6;
1018
+ $[11] = t7;
1019
+ } else {
1020
+ t6 = $[10];
1021
+ t7 = $[11];
1022
+ }
1023
+ let t8;
1024
+ if ($[12] !== isContentEditable || $[13] !== overlayState) {
1025
+ t8 = isContentEditable ? overlayState : {};
1026
+ $[12] = isContentEditable;
1027
+ $[13] = overlayState;
1028
+ $[14] = t8;
1029
+ } else t8 = $[14];
1030
+ let t9;
1031
+ if ($[15] !== children || $[16] !== handleClick || $[17] !== t5 || $[18] !== t8) {
1032
+ t9 = /* @__PURE__ */ jsx("div", {
1033
+ "data-camox-repeater-item-id": t5,
1034
+ onClickCapture: handleClick,
1035
+ onMouseEnter: t6,
1036
+ onMouseLeave: t7,
1037
+ ...t8,
879
1038
  "data-camox-overlay-mode": options.synced ? "synced" : void 0,
880
1039
  children
881
1040
  });
882
- $[4] = children;
883
- $[5] = t4;
884
- $[6] = t5;
885
- $[7] = t6;
886
- } else t6 = $[7];
887
- return t6;
1041
+ $[15] = children;
1042
+ $[16] = handleClick;
1043
+ $[17] = t5;
1044
+ $[18] = t8;
1045
+ $[19] = t9;
1046
+ } else t9 = $[19];
1047
+ return t9;
888
1048
  };
889
1049
  const RepeaterHoverProvider = (t0) => {
890
1050
  const $ = c(7);
891
- if ($[0] !== "d6c181312c1800a4e5ae8a8c97d5ce89a20fae6d141b3bb8b9dd5c16e3c88316") {
1051
+ if ($[0] !== "9390cfa3e0bf4e772e82a3d1352a7d56d8ae67f112d215b6d45231db17c01883") {
892
1052
  for (let $i = 0; $i < 7; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
893
- $[0] = "d6c181312c1800a4e5ae8a8c97d5ce89a20fae6d141b3bb8b9dd5c16e3c88316";
1053
+ $[0] = "9390cfa3e0bf4e772e82a3d1352a7d56d8ae67f112d215b6d45231db17c01883";
894
1054
  }
895
1055
  const { blockId, fieldName, children } = t0;
896
1056
  const isContentEditable = useIsEditable("site");
@@ -921,9 +1081,9 @@ function createEditableBlock(options) {
921
1081
  };
922
1082
  const Repeater = (t0) => {
923
1083
  const $ = c(27);
924
- if ($[0] !== "d6c181312c1800a4e5ae8a8c97d5ce89a20fae6d141b3bb8b9dd5c16e3c88316") {
1084
+ if ($[0] !== "9390cfa3e0bf4e772e82a3d1352a7d56d8ae67f112d215b6d45231db17c01883") {
925
1085
  for (let $i = 0; $i < 27; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
926
- $[0] = "d6c181312c1800a4e5ae8a8c97d5ce89a20fae6d141b3bb8b9dd5c16e3c88316";
1086
+ $[0] = "9390cfa3e0bf4e772e82a3d1352a7d56d8ae67f112d215b6d45231db17c01883";
927
1087
  }
928
1088
  const { name, children } = t0;
929
1089
  const blockContext = React.use(Context);
@@ -1047,19 +1207,21 @@ function createEditableBlock(options) {
1047
1207
  return t4;
1048
1208
  };
1049
1209
  const BlockComponent = (t0) => {
1050
- const $ = c(70);
1051
- if ($[0] !== "d6c181312c1800a4e5ae8a8c97d5ce89a20fae6d141b3bb8b9dd5c16e3c88316") {
1052
- for (let $i = 0; $i < 70; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
1053
- $[0] = "d6c181312c1800a4e5ae8a8c97d5ce89a20fae6d141b3bb8b9dd5c16e3c88316";
1210
+ const $ = c(74);
1211
+ if ($[0] !== "9390cfa3e0bf4e772e82a3d1352a7d56d8ae67f112d215b6d45231db17c01883") {
1212
+ for (let $i = 0; $i < 74; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
1213
+ $[0] = "9390cfa3e0bf4e772e82a3d1352a7d56d8ae67f112d215b6d45231db17c01883";
1054
1214
  }
1055
1215
  const { blockData, mode, isFirstBlock, showAddBlockTop, showAddBlockBottom, addBlockAfterPosition } = t0;
1056
1216
  const isContentEditable = useIsEditable(mode);
1057
1217
  const { window: iframeWindow } = useFrame();
1058
1218
  const [isHovered, setIsHovered] = React.useState(false);
1059
- const selection = useSelector(previewStore, _temp4);
1060
- const isPageEditorSidebarOpen = useSelector(previewStore, _temp5);
1219
+ const isCommentMode = useSelector(previewStore, selectIsCommentMode);
1220
+ const selection = useSelector(previewStore, _temp5);
1061
1221
  const isAddBlockSidebarOpen = useSelector(previewStore, _temp6);
1222
+ const selectTarget = usePreviewSelection();
1062
1223
  const isBlockSelected = selection?.blockId === blockData._id;
1224
+ const overlayState = useOverlayState(isHovered && !isBlockSelected, isBlockSelected);
1063
1225
  const ref = React.useRef(null);
1064
1226
  const [isFirstRender, setIsFirstRender] = React.useState(true);
1065
1227
  let t1;
@@ -1091,89 +1253,92 @@ function createEditableBlock(options) {
1091
1253
  $[6] = t3;
1092
1254
  } else t3 = $[6];
1093
1255
  let t4;
1094
- if ($[7] !== blockData._id || $[8] !== isBlockSelected || $[9] !== isFirstRender || $[10] !== isPageEditorSidebarOpen) {
1256
+ if ($[7] !== blockData._id || $[8] !== isBlockSelected || $[9] !== isFirstRender) {
1095
1257
  t4 = [
1096
1258
  blockData._id,
1097
1259
  isBlockSelected,
1098
- isFirstRender,
1099
- isPageEditorSidebarOpen
1260
+ isFirstRender
1100
1261
  ];
1101
1262
  $[7] = blockData._id;
1102
1263
  $[8] = isBlockSelected;
1103
1264
  $[9] = isFirstRender;
1104
- $[10] = isPageEditorSidebarOpen;
1105
- $[11] = t4;
1106
- } else t4 = $[11];
1265
+ $[10] = t4;
1266
+ } else t4 = $[10];
1107
1267
  React.useEffect(t3, t4);
1108
1268
  const t5 = String(blockData._id);
1109
1269
  let t6;
1110
- if ($[12] !== t5) {
1270
+ if ($[11] !== t5) {
1111
1271
  t6 = { blockId: t5 };
1112
- $[12] = t5;
1113
- $[13] = t6;
1114
- } else t6 = $[13];
1272
+ $[11] = t5;
1273
+ $[12] = t6;
1274
+ } else t6 = $[12];
1115
1275
  const isHoveredFromSidebar = useOverlayMessage(iframeWindow, isContentEditable, "CAMOX_HOVER_BLOCK", "CAMOX_HOVER_BLOCK_END", t6);
1116
1276
  let t7;
1117
1277
  let t8;
1118
- if ($[14] !== isHoveredFromSidebar) {
1278
+ if ($[13] !== isHoveredFromSidebar) {
1119
1279
  t7 = () => {
1120
1280
  setIsHovered(isHoveredFromSidebar);
1121
1281
  };
1122
1282
  t8 = [isHoveredFromSidebar];
1123
- $[14] = isHoveredFromSidebar;
1124
- $[15] = t7;
1125
- $[16] = t8;
1283
+ $[13] = isHoveredFromSidebar;
1284
+ $[14] = t7;
1285
+ $[15] = t8;
1126
1286
  } else {
1127
- t7 = $[15];
1128
- t8 = $[16];
1287
+ t7 = $[14];
1288
+ t8 = $[15];
1129
1289
  }
1130
1290
  React.useEffect(t7, t8);
1131
1291
  let result;
1132
- if ($[17] !== blockData.content) {
1292
+ if ($[16] !== blockData.content) {
1133
1293
  result = { ...blockData.content };
1134
1294
  for (const key in result) {
1135
1295
  const value = result[key];
1136
1296
  if (Array.isArray(value) && value.length > 0 && value[0]?.content !== void 0) result[key] = value.map(_temp7);
1137
1297
  }
1138
- $[17] = blockData.content;
1139
- $[18] = result;
1140
- } else result = $[18];
1298
+ $[16] = blockData.content;
1299
+ $[17] = result;
1300
+ } else result = $[17];
1141
1301
  const normalizedContent = result;
1142
1302
  let t9;
1143
- if ($[19] !== blockData._id || $[20] !== isContentEditable) {
1303
+ if ($[18] !== blockData._id || $[19] !== isCommentMode || $[20] !== isContentEditable || $[21] !== selectTarget) {
1144
1304
  t9 = (e) => {
1145
1305
  if (!isContentEditable) return;
1146
- if (e.target.closest("[data-camox-field-id]")) return;
1147
- previewStore.send({
1148
- type: "setFocusedBlock",
1306
+ const target = e.target;
1307
+ if (target.closest("[data-camox-field-id]")) return;
1308
+ if (isCommentMode && target.closest("[data-camox-repeater-item-id]")) return;
1309
+ if (target.closest("[data-camox-block-id], [data-camox-comment-block-id]") !== e.currentTarget) return;
1310
+ selectTarget({
1311
+ type: "block",
1149
1312
  blockId: blockData._id
1150
- });
1313
+ }, e);
1151
1314
  };
1152
- $[19] = blockData._id;
1315
+ $[18] = blockData._id;
1316
+ $[19] = isCommentMode;
1153
1317
  $[20] = isContentEditable;
1154
- $[21] = t9;
1155
- } else t9 = $[21];
1318
+ $[21] = selectTarget;
1319
+ $[22] = t9;
1320
+ } else t9 = $[22];
1156
1321
  const handleClick = t9;
1157
1322
  let t10;
1158
- if ($[22] !== isContentEditable) {
1323
+ if ($[23] !== isContentEditable) {
1159
1324
  t10 = () => {
1160
1325
  if (isContentEditable) setIsHovered(true);
1161
1326
  };
1162
- $[22] = isContentEditable;
1163
- $[23] = t10;
1164
- } else t10 = $[23];
1327
+ $[23] = isContentEditable;
1328
+ $[24] = t10;
1329
+ } else t10 = $[24];
1165
1330
  const handleMouseEnter = t10;
1166
1331
  let t11;
1167
- if ($[24] !== isContentEditable) {
1332
+ if ($[25] !== isContentEditable) {
1168
1333
  t11 = () => {
1169
1334
  if (isContentEditable) setIsHovered(false);
1170
1335
  };
1171
- $[24] = isContentEditable;
1172
- $[25] = t11;
1173
- } else t11 = $[25];
1336
+ $[25] = isContentEditable;
1337
+ $[26] = t11;
1338
+ } else t11 = $[26];
1174
1339
  const handleMouseLeave = t11;
1175
1340
  let t12;
1176
- if ($[26] !== addBlockAfterPosition || $[27] !== blockData.position) {
1341
+ if ($[27] !== addBlockAfterPosition || $[28] !== blockData.position) {
1177
1342
  t12 = (insertPosition) => {
1178
1343
  postOverlayMessage({
1179
1344
  type: "CAMOX_ADD_BLOCK_REQUEST",
@@ -1182,113 +1347,118 @@ function createEditableBlock(options) {
1182
1347
  ...addBlockAfterPosition !== void 0 && { afterPosition: addBlockAfterPosition }
1183
1348
  });
1184
1349
  };
1185
- $[26] = addBlockAfterPosition;
1186
- $[27] = blockData.position;
1187
- $[28] = t12;
1188
- } else t12 = $[28];
1350
+ $[27] = addBlockAfterPosition;
1351
+ $[28] = blockData.position;
1352
+ $[29] = t12;
1353
+ } else t12 = $[29];
1189
1354
  const handleAddBlockClick = t12;
1190
- const shouldShowOverlay = isContentEditable && (isHovered || isBlockSelected) && !isAddBlockSidebarOpen;
1355
+ const shouldShowOverlay = isContentEditable && (overlayState["data-camox-hovered"] || overlayState["data-camox-focused"]) && !isAddBlockSidebarOpen;
1191
1356
  const shouldShowAddBlockOverlay = isAddBlockSidebarOpen && mode !== "peek";
1192
1357
  let t13;
1193
- if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
1358
+ if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
1194
1359
  t13 = {
1195
1360
  position: "relative",
1196
1361
  scrollMargin: "5rem",
1197
1362
  background: "var(--background)"
1198
1363
  };
1199
- $[29] = t13;
1200
- } else t13 = $[29];
1364
+ $[30] = t13;
1365
+ } else t13 = $[30];
1201
1366
  const t14 = isContentEditable ? blockData._id : void 0;
1202
- const t15 = shouldShowOverlay && !isBlockSelected || void 0;
1203
- const t16 = shouldShowOverlay && isBlockSelected || void 0;
1204
- const t17 = blockData._id;
1205
- let t18;
1206
- if ($[30] !== blockData.content) {
1207
- t18 = {
1367
+ let t15;
1368
+ if ($[31] !== overlayState || $[32] !== shouldShowOverlay) {
1369
+ t15 = shouldShowOverlay ? overlayState : {};
1370
+ $[31] = overlayState;
1371
+ $[32] = shouldShowOverlay;
1372
+ $[33] = t15;
1373
+ } else t15 = $[33];
1374
+ const t16 = blockData._id;
1375
+ let t17;
1376
+ if ($[34] !== blockData.content) {
1377
+ t17 = {
1208
1378
  ...contentDefaults,
1209
1379
  ...blockData.content
1210
1380
  };
1211
- $[30] = blockData.content;
1212
- $[31] = t18;
1213
- } else t18 = $[31];
1214
- const merged = t18;
1381
+ $[34] = blockData.content;
1382
+ $[35] = t17;
1383
+ } else t17 = $[35];
1384
+ const merged = t17;
1215
1385
  let overrides;
1216
- if ($[32] !== merged) {
1386
+ if ($[36] !== merged) {
1217
1387
  overrides = {};
1218
1388
  for (const key_0 in merged) {
1219
1389
  const val = merged[key_0];
1220
1390
  if (val && typeof val === "object" && "url" in val && !val.url && contentDefaults[key_0]) overrides[key_0] = contentDefaults[key_0];
1221
1391
  }
1222
- $[32] = merged;
1223
- $[33] = overrides;
1224
- } else overrides = $[33];
1225
- let t19;
1226
- if ($[34] !== merged || $[35] !== overrides) {
1227
- t19 = {
1392
+ $[36] = merged;
1393
+ $[37] = overrides;
1394
+ } else overrides = $[37];
1395
+ let t18;
1396
+ if ($[38] !== merged || $[39] !== overrides) {
1397
+ t18 = {
1228
1398
  ...merged,
1229
1399
  ...overrides
1230
1400
  };
1231
- $[34] = merged;
1232
- $[35] = overrides;
1233
- $[36] = t19;
1234
- } else t19 = $[36];
1235
- const t20 = t19;
1236
- let t21;
1237
- if ($[37] !== blockData.settings) {
1238
- t21 = {
1401
+ $[38] = merged;
1402
+ $[39] = overrides;
1403
+ $[40] = t18;
1404
+ } else t18 = $[40];
1405
+ const t19 = t18;
1406
+ let t20;
1407
+ if ($[41] !== blockData.settings) {
1408
+ t20 = {
1239
1409
  ...settingsDefaults,
1240
1410
  ...blockData.settings
1241
1411
  };
1242
- $[37] = blockData.settings;
1243
- $[38] = t21;
1244
- } else t21 = $[38];
1245
- const t22 = t21;
1246
- let t23;
1247
- if ($[39] !== blockData._id || $[40] !== isHovered || $[41] !== mode || $[42] !== t20 || $[43] !== t22) {
1248
- t23 = {
1249
- blockId: t17,
1250
- content: t20,
1251
- settings: t22,
1412
+ $[41] = blockData.settings;
1413
+ $[42] = t20;
1414
+ } else t20 = $[42];
1415
+ const t21 = t20;
1416
+ let t22;
1417
+ if ($[43] !== blockData._id || $[44] !== isHovered || $[45] !== mode || $[46] !== t19 || $[47] !== t21) {
1418
+ t22 = {
1419
+ blockId: t16,
1420
+ content: t19,
1421
+ settings: t21,
1252
1422
  mode,
1253
1423
  isHovered,
1254
1424
  setIsHovered
1255
1425
  };
1256
- $[39] = blockData._id;
1257
- $[40] = isHovered;
1258
- $[41] = mode;
1259
- $[42] = t20;
1260
- $[43] = t22;
1261
- $[44] = t23;
1262
- } else t23 = $[44];
1426
+ $[43] = blockData._id;
1427
+ $[44] = isHovered;
1428
+ $[45] = mode;
1429
+ $[46] = t19;
1430
+ $[47] = t21;
1431
+ $[48] = t22;
1432
+ } else t22 = $[48];
1433
+ let t23;
1434
+ if ($[49] !== normalizedContent) {
1435
+ t23 = /* @__PURE__ */ jsx(options.component, { content: normalizedContent });
1436
+ $[49] = normalizedContent;
1437
+ $[50] = t23;
1438
+ } else t23 = $[50];
1263
1439
  let t24;
1264
- if ($[45] !== normalizedContent) {
1265
- t24 = /* @__PURE__ */ jsx(options.component, { content: normalizedContent });
1266
- $[45] = normalizedContent;
1267
- $[46] = t24;
1268
- } else t24 = $[46];
1269
- let t25;
1270
- if ($[47] !== t23 || $[48] !== t24) {
1271
- t25 = /* @__PURE__ */ jsx(Context.Provider, {
1272
- value: t23,
1273
- children: t24
1440
+ if ($[51] !== t22 || $[52] !== t23) {
1441
+ t24 = /* @__PURE__ */ jsx(Context.Provider, {
1442
+ value: t22,
1443
+ children: t23
1274
1444
  });
1275
- $[47] = t23;
1276
- $[48] = t24;
1277
- $[49] = t25;
1278
- } else t25 = $[49];
1279
- const t26 = shouldShowAddBlockOverlay || void 0;
1280
- let t27;
1281
- if ($[50] !== t26) {
1282
- t27 = /* @__PURE__ */ jsx("div", {
1445
+ $[51] = t22;
1446
+ $[52] = t23;
1447
+ $[53] = t24;
1448
+ } else t24 = $[53];
1449
+ const t25 = shouldShowAddBlockOverlay || void 0;
1450
+ let t26;
1451
+ if ($[54] !== t25) {
1452
+ t26 = /* @__PURE__ */ jsx("div", {
1283
1453
  className: "camox-sheet-overlay",
1284
- "data-camox-visible": t26
1454
+ "data-camox-visible": t25
1285
1455
  });
1286
- $[50] = t26;
1287
- $[51] = t27;
1288
- } else t27 = $[51];
1289
- let t28;
1290
- if ($[52] !== handleAddBlockClick || $[53] !== isAddBlockSidebarOpen || $[54] !== isFirstBlock || $[55] !== mode || $[56] !== shouldShowOverlay || $[57] !== showAddBlockBottom || $[58] !== showAddBlockTop) {
1291
- t28 = shouldShowOverlay && /* @__PURE__ */ jsxs(Fragment, { children: [(showAddBlockTop ?? (mode !== "layout" && !isFirstBlock)) && /* @__PURE__ */ jsx(AddBlockControlBar, {
1456
+ $[54] = t25;
1457
+ $[55] = t26;
1458
+ } else t26 = $[55];
1459
+ let t27;
1460
+ if ($[56] !== handleAddBlockClick || $[57] !== isAddBlockSidebarOpen || $[58] !== isCommentMode || $[59] !== isFirstBlock || $[60] !== mode || $[61] !== shouldShowOverlay || $[62] !== showAddBlockBottom || $[63] !== showAddBlockTop) {
1461
+ t27 = shouldShowOverlay && !isCommentMode && /* @__PURE__ */ jsxs(Fragment, { children: [(showAddBlockTop ?? (mode !== "layout" && !isFirstBlock)) && /* @__PURE__ */ jsx(AddBlockControlBar, {
1292
1462
  position: "top",
1293
1463
  hidden: isAddBlockSidebarOpen,
1294
1464
  onMouseLeave: () => setIsHovered(false),
@@ -1299,46 +1469,45 @@ function createEditableBlock(options) {
1299
1469
  onMouseLeave: () => setIsHovered(false),
1300
1470
  onClick: () => handleAddBlockClick("after")
1301
1471
  })] });
1302
- $[52] = handleAddBlockClick;
1303
- $[53] = isAddBlockSidebarOpen;
1304
- $[54] = isFirstBlock;
1305
- $[55] = mode;
1306
- $[56] = shouldShowOverlay;
1307
- $[57] = showAddBlockBottom;
1308
- $[58] = showAddBlockTop;
1309
- $[59] = t28;
1310
- } else t28 = $[59];
1311
- let t29;
1312
- if ($[60] !== handleClick || $[61] !== handleMouseEnter || $[62] !== handleMouseLeave || $[63] !== t14 || $[64] !== t15 || $[65] !== t16 || $[66] !== t25 || $[67] !== t27 || $[68] !== t28) {
1313
- t29 = /* @__PURE__ */ jsxs("div", {
1472
+ $[56] = handleAddBlockClick;
1473
+ $[57] = isAddBlockSidebarOpen;
1474
+ $[58] = isCommentMode;
1475
+ $[59] = isFirstBlock;
1476
+ $[60] = mode;
1477
+ $[61] = shouldShowOverlay;
1478
+ $[62] = showAddBlockBottom;
1479
+ $[63] = showAddBlockTop;
1480
+ $[64] = t27;
1481
+ } else t27 = $[64];
1482
+ let t28;
1483
+ if ($[65] !== handleClick || $[66] !== handleMouseEnter || $[67] !== handleMouseLeave || $[68] !== t14 || $[69] !== t15 || $[70] !== t24 || $[71] !== t26 || $[72] !== t27) {
1484
+ t28 = /* @__PURE__ */ jsxs("div", {
1314
1485
  className: "group visual-editing-block",
1315
1486
  ref,
1316
1487
  style: t13,
1317
1488
  "data-camox-block-id": t14,
1318
- "data-camox-hovered": t15,
1319
- "data-camox-focused": t16,
1489
+ ...t15,
1320
1490
  "data-camox-overlay-mode": options.synced ? "synced" : void 0,
1321
- onClick: handleClick,
1491
+ onClickCapture: handleClick,
1322
1492
  onMouseEnter: handleMouseEnter,
1323
1493
  onMouseLeave: handleMouseLeave,
1324
1494
  children: [
1325
- t25,
1326
- t27,
1327
- t28
1495
+ t24,
1496
+ t26,
1497
+ t27
1328
1498
  ]
1329
1499
  });
1330
- $[60] = handleClick;
1331
- $[61] = handleMouseEnter;
1332
- $[62] = handleMouseLeave;
1333
- $[63] = t14;
1334
- $[64] = t15;
1335
- $[65] = t16;
1336
- $[66] = t25;
1337
- $[67] = t27;
1338
- $[68] = t28;
1339
- $[69] = t29;
1340
- } else t29 = $[69];
1341
- return t29;
1500
+ $[65] = handleClick;
1501
+ $[66] = handleMouseEnter;
1502
+ $[67] = handleMouseLeave;
1503
+ $[68] = t14;
1504
+ $[69] = t15;
1505
+ $[70] = t24;
1506
+ $[71] = t26;
1507
+ $[72] = t27;
1508
+ $[73] = t28;
1509
+ } else t28 = $[73];
1510
+ return t28;
1342
1511
  };
1343
1512
  const useSetting = (name) => {
1344
1513
  const ctx = React.use(Context);
@@ -1350,10 +1519,10 @@ function createEditableBlock(options) {
1350
1519
  * Provides the same hover, selection, and sheet overlays as the main BlockComponent.
1351
1520
  */
1352
1521
  const Detached = (t0) => {
1353
- const $ = c(30);
1354
- if ($[0] !== "d6c181312c1800a4e5ae8a8c97d5ce89a20fae6d141b3bb8b9dd5c16e3c88316") {
1355
- for (let $i = 0; $i < 30; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
1356
- $[0] = "d6c181312c1800a4e5ae8a8c97d5ce89a20fae6d141b3bb8b9dd5c16e3c88316";
1522
+ const $ = c(32);
1523
+ if ($[0] !== "9390cfa3e0bf4e772e82a3d1352a7d56d8ae67f112d215b6d45231db17c01883") {
1524
+ for (let $i = 0; $i < 32; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
1525
+ $[0] = "9390cfa3e0bf4e772e82a3d1352a7d56d8ae67f112d215b6d45231db17c01883";
1357
1526
  }
1358
1527
  const { children } = t0;
1359
1528
  const ctx = React.use(Context);
@@ -1363,7 +1532,9 @@ function createEditableBlock(options) {
1363
1532
  const { window: iframeWindow } = useFrame();
1364
1533
  const selection = useSelector(previewStore, _temp8);
1365
1534
  const isAddBlockSidebarOpen = useSelector(previewStore, _temp9);
1535
+ const selectTarget = usePreviewSelection();
1366
1536
  const isBlockSelected = selection?.blockId === blockId;
1537
+ const overlayState = useOverlayState(isHovered && !isBlockSelected, isBlockSelected);
1367
1538
  const t1 = String(blockId);
1368
1539
  let t2;
1369
1540
  if ($[1] !== t1) {
@@ -1388,68 +1559,74 @@ function createEditableBlock(options) {
1388
1559
  t4 = $[6];
1389
1560
  }
1390
1561
  React.useEffect(t3, t4);
1391
- const shouldShowOverlay = isContentEditable && (isHovered || isBlockSelected) && !isAddBlockSidebarOpen;
1562
+ const shouldShowOverlay = isContentEditable && (overlayState["data-camox-hovered"] || overlayState["data-camox-focused"]) && !isAddBlockSidebarOpen;
1392
1563
  const shouldHideForAddBlockSidebar = isAddBlockSidebarOpen && mode !== "peek";
1393
1564
  let t5;
1394
- if ($[7] !== blockId || $[8] !== isContentEditable) {
1565
+ if ($[7] !== blockId || $[8] !== isContentEditable || $[9] !== selectTarget) {
1395
1566
  t5 = (e) => {
1396
1567
  if (!isContentEditable) return;
1397
- e.stopPropagation();
1398
- previewStore.send({
1399
- type: "setFocusedBlock",
1568
+ const target = e.target;
1569
+ if (target.closest("[data-camox-field-id]")) return;
1570
+ if (selectIsCommentMode(previewStore.getSnapshot()) && target.closest("[data-camox-repeater-item-id]")) return;
1571
+ if (target.closest("[data-camox-block-id], [data-camox-comment-block-id]") !== e.currentTarget) return;
1572
+ selectTarget({
1573
+ type: "block",
1400
1574
  blockId
1401
- });
1575
+ }, e);
1402
1576
  };
1403
1577
  $[7] = blockId;
1404
1578
  $[8] = isContentEditable;
1405
- $[9] = t5;
1406
- } else t5 = $[9];
1579
+ $[9] = selectTarget;
1580
+ $[10] = t5;
1581
+ } else t5 = $[10];
1407
1582
  const handleClick = t5;
1408
1583
  let t6;
1409
- if ($[10] !== isContentEditable || $[11] !== setIsHovered) {
1584
+ if ($[11] !== isContentEditable || $[12] !== setIsHovered) {
1410
1585
  t6 = () => {
1411
1586
  if (isContentEditable) setIsHovered(true);
1412
1587
  };
1413
- $[10] = isContentEditable;
1414
- $[11] = setIsHovered;
1415
- $[12] = t6;
1416
- } else t6 = $[12];
1588
+ $[11] = isContentEditable;
1589
+ $[12] = setIsHovered;
1590
+ $[13] = t6;
1591
+ } else t6 = $[13];
1417
1592
  const handleMouseEnter = t6;
1418
1593
  let t7;
1419
- if ($[13] !== isContentEditable || $[14] !== setIsHovered) {
1594
+ if ($[14] !== isContentEditable || $[15] !== setIsHovered) {
1420
1595
  t7 = () => {
1421
1596
  if (isContentEditable) setIsHovered(false);
1422
1597
  };
1423
- $[13] = isContentEditable;
1424
- $[14] = setIsHovered;
1425
- $[15] = t7;
1426
- } else t7 = $[15];
1598
+ $[14] = isContentEditable;
1599
+ $[15] = setIsHovered;
1600
+ $[16] = t7;
1601
+ } else t7 = $[16];
1427
1602
  const handleMouseLeave = t7;
1428
1603
  const [container, setContainer] = React.useState(null);
1429
- const t8 = shouldHideForAddBlockSidebar ? 0 : 1;
1430
- let t9;
1431
- if ($[16] !== children || $[17] !== handleClick || $[18] !== handleMouseEnter || $[19] !== handleMouseLeave || $[20] !== t8) {
1432
- t9 = children({
1604
+ const t8 = isContentEditable ? blockId : void 0;
1605
+ const t9 = shouldHideForAddBlockSidebar ? 0 : 1;
1606
+ let t10;
1607
+ if ($[17] !== children || $[18] !== handleClick || $[19] !== handleMouseEnter || $[20] !== handleMouseLeave || $[21] !== t8 || $[22] !== t9) {
1608
+ t10 = children({
1609
+ "data-camox-comment-block-id": t8,
1433
1610
  ref: setContainer,
1434
- style: { opacity: t8 },
1435
- onClick: handleClick,
1611
+ style: { opacity: t9 },
1612
+ onClickCapture: handleClick,
1436
1613
  onMouseEnter: handleMouseEnter,
1437
1614
  onMouseLeave: handleMouseLeave
1438
1615
  });
1439
- $[16] = children;
1440
- $[17] = handleClick;
1441
- $[18] = handleMouseEnter;
1442
- $[19] = handleMouseLeave;
1443
- $[20] = t8;
1444
- $[21] = t9;
1445
- } else t9 = $[21];
1446
- let t10;
1447
- if ($[22] !== blockId || $[23] !== container || $[24] !== isBlockSelected || $[25] !== shouldShowOverlay) {
1448
- t10 = container && createPortal(/* @__PURE__ */ jsx(Fragment, { children: shouldShowOverlay && /* @__PURE__ */ jsx("div", {
1616
+ $[17] = children;
1617
+ $[18] = handleClick;
1618
+ $[19] = handleMouseEnter;
1619
+ $[20] = handleMouseLeave;
1620
+ $[21] = t8;
1621
+ $[22] = t9;
1622
+ $[23] = t10;
1623
+ } else t10 = $[23];
1624
+ let t11;
1625
+ if ($[24] !== blockId || $[25] !== container || $[26] !== overlayState || $[27] !== shouldShowOverlay) {
1626
+ t11 = container && createPortal(/* @__PURE__ */ jsx(Fragment, { children: shouldShowOverlay && /* @__PURE__ */ jsx("div", {
1449
1627
  "data-camox-block-id": blockId,
1450
1628
  "data-camox-detached": true,
1451
- "data-camox-hovered": !isBlockSelected || void 0,
1452
- "data-camox-focused": isBlockSelected || void 0,
1629
+ ...overlayState,
1453
1630
  "data-camox-overlay-mode": options.synced ? "synced" : void 0,
1454
1631
  style: {
1455
1632
  position: "absolute",
@@ -1457,20 +1634,20 @@ function createEditableBlock(options) {
1457
1634
  zIndex: 10
1458
1635
  }
1459
1636
  }) }), container);
1460
- $[22] = blockId;
1461
- $[23] = container;
1462
- $[24] = isBlockSelected;
1463
- $[25] = shouldShowOverlay;
1464
- $[26] = t10;
1465
- } else t10 = $[26];
1466
- let t11;
1467
- if ($[27] !== t10 || $[28] !== t9) {
1468
- t11 = /* @__PURE__ */ jsxs(Fragment, { children: [t9, t10] });
1469
- $[27] = t10;
1470
- $[28] = t9;
1471
- $[29] = t11;
1472
- } else t11 = $[29];
1473
- return t11;
1637
+ $[24] = blockId;
1638
+ $[25] = container;
1639
+ $[26] = overlayState;
1640
+ $[27] = shouldShowOverlay;
1641
+ $[28] = t11;
1642
+ } else t11 = $[28];
1643
+ let t12;
1644
+ if ($[29] !== t10 || $[30] !== t11) {
1645
+ t12 = /* @__PURE__ */ jsxs(Fragment, { children: [t10, t11] });
1646
+ $[29] = t10;
1647
+ $[30] = t11;
1648
+ $[31] = t12;
1649
+ } else t12 = $[31];
1650
+ return t12;
1474
1651
  };
1475
1652
  return {
1476
1653
  Detached,
@@ -1550,20 +1727,20 @@ function createEditableBlock(options) {
1550
1727
  function _temp(l) {
1551
1728
  return l.pathname;
1552
1729
  }
1553
- function _temp2(e_0) {
1730
+ function _temp2(l) {
1731
+ return l.pathname;
1732
+ }
1733
+ function _temp3(e_0) {
1554
1734
  return e_0.preventDefault();
1555
1735
  }
1556
- function _temp3(e_1) {
1736
+ function _temp4(e_1) {
1557
1737
  if (e_1.key === "Escape") e_1.target.blur();
1558
1738
  }
1559
- function _temp4(state) {
1739
+ function _temp5(state) {
1560
1740
  return state.context.selection;
1561
1741
  }
1562
- function _temp5(state_0) {
1563
- return state_0.context.isPageEditorSidebarOpen;
1564
- }
1565
- function _temp6(state_1) {
1566
- return state_1.context.isAddBlockSidebarOpen;
1742
+ function _temp6(state_0) {
1743
+ return state_0.context.isAddBlockSidebarOpen;
1567
1744
  }
1568
1745
  function _temp7(item) {
1569
1746
  return item.content;