camox 0.32.0 → 0.33.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.
- package/dist/core/createBlock.d.ts +1 -1
- package/dist/core/createBlock.js +88 -108
- package/dist/core/hooks/useIsEditable.js +6 -10
- package/dist/core/lib/fieldTypes.js +10 -219
- package/dist/features/agent-chat/components/AgentChatSidebar.js +172 -0
- package/dist/features/agent-chat/components/AgentChatThread.js +9 -9
- package/dist/features/preview/CamoxPreview.js +137 -729
- package/dist/features/preview/components/{AddBlockSheet.js → AddBlockSidebar.js} +121 -131
- package/dist/features/preview/components/AssetFieldEditor.js +107 -82
- package/dist/features/preview/components/AssetLightbox.js +4 -4
- package/dist/features/preview/components/AssetPickerModal.js +277 -0
- package/dist/features/preview/components/BlockActionsPopover.js +18 -24
- package/dist/features/preview/components/CreatePageModal.js +6 -6
- package/dist/features/preview/components/FieldToolbar.js +64 -127
- package/dist/features/preview/components/ItemFieldsEditor.js +98 -125
- package/dist/features/preview/components/LeftSidebar.js +64 -0
- package/dist/features/preview/components/LinkFieldEditor.js +1 -1
- package/dist/features/preview/components/MultipleAssetFieldEditor.js +94 -56
- package/dist/features/preview/components/OverlayTracker.js +15 -15
- package/dist/features/preview/components/Overlays.js +12 -12
- package/dist/features/preview/components/PageEditorSidebar.js +563 -0
- package/dist/features/preview/components/PageInfoSidebar.js +1453 -0
- package/dist/features/preview/components/PageNavigatorSidebar.js +590 -0
- package/dist/features/preview/components/PagePicker.js +3 -3
- package/dist/features/preview/components/PageStatusBadge.js +1 -1
- package/dist/features/preview/components/PageTree.js +204 -564
- package/dist/features/preview/components/PreviewPanel.js +123 -158
- package/dist/features/preview/components/PreviewToolbar.js +260 -256
- package/dist/features/preview/components/PublishDialog.js +2 -2
- package/dist/features/preview/components/RepeatableItemsList.js +2 -2
- package/dist/features/preview/components/RightSidebar.js +109 -0
- package/dist/features/preview/components/UnlinkAssetButton.js +2 -2
- package/dist/features/preview/components/useRepeatableItemActions.js +3 -138
- package/dist/features/preview/components/useUpdateBlockPosition.js +1 -1
- package/dist/features/preview/previewQueryFns.js +23 -0
- package/dist/features/preview/previewStore.js +46 -63
- package/dist/features/provider/CamoxProvider.js +255 -70
- package/dist/features/provider/useAdminShortcuts.js +5 -48
- package/dist/features/routes/pageRoute.js +1 -1
- package/dist/features/studio/CamoxStudio.js +6 -5
- package/dist/features/studio/components/EnvironmentMenu.js +2 -2
- package/dist/features/studio/components/Navbar.js +53 -71
- package/dist/features/studio/components/ProjectMenu.js +1 -1
- package/dist/features/studio/components/UserButton.js +1 -1
- package/dist/features/studio/routes.js +7 -0
- package/dist/features/studio/useTheme.js +67 -33
- package/dist/features/vite/routeGeneration.js +68 -66
- package/dist/hooks/use-file-upload.js +1 -1
- package/dist/lib/auth.js +23 -22
- package/dist/lib/utils.js +1 -1
- package/dist/studio-overlays.css +1 -1
- package/dist/studio.css +1 -1
- package/package.json +4 -4
- package/dist/features/agent-chat/components/AgentChatSheet.js +0 -207
- package/dist/features/preview/components/AssetPickerGrid.js +0 -236
- package/dist/features/preview/components/PageContentSheet.js +0 -608
- package/dist/features/preview/components/PageMetadataModal.js +0 -908
- package/dist/features/preview/components/PreviewSideSheet.js +0 -76
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { previewStore, selectionBlockId } from "../previewStore.js";
|
|
2
|
+
import { AgentChatSidebar } from "../../agent-chat/components/AgentChatSidebar.js";
|
|
3
|
+
import { PageEditorSidebar } from "./PageEditorSidebar.js";
|
|
4
|
+
import { PageInfoSidebar } from "./PageInfoSidebar.js";
|
|
5
|
+
import { c } from "react/compiler-runtime";
|
|
6
|
+
import { useSelector } from "@xstate/store-react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
|
|
9
|
+
//#region src/features/preview/components/RightSidebar.tsx
|
|
10
|
+
const getRightSidebarRoute = ({ pageId, selectedBlockId, isAgentChatSidebarOpen }) => {
|
|
11
|
+
if (isAgentChatSidebarOpen) return { type: "agent-chat" };
|
|
12
|
+
if (selectedBlockId == null) return {
|
|
13
|
+
type: "page-info",
|
|
14
|
+
pageId
|
|
15
|
+
};
|
|
16
|
+
return { type: "page-editor" };
|
|
17
|
+
};
|
|
18
|
+
const RightSidebar = (t0) => {
|
|
19
|
+
const $ = c(20);
|
|
20
|
+
if ($[0] !== "e28d4f43142dcdc5527c359ae145ad38b0701935b08a0740871f5af399460a0b") {
|
|
21
|
+
for (let $i = 0; $i < 20; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
22
|
+
$[0] = "e28d4f43142dcdc5527c359ae145ad38b0701935b08a0740871f5af399460a0b";
|
|
23
|
+
}
|
|
24
|
+
const { pageId } = t0;
|
|
25
|
+
const selection = useSelector(previewStore, _temp);
|
|
26
|
+
const isAgentChatSidebarOpen = useSelector(previewStore, _temp2);
|
|
27
|
+
const isAddBlockSidebarOpen = useSelector(previewStore, _temp3);
|
|
28
|
+
let t1;
|
|
29
|
+
if ($[1] !== isAgentChatSidebarOpen || $[2] !== pageId || $[3] !== selection) {
|
|
30
|
+
t1 = getRightSidebarRoute({
|
|
31
|
+
pageId,
|
|
32
|
+
selectedBlockId: selectionBlockId(selection),
|
|
33
|
+
isAgentChatSidebarOpen
|
|
34
|
+
});
|
|
35
|
+
$[1] = isAgentChatSidebarOpen;
|
|
36
|
+
$[2] = pageId;
|
|
37
|
+
$[3] = selection;
|
|
38
|
+
$[4] = t1;
|
|
39
|
+
} else t1 = $[4];
|
|
40
|
+
const route = t1;
|
|
41
|
+
let t2;
|
|
42
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
43
|
+
t2 = { width: 250 };
|
|
44
|
+
$[5] = t2;
|
|
45
|
+
} else t2 = $[5];
|
|
46
|
+
let t3;
|
|
47
|
+
if ($[6] !== route.type) {
|
|
48
|
+
t3 = route.type === "agent-chat" && /* @__PURE__ */ jsx(AgentChatSidebar, {});
|
|
49
|
+
$[6] = route.type;
|
|
50
|
+
$[7] = t3;
|
|
51
|
+
} else t3 = $[7];
|
|
52
|
+
let t4;
|
|
53
|
+
if ($[8] !== route.pageId || $[9] !== route.type) {
|
|
54
|
+
t4 = route.type === "page-info" && /* @__PURE__ */ jsx(PageInfoSidebar, { pageId: route.pageId });
|
|
55
|
+
$[8] = route.pageId;
|
|
56
|
+
$[9] = route.type;
|
|
57
|
+
$[10] = t4;
|
|
58
|
+
} else t4 = $[10];
|
|
59
|
+
let t5;
|
|
60
|
+
if ($[11] !== route.type) {
|
|
61
|
+
t5 = route.type === "page-editor" && /* @__PURE__ */ jsx(PageEditorSidebar, {});
|
|
62
|
+
$[11] = route.type;
|
|
63
|
+
$[12] = t5;
|
|
64
|
+
} else t5 = $[12];
|
|
65
|
+
let t6;
|
|
66
|
+
if ($[13] !== isAddBlockSidebarOpen) {
|
|
67
|
+
t6 = isAddBlockSidebarOpen && /* @__PURE__ */ jsx("div", {
|
|
68
|
+
className: "absolute inset-0 z-20",
|
|
69
|
+
style: { background: "rgba(0, 0, 0, 0.66)" },
|
|
70
|
+
onClick: _temp4
|
|
71
|
+
});
|
|
72
|
+
$[13] = isAddBlockSidebarOpen;
|
|
73
|
+
$[14] = t6;
|
|
74
|
+
} else t6 = $[14];
|
|
75
|
+
let t7;
|
|
76
|
+
if ($[15] !== t3 || $[16] !== t4 || $[17] !== t5 || $[18] !== t6) {
|
|
77
|
+
t7 = /* @__PURE__ */ jsxs("aside", {
|
|
78
|
+
className: "bg-background relative flex shrink-0 flex-col border-l-2",
|
|
79
|
+
style: t2,
|
|
80
|
+
children: [
|
|
81
|
+
t3,
|
|
82
|
+
t4,
|
|
83
|
+
t5,
|
|
84
|
+
t6
|
|
85
|
+
]
|
|
86
|
+
});
|
|
87
|
+
$[15] = t3;
|
|
88
|
+
$[16] = t4;
|
|
89
|
+
$[17] = t5;
|
|
90
|
+
$[18] = t6;
|
|
91
|
+
$[19] = t7;
|
|
92
|
+
} else t7 = $[19];
|
|
93
|
+
return t7;
|
|
94
|
+
};
|
|
95
|
+
function _temp(state) {
|
|
96
|
+
return state.context.selection;
|
|
97
|
+
}
|
|
98
|
+
function _temp2(state_0) {
|
|
99
|
+
return state_0.context.isAgentChatSidebarOpen;
|
|
100
|
+
}
|
|
101
|
+
function _temp3(state_1) {
|
|
102
|
+
return state_1.context.isAddBlockSidebarOpen;
|
|
103
|
+
}
|
|
104
|
+
function _temp4() {
|
|
105
|
+
return previewStore.send({ type: "closeAddBlockSidebar" });
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
//#endregion
|
|
109
|
+
export { RightSidebar };
|
|
@@ -4,10 +4,10 @@ import { c } from "react/compiler-runtime";
|
|
|
4
4
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
5
5
|
import { useState } from "react";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { AlertDialog, AlertDialogAction, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
|
|
8
7
|
import { Button } from "@camox/ui/button";
|
|
9
|
-
import { Tooltip, TooltipContent, TooltipTrigger } from "@camox/ui/tooltip";
|
|
10
8
|
import { X } from "lucide-react";
|
|
9
|
+
import { AlertDialog, AlertDialogAction, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
|
|
10
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "@camox/ui/tooltip";
|
|
11
11
|
|
|
12
12
|
//#region src/features/preview/components/UnlinkAssetButton.tsx
|
|
13
13
|
const UnlinkAssetButton = (t0) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { repeatableItemMutations } from "../../../lib/queries.js";
|
|
1
2
|
import { previewStore } from "../previewStore.js";
|
|
2
|
-
import
|
|
3
|
-
import { useCamoxApp } from "../../provider/components/CamoxAppContext.js";
|
|
3
|
+
import "../../provider/components/CamoxAppContext.js";
|
|
4
4
|
import { useRequireDraftSource } from "../../../core/hooks/useRequireDraftSource.js";
|
|
5
5
|
import { c } from "react/compiler-runtime";
|
|
6
6
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
@@ -133,141 +133,6 @@ const useRepeatableItemActions = (t0) => {
|
|
|
133
133
|
} else t5 = $[17];
|
|
134
134
|
return t5;
|
|
135
135
|
};
|
|
136
|
-
const getArraySchemaForItem = (contentSchema, itemId, itemsMap) => {
|
|
137
|
-
const path = [];
|
|
138
|
-
let current = itemsMap.get(itemId);
|
|
139
|
-
while (current) {
|
|
140
|
-
path.unshift(current.fieldName);
|
|
141
|
-
current = current.parentItemId ? itemsMap.get(current.parentItemId) : void 0;
|
|
142
|
-
}
|
|
143
|
-
let schema = contentSchema;
|
|
144
|
-
for (let i = 0; i < path.length; i++) {
|
|
145
|
-
const prop = schema?.properties?.[path[i]];
|
|
146
|
-
if (!prop?.items) return null;
|
|
147
|
-
if (i === path.length - 1) return prop;
|
|
148
|
-
schema = prop.items;
|
|
149
|
-
}
|
|
150
|
-
return null;
|
|
151
|
-
};
|
|
152
|
-
/**
|
|
153
|
-
* Resolves the action surface for the currently-edited repeatable item by
|
|
154
|
-
* fetching the block bundle, locating the item's array-level schema, and
|
|
155
|
-
* counting siblings. Hook is safe to call when ids are null — it'll just
|
|
156
|
-
* return disabled actions.
|
|
157
|
-
*/
|
|
158
|
-
const useCurrentItemActions = (blockId, itemId) => {
|
|
159
|
-
const $ = c(27);
|
|
160
|
-
if ($[0] !== "16e9f8f4b1a1e8d41d093c0930e510d6bea72e481f78c01b1ca1e595bec9f4cb") {
|
|
161
|
-
for (let $i = 0; $i < 27; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
162
|
-
$[0] = "16e9f8f4b1a1e8d41d093c0930e510d6bea72e481f78c01b1ca1e595bec9f4cb";
|
|
163
|
-
}
|
|
164
|
-
const camoxApp = useCamoxApp();
|
|
165
|
-
let t0;
|
|
166
|
-
if ($[1] !== blockId) {
|
|
167
|
-
t0 = blockQueries.get(blockId);
|
|
168
|
-
$[1] = blockId;
|
|
169
|
-
$[2] = t0;
|
|
170
|
-
} else t0 = $[2];
|
|
171
|
-
const t1 = blockId != null;
|
|
172
|
-
let t2;
|
|
173
|
-
if ($[3] !== t0 || $[4] !== t1) {
|
|
174
|
-
t2 = {
|
|
175
|
-
...t0,
|
|
176
|
-
enabled: t1
|
|
177
|
-
};
|
|
178
|
-
$[3] = t0;
|
|
179
|
-
$[4] = t1;
|
|
180
|
-
$[5] = t2;
|
|
181
|
-
} else t2 = $[5];
|
|
182
|
-
const { data: blockBundle } = useQuery(t2);
|
|
183
|
-
blockBundle?.repeatableItems;
|
|
184
|
-
let t3;
|
|
185
|
-
if ($[6] !== blockBundle?.repeatableItems) {
|
|
186
|
-
t3 = new Map((blockBundle?.repeatableItems ?? []).map(_temp));
|
|
187
|
-
$[6] = blockBundle?.repeatableItems;
|
|
188
|
-
$[7] = t3;
|
|
189
|
-
} else t3 = $[7];
|
|
190
|
-
const itemsMap = t3;
|
|
191
|
-
let t4;
|
|
192
|
-
if ($[8] !== itemId || $[9] !== itemsMap) {
|
|
193
|
-
t4 = itemId != null ? itemsMap.get(itemId) ?? null : null;
|
|
194
|
-
$[8] = itemId;
|
|
195
|
-
$[9] = itemsMap;
|
|
196
|
-
$[10] = t4;
|
|
197
|
-
} else t4 = $[10];
|
|
198
|
-
const currentItem = t4;
|
|
199
|
-
const block = blockBundle?.block ?? null;
|
|
200
|
-
let t5;
|
|
201
|
-
if ($[11] !== block || $[12] !== camoxApp) {
|
|
202
|
-
t5 = block ? camoxApp.getBlockById(block.type) : null;
|
|
203
|
-
$[11] = block;
|
|
204
|
-
$[12] = camoxApp;
|
|
205
|
-
$[13] = t5;
|
|
206
|
-
} else t5 = $[13];
|
|
207
|
-
const blockDef = t5;
|
|
208
|
-
let t6;
|
|
209
|
-
bb0: {
|
|
210
|
-
if (!blockDef || itemId == null) {
|
|
211
|
-
t6 = null;
|
|
212
|
-
break bb0;
|
|
213
|
-
}
|
|
214
|
-
let t7;
|
|
215
|
-
if ($[14] !== blockDef._internal.contentSchema || $[15] !== itemId || $[16] !== itemsMap) {
|
|
216
|
-
t7 = getArraySchemaForItem(blockDef._internal.contentSchema, itemId, itemsMap);
|
|
217
|
-
$[14] = blockDef._internal.contentSchema;
|
|
218
|
-
$[15] = itemId;
|
|
219
|
-
$[16] = itemsMap;
|
|
220
|
-
$[17] = t7;
|
|
221
|
-
} else t7 = $[17];
|
|
222
|
-
t6 = t7;
|
|
223
|
-
}
|
|
224
|
-
const arraySchema = t6;
|
|
225
|
-
let t7;
|
|
226
|
-
bb1: {
|
|
227
|
-
if (!currentItem) {
|
|
228
|
-
t7 = 0;
|
|
229
|
-
break bb1;
|
|
230
|
-
}
|
|
231
|
-
let count = 0;
|
|
232
|
-
for (const it of itemsMap.values()) if (it.fieldName === currentItem.fieldName && it.parentItemId === currentItem.parentItemId) count++;
|
|
233
|
-
t7 = count;
|
|
234
|
-
}
|
|
235
|
-
const siblingCount = t7;
|
|
236
|
-
const t8 = block?.id ?? -1;
|
|
237
|
-
const t9 = currentItem?.fieldName ?? "";
|
|
238
|
-
const t10 = currentItem?.parentItemId ?? null;
|
|
239
|
-
let t11;
|
|
240
|
-
if ($[18] !== arraySchema || $[19] !== siblingCount || $[20] !== t10 || $[21] !== t8 || $[22] !== t9) {
|
|
241
|
-
t11 = {
|
|
242
|
-
blockId: t8,
|
|
243
|
-
fieldName: t9,
|
|
244
|
-
parentItemId: t10,
|
|
245
|
-
arraySchema,
|
|
246
|
-
siblingCount
|
|
247
|
-
};
|
|
248
|
-
$[18] = arraySchema;
|
|
249
|
-
$[19] = siblingCount;
|
|
250
|
-
$[20] = t10;
|
|
251
|
-
$[21] = t8;
|
|
252
|
-
$[22] = t9;
|
|
253
|
-
$[23] = t11;
|
|
254
|
-
} else t11 = $[23];
|
|
255
|
-
const actions = useRepeatableItemActions(t11);
|
|
256
|
-
let t12;
|
|
257
|
-
if ($[24] !== actions || $[25] !== currentItem) {
|
|
258
|
-
t12 = {
|
|
259
|
-
...actions,
|
|
260
|
-
currentItem
|
|
261
|
-
};
|
|
262
|
-
$[24] = actions;
|
|
263
|
-
$[25] = currentItem;
|
|
264
|
-
$[26] = t12;
|
|
265
|
-
} else t12 = $[26];
|
|
266
|
-
return t12;
|
|
267
|
-
};
|
|
268
|
-
function _temp(i) {
|
|
269
|
-
return [i.id, i];
|
|
270
|
-
}
|
|
271
136
|
|
|
272
137
|
//#endregion
|
|
273
|
-
export {
|
|
138
|
+
export { useRepeatableItemActions };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { previewStore } from "../previewStore.js";
|
|
2
1
|
import { blockMutations } from "../../../lib/queries.js";
|
|
2
|
+
import { previewStore } from "../previewStore.js";
|
|
3
3
|
import { c } from "react/compiler-runtime";
|
|
4
4
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
5
5
|
import { useLocation } from "@tanstack/react-router";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getApiClient } from "../../lib/api-client.js";
|
|
2
|
+
import { seedBlockCaches } from "../../lib/normalized-data.js";
|
|
3
|
+
|
|
4
|
+
//#region src/features/preview/previewQueryFns.ts
|
|
5
|
+
function pageFullQueryFn(queryClient, path, projectSlug, source) {
|
|
6
|
+
return async () => {
|
|
7
|
+
const data = await getApiClient().pages.getByPath({
|
|
8
|
+
path,
|
|
9
|
+
projectSlug,
|
|
10
|
+
source
|
|
11
|
+
});
|
|
12
|
+
seedBlockCaches(queryClient, data, source);
|
|
13
|
+
return {
|
|
14
|
+
page: data.page,
|
|
15
|
+
layout: data.layout,
|
|
16
|
+
projectName: data.projectName,
|
|
17
|
+
project: data.project
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { pageFullQueryFn };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { trackClientEvent } from "../../lib/telemetry-client.js";
|
|
2
|
-
import { toast } from "@camox/ui/toaster";
|
|
3
2
|
import { createStore } from "@xstate/store-react";
|
|
3
|
+
import { toast } from "@camox/ui/toaster";
|
|
4
4
|
|
|
5
5
|
//#region src/features/preview/previewStore.ts
|
|
6
6
|
/** Extract the blockId from any selection variant. */
|
|
@@ -24,19 +24,18 @@ function selectionField(sel) {
|
|
|
24
24
|
}
|
|
25
25
|
const previewStore = createStore({
|
|
26
26
|
context: {
|
|
27
|
-
|
|
27
|
+
isEditMode: false,
|
|
28
|
+
isToolbarHidden: false,
|
|
28
29
|
isSidebarOpen: true,
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
isPageEditorSidebarOpen: false,
|
|
31
|
+
isAddBlockSidebarOpen: false,
|
|
31
32
|
addBlockSource: null,
|
|
32
|
-
|
|
33
|
+
isAgentChatSidebarOpen: false,
|
|
33
34
|
agentChatPageScaffoldContext: null,
|
|
34
35
|
isCreatePageModalOpen: false,
|
|
35
36
|
editingPageId: null,
|
|
36
|
-
isContentLocked: false,
|
|
37
|
-
prePreviewLockState: null,
|
|
38
37
|
isDraftSwitchDialogOpen: false,
|
|
39
|
-
|
|
38
|
+
viewportMode: "full",
|
|
40
39
|
peekedBlock: null,
|
|
41
40
|
peekedBlockPosition: null,
|
|
42
41
|
peekedPagePathname: null,
|
|
@@ -47,51 +46,47 @@ const previewStore = createStore({
|
|
|
47
46
|
previewSource: "draft"
|
|
48
47
|
},
|
|
49
48
|
on: {
|
|
50
|
-
|
|
51
|
-
if (context.
|
|
49
|
+
exitEditMode: (context, _, enqueue) => {
|
|
50
|
+
if (!context.isEditMode) return context;
|
|
52
51
|
enqueue.effect(() => {
|
|
53
|
-
|
|
54
|
-
trackClientEvent("presentation_mode_toggled", { enabled: true });
|
|
52
|
+
trackClientEvent("edit_mode_toggled", { enabled: false });
|
|
55
53
|
});
|
|
56
54
|
return {
|
|
57
55
|
...context,
|
|
58
|
-
|
|
56
|
+
isEditMode: false
|
|
59
57
|
};
|
|
60
58
|
},
|
|
61
|
-
|
|
62
|
-
if (
|
|
59
|
+
enterEditMode: (context, _, enqueue) => {
|
|
60
|
+
if (context.isEditMode) return context;
|
|
63
61
|
enqueue.effect(() => {
|
|
64
|
-
trackClientEvent("
|
|
62
|
+
trackClientEvent("edit_mode_toggled", { enabled: true });
|
|
65
63
|
});
|
|
66
64
|
return {
|
|
67
65
|
...context,
|
|
68
|
-
|
|
66
|
+
isEditMode: true,
|
|
67
|
+
isSidebarOpen: true
|
|
69
68
|
};
|
|
70
69
|
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
toast(context.isContentLocked ? "Enabling edits" : "Preventing edits");
|
|
82
|
-
});
|
|
70
|
+
hideToolbar: (context) => ({
|
|
71
|
+
...context,
|
|
72
|
+
isToolbarHidden: true
|
|
73
|
+
}),
|
|
74
|
+
toggleSidebar: (context) => ({
|
|
75
|
+
...context,
|
|
76
|
+
isSidebarOpen: true
|
|
77
|
+
}),
|
|
78
|
+
setViewportMode: (context, event) => {
|
|
79
|
+
if (context.viewportMode === event.mode) return context;
|
|
83
80
|
return {
|
|
84
81
|
...context,
|
|
85
|
-
|
|
82
|
+
viewportMode: event.mode
|
|
86
83
|
};
|
|
87
84
|
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
toast(context.isMobileMode ? "Leaving mobile mode" : "Entering mobile mode");
|
|
91
|
-
});
|
|
85
|
+
cycleViewportMode: (context) => {
|
|
86
|
+
const nextMode = context.viewportMode === "full" ? "tablet" : context.viewportMode === "tablet" ? "mobile" : "full";
|
|
92
87
|
return {
|
|
93
88
|
...context,
|
|
94
|
-
|
|
89
|
+
viewportMode: nextMode
|
|
95
90
|
};
|
|
96
91
|
},
|
|
97
92
|
setPeekedBlock: (context, event) => {
|
|
@@ -106,7 +101,7 @@ const previewStore = createStore({
|
|
|
106
101
|
...context,
|
|
107
102
|
peekedBlock: null,
|
|
108
103
|
peekedBlockPosition: null,
|
|
109
|
-
|
|
104
|
+
isAddBlockSidebarOpen: false
|
|
110
105
|
}),
|
|
111
106
|
clearPeekedBlock: (context) => ({
|
|
112
107
|
...context,
|
|
@@ -127,7 +122,7 @@ const previewStore = createStore({
|
|
|
127
122
|
pendingAgentBlockFocus: null,
|
|
128
123
|
peekedBlock: null,
|
|
129
124
|
peekedBlockPosition: null,
|
|
130
|
-
|
|
125
|
+
isAddBlockSidebarOpen: false
|
|
131
126
|
}),
|
|
132
127
|
focusAgentBlock: (context, event) => ({
|
|
133
128
|
...context,
|
|
@@ -141,7 +136,7 @@ const previewStore = createStore({
|
|
|
141
136
|
},
|
|
142
137
|
peekedBlock: null,
|
|
143
138
|
peekedBlockPosition: null,
|
|
144
|
-
|
|
139
|
+
isAddBlockSidebarOpen: false
|
|
145
140
|
}),
|
|
146
141
|
clearPendingAgentBlockFocus: (context, event) => {
|
|
147
142
|
if (context.pendingAgentBlockFocus?.requestId !== event.requestId) return context;
|
|
@@ -222,16 +217,16 @@ const previewStore = createStore({
|
|
|
222
217
|
...context,
|
|
223
218
|
peekedPagePathname: null
|
|
224
219
|
}),
|
|
225
|
-
|
|
220
|
+
openAddBlockSidebar: (context, event) => ({
|
|
226
221
|
...context,
|
|
227
|
-
|
|
222
|
+
isAddBlockSidebarOpen: true,
|
|
228
223
|
addBlockSource: event.via ?? null,
|
|
229
224
|
peekedBlock: null,
|
|
230
225
|
peekedBlockPosition: event.afterPosition ?? null
|
|
231
226
|
}),
|
|
232
|
-
|
|
227
|
+
closeAddBlockSidebar: (context) => ({
|
|
233
228
|
...context,
|
|
234
|
-
|
|
229
|
+
isAddBlockSidebarOpen: false,
|
|
235
230
|
addBlockSource: null,
|
|
236
231
|
peekedBlock: null,
|
|
237
232
|
peekedBlockPosition: null
|
|
@@ -243,7 +238,7 @@ const previewStore = createStore({
|
|
|
243
238
|
blockId: event.blockId
|
|
244
239
|
},
|
|
245
240
|
pendingAgentBlockFocus: null,
|
|
246
|
-
|
|
241
|
+
isAddBlockSidebarOpen: false,
|
|
247
242
|
peekedBlock: null,
|
|
248
243
|
peekedBlockPosition: null,
|
|
249
244
|
skipPeekedBlockExitAnimation: true
|
|
@@ -254,13 +249,13 @@ const previewStore = createStore({
|
|
|
254
249
|
}),
|
|
255
250
|
toggleContentSheet: (context) => ({
|
|
256
251
|
...context,
|
|
257
|
-
|
|
252
|
+
isPageEditorSidebarOpen: false
|
|
258
253
|
}),
|
|
259
254
|
openBlockContentSheet: (context, event) => {
|
|
260
255
|
const currentBlockMatches = context.selection?.blockId === event.blockId;
|
|
261
256
|
return {
|
|
262
257
|
...context,
|
|
263
|
-
|
|
258
|
+
isPageEditorSidebarOpen: false,
|
|
264
259
|
selection: currentBlockMatches ? context.selection : {
|
|
265
260
|
type: "block",
|
|
266
261
|
blockId: event.blockId
|
|
@@ -269,15 +264,15 @@ const previewStore = createStore({
|
|
|
269
264
|
},
|
|
270
265
|
closeBlockContentSheet: (context) => ({
|
|
271
266
|
...context,
|
|
272
|
-
|
|
267
|
+
isPageEditorSidebarOpen: false
|
|
273
268
|
}),
|
|
274
|
-
|
|
269
|
+
openAgentChatSidebar: (context, event, enqueue) => {
|
|
275
270
|
const pageScaffoldContext = event?.pageScaffoldContext;
|
|
276
|
-
if (context.
|
|
271
|
+
if (context.isAgentChatSidebarOpen && !pageScaffoldContext) return context;
|
|
277
272
|
enqueue.effect(() => trackClientEvent("agent_chat_opened"));
|
|
278
273
|
return {
|
|
279
274
|
...context,
|
|
280
|
-
|
|
275
|
+
isAgentChatSidebarOpen: true,
|
|
281
276
|
agentChatPageScaffoldContext: pageScaffoldContext ? {
|
|
282
277
|
id: Date.now(),
|
|
283
278
|
nickname: pageScaffoldContext.nickname,
|
|
@@ -285,9 +280,9 @@ const previewStore = createStore({
|
|
|
285
280
|
} : context.agentChatPageScaffoldContext
|
|
286
281
|
};
|
|
287
282
|
},
|
|
288
|
-
|
|
283
|
+
closeAgentChatSidebar: (context) => ({
|
|
289
284
|
...context,
|
|
290
|
-
|
|
285
|
+
isAgentChatSidebarOpen: false
|
|
291
286
|
}),
|
|
292
287
|
clearAgentChatPageScaffoldContext: (context) => ({
|
|
293
288
|
...context,
|
|
@@ -322,18 +317,6 @@ const previewStore = createStore({
|
|
|
322
317
|
enqueue.effect(() => {
|
|
323
318
|
toast(event.source === "draft" ? "Previewing draft content" : "Previewing live content", { duration: 2500 });
|
|
324
319
|
});
|
|
325
|
-
if (event.source !== "draft" && context.previewSource === "draft") return {
|
|
326
|
-
...context,
|
|
327
|
-
previewSource: event.source,
|
|
328
|
-
prePreviewLockState: context.isContentLocked,
|
|
329
|
-
isContentLocked: true
|
|
330
|
-
};
|
|
331
|
-
if (event.source === "draft" && context.previewSource !== "draft") return {
|
|
332
|
-
...context,
|
|
333
|
-
previewSource: "draft",
|
|
334
|
-
isContentLocked: context.prePreviewLockState ?? false,
|
|
335
|
-
prePreviewLockState: null
|
|
336
|
-
};
|
|
337
320
|
return {
|
|
338
321
|
...context,
|
|
339
322
|
previewSource: event.source
|