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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
4
|
import { codeToHtml } from "shiki";
|
|
@@ -9,29 +10,54 @@ var css = `
|
|
|
9
10
|
background-color: var(--shiki-dark-bg) !important;
|
|
10
11
|
}
|
|
11
12
|
`;
|
|
12
|
-
var ShikiMarkdown = (
|
|
13
|
+
var ShikiMarkdown = (t0) => {
|
|
14
|
+
const $ = c(6);
|
|
15
|
+
const { code } = t0;
|
|
13
16
|
const [html, setHtml] = React.useState("");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
let t1;
|
|
18
|
+
let t2;
|
|
19
|
+
if ($[0] !== code) {
|
|
20
|
+
t1 = () => {
|
|
21
|
+
let cancelled = false;
|
|
22
|
+
codeToHtml(code, {
|
|
23
|
+
lang: "markdown",
|
|
24
|
+
themes: {
|
|
25
|
+
light: "github-light",
|
|
26
|
+
dark: "github-dark-high-contrast"
|
|
27
|
+
},
|
|
28
|
+
defaultColor: false
|
|
29
|
+
}).then((result) => {
|
|
30
|
+
if (!cancelled) setHtml(result);
|
|
31
|
+
});
|
|
32
|
+
return () => {
|
|
33
|
+
cancelled = true;
|
|
34
|
+
};
|
|
28
35
|
};
|
|
29
|
-
|
|
36
|
+
t2 = [code];
|
|
37
|
+
$[0] = code;
|
|
38
|
+
$[1] = t1;
|
|
39
|
+
$[2] = t2;
|
|
40
|
+
} else {
|
|
41
|
+
t1 = $[1];
|
|
42
|
+
t2 = $[2];
|
|
43
|
+
}
|
|
44
|
+
React.useEffect(t1, t2);
|
|
30
45
|
if (!html) return null;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
46
|
+
let t3;
|
|
47
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
48
|
+
t3 = /* @__PURE__ */ jsx("style", { children: css });
|
|
49
|
+
$[3] = t3;
|
|
50
|
+
} else t3 = $[3];
|
|
51
|
+
let t4;
|
|
52
|
+
if ($[4] !== html) {
|
|
53
|
+
t4 = /* @__PURE__ */ jsxs(Fragment, { children: [t3, /* @__PURE__ */ jsx("div", {
|
|
54
|
+
className: "border-input w-full min-w-0 overflow-hidden rounded-md border text-sm [&_code]:font-mono [&_pre]:rounded-md [&_pre]:px-3 [&_pre]:py-2 [&_pre]:break-all [&_pre]:whitespace-pre-wrap",
|
|
55
|
+
dangerouslySetInnerHTML: { __html: html }
|
|
56
|
+
})] });
|
|
57
|
+
$[4] = html;
|
|
58
|
+
$[5] = t4;
|
|
59
|
+
} else t4 = $[5];
|
|
60
|
+
return t4;
|
|
35
61
|
};
|
|
36
62
|
//#endregion
|
|
37
63
|
export { ShikiMarkdown };
|
|
@@ -3,6 +3,7 @@ import { useIsPreviewSheetOpen } from "./PreviewSideSheet.js";
|
|
|
3
3
|
import { isOverlayMessage } from "../overlayMessages.js";
|
|
4
4
|
import { FORMAT_FLAGS } from "../../../core/lib/modifierFormats.js";
|
|
5
5
|
import { cn } from "../../../lib/utils.js";
|
|
6
|
+
import { c } from "react/compiler-runtime";
|
|
6
7
|
import { Kbd } from "@camox/ui/kbd";
|
|
7
8
|
import { useSelector } from "@xstate/store/react";
|
|
8
9
|
import * as React from "react";
|
|
@@ -27,33 +28,63 @@ var FORMAT_BUTTONS = [{
|
|
|
27
28
|
shortcut: "⌘ I"
|
|
28
29
|
}];
|
|
29
30
|
var TextFormatToolbar = () => {
|
|
30
|
-
const
|
|
31
|
+
const $ = c(15);
|
|
32
|
+
const iframeElement = useSelector(previewStore, _temp);
|
|
31
33
|
const isAnySideSheetOpen = useIsPreviewSheetOpen();
|
|
32
34
|
const [hasSelection, setHasSelection] = React.useState(false);
|
|
33
35
|
const [activeFormats, setActiveFormats] = React.useState(0);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
let t0;
|
|
37
|
+
let t1;
|
|
38
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
39
|
+
t0 = () => {
|
|
40
|
+
const handleMessage = (event) => {
|
|
41
|
+
const data = event.data;
|
|
42
|
+
if (!isOverlayMessage(data) || data.type !== "CAMOX_TEXT_SELECTION_STATE") return;
|
|
43
|
+
setHasSelection(data.hasSelection);
|
|
44
|
+
setActiveFormats(data.activeFormats);
|
|
45
|
+
};
|
|
46
|
+
window.addEventListener("message", handleMessage);
|
|
47
|
+
return () => window.removeEventListener("message", handleMessage);
|
|
40
48
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
t1 = [];
|
|
50
|
+
$[0] = t0;
|
|
51
|
+
$[1] = t1;
|
|
52
|
+
} else {
|
|
53
|
+
t0 = $[0];
|
|
54
|
+
t1 = $[1];
|
|
55
|
+
}
|
|
56
|
+
React.useEffect(t0, t1);
|
|
57
|
+
let t2;
|
|
58
|
+
if ($[2] !== iframeElement?.contentWindow) {
|
|
59
|
+
t2 = (formatKey) => {
|
|
60
|
+
iframeElement?.contentWindow?.postMessage({
|
|
61
|
+
type: "CAMOX_FORMAT_TEXT",
|
|
62
|
+
formatKey
|
|
63
|
+
}, "*");
|
|
64
|
+
};
|
|
65
|
+
$[2] = iframeElement?.contentWindow;
|
|
66
|
+
$[3] = t2;
|
|
67
|
+
} else t2 = $[3];
|
|
68
|
+
const sendFormat = t2;
|
|
69
|
+
const t3 = hasSelection && !isAnySideSheetOpen ? "opacity-100 translate-y-0" : "opacity-0 pointer-events-none translate-y-2";
|
|
70
|
+
let t4;
|
|
71
|
+
if ($[4] !== t3) {
|
|
72
|
+
t4 = cn("bottom-17 gap-2", t3);
|
|
73
|
+
$[4] = t3;
|
|
74
|
+
$[5] = t4;
|
|
75
|
+
} else t4 = $[5];
|
|
76
|
+
let t5;
|
|
77
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
78
|
+
t5 = /* @__PURE__ */ jsx("span", {
|
|
54
79
|
className: "text-muted-foreground text-sm",
|
|
55
80
|
children: "Selected text"
|
|
56
|
-
})
|
|
81
|
+
});
|
|
82
|
+
$[6] = t5;
|
|
83
|
+
} else t5 = $[6];
|
|
84
|
+
let t6;
|
|
85
|
+
if ($[7] !== activeFormats || $[8] !== sendFormat) {
|
|
86
|
+
t6 = FORMAT_BUTTONS.map((t7) => {
|
|
87
|
+
const { key, flag, icon: Icon, label, shortcut } = t7;
|
|
57
88
|
const isActive = !!(activeFormats & flag);
|
|
58
89
|
return /* @__PURE__ */ jsxs(Tooltip$1.Tooltip, { children: [/* @__PURE__ */ jsx(Tooltip$1.TooltipTrigger, {
|
|
59
90
|
asChild: true,
|
|
@@ -69,8 +100,35 @@ var TextFormatToolbar = () => {
|
|
|
69
100
|
" ",
|
|
70
101
|
/* @__PURE__ */ jsx(Kbd, { children: shortcut })
|
|
71
102
|
] })] }, key);
|
|
72
|
-
})
|
|
73
|
-
|
|
103
|
+
});
|
|
104
|
+
$[7] = activeFormats;
|
|
105
|
+
$[8] = sendFormat;
|
|
106
|
+
$[9] = t6;
|
|
107
|
+
} else t6 = $[9];
|
|
108
|
+
let t7;
|
|
109
|
+
if ($[10] !== t6) {
|
|
110
|
+
t7 = /* @__PURE__ */ jsx(ButtonGroup, { children: t6 });
|
|
111
|
+
$[10] = t6;
|
|
112
|
+
$[11] = t7;
|
|
113
|
+
} else t7 = $[11];
|
|
114
|
+
let t8;
|
|
115
|
+
if ($[12] !== t4 || $[13] !== t7) {
|
|
116
|
+
t8 = /* @__PURE__ */ jsxs(FloatingToolbar, {
|
|
117
|
+
onMouseDown: _temp2,
|
|
118
|
+
className: t4,
|
|
119
|
+
children: [t5, t7]
|
|
120
|
+
});
|
|
121
|
+
$[12] = t4;
|
|
122
|
+
$[13] = t7;
|
|
123
|
+
$[14] = t8;
|
|
124
|
+
} else t8 = $[14];
|
|
125
|
+
return t8;
|
|
74
126
|
};
|
|
127
|
+
function _temp(state) {
|
|
128
|
+
return state.context.iframeElement;
|
|
129
|
+
}
|
|
130
|
+
function _temp2(e) {
|
|
131
|
+
return e.preventDefault();
|
|
132
|
+
}
|
|
75
133
|
//#endregion
|
|
76
134
|
export { TextFormatToolbar };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { fileMutations, fileQueries } from "../../../lib/queries.js";
|
|
2
2
|
import { cn } from "../../../lib/utils.js";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
3
4
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
4
5
|
import { useState } from "react";
|
|
5
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -8,51 +9,171 @@ import { Tooltip, TooltipContent, TooltipTrigger } from "@camox/ui/tooltip";
|
|
|
8
9
|
import { X } from "lucide-react";
|
|
9
10
|
import { AlertDialog, AlertDialogAction, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
|
|
10
11
|
//#region src/features/preview/components/UnlinkAssetButton.tsx
|
|
11
|
-
var UnlinkAssetButton = (
|
|
12
|
+
var UnlinkAssetButton = (t0) => {
|
|
13
|
+
const $ = c(41);
|
|
14
|
+
const { fileId, onUnlink, className } = t0;
|
|
12
15
|
const [dialogOpen, setDialogOpen] = useState(false);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
16
|
+
let t1;
|
|
17
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
18
|
+
t1 = fileMutations.delete();
|
|
19
|
+
$[0] = t1;
|
|
20
|
+
} else t1 = $[0];
|
|
21
|
+
const deleteFile = useMutation(t1);
|
|
22
|
+
let t2;
|
|
23
|
+
if ($[1] !== fileId) {
|
|
24
|
+
t2 = fileQueries.getUsageCount(fileId);
|
|
25
|
+
$[1] = fileId;
|
|
26
|
+
$[2] = t2;
|
|
27
|
+
} else t2 = $[2];
|
|
28
|
+
const t3 = !!fileId;
|
|
29
|
+
let t4;
|
|
30
|
+
if ($[3] !== t2 || $[4] !== t3) {
|
|
31
|
+
t4 = {
|
|
32
|
+
...t2,
|
|
33
|
+
enabled: t3
|
|
34
|
+
};
|
|
35
|
+
$[3] = t2;
|
|
36
|
+
$[4] = t3;
|
|
37
|
+
$[5] = t4;
|
|
38
|
+
} else t4 = $[5];
|
|
39
|
+
const { data: usageCount } = useQuery(t4);
|
|
40
|
+
let t5;
|
|
41
|
+
if ($[6] !== fileId || $[7] !== onUnlink || $[8] !== usageCount) {
|
|
42
|
+
t5 = (e) => {
|
|
43
|
+
e.stopPropagation();
|
|
44
|
+
if (!fileId || usageCount === void 0 || usageCount > 1) {
|
|
45
|
+
onUnlink();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
setDialogOpen(true);
|
|
49
|
+
};
|
|
50
|
+
$[6] = fileId;
|
|
51
|
+
$[7] = onUnlink;
|
|
52
|
+
$[8] = usageCount;
|
|
53
|
+
$[9] = t5;
|
|
54
|
+
} else t5 = $[9];
|
|
55
|
+
const handleClick = t5;
|
|
56
|
+
let t6;
|
|
57
|
+
if ($[10] !== className) {
|
|
58
|
+
t6 = cn("text-muted-foreground hover:text-foreground shrink-0", className);
|
|
59
|
+
$[10] = className;
|
|
60
|
+
$[11] = t6;
|
|
61
|
+
} else t6 = $[11];
|
|
62
|
+
let t7;
|
|
63
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
64
|
+
t7 = /* @__PURE__ */ jsx(X, { className: "h-4 w-4" });
|
|
65
|
+
$[12] = t7;
|
|
66
|
+
} else t7 = $[12];
|
|
67
|
+
let t8;
|
|
68
|
+
if ($[13] !== handleClick || $[14] !== t6) {
|
|
69
|
+
t8 = /* @__PURE__ */ jsx(TooltipTrigger, {
|
|
41
70
|
asChild: true,
|
|
42
71
|
children: /* @__PURE__ */ jsx(Button, {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
72
|
+
type: "button",
|
|
73
|
+
variant: "ghost",
|
|
74
|
+
size: "icon-sm",
|
|
75
|
+
className: t6,
|
|
76
|
+
onClick: handleClick,
|
|
77
|
+
children: t7
|
|
46
78
|
})
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
79
|
+
});
|
|
80
|
+
$[13] = handleClick;
|
|
81
|
+
$[14] = t6;
|
|
82
|
+
$[15] = t8;
|
|
83
|
+
} else t8 = $[15];
|
|
84
|
+
let t9;
|
|
85
|
+
if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
|
|
86
|
+
t9 = /* @__PURE__ */ jsx(TooltipContent, { children: "Unlink" });
|
|
87
|
+
$[16] = t9;
|
|
88
|
+
} else t9 = $[16];
|
|
89
|
+
let t10;
|
|
90
|
+
if ($[17] !== t8) {
|
|
91
|
+
t10 = /* @__PURE__ */ jsxs(Tooltip, { children: [t8, t9] });
|
|
92
|
+
$[17] = t8;
|
|
93
|
+
$[18] = t10;
|
|
94
|
+
} else t10 = $[18];
|
|
95
|
+
let t11;
|
|
96
|
+
if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
|
|
97
|
+
t11 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: "Unlink file" }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: "This file is not used anywhere else. Would you like to also delete it?" })] });
|
|
98
|
+
$[19] = t11;
|
|
99
|
+
} else t11 = $[19];
|
|
100
|
+
let t12;
|
|
101
|
+
if ($[20] !== onUnlink) {
|
|
102
|
+
t12 = () => onUnlink();
|
|
103
|
+
$[20] = onUnlink;
|
|
104
|
+
$[21] = t12;
|
|
105
|
+
} else t12 = $[21];
|
|
106
|
+
let t13;
|
|
107
|
+
if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
|
|
108
|
+
t13 = /* @__PURE__ */ jsx(Button, {
|
|
109
|
+
variant: "outline",
|
|
110
|
+
className: "bg-background hover:bg-accent text-foreground",
|
|
111
|
+
children: "Unlink only"
|
|
112
|
+
});
|
|
113
|
+
$[22] = t13;
|
|
114
|
+
} else t13 = $[22];
|
|
115
|
+
let t14;
|
|
116
|
+
if ($[23] !== t12) {
|
|
117
|
+
t14 = /* @__PURE__ */ jsx(AlertDialogAction, {
|
|
118
|
+
onClick: t12,
|
|
119
|
+
asChild: true,
|
|
120
|
+
children: t13
|
|
121
|
+
});
|
|
122
|
+
$[23] = t12;
|
|
123
|
+
$[24] = t14;
|
|
124
|
+
} else t14 = $[24];
|
|
125
|
+
let t15;
|
|
126
|
+
if ($[25] !== deleteFile || $[26] !== fileId || $[27] !== onUnlink) {
|
|
127
|
+
t15 = () => {
|
|
128
|
+
onUnlink();
|
|
129
|
+
if (fileId) deleteFile.mutate({ id: fileId });
|
|
130
|
+
};
|
|
131
|
+
$[25] = deleteFile;
|
|
132
|
+
$[26] = fileId;
|
|
133
|
+
$[27] = onUnlink;
|
|
134
|
+
$[28] = t15;
|
|
135
|
+
} else t15 = $[28];
|
|
136
|
+
let t16;
|
|
137
|
+
if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
|
|
138
|
+
t16 = /* @__PURE__ */ jsx(Button, { children: "Delete file" });
|
|
139
|
+
$[29] = t16;
|
|
140
|
+
} else t16 = $[29];
|
|
141
|
+
let t17;
|
|
142
|
+
if ($[30] !== t15) {
|
|
143
|
+
t17 = /* @__PURE__ */ jsx(AlertDialogAction, {
|
|
144
|
+
onClick: t15,
|
|
52
145
|
asChild: true,
|
|
53
|
-
children:
|
|
54
|
-
})
|
|
55
|
-
|
|
146
|
+
children: t16
|
|
147
|
+
});
|
|
148
|
+
$[30] = t15;
|
|
149
|
+
$[31] = t17;
|
|
150
|
+
} else t17 = $[31];
|
|
151
|
+
let t18;
|
|
152
|
+
if ($[32] !== t14 || $[33] !== t17) {
|
|
153
|
+
t18 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t11, /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t14, t17] })] });
|
|
154
|
+
$[32] = t14;
|
|
155
|
+
$[33] = t17;
|
|
156
|
+
$[34] = t18;
|
|
157
|
+
} else t18 = $[34];
|
|
158
|
+
let t19;
|
|
159
|
+
if ($[35] !== dialogOpen || $[36] !== t18) {
|
|
160
|
+
t19 = /* @__PURE__ */ jsx(AlertDialog, {
|
|
161
|
+
open: dialogOpen,
|
|
162
|
+
onOpenChange: setDialogOpen,
|
|
163
|
+
children: t18
|
|
164
|
+
});
|
|
165
|
+
$[35] = dialogOpen;
|
|
166
|
+
$[36] = t18;
|
|
167
|
+
$[37] = t19;
|
|
168
|
+
} else t19 = $[37];
|
|
169
|
+
let t20;
|
|
170
|
+
if ($[38] !== t10 || $[39] !== t19) {
|
|
171
|
+
t20 = /* @__PURE__ */ jsxs(Fragment, { children: [t10, t19] });
|
|
172
|
+
$[38] = t10;
|
|
173
|
+
$[39] = t19;
|
|
174
|
+
$[40] = t20;
|
|
175
|
+
} else t20 = $[40];
|
|
176
|
+
return t20;
|
|
56
177
|
};
|
|
57
178
|
//#endregion
|
|
58
179
|
export { UnlinkAssetButton };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { previewStore } from "../previewStore.js";
|
|
2
2
|
import { blockMutations } from "../../../lib/queries.js";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
3
4
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
4
5
|
import { useSelector } from "@xstate/store/react";
|
|
5
6
|
import { generateKeyBetween } from "fractional-indexing";
|
|
@@ -7,57 +8,73 @@ import { queryKeys } from "@camox/api/query-keys";
|
|
|
7
8
|
import { useLocation } from "@tanstack/react-router";
|
|
8
9
|
//#region src/features/preview/components/useUpdateBlockPosition.ts
|
|
9
10
|
function useUpdateBlockPosition() {
|
|
11
|
+
const $ = c(4);
|
|
10
12
|
const queryClient = useQueryClient();
|
|
11
13
|
const { pathname } = useLocation();
|
|
12
|
-
const pagePathname = useSelector(previewStore,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
const pagePathname = useSelector(previewStore, _temp) ?? pathname;
|
|
15
|
+
let t0;
|
|
16
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
17
|
+
t0 = blockMutations.updatePosition();
|
|
18
|
+
$[0] = t0;
|
|
19
|
+
} else t0 = $[0];
|
|
20
|
+
let t1;
|
|
21
|
+
if ($[1] !== pagePathname || $[2] !== queryClient) {
|
|
22
|
+
t1 = {
|
|
23
|
+
...t0,
|
|
24
|
+
onMutate: (variables) => {
|
|
25
|
+
const pageQueryKey = queryKeys.pages.getByPath(pagePathname);
|
|
26
|
+
const previousPage = queryClient.getQueryData(pageQueryKey);
|
|
27
|
+
if (!previousPage) return {};
|
|
28
|
+
const newPosition = generateKeyBetween(variables.afterPosition ?? null, variables.beforePosition ?? null);
|
|
29
|
+
const prevBundle = queryClient.getQueryData(queryKeys.blocks.get(variables.id));
|
|
30
|
+
if (prevBundle) queryClient.setQueryData(queryKeys.blocks.get(variables.id), {
|
|
31
|
+
...prevBundle,
|
|
32
|
+
block: {
|
|
33
|
+
...prevBundle.block,
|
|
34
|
+
position: newPosition
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const blockIds = previousPage.page.blockIds;
|
|
38
|
+
const positions = /* @__PURE__ */ new Map();
|
|
39
|
+
for (const id of blockIds) if (id === variables.id) positions.set(id, newPosition);
|
|
40
|
+
else {
|
|
41
|
+
const bundle = queryClient.getQueryData(queryKeys.blocks.get(id));
|
|
42
|
+
if (bundle) positions.set(id, bundle.block.position);
|
|
26
43
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
44
|
+
const sortedIds = [...blockIds].sort((a, b) => {
|
|
45
|
+
const posA = positions.get(a) ?? "";
|
|
46
|
+
const posB = positions.get(b) ?? "";
|
|
47
|
+
return posA.localeCompare(posB);
|
|
48
|
+
});
|
|
49
|
+
queryClient.setQueryData(pageQueryKey, {
|
|
50
|
+
...previousPage,
|
|
51
|
+
page: {
|
|
52
|
+
...previousPage.page,
|
|
53
|
+
blockIds: sortedIds
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
queryClient.cancelQueries({ queryKey: pageQueryKey });
|
|
57
|
+
return {
|
|
58
|
+
previousPage,
|
|
59
|
+
prevBundle
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
onError: (_error, variables_0, context) => {
|
|
63
|
+
if (context?.previousPage) queryClient.setQueryData(queryKeys.pages.getByPath(pagePathname), context.previousPage);
|
|
64
|
+
if (context?.prevBundle) queryClient.setQueryData(queryKeys.blocks.get(variables_0.id), context.prevBundle);
|
|
65
|
+
},
|
|
66
|
+
onSettled: () => {
|
|
67
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.pages.getByPath(pagePathname) });
|
|
34
68
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
blockIds: sortedIds
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
queryClient.cancelQueries({ queryKey: pageQueryKey });
|
|
48
|
-
return {
|
|
49
|
-
previousPage,
|
|
50
|
-
prevBundle
|
|
51
|
-
};
|
|
52
|
-
},
|
|
53
|
-
onError: (_error, variables, context) => {
|
|
54
|
-
if (context?.previousPage) queryClient.setQueryData(queryKeys.pages.getByPath(pagePathname), context.previousPage);
|
|
55
|
-
if (context?.prevBundle) queryClient.setQueryData(queryKeys.blocks.get(variables.id), context.prevBundle);
|
|
56
|
-
},
|
|
57
|
-
onSettled: () => {
|
|
58
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.pages.getByPath(pagePathname) });
|
|
59
|
-
}
|
|
60
|
-
});
|
|
69
|
+
};
|
|
70
|
+
$[1] = pagePathname;
|
|
71
|
+
$[2] = queryClient;
|
|
72
|
+
$[3] = t1;
|
|
73
|
+
} else t1 = $[3];
|
|
74
|
+
return useMutation(t1);
|
|
75
|
+
}
|
|
76
|
+
function _temp(state) {
|
|
77
|
+
return state.context.peekedPagePathname;
|
|
61
78
|
}
|
|
62
79
|
//#endregion
|
|
63
80
|
export { useUpdateBlockPosition };
|
|
@@ -45,7 +45,7 @@ interface PreviewContext {
|
|
|
45
45
|
selection: Selection | null;
|
|
46
46
|
iframeElement: HTMLIFrameElement | null;
|
|
47
47
|
}
|
|
48
|
-
export declare const previewStore: import('@xstate/store').Store<PreviewContext,
|
|
48
|
+
export declare const previewStore: import('@xstate/store').Store<PreviewContext, {
|
|
49
49
|
enterPresentationMode: {
|
|
50
50
|
type: "enterPresentationMode";
|
|
51
51
|
};
|
|
@@ -116,7 +116,7 @@ export declare const previewStore: import('@xstate/store').Store<PreviewContext,
|
|
|
116
116
|
setIframeElement: {
|
|
117
117
|
element: HTMLIFrameElement | null;
|
|
118
118
|
};
|
|
119
|
-
}
|
|
119
|
+
}, {
|
|
120
120
|
type: string;
|
|
121
121
|
}>;
|
|
122
122
|
export {};
|