camox 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AuthGate.js +2 -1
- package/dist/core/components/AddBlockControlBar.js +117 -44
- package/dist/core/components/lexical/InlineContentEditable.js +37 -17
- package/dist/core/components/lexical/InlineLexicalEditor.js +84 -25
- package/dist/core/components/lexical/SelectionBroadcaster.js +84 -47
- package/dist/core/components/lexical/SidebarLexicalEditor.js +54 -19
- package/dist/core/createBlock.js +1172 -414
- package/dist/core/createLayout.js +48 -16
- package/dist/core/hooks/useFieldSelection.js +24 -13
- package/dist/core/hooks/useIsEditable.js +8 -2
- package/dist/core/hooks/useOverlayMessage.js +51 -20
- package/dist/features/content/CamoxContent.js +239 -107
- package/dist/features/content/components/AssetCard.js +78 -16
- package/dist/features/content/components/AssetCardSkeleton.js +11 -4
- package/dist/features/content/components/ContentSidebar.js +15 -8
- package/dist/features/content/components/UploadDropZone.js +77 -34
- package/dist/features/content/components/UploadProgressDrawer.js +201 -58
- package/dist/features/metadata/sitemap.js +15 -0
- package/dist/features/preview/CamoxPreview.js +447 -179
- package/dist/features/preview/components/AddBlockSheet.js +344 -167
- package/dist/features/preview/components/AgentChatSheet.js +32 -10
- package/dist/features/preview/components/AssetFieldEditor.js +185 -50
- package/dist/features/preview/components/AssetLightbox.js +60 -33
- package/dist/features/preview/components/AssetPickerGrid.js +203 -71
- package/dist/features/preview/components/BlockActionsPopover.js +295 -218
- package/dist/features/preview/components/CreatePageSheet.js +3 -3
- package/dist/features/preview/components/DebouncedFieldEditor.js +80 -23
- package/dist/features/preview/components/EditPageSheet.js +241 -86
- package/dist/features/preview/components/ItemFieldsEditor.js +209 -115
- package/dist/features/preview/components/LinkFieldEditor.js +351 -153
- package/dist/features/preview/components/MultipleAssetFieldEditor.js +245 -92
- package/dist/features/preview/components/OverlayTracker.js +58 -23
- package/dist/features/preview/components/Overlays.js +85 -43
- package/dist/features/preview/components/PageContentSheet.js +18 -18
- package/dist/features/preview/components/PageLocationFieldset.js +229 -63
- package/dist/features/preview/components/PagePicker.js +27 -27
- package/dist/features/preview/components/PageTree.js +921 -319
- package/dist/features/preview/components/PeekedBlock.js +173 -63
- package/dist/features/preview/components/PreviewPanel.js +271 -148
- package/dist/features/preview/components/PreviewSideSheet.js +44 -11
- package/dist/features/preview/components/PreviewToolbar.js +262 -59
- package/dist/features/preview/components/RepeatableItemsList.js +187 -78
- package/dist/features/preview/components/ShikiMarkdown.js +46 -20
- package/dist/features/preview/components/TextFormatToolbar.js +81 -23
- package/dist/features/preview/components/UnlinkAssetButton.js +161 -40
- package/dist/features/preview/components/useUpdateBlockPosition.js +64 -47
- package/dist/features/preview/previewStore.d.ts +2 -2
- package/dist/features/provider/CamoxProvider.js +69 -21
- package/dist/features/provider/actionsStore.d.ts +2 -2
- package/dist/features/provider/components/CamoxAppContext.js +15 -5
- package/dist/features/provider/components/CommandPalette.js +199 -92
- package/dist/features/provider/useAdminShortcuts.js +80 -64
- package/dist/features/routes/pageRoute.js +8 -1
- package/dist/features/studio/CamoxStudio.js +45 -9
- package/dist/features/studio/components/EnvironmentMenu.js +47 -12
- package/dist/features/studio/components/Navbar.js +163 -65
- package/dist/features/studio/components/ProjectMenu.js +263 -82
- package/dist/features/studio/components/UserButton.js +21 -6
- package/dist/features/studio/studioStore.d.ts +2 -2
- package/dist/features/studio/useTheme.js +128 -74
- package/dist/hooks/use-file-upload.js +11 -11
- package/dist/hooks/use-marquee-selection.js +121 -74
- package/dist/lib/auth.js +95 -51
- package/dist/lib/normalized-data.js +103 -30
- package/dist/lib/use-project-room.js +55 -22
- package/dist/studio.css +2 -2
- package/package.json +29 -26
- package/dist/lib/auth.d.ts +0 -2130
- package/dist/lib/auth.d.ts.map +0 -1
|
@@ -9,6 +9,7 @@ import { AuthGate } from "../../components/AuthGate.js";
|
|
|
9
9
|
import { useProjectRoom } from "../../lib/use-project-room.js";
|
|
10
10
|
import { CommandPalette, useCommandPaletteActions } from "./components/CommandPalette.js";
|
|
11
11
|
import { useAdminShortcuts } from "./useAdminShortcuts.js";
|
|
12
|
+
import { c } from "react/compiler-runtime";
|
|
12
13
|
import { Toaster } from "@camox/ui/toaster";
|
|
13
14
|
import { useQuery } from "@tanstack/react-query";
|
|
14
15
|
import * as React from "react";
|
|
@@ -16,7 +17,9 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
16
17
|
import { ReactQueryDevtools } from "@tanstack/react-query-devtools/production";
|
|
17
18
|
import studioCssUrl from "virtual:camox-studio-css";
|
|
18
19
|
//#region src/features/provider/CamoxProvider.tsx
|
|
19
|
-
var AuthenticatedCamoxProvider = (
|
|
20
|
+
var AuthenticatedCamoxProvider = (t0) => {
|
|
21
|
+
const $ = c(8);
|
|
22
|
+
const { children } = t0;
|
|
20
23
|
useAdminShortcuts();
|
|
21
24
|
useCommandPaletteActions();
|
|
22
25
|
useThemeActions();
|
|
@@ -24,32 +27,77 @@ var AuthenticatedCamoxProvider = ({ children }) => {
|
|
|
24
27
|
useNavbarActions();
|
|
25
28
|
usePreviewPagesActions();
|
|
26
29
|
const { apiUrl, projectSlug } = React.useContext(AuthContext);
|
|
27
|
-
|
|
30
|
+
let t1;
|
|
31
|
+
if ($[0] !== projectSlug) {
|
|
32
|
+
t1 = projectQueries.getBySlug(projectSlug);
|
|
33
|
+
$[0] = projectSlug;
|
|
34
|
+
$[1] = t1;
|
|
35
|
+
} else t1 = $[1];
|
|
36
|
+
const { data: project } = useQuery(t1);
|
|
28
37
|
useProjectRoom(apiUrl, project?.id);
|
|
29
38
|
const { theme } = useTheme();
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/* @__PURE__ */ jsx(Toaster, { theme })
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
let t2;
|
|
40
|
+
if ($[2] !== theme) {
|
|
41
|
+
t2 = /* @__PURE__ */ jsx(Toaster, { theme });
|
|
42
|
+
$[2] = theme;
|
|
43
|
+
$[3] = t2;
|
|
44
|
+
} else t2 = $[3];
|
|
45
|
+
let t3;
|
|
46
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
47
|
+
t3 = /* @__PURE__ */ jsx(CommandPalette, {});
|
|
48
|
+
$[4] = t3;
|
|
49
|
+
} else t3 = $[4];
|
|
50
|
+
let t4;
|
|
51
|
+
if ($[5] !== children || $[6] !== t2) {
|
|
52
|
+
t4 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
53
|
+
children,
|
|
54
|
+
t2,
|
|
55
|
+
t3
|
|
56
|
+
] });
|
|
57
|
+
$[5] = children;
|
|
58
|
+
$[6] = t2;
|
|
59
|
+
$[7] = t4;
|
|
60
|
+
} else t4 = $[7];
|
|
61
|
+
return t4;
|
|
35
62
|
};
|
|
36
|
-
var UnauthenticatedCamoxProvider = (
|
|
63
|
+
var UnauthenticatedCamoxProvider = (t0) => {
|
|
64
|
+
const $ = c(7);
|
|
65
|
+
const { children } = t0;
|
|
37
66
|
const signInRedirect = useSignInRedirect();
|
|
38
67
|
const { authenticationUrl } = useAuthContext();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
68
|
+
let t1;
|
|
69
|
+
if ($[0] !== signInRedirect) {
|
|
70
|
+
t1 = () => {
|
|
71
|
+
const handleKeyDown = (event) => {
|
|
72
|
+
if ((event.metaKey || event.ctrlKey) && event.key === "Escape") {
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
signInRedirect();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
78
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
45
79
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
80
|
+
$[0] = signInRedirect;
|
|
81
|
+
$[1] = t1;
|
|
82
|
+
} else t1 = $[1];
|
|
83
|
+
let t2;
|
|
84
|
+
if ($[2] !== authenticationUrl || $[3] !== signInRedirect) {
|
|
85
|
+
t2 = [signInRedirect, authenticationUrl];
|
|
86
|
+
$[2] = authenticationUrl;
|
|
87
|
+
$[3] = signInRedirect;
|
|
88
|
+
$[4] = t2;
|
|
89
|
+
} else t2 = $[4];
|
|
90
|
+
React.useEffect(t1, t2);
|
|
91
|
+
let t3;
|
|
92
|
+
if ($[5] !== children) {
|
|
93
|
+
t3 = /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", {
|
|
94
|
+
className: "bg-background min-h-screen",
|
|
95
|
+
children
|
|
96
|
+
}) });
|
|
97
|
+
$[5] = children;
|
|
98
|
+
$[6] = t3;
|
|
99
|
+
} else t3 = $[6];
|
|
100
|
+
return t3;
|
|
53
101
|
};
|
|
54
102
|
function CamoxProvider({ children, camoxApp, authenticationUrl, apiUrl, projectSlug, environmentName }) {
|
|
55
103
|
const authClient = React.useMemo(() => createCamoxAuthClient(apiUrl), [apiUrl]);
|
|
@@ -16,7 +16,7 @@ export interface Action {
|
|
|
16
16
|
}
|
|
17
17
|
export declare const actionsStore: import('@xstate/store').Store<{
|
|
18
18
|
actions: Action[];
|
|
19
|
-
},
|
|
19
|
+
}, {
|
|
20
20
|
registerAction: {
|
|
21
21
|
action: Action;
|
|
22
22
|
};
|
|
@@ -29,7 +29,7 @@ export declare const actionsStore: import('@xstate/store').Store<{
|
|
|
29
29
|
unregisterManyActions: {
|
|
30
30
|
ids: string[];
|
|
31
31
|
};
|
|
32
|
-
}
|
|
32
|
+
}, {
|
|
33
33
|
type: string;
|
|
34
34
|
}>;
|
|
35
35
|
//# sourceMappingURL=actionsStore.d.ts.map
|
|
@@ -1,12 +1,22 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
import { jsx } from "react/jsx-runtime";
|
|
3
4
|
//#region src/features/provider/components/CamoxAppContext.tsx
|
|
4
5
|
var CamoxAppContext = React.createContext(void 0);
|
|
5
|
-
var CamoxAppProvider = (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
var CamoxAppProvider = (t0) => {
|
|
7
|
+
const $ = c(3);
|
|
8
|
+
const { app, children } = t0;
|
|
9
|
+
let t1;
|
|
10
|
+
if ($[0] !== app || $[1] !== children) {
|
|
11
|
+
t1 = /* @__PURE__ */ jsx(CamoxAppContext.Provider, {
|
|
12
|
+
value: app,
|
|
13
|
+
children
|
|
14
|
+
});
|
|
15
|
+
$[0] = app;
|
|
16
|
+
$[1] = children;
|
|
17
|
+
$[2] = t1;
|
|
18
|
+
} else t1 = $[2];
|
|
19
|
+
return t1;
|
|
10
20
|
};
|
|
11
21
|
function useCamoxApp() {
|
|
12
22
|
const context = React.use(CamoxAppContext);
|
|
@@ -1,119 +1,226 @@
|
|
|
1
1
|
import { actionsStore } from "../actionsStore.js";
|
|
2
2
|
import { formatShortcut } from "../../../lib/utils.js";
|
|
3
3
|
import { studioStore } from "../../studio/studioStore.js";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
4
5
|
import { useSelector } from "@xstate/store/react";
|
|
5
6
|
import * as React from "react";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import { CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@camox/ui/command";
|
|
8
9
|
//#region src/features/provider/components/CommandPalette.tsx
|
|
9
10
|
function CommandPalette() {
|
|
10
|
-
const
|
|
11
|
+
const $ = c(33);
|
|
12
|
+
const isOpen = useSelector(studioStore, _temp);
|
|
11
13
|
const [search, setSearch] = React.useState("");
|
|
12
14
|
const [value, setValue] = React.useState("");
|
|
13
|
-
const actions = useSelector(actionsStore,
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
const actions = useSelector(actionsStore, _temp2);
|
|
16
|
+
const pages = useSelector(studioStore, _temp3);
|
|
17
|
+
let t0;
|
|
18
|
+
if ($[0] !== pages) {
|
|
19
|
+
t0 = pages.at(-1);
|
|
20
|
+
$[0] = pages;
|
|
21
|
+
$[1] = t0;
|
|
22
|
+
} else t0 = $[1];
|
|
23
|
+
const page = t0;
|
|
24
|
+
let groups;
|
|
25
|
+
if ($[2] !== actions || $[3] !== page || $[4] !== search) {
|
|
26
|
+
let t1;
|
|
27
|
+
if ($[6] !== page || $[7] !== search) {
|
|
28
|
+
t1 = (action) => {
|
|
29
|
+
if (!action.checkIfAvailable()) return false;
|
|
30
|
+
if (action.groupLabel === "Invisible") return false;
|
|
31
|
+
if (page) return action.parentActionId === page;
|
|
32
|
+
if (search.length > 0) return true;
|
|
33
|
+
return !action.parentActionId;
|
|
34
|
+
};
|
|
35
|
+
$[6] = page;
|
|
36
|
+
$[7] = search;
|
|
37
|
+
$[8] = t1;
|
|
38
|
+
} else t1 = $[8];
|
|
39
|
+
const availableActions = actions.filter(t1);
|
|
40
|
+
groups = /* @__PURE__ */ new Map();
|
|
41
|
+
for (const action_0 of availableActions) {
|
|
42
|
+
const existing = groups.get(action_0.groupLabel) || [];
|
|
43
|
+
groups.set(action_0.groupLabel, [...existing, action_0]);
|
|
27
44
|
}
|
|
28
|
-
|
|
45
|
+
$[2] = actions;
|
|
46
|
+
$[3] = page;
|
|
47
|
+
$[4] = search;
|
|
48
|
+
$[5] = groups;
|
|
49
|
+
} else groups = $[5];
|
|
50
|
+
let t1;
|
|
51
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
52
|
+
t1 = [
|
|
29
53
|
"Preview",
|
|
30
54
|
"Navigation",
|
|
31
55
|
"Studio"
|
|
32
56
|
];
|
|
33
|
-
|
|
57
|
+
$[9] = t1;
|
|
58
|
+
} else t1 = $[9];
|
|
59
|
+
const groupOrder = t1;
|
|
60
|
+
let sortedGroups;
|
|
61
|
+
if ($[10] !== groups) {
|
|
62
|
+
sortedGroups = /* @__PURE__ */ new Map();
|
|
34
63
|
for (const groupLabel of groupOrder) if (groups.has(groupLabel)) sortedGroups.set(groupLabel, groups.get(groupLabel));
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
$[10] = groups;
|
|
65
|
+
$[11] = sortedGroups;
|
|
66
|
+
} else sortedGroups = $[11];
|
|
67
|
+
const groupedActions = sortedGroups;
|
|
68
|
+
let t2;
|
|
69
|
+
let t3;
|
|
70
|
+
if ($[12] !== actions || $[13] !== page) {
|
|
71
|
+
t2 = () => {
|
|
72
|
+
if (page) {
|
|
73
|
+
const firstChild = actions.find((a) => a.parentActionId === page && a.checkIfAvailable());
|
|
74
|
+
if (firstChild) setValue(firstChild.id);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
t3 = [page, actions];
|
|
78
|
+
$[12] = actions;
|
|
79
|
+
$[13] = page;
|
|
80
|
+
$[14] = t2;
|
|
81
|
+
$[15] = t3;
|
|
82
|
+
} else {
|
|
83
|
+
t2 = $[14];
|
|
84
|
+
t3 = $[15];
|
|
85
|
+
}
|
|
86
|
+
React.useEffect(t2, t3);
|
|
87
|
+
let t4;
|
|
88
|
+
if ($[16] !== actions) {
|
|
89
|
+
t4 = (actionId) => {
|
|
90
|
+
const action_1 = actions.find((a_0) => a_0.id === actionId);
|
|
91
|
+
if (!action_1) return;
|
|
92
|
+
action_1.execute();
|
|
93
|
+
setSearch("");
|
|
94
|
+
if (action_1.hasChildren) studioStore.send({
|
|
95
|
+
type: "pushCommandPalettePage",
|
|
96
|
+
page: action_1.id
|
|
97
|
+
});
|
|
98
|
+
else studioStore.send({ type: "closeCommandPalette" });
|
|
99
|
+
};
|
|
100
|
+
$[16] = actions;
|
|
101
|
+
$[17] = t4;
|
|
102
|
+
} else t4 = $[17];
|
|
103
|
+
const handleSelect = t4;
|
|
104
|
+
let t5;
|
|
105
|
+
if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
|
|
106
|
+
t5 = (open) => {
|
|
107
|
+
if (open) studioStore.send({ type: "openCommandPalette" });
|
|
108
|
+
else {
|
|
109
|
+
setValue("");
|
|
110
|
+
studioStore.send({ type: "closeCommandPalette" });
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
$[18] = t5;
|
|
114
|
+
} else t5 = $[18];
|
|
115
|
+
const handleOpenChange = t5;
|
|
116
|
+
let t6;
|
|
117
|
+
if ($[19] !== search) {
|
|
118
|
+
t6 = (e) => {
|
|
119
|
+
if (e.key === "Escape" || e.key === "Backspace" && !search) {
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
studioStore.send({ type: "popCommandPalettePage" });
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
$[19] = search;
|
|
125
|
+
$[20] = t6;
|
|
126
|
+
} else t6 = $[20];
|
|
127
|
+
let t7;
|
|
128
|
+
if ($[21] !== search || $[22] !== t6) {
|
|
129
|
+
t7 = /* @__PURE__ */ jsx(CommandInput, {
|
|
71
130
|
value: search,
|
|
72
131
|
onValueChange: setSearch,
|
|
73
132
|
placeholder: "Type a command or search...",
|
|
74
|
-
onKeyDown:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
133
|
+
onKeyDown: t6
|
|
134
|
+
});
|
|
135
|
+
$[21] = search;
|
|
136
|
+
$[22] = t6;
|
|
137
|
+
$[23] = t7;
|
|
138
|
+
} else t7 = $[23];
|
|
139
|
+
let t8;
|
|
140
|
+
if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
|
|
141
|
+
t8 = /* @__PURE__ */ jsx(CommandEmpty, { children: "No results found." });
|
|
142
|
+
$[24] = t8;
|
|
143
|
+
} else t8 = $[24];
|
|
144
|
+
let t9;
|
|
145
|
+
if ($[25] !== groupedActions || $[26] !== handleSelect) {
|
|
146
|
+
t9 = /* @__PURE__ */ jsxs(CommandList, { children: [t8, Array.from(groupedActions.entries()).map((t10) => {
|
|
147
|
+
const [groupLabel_0, groupActions] = t10;
|
|
148
|
+
return /* @__PURE__ */ jsx(CommandGroup, {
|
|
149
|
+
heading: groupLabel_0,
|
|
150
|
+
children: groupActions.map((action_2) => /* @__PURE__ */ jsxs(CommandItem, {
|
|
151
|
+
onSelect: () => handleSelect(action_2.id),
|
|
85
152
|
className: "justify-between",
|
|
86
|
-
children: [
|
|
87
|
-
},
|
|
88
|
-
})
|
|
89
|
-
}
|
|
90
|
-
|
|
153
|
+
children: [action_2.label, action_2.shortcut && formatShortcut(action_2.shortcut)]
|
|
154
|
+
}, action_2.id))
|
|
155
|
+
}, groupLabel_0);
|
|
156
|
+
})] });
|
|
157
|
+
$[25] = groupedActions;
|
|
158
|
+
$[26] = handleSelect;
|
|
159
|
+
$[27] = t9;
|
|
160
|
+
} else t9 = $[27];
|
|
161
|
+
let t10;
|
|
162
|
+
if ($[28] !== isOpen || $[29] !== t7 || $[30] !== t9 || $[31] !== value) {
|
|
163
|
+
t10 = /* @__PURE__ */ jsxs(CommandDialog, {
|
|
164
|
+
open: isOpen,
|
|
165
|
+
onOpenChange: handleOpenChange,
|
|
166
|
+
value,
|
|
167
|
+
onValueChange: setValue,
|
|
168
|
+
children: [t7, t9]
|
|
169
|
+
});
|
|
170
|
+
$[28] = isOpen;
|
|
171
|
+
$[29] = t7;
|
|
172
|
+
$[30] = t9;
|
|
173
|
+
$[31] = value;
|
|
174
|
+
$[32] = t10;
|
|
175
|
+
} else t10 = $[32];
|
|
176
|
+
return t10;
|
|
177
|
+
}
|
|
178
|
+
function _temp3(state_1) {
|
|
179
|
+
return state_1.context.commandPalettePages;
|
|
180
|
+
}
|
|
181
|
+
function _temp2(state_0) {
|
|
182
|
+
return state_0.context.actions;
|
|
183
|
+
}
|
|
184
|
+
function _temp(state) {
|
|
185
|
+
return state.context.isCommandPaletteOpen;
|
|
91
186
|
}
|
|
92
187
|
function useCommandPaletteActions() {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
188
|
+
const $ = c(1);
|
|
189
|
+
let t0;
|
|
190
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
191
|
+
t0 = [];
|
|
192
|
+
$[0] = t0;
|
|
193
|
+
} else t0 = $[0];
|
|
194
|
+
React.useEffect(_temp7, t0);
|
|
195
|
+
}
|
|
196
|
+
function _temp7() {
|
|
197
|
+
actionsStore.send({
|
|
198
|
+
type: "registerAction",
|
|
199
|
+
action: {
|
|
200
|
+
id: "toggle-command-palette",
|
|
201
|
+
label: "Toggle command palette",
|
|
202
|
+
groupLabel: "Invisible",
|
|
203
|
+
checkIfAvailable: _temp4,
|
|
204
|
+
execute: _temp5,
|
|
205
|
+
shortcut: {
|
|
206
|
+
key: "k",
|
|
207
|
+
withMeta: true
|
|
108
208
|
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
return _temp6;
|
|
212
|
+
}
|
|
213
|
+
function _temp6() {
|
|
214
|
+
actionsStore.send({
|
|
215
|
+
type: "unregisterAction",
|
|
216
|
+
id: "toggle-command-palette"
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
function _temp5() {
|
|
220
|
+
studioStore.send({ type: "toggleCommandPalette" });
|
|
221
|
+
}
|
|
222
|
+
function _temp4() {
|
|
223
|
+
return true;
|
|
117
224
|
}
|
|
118
225
|
//#endregion
|
|
119
226
|
export { CommandPalette, useCommandPaletteActions };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { previewStore } from "../preview/previewStore.js";
|
|
2
2
|
import { actionsStore } from "./actionsStore.js";
|
|
3
3
|
import { checkIfInputFocused } from "../../lib/utils.js";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
4
5
|
import { useSelector } from "@xstate/store/react";
|
|
5
6
|
import * as React from "react";
|
|
6
7
|
//#region src/features/provider/useAdminShortcuts.tsx
|
|
@@ -8,76 +9,91 @@ import * as React from "react";
|
|
|
8
9
|
* Hook that listens for global keyboard shortcuts defined in the actionsStore
|
|
9
10
|
*/
|
|
10
11
|
function useAdminShortcuts() {
|
|
11
|
-
const
|
|
12
|
+
const $ = c(3);
|
|
13
|
+
const actions = useSelector(actionsStore, _temp);
|
|
12
14
|
const previousLockState = React.useRef(null);
|
|
13
15
|
const lockKeyDownTime = React.useRef(null);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (
|
|
16
|
+
let t0;
|
|
17
|
+
let t1;
|
|
18
|
+
if ($[0] !== actions) {
|
|
19
|
+
t0 = () => {
|
|
20
|
+
const handleKeyDown = (event) => {
|
|
21
|
+
if (event.key.toLowerCase() === "l" && !event.metaKey && !event.altKey && !event.shiftKey) {
|
|
22
|
+
if (event.repeat) return;
|
|
23
|
+
if (checkIfInputFocused()) return;
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
if (previousLockState.current === null) {
|
|
26
|
+
lockKeyDownTime.current = Date.now();
|
|
27
|
+
previousLockState.current = previewStore.getSnapshot().context.isContentLocked;
|
|
28
|
+
if (!previousLockState.current) previewStore.send({ type: "toggleLockContent" });
|
|
29
|
+
}
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const matchingAction = actions.find((action) => {
|
|
33
|
+
if (!action.shortcut) return false;
|
|
34
|
+
if (!action.checkIfAvailable()) return false;
|
|
35
|
+
const { key, withMeta, withAlt, withShift } = action.shortcut;
|
|
36
|
+
return (withAlt && key.length === 1 && /[a-z]/i.test(key) ? event.code === `Key${key.toUpperCase()}` : key.toLowerCase() === event.key.toLowerCase()) && !!withMeta === (event.metaKey || event.ctrlKey) && !!withAlt === event.altKey && !!withShift === event.shiftKey;
|
|
37
|
+
});
|
|
38
|
+
if (!matchingAction) return;
|
|
39
|
+
const shortcut = matchingAction.shortcut;
|
|
40
|
+
if (checkIfInputFocused()) {
|
|
41
|
+
if (!shortcut.withMeta && !shortcut.withAlt) return;
|
|
42
|
+
if (shortcut.key === "Backspace") return;
|
|
43
|
+
}
|
|
20
44
|
event.preventDefault();
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
45
|
+
matchingAction.execute();
|
|
46
|
+
};
|
|
47
|
+
const handleKeyUp = (event_0) => {
|
|
48
|
+
if (event_0.key.toLowerCase() === "l") releaseLock();
|
|
49
|
+
};
|
|
50
|
+
const releaseLock = () => {
|
|
51
|
+
if (previousLockState.current === null) return;
|
|
52
|
+
const holdDuration = lockKeyDownTime.current !== null ? Date.now() - lockKeyDownTime.current : Infinity;
|
|
53
|
+
lockKeyDownTime.current = null;
|
|
54
|
+
if ((holdDuration < 300 ? !previousLockState.current : previousLockState.current) !== previewStore.getSnapshot().context.isContentLocked) previewStore.send({ type: "toggleLockContent" });
|
|
55
|
+
previousLockState.current = null;
|
|
56
|
+
};
|
|
57
|
+
const handleMessage = (event_1) => {
|
|
58
|
+
if (event_1.data?.type === "holdLockContent") {
|
|
59
|
+
if (previousLockState.current === null) {
|
|
60
|
+
lockKeyDownTime.current = Date.now();
|
|
61
|
+
previousLockState.current = previewStore.getSnapshot().context.isContentLocked;
|
|
62
|
+
if (!previousLockState.current) previewStore.send({ type: "toggleLockContent" });
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
25
65
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (!action.shortcut) return false;
|
|
30
|
-
if (!action.checkIfAvailable()) return false;
|
|
31
|
-
const { key, withMeta, withAlt, withShift } = action.shortcut;
|
|
32
|
-
return (withAlt && key.length === 1 && /[a-z]/i.test(key) ? event.code === `Key${key.toUpperCase()}` : key.toLowerCase() === event.key.toLowerCase()) && !!withMeta === (event.metaKey || event.ctrlKey) && !!withAlt === event.altKey && !!withShift === event.shiftKey;
|
|
33
|
-
});
|
|
34
|
-
if (!matchingAction) return;
|
|
35
|
-
const shortcut = matchingAction.shortcut;
|
|
36
|
-
if (checkIfInputFocused()) {
|
|
37
|
-
if (!shortcut.withMeta && !shortcut.withAlt) return;
|
|
38
|
-
if (shortcut.key === "Backspace") return;
|
|
39
|
-
}
|
|
40
|
-
event.preventDefault();
|
|
41
|
-
matchingAction.execute();
|
|
42
|
-
};
|
|
43
|
-
const handleKeyUp = (event) => {
|
|
44
|
-
if (event.key.toLowerCase() === "l") releaseLock();
|
|
45
|
-
};
|
|
46
|
-
const releaseLock = () => {
|
|
47
|
-
if (previousLockState.current === null) return;
|
|
48
|
-
const holdDuration = lockKeyDownTime.current !== null ? Date.now() - lockKeyDownTime.current : Infinity;
|
|
49
|
-
lockKeyDownTime.current = null;
|
|
50
|
-
if ((holdDuration < HOLD_THRESHOLD_MS ? !previousLockState.current : previousLockState.current) !== previewStore.getSnapshot().context.isContentLocked) previewStore.send({ type: "toggleLockContent" });
|
|
51
|
-
previousLockState.current = null;
|
|
52
|
-
};
|
|
53
|
-
const handleMessage = (event) => {
|
|
54
|
-
if (event.data?.type === "holdLockContent") {
|
|
55
|
-
if (previousLockState.current === null) {
|
|
56
|
-
lockKeyDownTime.current = Date.now();
|
|
57
|
-
previousLockState.current = previewStore.getSnapshot().context.isContentLocked;
|
|
58
|
-
if (!previousLockState.current) previewStore.send({ type: "toggleLockContent" });
|
|
66
|
+
if (event_1.data?.type === "releaseLockContent") {
|
|
67
|
+
releaseLock();
|
|
68
|
+
return;
|
|
59
69
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
window.addEventListener("message", handleMessage);
|
|
75
|
-
return () => {
|
|
76
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
77
|
-
document.removeEventListener("keyup", handleKeyUp);
|
|
78
|
-
window.removeEventListener("message", handleMessage);
|
|
70
|
+
if (event_1.data?.type === "executeAction") {
|
|
71
|
+
const { actionId } = event_1.data;
|
|
72
|
+
const action_0 = actions.find((a) => a.id === actionId);
|
|
73
|
+
if (action_0) action_0.execute();
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
77
|
+
document.addEventListener("keyup", handleKeyUp);
|
|
78
|
+
window.addEventListener("message", handleMessage);
|
|
79
|
+
return () => {
|
|
80
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
81
|
+
document.removeEventListener("keyup", handleKeyUp);
|
|
82
|
+
window.removeEventListener("message", handleMessage);
|
|
83
|
+
};
|
|
79
84
|
};
|
|
80
|
-
|
|
85
|
+
t1 = [actions];
|
|
86
|
+
$[0] = actions;
|
|
87
|
+
$[1] = t0;
|
|
88
|
+
$[2] = t1;
|
|
89
|
+
} else {
|
|
90
|
+
t0 = $[1];
|
|
91
|
+
t1 = $[2];
|
|
92
|
+
}
|
|
93
|
+
React.useEffect(t0, t1);
|
|
94
|
+
}
|
|
95
|
+
function _temp(state) {
|
|
96
|
+
return state.context.actions;
|
|
81
97
|
}
|
|
82
98
|
//#endregion
|
|
83
99
|
export { useAdminShortcuts };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { seedBlockCaches } from "../../lib/normalized-data.js";
|
|
2
2
|
import { CamoxPreview, PageContent } from "../preview/CamoxPreview.js";
|
|
3
3
|
import { trackEvent } from "../../lib/analytics.js";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
import { queryKeys } from "@camox/api/query-keys";
|
|
6
7
|
import { createORPCClient } from "@orpc/client";
|
|
@@ -139,7 +140,13 @@ function createPageHead(camoxApp) {
|
|
|
139
140
|
};
|
|
140
141
|
}
|
|
141
142
|
var PageRouteComponent = () => {
|
|
142
|
-
|
|
143
|
+
const $ = c(1);
|
|
144
|
+
let t0;
|
|
145
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
146
|
+
t0 = /* @__PURE__ */ jsx(CamoxPreview, { children: /* @__PURE__ */ jsx(PageContent, {}) });
|
|
147
|
+
$[0] = t0;
|
|
148
|
+
} else t0 = $[0];
|
|
149
|
+
return t0;
|
|
143
150
|
};
|
|
144
151
|
//#endregion
|
|
145
152
|
export { PageRouteComponent, createMarkdownMiddleware, createPageHead, createPageLoader, getOrigin, parseQuality, prefersMarkdown };
|