camox 0.41.0 → 0.41.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/core/createApp.d.ts +2 -2
  2. package/dist/core/createBlock.js +11 -25
  3. package/dist/core/createLayout.d.ts +1 -1
  4. package/dist/core/editing/BlockEditingRuntime.js +4 -4
  5. package/dist/core/editing/CompleteBlockEditingRuntime.js +5 -5
  6. package/dist/core/editing/createEditableBlock.js +169 -306
  7. package/dist/core/hooks/useIsEditable.js +4 -7
  8. package/dist/core/hooks/useRequireDraftSource.js +7 -11
  9. package/dist/features/preview/CamoxPreview.js +59 -80
  10. package/dist/features/preview/DerivedPreview.js +6 -9
  11. package/dist/features/preview/components/BlockActionsPopover.js +8 -8
  12. package/dist/features/preview/components/DerivedLayoutSidebar.js +4 -7
  13. package/dist/features/preview/components/LinkFieldEditor.js +3 -4
  14. package/dist/features/preview/components/MobilePreviewDrawer.js +3 -3
  15. package/dist/features/preview/components/Overlays.js +6 -9
  16. package/dist/features/preview/components/PageEditorSidebar.js +194 -203
  17. package/dist/features/preview/components/PageTree.js +162 -228
  18. package/dist/features/preview/components/PreviewPanel.js +39 -41
  19. package/dist/features/preview/components/PreviewToolbar.js +15 -18
  20. package/dist/features/preview/components/PreviewToolbarSpacer.js +43 -0
  21. package/dist/features/preview/components/PublicationRow.js +11 -17
  22. package/dist/features/preview/previewStore.js +18 -29
  23. package/dist/features/provider/useAdminShortcuts.js +5 -4
  24. package/dist/features/runtime/RuntimeChrome.js +98 -86
  25. package/dist/features/studio/components/UserButton.js +4 -4
  26. package/package.json +4 -4
  27. package/dist/features/preview/components/DraftSwitchDialog.js +0 -66
@@ -1,7 +1,7 @@
1
1
  import { actionsStore } from "../../provider/actionsStore.js";
2
2
  import { checkIfInputFocused, cn } from "../../../lib/utils.js";
3
3
  import { SharedChromeContext } from "../../runtime/SharedChromeContext.js";
4
- import { previewStore } from "../previewStore.js";
4
+ import { previewStore, selectIsEditMode } from "../previewStore.js";
5
5
  import { useBlockActionsShortcuts } from "./BlockActionsPopover.js";
6
6
  import { FieldOverlayStyles } from "./FieldOverlayStyles.js";
7
7
  import { FieldToolbar } from "./FieldToolbar.js";
@@ -19,9 +19,9 @@ import { PanelContent } from "@camox/ui/panel";
19
19
  //#region src/features/preview/components/PreviewPanel.tsx
20
20
  const PreviewFrame = (t0) => {
21
21
  const $ = c(9);
22
- if ($[0] !== "d1fef758f47859e4d6ac1a8436e009a46839990f032b83d1c6b20b946ff84297") {
22
+ if ($[0] !== "647d74b06c71c6ab8b55c8d5a27ecde77d7de427871f875c0c983ee0b4506ad2") {
23
23
  for (let $i = 0; $i < 9; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
24
- $[0] = "d1fef758f47859e4d6ac1a8436e009a46839990f032b83d1c6b20b946ff84297";
24
+ $[0] = "647d74b06c71c6ab8b55c8d5a27ecde77d7de427871f875c0c983ee0b4506ad2";
25
25
  }
26
26
  const { children, style, className, onIframeReady } = t0;
27
27
  let t1;
@@ -62,9 +62,9 @@ const PreviewFrame = (t0) => {
62
62
  };
63
63
  const KeyDownForwarder = () => {
64
64
  const $ = c(5);
65
- if ($[0] !== "d1fef758f47859e4d6ac1a8436e009a46839990f032b83d1c6b20b946ff84297") {
65
+ if ($[0] !== "647d74b06c71c6ab8b55c8d5a27ecde77d7de427871f875c0c983ee0b4506ad2") {
66
66
  for (let $i = 0; $i < 5; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
67
- $[0] = "d1fef758f47859e4d6ac1a8436e009a46839990f032b83d1c6b20b946ff84297";
67
+ $[0] = "647d74b06c71c6ab8b55c8d5a27ecde77d7de427871f875c0c983ee0b4506ad2";
68
68
  }
69
69
  const { window: iframeWindow } = useFrame();
70
70
  const actions = useSelector(actionsStore, _temp);
@@ -86,15 +86,16 @@ const KeyDownForwarder = () => {
86
86
  });
87
87
  if (matchingAction) {
88
88
  e.preventDefault();
89
+ e.stopPropagation();
89
90
  iframeWindow.parent.postMessage({
90
91
  type: "executeAction",
91
92
  actionId: matchingAction.id
92
93
  }, "*");
93
94
  }
94
95
  };
95
- iframeWindow.addEventListener("keydown", handleKeyDown);
96
+ iframeWindow.addEventListener("keydown", handleKeyDown, true);
96
97
  return () => {
97
- iframeWindow.removeEventListener("keydown", handleKeyDown);
98
+ iframeWindow.removeEventListener("keydown", handleKeyDown, true);
98
99
  };
99
100
  };
100
101
  t1 = [iframeWindow, actions];
@@ -115,18 +116,18 @@ const viewportClassName = {
115
116
  };
116
117
  function CuratedBlockShortcuts() {
117
118
  const $ = c(1);
118
- if ($[0] !== "d1fef758f47859e4d6ac1a8436e009a46839990f032b83d1c6b20b946ff84297") {
119
+ if ($[0] !== "647d74b06c71c6ab8b55c8d5a27ecde77d7de427871f875c0c983ee0b4506ad2") {
119
120
  for (let $i = 0; $i < 1; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
120
- $[0] = "d1fef758f47859e4d6ac1a8436e009a46839990f032b83d1c6b20b946ff84297";
121
+ $[0] = "647d74b06c71c6ab8b55c8d5a27ecde77d7de427871f875c0c983ee0b4506ad2";
121
122
  }
122
123
  useBlockActionsShortcuts();
123
124
  return null;
124
125
  }
125
126
  const PreviewPanel = (t0) => {
126
127
  const $ = c(26);
127
- if ($[0] !== "d1fef758f47859e4d6ac1a8436e009a46839990f032b83d1c6b20b946ff84297") {
128
+ if ($[0] !== "647d74b06c71c6ab8b55c8d5a27ecde77d7de427871f875c0c983ee0b4506ad2") {
128
129
  for (let $i = 0; $i < 26; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
129
- $[0] = "d1fef758f47859e4d6ac1a8436e009a46839990f032b83d1c6b20b946ff84297";
130
+ $[0] = "647d74b06c71c6ab8b55c8d5a27ecde77d7de427871f875c0c983ee0b4506ad2";
130
131
  }
131
132
  const { children, isMobileExperience: t1, page, projectName: t2, toolbarProps } = t0;
132
133
  const isMobileExperience = t1 === void 0 ? false : t1;
@@ -135,14 +136,14 @@ const PreviewPanel = (t0) => {
135
136
  const iframeElement = useSelector(previewStore, _temp2);
136
137
  const handleIframeReady = _temp3;
137
138
  const viewportMode = useSelector(previewStore, _temp4);
138
- const isEditMode = useSelector(previewStore, _temp5);
139
- const isToolbarHidden = useSelector(previewStore, _temp6);
139
+ const isEditMode = useSelector(previewStore, selectIsEditMode);
140
+ const isToolbarHidden = useSelector(previewStore, _temp5);
140
141
  let t3;
141
142
  if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
142
143
  t3 = [];
143
144
  $[1] = t3;
144
145
  } else t3 = $[1];
145
- React.useEffect(_temp16, t3);
146
+ React.useEffect(_temp15, t3);
146
147
  if (isMobileExperience) {
147
148
  let t4;
148
149
  if ($[2] !== children) {
@@ -260,54 +261,51 @@ function _temp4(state_0) {
260
261
  return state_0.context.viewportMode;
261
262
  }
262
263
  function _temp5(state_1) {
263
- return state_1.context.isEditMode;
264
+ return state_1.context.isToolbarHidden;
264
265
  }
265
- function _temp6(state_2) {
266
- return state_2.context.isToolbarHidden;
267
- }
268
- function _temp7() {
266
+ function _temp6() {
269
267
  return true;
270
268
  }
271
- function _temp8() {
269
+ function _temp7() {
272
270
  return previewStore.send({ type: "cycleViewportMode" });
273
271
  }
274
- function _temp9() {
272
+ function _temp8() {
275
273
  return true;
276
274
  }
277
- function _temp0() {
275
+ function _temp9() {
278
276
  return previewStore.send({
279
277
  type: "setViewportMode",
280
278
  mode: "full"
281
279
  });
282
280
  }
283
- function _temp1() {
281
+ function _temp0() {
284
282
  return true;
285
283
  }
286
- function _temp10() {
284
+ function _temp1() {
287
285
  return previewStore.send({
288
286
  type: "setViewportMode",
289
287
  mode: "tablet"
290
288
  });
291
289
  }
292
- function _temp11() {
290
+ function _temp10() {
293
291
  return true;
294
292
  }
295
- function _temp12() {
293
+ function _temp11() {
296
294
  return previewStore.send({
297
295
  type: "setViewportMode",
298
296
  mode: "mobile"
299
297
  });
300
298
  }
301
- function _temp13() {
299
+ function _temp12() {
302
300
  return true;
303
301
  }
304
- function _temp14() {
302
+ function _temp13() {
305
303
  previewStore.send({ type: "clearSelection" });
306
304
  }
307
- function _temp15(a) {
305
+ function _temp14(a) {
308
306
  return a.id;
309
307
  }
310
- function _temp16() {
308
+ function _temp15() {
311
309
  const actions = [
312
310
  {
313
311
  id: "cycle-viewport-mode",
@@ -318,8 +316,8 @@ function _temp16() {
318
316
  "Device preview"
319
317
  ],
320
318
  groupLabel: "Preview",
321
- checkIfAvailable: _temp7,
322
- execute: _temp8,
319
+ checkIfAvailable: _temp6,
320
+ execute: _temp7,
323
321
  shortcut: { key: "m" }
324
322
  },
325
323
  {
@@ -331,16 +329,16 @@ function _temp16() {
331
329
  "Full width preview"
332
330
  ],
333
331
  groupLabel: "Preview",
334
- checkIfAvailable: _temp9,
335
- execute: _temp0
332
+ checkIfAvailable: _temp8,
333
+ execute: _temp9
336
334
  },
337
335
  {
338
336
  id: "set-viewport-tablet",
339
337
  label: "Set tablet viewport",
340
338
  aliases: ["Tablet preview", "Responsive preview"],
341
339
  groupLabel: "Preview",
342
- checkIfAvailable: _temp1,
343
- execute: _temp10
340
+ checkIfAvailable: _temp0,
341
+ execute: _temp1
344
342
  },
345
343
  {
346
344
  id: "set-viewport-mobile",
@@ -351,16 +349,16 @@ function _temp16() {
351
349
  "Responsive preview"
352
350
  ],
353
351
  groupLabel: "Preview",
354
- checkIfAvailable: _temp11,
355
- execute: _temp12
352
+ checkIfAvailable: _temp10,
353
+ execute: _temp11
356
354
  },
357
355
  {
358
356
  id: "clear-selection",
359
357
  label: "Clear selection",
360
358
  aliases: ["Deselect", "Unselect"],
361
359
  groupLabel: "Preview",
362
- checkIfAvailable: _temp13,
363
- execute: _temp14,
360
+ checkIfAvailable: _temp12,
361
+ execute: _temp13,
364
362
  shortcut: { key: "Escape" }
365
363
  }
366
364
  ];
@@ -371,7 +369,7 @@ function _temp16() {
371
369
  return () => {
372
370
  actionsStore.send({
373
371
  type: "unregisterManyActions",
374
- ids: actions.map(_temp15)
372
+ ids: actions.map(_temp14)
375
373
  });
376
374
  };
377
375
  }
@@ -1,5 +1,5 @@
1
1
  import { formatShortcut } from "../../../lib/utils.js";
2
- import { previewStore } from "../previewStore.js";
2
+ import { previewStore, selectIsEditMode } from "../previewStore.js";
3
3
  import { EDIT_MODE_SHORTCUT } from "../previewConstants.js";
4
4
  import { c } from "react/compiler-runtime";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -16,15 +16,15 @@ import { Toggle } from "@camox/ui/toggle";
16
16
  //#region src/features/preview/components/PreviewToolbar.tsx
17
17
  const PreviewToolbar = (t0) => {
18
18
  const $ = c(69);
19
- if ($[0] !== "28b5aba454e9e27b527d788b0a718f0f7279d24fb295ca9356bcc28d27dd3df0") {
19
+ if ($[0] !== "fb98dbcd5b77e1b92293b563eda01ddd23323e31658e31434745ec2447418130") {
20
20
  for (let $i = 0; $i < 69; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
21
- $[0] = "28b5aba454e9e27b527d788b0a718f0f7279d24fb295ca9356bcc28d27dd3df0";
21
+ $[0] = "fb98dbcd5b77e1b92293b563eda01ddd23323e31658e31434745ec2447418130";
22
22
  }
23
23
  const { onEditModeChange, pageStatus, hasLiveVersion } = t0;
24
- const isEditMode = useSelector(previewStore, _temp);
25
- const isToolbarHidden = useSelector(previewStore, _temp2);
26
- const peekedBlock = useSelector(previewStore, _temp3);
27
- const viewportMode = useSelector(previewStore, _temp4);
24
+ const isEditMode = useSelector(previewStore, selectIsEditMode);
25
+ const isToolbarHidden = useSelector(previewStore, _temp);
26
+ const peekedBlock = useSelector(previewStore, _temp2);
27
+ const viewportMode = useSelector(previewStore, _temp3);
28
28
  if (isToolbarHidden || peekedBlock) return null;
29
29
  let t1;
30
30
  if ($[1] !== onEditModeChange) {
@@ -241,8 +241,8 @@ const PreviewToolbar = (t0) => {
241
241
  type: "button",
242
242
  variant: "outline",
243
243
  disabled: pageStatus === "published" || !hasLiveVersion,
244
- onClick: _temp5,
245
- children: "View published page"
244
+ onClick: _temp4,
245
+ children: "View live page"
246
246
  });
247
247
  $[49] = hasLiveVersion;
248
248
  $[50] = pageStatus;
@@ -255,7 +255,7 @@ const PreviewToolbar = (t0) => {
255
255
  variant: "ghost",
256
256
  size: "icon",
257
257
  disabled: isEditMode,
258
- onClick: _temp6,
258
+ onClick: _temp5,
259
259
  "aria-label": "Hide toolbar",
260
260
  className: "text-muted-foreground"
261
261
  });
@@ -320,21 +320,18 @@ const PreviewToolbar = (t0) => {
320
320
  return t38;
321
321
  };
322
322
  function _temp(state) {
323
- return state.context.isEditMode;
323
+ return state.context.isToolbarHidden;
324
324
  }
325
325
  function _temp2(state_0) {
326
- return state_0.context.isToolbarHidden;
326
+ return state_0.context.peekedBlock;
327
327
  }
328
328
  function _temp3(state_1) {
329
- return state_1.context.peekedBlock;
330
- }
331
- function _temp4(state_2) {
332
- return state_2.context.viewportMode;
329
+ return state_1.context.viewportMode;
333
330
  }
334
- function _temp5() {
331
+ function _temp4() {
335
332
  return previewStore.send({ type: "viewLivePage" });
336
333
  }
337
- function _temp6() {
334
+ function _temp5() {
338
335
  return previewStore.send({ type: "hideToolbar" });
339
336
  }
340
337
 
@@ -0,0 +1,43 @@
1
+ import { useFrame } from "./Frame.js";
2
+ import * as React from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+
5
+ //#region src/features/preview/components/PreviewToolbarSpacer.tsx
6
+ /** Reserve scroll space without painting the site's document background over it. */
7
+ function PreviewToolbarSpacer() {
8
+ const { window: frameWindow, iframeElement } = useFrame();
9
+ const spacerRef = React.useRef(null);
10
+ React.useLayoutEffect(() => {
11
+ const spacer = spacerRef.current;
12
+ if (!frameWindow || !iframeElement || !spacer) return;
13
+ const previousClipPath = iframeElement.style.clipPath;
14
+ const updateClip = () => {
15
+ const { top, height } = spacer.getBoundingClientRect();
16
+ const visibleHeight = Math.max(0, Math.min(height, frameWindow.innerHeight - top));
17
+ iframeElement.style.clipPath = `inset(0 0 ${visibleHeight}px 0)`;
18
+ };
19
+ const observer = new ResizeObserver(updateClip);
20
+ observer.observe(frameWindow.document.documentElement);
21
+ observer.observe(spacer.parentElement);
22
+ frameWindow.addEventListener("scroll", updateClip);
23
+ frameWindow.addEventListener("resize", updateClip);
24
+ updateClip();
25
+ return () => {
26
+ observer.disconnect();
27
+ frameWindow.removeEventListener("scroll", updateClip);
28
+ frameWindow.removeEventListener("resize", updateClip);
29
+ iframeElement.style.clipPath = previousClipPath;
30
+ };
31
+ }, [frameWindow, iframeElement]);
32
+ return /* @__PURE__ */ jsx("div", {
33
+ ref: spacerRef,
34
+ "aria-hidden": true,
35
+ style: {
36
+ height: 80,
37
+ flexShrink: 0
38
+ }
39
+ });
40
+ }
41
+
42
+ //#endregion
43
+ export { PreviewToolbarSpacer };
@@ -1,7 +1,7 @@
1
1
  import { actionsStore } from "../../provider/actionsStore.js";
2
2
  import { getApiClient } from "../../../lib/api-client.js";
3
3
  import { trackClientEvent } from "../../../lib/telemetry-client.js";
4
- import { previewStore } from "../previewStore.js";
4
+ import { previewStore, selectPreviewSource } from "../previewStore.js";
5
5
  import { buildPublicationPlan, getPublicationCapabilities, getPublicationRequest } from "../publication.js";
6
6
  import { PublishDialog } from "./PublishDialog.js";
7
7
  import { c } from "react/compiler-runtime";
@@ -20,9 +20,9 @@ import { ButtonGroup } from "@camox/ui/button-group";
20
20
  //#region src/features/preview/components/PublicationRow.tsx
21
21
  function PublicationRow(t0) {
22
22
  const $ = c(4);
23
- if ($[0] !== "bef0702fd89aac7465952e09d43979741129da566cd392625f8739ebc2b0b2f9") {
23
+ if ($[0] !== "21f8ad447322b8ca3d57008039e0bedc782b582388e82eacae91c1f0ad25aee6") {
24
24
  for (let $i = 0; $i < 4; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
25
- $[0] = "bef0702fd89aac7465952e09d43979741129da566cd392625f8739ebc2b0b2f9";
25
+ $[0] = "21f8ad447322b8ca3d57008039e0bedc782b582388e82eacae91c1f0ad25aee6";
26
26
  }
27
27
  const { target } = t0;
28
28
  const identity = target ? `${target.kind}:${target.kind === "page" ? target.page.id : target.layout.id}` : "loading";
@@ -37,12 +37,12 @@ function PublicationRow(t0) {
37
37
  }
38
38
  function PublicationControls(t0) {
39
39
  const $ = c(78);
40
- if ($[0] !== "bef0702fd89aac7465952e09d43979741129da566cd392625f8739ebc2b0b2f9") {
40
+ if ($[0] !== "21f8ad447322b8ca3d57008039e0bedc782b582388e82eacae91c1f0ad25aee6") {
41
41
  for (let $i = 0; $i < 78; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
42
- $[0] = "bef0702fd89aac7465952e09d43979741129da566cd392625f8739ebc2b0b2f9";
42
+ $[0] = "21f8ad447322b8ca3d57008039e0bedc782b582388e82eacae91c1f0ad25aee6";
43
43
  }
44
44
  const { target } = t0;
45
- const source = useSelector(previewStore, _temp);
45
+ const source = useSelector(previewStore, selectPreviewSource);
46
46
  const queryClient = useQueryClient();
47
47
  const [action, setAction] = React.useState(null);
48
48
  let t1;
@@ -100,10 +100,7 @@ function PublicationControls(t0) {
100
100
  if ($[9] !== queryClient) {
101
101
  t4 = async (_, t5) => {
102
102
  const { operation: operation_0 } = t5;
103
- if (operation_0 !== "publish") previewStore.send({
104
- type: "setPreviewSource",
105
- source: "draft"
106
- });
103
+ if (operation_0 !== "publish") previewStore.send({ type: "viewDraftPage" });
107
104
  setAction(null);
108
105
  toast.success(operation_0 === "publish" ? "Published selected changes" : operation_0 === "unpublish" ? "Unpublished successfully" : "Discarded draft changes");
109
106
  await Promise.all([
@@ -130,7 +127,7 @@ function PublicationControls(t0) {
130
127
  t5 = {
131
128
  mutationFn: t3,
132
129
  onSuccess: t4,
133
- onError: _temp2
130
+ onError: _temp
134
131
  };
135
132
  $[11] = t3;
136
133
  $[12] = t4;
@@ -180,7 +177,7 @@ function PublicationControls(t0) {
180
177
  });
181
178
  return () => actionsStore.send({
182
179
  type: "unregisterManyActions",
183
- ids: actions.map(_temp3)
180
+ ids: actions.map(_temp2)
184
181
  });
185
182
  };
186
183
  t7 = [
@@ -417,15 +414,12 @@ function PublicationControls(t0) {
417
414
  } else t33 = $[77];
418
415
  return t33;
419
416
  }
420
- function _temp3(item) {
417
+ function _temp2(item) {
421
418
  return item.id;
422
419
  }
423
- function _temp2() {
420
+ function _temp() {
424
421
  return toast.error("Could not complete this action. Please try again.");
425
422
  }
426
- function _temp(state) {
427
- return state.context.previewSource;
428
- }
429
423
 
430
424
  //#endregion
431
425
  export { PublicationRow };
@@ -22,43 +22,43 @@ function selectionField(sel) {
22
22
  };
23
23
  return null;
24
24
  }
25
+ const selectIsEditMode = (state) => state.context.mode === "editing-draft";
26
+ const selectPreviewSource = (state) => state.context.mode === "previewing-live" ? "live" : "draft";
25
27
  const previewStore = createStore({
26
28
  context: {
27
- isEditMode: false,
29
+ mode: "previewing-draft",
28
30
  isToolbarHidden: false,
29
31
  isPageEditorSidebarOpen: false,
30
32
  isAddBlockSidebarOpen: false,
31
33
  addBlockSource: null,
32
34
  isCreatePageModalOpen: false,
33
35
  editingPageId: null,
34
- isDraftSwitchDialogOpen: false,
35
36
  viewportMode: "full",
36
37
  peekedBlock: null,
37
38
  peekedBlockPosition: null,
38
39
  skipPeekedBlockExitAnimation: false,
39
40
  selection: null,
40
- iframeElement: null,
41
- previewSource: "draft"
41
+ iframeElement: null
42
42
  },
43
43
  on: {
44
44
  exitEditMode: (context, _, enqueue) => {
45
- if (!context.isEditMode) return context;
45
+ if (context.mode !== "editing-draft") return context;
46
46
  enqueue.effect(() => {
47
47
  trackClientEvent("edit_mode_toggled", { enabled: false });
48
48
  });
49
49
  return {
50
50
  ...context,
51
- isEditMode: false
51
+ mode: "previewing-draft"
52
52
  };
53
53
  },
54
54
  enterEditMode: (context, _, enqueue) => {
55
- if (context.isEditMode) return context;
55
+ if (context.mode === "editing-draft") return context;
56
56
  enqueue.effect(() => {
57
57
  trackClientEvent("edit_mode_toggled", { enabled: true });
58
58
  });
59
59
  return {
60
60
  ...context,
61
- isEditMode: true,
61
+ mode: "editing-draft",
62
62
  isToolbarHidden: false
63
63
  };
64
64
  },
@@ -68,14 +68,13 @@ const previewStore = createStore({
68
68
  }),
69
69
  viewLivePage: (context, _, enqueue) => {
70
70
  enqueue.effect(() => {
71
- if (context.isEditMode) trackClientEvent("edit_mode_toggled", { enabled: false });
71
+ if (context.mode === "editing-draft") trackClientEvent("edit_mode_toggled", { enabled: false });
72
72
  toast("Viewing live version of the site");
73
73
  });
74
74
  return {
75
75
  ...context,
76
- isEditMode: false,
77
- isToolbarHidden: true,
78
- previewSource: "live"
76
+ mode: "previewing-live",
77
+ isToolbarHidden: true
79
78
  };
80
79
  },
81
80
  setViewportMode: (context, event) => {
@@ -255,29 +254,19 @@ const previewStore = createStore({
255
254
  ...context,
256
255
  iframeElement: event.element
257
256
  }),
258
- setPreviewSource: (context, event, enqueue) => {
259
- if (event.source === context.previewSource) return context;
257
+ viewDraftPage: (context, _, enqueue) => {
258
+ if (context.mode !== "previewing-live") return context;
260
259
  enqueue.effect(() => {
261
- toast(event.source === "draft" ? "Previewing draft content" : "Previewing live content", { duration: 2500 });
260
+ toast("Previewing draft content", { duration: 2500 });
262
261
  });
263
262
  return {
264
263
  ...context,
265
- previewSource: event.source
266
- };
267
- },
268
- requestDraftSwitch: (context) => {
269
- if (context.previewSource === "draft") return context;
270
- return {
271
- ...context,
272
- isDraftSwitchDialogOpen: true
264
+ mode: "previewing-draft",
265
+ isToolbarHidden: false
273
266
  };
274
- },
275
- dismissDraftSwitch: (context) => ({
276
- ...context,
277
- isDraftSwitchDialogOpen: false
278
- })
267
+ }
279
268
  }
280
269
  });
281
270
 
282
271
  //#endregion
283
- export { previewStore, selectionBlockId, selectionField, selectionItemId };
272
+ export { previewStore, selectIsEditMode, selectPreviewSource, selectionBlockId, selectionField, selectionItemId };
@@ -10,9 +10,9 @@ import { useSelector } from "@xstate/store-react";
10
10
  */
11
11
  function useAdminShortcuts() {
12
12
  const $ = c(4);
13
- if ($[0] !== "e5d3a4bbb325cbcce579826abdfc85cc9e0df725cd31dd3b6fd2c699d88a926c") {
13
+ if ($[0] !== "0255d4249a070c82da3a967d899d13f2ef37b37575822c7a0d008029181a2db4") {
14
14
  for (let $i = 0; $i < 4; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
15
- $[0] = "e5d3a4bbb325cbcce579826abdfc85cc9e0df725cd31dd3b6fd2c699d88a926c";
15
+ $[0] = "0255d4249a070c82da3a967d899d13f2ef37b37575822c7a0d008029181a2db4";
16
16
  }
17
17
  const actions = useSelector(actionsStore, _temp);
18
18
  let t0;
@@ -33,6 +33,7 @@ function useAdminShortcuts() {
33
33
  if (shortcut.key === "Backspace") return;
34
34
  }
35
35
  event.preventDefault();
36
+ event.stopPropagation();
36
37
  matchingAction.execute();
37
38
  };
38
39
  const handleMessage = (event_0) => {
@@ -42,10 +43,10 @@ function useAdminShortcuts() {
42
43
  if (action_0) action_0.execute();
43
44
  }
44
45
  };
45
- document.addEventListener("keydown", handleKeyDown);
46
+ document.addEventListener("keydown", handleKeyDown, true);
46
47
  window.addEventListener("message", handleMessage);
47
48
  return () => {
48
- document.removeEventListener("keydown", handleKeyDown);
49
+ document.removeEventListener("keydown", handleKeyDown, true);
49
50
  window.removeEventListener("message", handleMessage);
50
51
  };
51
52
  };