@conloca/cms-spa 0.1.14 → 0.1.15
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/index.d.mts +5 -16
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/main.mjs +1967 -1284
- package/dist/main.mjs.map +1 -1
- package/dist/{puck-CvjeYQRH.mjs → puck-C9_F3_cJ.mjs} +459 -403
- package/dist/puck-C9_F3_cJ.mjs.map +1 -0
- package/dist/puck-config.d.mts +9 -0
- package/dist/puck-config.d.mts.map +1 -1
- package/dist/puck-config.mjs.map +1 -1
- package/dist/site-styles.d.mts +41 -0
- package/dist/site-styles.d.mts.map +1 -0
- package/dist/site-styles.mjs +52 -0
- package/dist/site-styles.mjs.map +1 -0
- package/dist/spa/main.css +4765 -4202
- package/package.json +9 -4
- package/dist/puck-CvjeYQRH.mjs.map +0 -1
|
@@ -1,13 +1,260 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
-
import "
|
|
4
|
-
import { Folder, FolderPlus, Search, Upload, X } from "lucide-react";
|
|
5
|
-
import { useAssetFolders, useAssetUsage, useBulkDeleteAssets, useCreateFolder, useDeleteAsset, useFolderTree as useFolderTree$1, useImportAssetUrl, useMoveAssets, useUpdateAssetMetadata, useUploadAsset } from "@conloca/content-api-client";
|
|
1
|
+
import { BaseMDXEditor, BaseMDXEditorModal, useMDXEvaluation } from "@conloca/mdx";
|
|
2
|
+
import React, { createContext, forwardRef, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
4
|
import { clsx } from "clsx";
|
|
7
5
|
import { twMerge } from "tailwind-merge";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { AlertTriangle, Check, Folder, FolderPlus, Loader2, Search, Upload, X } from "lucide-react";
|
|
7
|
+
import { closeImageDialog$, imageDialogState$, insertImage$, useCellValue, usePublisher } from "@mdxeditor/editor";
|
|
8
|
+
import { useAssetFolders, useAssetUsage, useBulkDeleteAssets, useCompileMDX, useCreateFolder, useDeleteAsset, useFolderTree as useFolderTree$1, useImportAssetUrl, useMoveAssets, useUpdateAssetMetadata, useUploadAsset } from "@conloca/content-api-client";
|
|
9
|
+
|
|
10
|
+
//#region src/hooks/useTheme.tsx
|
|
11
|
+
const STORAGE_KEY = "conloca-theme";
|
|
12
|
+
const ThemeContext = createContext(null);
|
|
13
|
+
function getSystemTheme() {
|
|
14
|
+
if (typeof window === "undefined") return "light";
|
|
15
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
16
|
+
}
|
|
17
|
+
function getStoredTheme() {
|
|
18
|
+
if (typeof window === "undefined") return "system";
|
|
19
|
+
const stored = localStorage.getItem(STORAGE_KEY);
|
|
20
|
+
if (stored === "light" || stored === "dark" || stored === "system") return stored;
|
|
21
|
+
return "system";
|
|
22
|
+
}
|
|
23
|
+
function applyTheme(resolved) {
|
|
24
|
+
const root = document.documentElement;
|
|
25
|
+
if (resolved === "dark") root.classList.add("dark");
|
|
26
|
+
else root.classList.remove("dark");
|
|
27
|
+
}
|
|
28
|
+
function ThemeProvider({ children }) {
|
|
29
|
+
const [theme, setThemeState] = useState(getStoredTheme);
|
|
30
|
+
const [systemTheme, setSystemTheme] = useState(getSystemTheme);
|
|
31
|
+
const resolvedTheme = theme === "system" ? systemTheme : theme;
|
|
32
|
+
const setTheme = useCallback((newTheme) => {
|
|
33
|
+
setThemeState(newTheme);
|
|
34
|
+
localStorage.setItem(STORAGE_KEY, newTheme);
|
|
35
|
+
}, []);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
applyTheme(resolvedTheme);
|
|
38
|
+
}, [resolvedTheme]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const mq = window.matchMedia("(prefers-color-scheme: dark)");
|
|
41
|
+
const handler = (e) => {
|
|
42
|
+
setSystemTheme(e.matches ? "dark" : "light");
|
|
43
|
+
};
|
|
44
|
+
mq.addEventListener("change", handler);
|
|
45
|
+
return () => mq.removeEventListener("change", handler);
|
|
46
|
+
}, []);
|
|
47
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, {
|
|
48
|
+
value: {
|
|
49
|
+
theme,
|
|
50
|
+
resolvedTheme,
|
|
51
|
+
setTheme
|
|
52
|
+
},
|
|
53
|
+
children
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const NOOP_THEME = {
|
|
57
|
+
theme: "system",
|
|
58
|
+
resolvedTheme: "light",
|
|
59
|
+
setTheme: () => {}
|
|
60
|
+
};
|
|
61
|
+
function useTheme() {
|
|
62
|
+
return useContext(ThemeContext) ?? NOOP_THEME;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/utils/cn.ts
|
|
67
|
+
function cn(...inputs) {
|
|
68
|
+
return twMerge(clsx(inputs));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/components/ui/Button.tsx
|
|
73
|
+
function Button({ variant = "primary", size = "default", type = "button", className, ref, ...props }) {
|
|
74
|
+
return /* @__PURE__ */ jsx("button", {
|
|
75
|
+
ref,
|
|
76
|
+
type,
|
|
77
|
+
className: cn("rounded-md transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed", {
|
|
78
|
+
default: "px-4 py-2",
|
|
79
|
+
sm: "px-3 py-1.5 text-sm"
|
|
80
|
+
}[size], {
|
|
81
|
+
primary: "bg-azure-04 text-white hover:bg-azure-03",
|
|
82
|
+
outline: "border border-line bg-panel text-grey-04 dark:text-grey-07 hover:bg-hover hover:text-grey-01 dark:hover:text-grey-12",
|
|
83
|
+
ghost: "text-grey-04 dark:text-grey-07 hover:bg-hover hover:text-grey-01 dark:hover:text-grey-12",
|
|
84
|
+
destructive: "bg-red-04 text-white hover:bg-red-03"
|
|
85
|
+
}[variant], className),
|
|
86
|
+
...props
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/components/ui/IconButton.tsx
|
|
92
|
+
function IconButton({ icon: Icon, onClick, ariaLabel, title, className, iconSize = "h-4 w-4", variant = "default" }) {
|
|
93
|
+
return /* @__PURE__ */ jsx("button", {
|
|
94
|
+
onClick,
|
|
95
|
+
className: cn("p-2 rounded-md transition-all duration-150 cursor-pointer", {
|
|
96
|
+
default: "text-grey-03 dark:text-grey-09 hover:bg-hover hover:text-grey-01 dark:hover:text-grey-12",
|
|
97
|
+
ghost: "text-grey-04 dark:text-grey-07 hover:bg-hover hover:text-grey-01 dark:hover:text-grey-12"
|
|
98
|
+
}[variant], className),
|
|
99
|
+
"aria-label": ariaLabel,
|
|
100
|
+
title: title || ariaLabel,
|
|
101
|
+
children: /* @__PURE__ */ jsx(Icon, { className: iconSize })
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/components/ui/Input.tsx
|
|
107
|
+
function Input({ size = "default", error, className, ref, ...props }) {
|
|
108
|
+
return /* @__PURE__ */ jsx("input", {
|
|
109
|
+
ref,
|
|
110
|
+
className: cn("w-full rounded-md border bg-panel text-grey-01 dark:text-grey-12", "focus:outline-none focus:ring-2 focus:ring-azure-04", size === "sm" ? "px-3 py-2 text-sm" : "px-3 py-2", error ? "border-red-04 focus:ring-red-04" : "border-line", className),
|
|
111
|
+
...props
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/components/ui/Select.tsx
|
|
117
|
+
function Select({ size = "default", className, children, ref, ...props }) {
|
|
118
|
+
return /* @__PURE__ */ jsx("select", {
|
|
119
|
+
ref,
|
|
120
|
+
className: cn("w-full rounded-md border bg-panel border-line text-grey-01 dark:text-grey-12", "focus:outline-none focus:ring-2 focus:ring-azure-04", size === "sm" ? "px-3 py-2 text-sm" : "px-3 py-2", className),
|
|
121
|
+
...props,
|
|
122
|
+
children
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/components/ui/Separator.tsx
|
|
128
|
+
function Separator({ className, orientation = "vertical" }) {
|
|
129
|
+
if (orientation === "horizontal") return /* @__PURE__ */ jsx("div", {
|
|
130
|
+
className: cn("w-full h-px bg-grey-09 dark:bg-grey-04", className),
|
|
131
|
+
role: "separator",
|
|
132
|
+
"aria-orientation": "horizontal"
|
|
133
|
+
});
|
|
134
|
+
return /* @__PURE__ */ jsx("div", {
|
|
135
|
+
className: cn("h-5 w-px bg-grey-09 dark:bg-grey-04", className),
|
|
136
|
+
role: "separator",
|
|
137
|
+
"aria-orientation": "vertical"
|
|
138
|
+
});
|
|
139
|
+
}
|
|
10
140
|
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/components/ui/Textarea.tsx
|
|
143
|
+
function Textarea({ error, className, ref, ...props }) {
|
|
144
|
+
return /* @__PURE__ */ jsx("textarea", {
|
|
145
|
+
ref,
|
|
146
|
+
className: cn("w-full px-3 py-2 rounded-md border bg-panel text-grey-01 dark:text-grey-12", "focus:outline-none focus:ring-2 focus:ring-azure-04", error ? "border-red-04 focus:ring-red-04" : "border-line", className),
|
|
147
|
+
...props
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/components/ui/Tooltip.tsx
|
|
153
|
+
function Tooltip({ content, children, className = "" }) {
|
|
154
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
155
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
156
|
+
className: "relative inline-block",
|
|
157
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
158
|
+
onMouseEnter: () => setIsVisible(true),
|
|
159
|
+
onMouseLeave: () => setIsVisible(false),
|
|
160
|
+
children
|
|
161
|
+
}), isVisible && /* @__PURE__ */ jsxs("div", {
|
|
162
|
+
className: `absolute z-10 px-3 py-2 text-sm text-white bg-grey-01 rounded-lg shadow-sm
|
|
163
|
+
bottom-full left-1/2 transform -translate-x-1/2 mb-2 whitespace-nowrap ${className}`,
|
|
164
|
+
children: [content, /* @__PURE__ */ jsx("div", {
|
|
165
|
+
className: "absolute top-full left-1/2 transform -translate-x-1/2 -mt-1",
|
|
166
|
+
children: /* @__PURE__ */ jsx("div", { className: "w-0 h-0 border-l-4 border-r-4 border-t-4 border-l-transparent border-r-transparent border-t-grey-01" })
|
|
167
|
+
})]
|
|
168
|
+
})]
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/components/editor/content-block-templates.ts
|
|
174
|
+
const contentBlockTemplates = [
|
|
175
|
+
{
|
|
176
|
+
id: "long-form",
|
|
177
|
+
label: "Long-Form Text",
|
|
178
|
+
description: "Article-style prose for deep explanations, narrative sections, and documentation-style content.",
|
|
179
|
+
category: "content",
|
|
180
|
+
content: "# {{title}}\n\nLead with the most important point in 2-3 sentences. Explain why it matters before diving into the details.\n\n> Editors should understand the value of this section before they finish the first paragraph.\n\n## Key idea\n\nAdd the main explanation here. Use short paragraphs and one list if it helps the reader scan faster.\n\n- First takeaway\n- Second takeaway\n- Third takeaway\n\n## What changes for the team\n\nDescribe the before and after. Focus on clarity, speed, ownership, or workflow quality.\n"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
id: "feature-narrative",
|
|
184
|
+
label: "Feature Narrative",
|
|
185
|
+
description: "A polished feature story that introduces a capability, explains the workflow, and lands on the user benefit.",
|
|
186
|
+
category: "features",
|
|
187
|
+
content: "# {{title}}\n\nStart with the user problem this block solves and the moment when it becomes obvious they need it.\n\n## Why teams hit this wall\n\nDescribe the friction or limitation in the current workflow. Keep it grounded in real editorial behavior.\n\n## What Conloca changes\n\nExplain the workflow in plain language. Focus on what changes for the editor, not implementation details.\n\n## What it unlocks\n\nClose with the outcome: faster publishing, clearer content operations, fewer bottlenecks, or better site quality.\n\n| Before | After |\n| --- | --- |\n| Manual handoffs | Shared visual workflow |\n| Hidden content state | Git-visible changes |\n"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
id: "callout-note",
|
|
191
|
+
label: "Callout Note",
|
|
192
|
+
description: "Compact supporting content for tips, clarifications, or key reminders inside a larger landing page.",
|
|
193
|
+
category: "callouts",
|
|
194
|
+
content: "## {{title}}\n\n> Lead with a concise note, recommendation, or point of emphasis.\n\nAdd one short paragraph that gives the reader extra context, guidance, or a best practice.\n\n- Keep the point crisp\n- Explain why it matters\n- Point to the next action\n"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
id: "comparison-narrative",
|
|
198
|
+
label: "Comparison Narrative",
|
|
199
|
+
description: "Structured prose for explaining tradeoffs between Conloca and another category of CMS or workflow.",
|
|
200
|
+
category: "comparison",
|
|
201
|
+
content: "# {{title}}\n\nFrame the choice clearly. What are teams actually choosing between here?\n\n## Where the usual approach breaks\n\nExplain the operational cost, not just the missing feature list.\n\n## Why Conloca feels different\n\nUse this section to connect architecture to daily editing experience.\n\n| Concern | Typical setup | Conloca |\n| --- | --- | --- |\n| Content ownership | External service | Lives in your repo |\n| Editorial UX | Form-heavy | Visual + reusable blocks |\n| Change history | Separate tools | Git-native |\n"
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
id: "founder-note",
|
|
205
|
+
label: "Founder Note",
|
|
206
|
+
description: "A more personal voice for opinionated product philosophy, launch notes, or roadmap framing.",
|
|
207
|
+
category: "story",
|
|
208
|
+
content: "# {{title}}\n\nStart with a direct statement of belief. This should sound like a human, not a feature checklist.\n\n## What we kept seeing\n\nDescribe the repeated pattern that convinced you the problem was real.\n\n## What we decided to build instead\n\nExplain the product choice and the philosophy behind it.\n\n> The best CMS should make editors faster without taking the codebase away from developers.\n"
|
|
209
|
+
}
|
|
210
|
+
];
|
|
211
|
+
const contentBlockSnippets = [
|
|
212
|
+
{
|
|
213
|
+
id: "section-heading",
|
|
214
|
+
label: "Section Heading",
|
|
215
|
+
content: "## Section title\n\nWrite the opening paragraph for this section here.\n"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
id: "callout-quote",
|
|
219
|
+
label: "Callout Quote",
|
|
220
|
+
content: "> A short, sharp takeaway or highlighted recommendation.\n"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
id: "proof-points",
|
|
224
|
+
label: "Proof Points",
|
|
225
|
+
content: "- Clear editorial workflow\n- Reusable narrative blocks\n- Git-native publishing history\n"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
id: "comparison-table",
|
|
229
|
+
label: "Comparison Table",
|
|
230
|
+
content: "| Option | Best for | Tradeoff |\n| --- | --- | --- |\n| Option A | Teams that want speed | Less flexibility |\n| Option B | Teams that need control | More setup |\n"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
id: "before-after",
|
|
234
|
+
label: "Before / After Table",
|
|
235
|
+
content: "| Before | After |\n| --- | --- |\n| Editors wait on developers | Editors publish with reusable blocks |\n| Content lives in tools | Content lives in the repo |\n"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
id: "next-steps",
|
|
239
|
+
label: "Next Steps List",
|
|
240
|
+
content: "## Next steps\n\n1. First action\n2. Second action\n3. Third action\n"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
id: "code-callout",
|
|
244
|
+
label: "Code Callout",
|
|
245
|
+
content: "```ts\nconlocaCMS({\n contentRoot: \"./content\",\n puckConfigPath: \"./src/puck.config.tsx\",\n})\n```\n"
|
|
246
|
+
}
|
|
247
|
+
];
|
|
248
|
+
function getContentBlockTemplate(templateId) {
|
|
249
|
+
return contentBlockTemplates.find((template) => template.id === templateId);
|
|
250
|
+
}
|
|
251
|
+
function renderContentBlockTemplate(templateId, title) {
|
|
252
|
+
const template = getContentBlockTemplate(templateId);
|
|
253
|
+
if (!template) return `# ${title}\n\nWrite your content here.\n`;
|
|
254
|
+
return template.content.split("{{title}}").join(title || "Untitled Block");
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
//#endregion
|
|
11
258
|
//#region src/hooks/useClickOutside.ts
|
|
12
259
|
/**
|
|
13
260
|
* Hook that triggers a callback when clicking outside the referenced element.
|
|
@@ -386,12 +633,6 @@ function useUploadFlow({ folder, onUploadComplete, onSuccess }) {
|
|
|
386
633
|
};
|
|
387
634
|
}
|
|
388
635
|
|
|
389
|
-
//#endregion
|
|
390
|
-
//#region src/utils/cn.ts
|
|
391
|
-
function cn$1(...inputs) {
|
|
392
|
-
return twMerge(clsx(inputs));
|
|
393
|
-
}
|
|
394
|
-
|
|
395
636
|
//#endregion
|
|
396
637
|
//#region src/components/dialogs/CreateFolderDialog.tsx
|
|
397
638
|
function CreateFolderDialog({ open, isPending, onClose, onCreate }) {
|
|
@@ -415,46 +656,43 @@ function CreateFolderDialog({ open, isPending, onClose, onCreate }) {
|
|
|
415
656
|
if (!open) return null;
|
|
416
657
|
const isValid = folderName.trim().length > 0;
|
|
417
658
|
return /* @__PURE__ */ jsx("div", {
|
|
418
|
-
className: "fixed inset-0 bg-black/50 flex items-center justify-center z-50",
|
|
659
|
+
className: "fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50",
|
|
419
660
|
role: "dialog",
|
|
420
661
|
onKeyDown: handleKeyDown,
|
|
421
662
|
children: /* @__PURE__ */ jsxs("div", {
|
|
422
|
-
className: "bg-
|
|
663
|
+
className: "bg-overlay rounded-lg p-6 w-full max-w-md",
|
|
423
664
|
"data-testid": "create-folder-dialog",
|
|
424
665
|
children: [
|
|
425
666
|
/* @__PURE__ */ jsx("h2", {
|
|
426
|
-
className: "text-xl font-semibold text-grey-01 mb-4",
|
|
667
|
+
className: "text-xl font-semibold text-grey-01 dark:text-grey-12 mb-4",
|
|
427
668
|
children: "Create New Folder"
|
|
428
669
|
}),
|
|
429
670
|
/* @__PURE__ */ jsxs("div", {
|
|
430
671
|
className: "mb-4",
|
|
431
672
|
children: [/* @__PURE__ */ jsx("label", {
|
|
432
673
|
htmlFor: "folder-name",
|
|
433
|
-
className: "block text-sm font-medium text-grey-01 mb-2",
|
|
674
|
+
className: "block text-sm font-medium text-grey-01 dark:text-grey-12 mb-2",
|
|
434
675
|
children: "Folder Name"
|
|
435
|
-
}), /* @__PURE__ */ jsx(
|
|
676
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
436
677
|
ref: inputRef,
|
|
437
678
|
id: "folder-name",
|
|
438
679
|
type: "text",
|
|
439
680
|
value: folderName,
|
|
440
681
|
onChange: (e) => setFolderName(e.target.value),
|
|
441
682
|
placeholder: "Enter folder name",
|
|
442
|
-
className: "w-full px-3 py-2 border border-grey-09 rounded focus:outline-none focus:ring-2 focus:ring-azure-04",
|
|
443
683
|
"data-testid": "folder-name-input"
|
|
444
684
|
})]
|
|
445
685
|
}),
|
|
446
686
|
/* @__PURE__ */ jsxs("div", {
|
|
447
687
|
className: "flex justify-end gap-3",
|
|
448
|
-
children: [/* @__PURE__ */ jsx(
|
|
449
|
-
|
|
688
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
689
|
+
variant: "outline",
|
|
450
690
|
onClick: onClose,
|
|
451
|
-
className: "px-4 py-2 border border-grey-09 rounded hover:bg-grey-11 transition-colors",
|
|
452
691
|
children: "Cancel"
|
|
453
|
-
}), /* @__PURE__ */ jsx(
|
|
454
|
-
|
|
692
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
693
|
+
variant: "primary",
|
|
455
694
|
onClick: handleCreate,
|
|
456
695
|
disabled: !isValid || isPending,
|
|
457
|
-
className: "px-4 py-2 bg-azure-04 text-white rounded hover:bg-azure-03 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
|
|
458
696
|
"data-testid": "create-folder-submit",
|
|
459
697
|
children: isPending ? "Creating..." : "Create"
|
|
460
698
|
})]
|
|
@@ -472,9 +710,9 @@ function FolderNode({ node, depth, currentFolder, dropTargetFolder, onFolderSele
|
|
|
472
710
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("button", {
|
|
473
711
|
type: "button",
|
|
474
712
|
onClick: () => onFolderSelect(node.path),
|
|
475
|
-
className: cn
|
|
476
|
-
"bg-azure-11 text-azure-01": isActive,
|
|
477
|
-
"hover:bg-grey-11": !isActive,
|
|
713
|
+
className: cn("w-full flex items-center gap-2 py-1.5 px-3 rounded-md text-sm transition-colors text-left", {
|
|
714
|
+
"bg-azure-11 dark:bg-azure-03 text-azure-01 dark:text-azure-11": isActive,
|
|
715
|
+
"hover:bg-grey-11 dark:hover:bg-grey-03": !isActive,
|
|
478
716
|
"ring-2 ring-azure-04": isDropTarget
|
|
479
717
|
}),
|
|
480
718
|
style: { paddingLeft: `${depth * 16 + 12}px` },
|
|
@@ -485,7 +723,7 @@ function FolderNode({ node, depth, currentFolder, dropTargetFolder, onFolderSele
|
|
|
485
723
|
children: node.name
|
|
486
724
|
}),
|
|
487
725
|
/* @__PURE__ */ jsxs("span", {
|
|
488
|
-
className: "text-grey-05 text-xs",
|
|
726
|
+
className: "text-grey-05 dark:text-grey-06 text-xs",
|
|
489
727
|
children: [
|
|
490
728
|
"(",
|
|
491
729
|
node.assetCount,
|
|
@@ -515,33 +753,33 @@ function FolderTreeSidebar({ currentFolder, onFolderSelect, dropTargetFolder })
|
|
|
515
753
|
};
|
|
516
754
|
const rootAssetCount = rawTree.length === 1 && rawTree[0].path === "/" ? rawTree[0].assetCount : tree.reduce((sum, node) => sum + node.assetCount, 0);
|
|
517
755
|
return /* @__PURE__ */ jsxs("div", {
|
|
518
|
-
className: "w-56 flex-shrink-0 border-r border-grey-09 bg-white",
|
|
756
|
+
className: "w-56 flex-shrink-0 border-r border-grey-09 dark:border-grey-03 bg-white dark:bg-grey-02",
|
|
519
757
|
children: [
|
|
520
758
|
/* @__PURE__ */ jsxs("div", {
|
|
521
|
-
className: "flex items-center justify-between px-4 py-3 border-b border-grey-09",
|
|
759
|
+
className: "flex items-center justify-between px-4 py-3 border-b border-grey-09 dark:border-grey-03",
|
|
522
760
|
children: [/* @__PURE__ */ jsx("h3", {
|
|
523
|
-
className: "font-semibold text-grey-01",
|
|
761
|
+
className: "font-semibold text-grey-01 dark:text-grey-12",
|
|
524
762
|
children: "Folders"
|
|
525
763
|
}), /* @__PURE__ */ jsx("button", {
|
|
526
764
|
type: "button",
|
|
527
765
|
onClick: () => setShowCreateFolderDialog(true),
|
|
528
|
-
className: "p-1.5 rounded hover:bg-grey-11 transition-colors",
|
|
766
|
+
className: "p-1.5 rounded-md hover:bg-grey-11 dark:hover:bg-grey-03 transition-colors",
|
|
529
767
|
title: "New Folder",
|
|
530
|
-
children: /* @__PURE__ */ jsx(FolderPlus, { className: "w-4 h-4 text-grey-04" })
|
|
768
|
+
children: /* @__PURE__ */ jsx(FolderPlus, { className: "w-4 h-4 text-grey-04 dark:text-grey-07" })
|
|
531
769
|
})]
|
|
532
770
|
}),
|
|
533
771
|
/* @__PURE__ */ jsx("div", {
|
|
534
772
|
className: "p-2 overflow-y-auto",
|
|
535
773
|
style: { maxHeight: "calc(100vh - 200px)" },
|
|
536
774
|
children: isLoading ? /* @__PURE__ */ jsx("div", {
|
|
537
|
-
className: "text-sm text-grey-05 px-3 py-2",
|
|
775
|
+
className: "text-sm text-grey-05 dark:text-grey-06 px-3 py-2",
|
|
538
776
|
children: "Loading..."
|
|
539
777
|
}) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("button", {
|
|
540
778
|
type: "button",
|
|
541
779
|
onClick: () => onFolderSelect("/"),
|
|
542
|
-
className: cn
|
|
543
|
-
"bg-azure-11 text-azure-01": currentFolder === "/",
|
|
544
|
-
"hover:bg-grey-11": currentFolder !== "/",
|
|
780
|
+
className: cn("w-full flex items-center gap-2 py-1.5 px-3 rounded-md text-sm transition-colors text-left", {
|
|
781
|
+
"bg-azure-11 dark:bg-azure-03 text-azure-01 dark:text-azure-11": currentFolder === "/",
|
|
782
|
+
"hover:bg-grey-11 dark:hover:bg-grey-03": currentFolder !== "/",
|
|
545
783
|
"ring-2 ring-azure-04": dropTargetFolder === "/"
|
|
546
784
|
}),
|
|
547
785
|
children: [
|
|
@@ -551,7 +789,7 @@ function FolderTreeSidebar({ currentFolder, onFolderSelect, dropTargetFolder })
|
|
|
551
789
|
children: "Root"
|
|
552
790
|
}),
|
|
553
791
|
/* @__PURE__ */ jsxs("span", {
|
|
554
|
-
className: "text-grey-05 text-xs",
|
|
792
|
+
className: "text-grey-05 dark:text-grey-06 text-xs",
|
|
555
793
|
children: [
|
|
556
794
|
"(",
|
|
557
795
|
rootAssetCount,
|
|
@@ -566,7 +804,7 @@ function FolderTreeSidebar({ currentFolder, onFolderSelect, dropTargetFolder })
|
|
|
566
804
|
dropTargetFolder,
|
|
567
805
|
onFolderSelect
|
|
568
806
|
}, node.path)) : /* @__PURE__ */ jsx("div", {
|
|
569
|
-
className: "text-sm text-grey-05 px-3 py-2",
|
|
807
|
+
className: "text-sm text-grey-05 dark:text-grey-06 px-3 py-2",
|
|
570
808
|
children: "No folders yet"
|
|
571
809
|
})] })
|
|
572
810
|
}),
|
|
@@ -608,9 +846,9 @@ function AssetCard({ asset, isSelected, onClick, onDoubleClick, assetsBasePath =
|
|
|
608
846
|
},
|
|
609
847
|
role: "button",
|
|
610
848
|
tabIndex: 0,
|
|
611
|
-
className: cn
|
|
849
|
+
className: cn("group relative rounded-md overflow-hidden cursor-pointer transition-colors", "bg-white dark:bg-grey-02 hover:border-azure-04", isSelected ? "border-2 border-azure-04" : "border border-grey-09 dark:border-grey-03"),
|
|
612
850
|
children: [/* @__PURE__ */ jsx("div", {
|
|
613
|
-
className: "aspect-square bg-grey-11 flex items-center justify-center overflow-hidden",
|
|
851
|
+
className: "aspect-square bg-grey-11 dark:bg-grey-03 flex items-center justify-center overflow-hidden",
|
|
614
852
|
children: /* @__PURE__ */ jsx("img", {
|
|
615
853
|
src: buildAssetServeUrl(assetsBasePath, asset.folder, asset.filename),
|
|
616
854
|
alt: asset.alt || asset.originalName,
|
|
@@ -620,7 +858,7 @@ function AssetCard({ asset, isSelected, onClick, onDoubleClick, assetsBasePath =
|
|
|
620
858
|
}), /* @__PURE__ */ jsx("div", {
|
|
621
859
|
className: "px-2 py-1.5",
|
|
622
860
|
children: /* @__PURE__ */ jsx("p", {
|
|
623
|
-
className: "text-xs text-grey-01 truncate",
|
|
861
|
+
className: "text-xs text-grey-01 dark:text-grey-12 truncate",
|
|
624
862
|
title: asset.originalName,
|
|
625
863
|
children: asset.originalName
|
|
626
864
|
})
|
|
@@ -635,19 +873,21 @@ function MediaToolbar({ search, onSearchChange, fileType, onFileTypeChange, sort
|
|
|
635
873
|
className: "flex items-center gap-3 flex-wrap",
|
|
636
874
|
children: [
|
|
637
875
|
/* @__PURE__ */ jsxs("div", {
|
|
638
|
-
className: "relative flex-1 min-w-[
|
|
639
|
-
children: [/* @__PURE__ */ jsx(Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-grey-04" }), /* @__PURE__ */ jsx(
|
|
876
|
+
className: "relative flex-1 min-w-[150px]",
|
|
877
|
+
children: [/* @__PURE__ */ jsx(Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-grey-04 dark:text-grey-07 z-10" }), /* @__PURE__ */ jsx(Input, {
|
|
878
|
+
size: "sm",
|
|
640
879
|
type: "text",
|
|
641
880
|
value: search,
|
|
642
881
|
onChange: (e) => onSearchChange(e.target.value),
|
|
643
882
|
placeholder: "Search files...",
|
|
644
|
-
className: "
|
|
883
|
+
className: "pl-9"
|
|
645
884
|
})]
|
|
646
885
|
}),
|
|
647
|
-
/* @__PURE__ */ jsxs(
|
|
886
|
+
/* @__PURE__ */ jsxs(Select, {
|
|
887
|
+
size: "sm",
|
|
648
888
|
value: fileType,
|
|
649
889
|
onChange: (e) => onFileTypeChange(e.target.value),
|
|
650
|
-
className: "
|
|
890
|
+
className: "w-auto shrink-0",
|
|
651
891
|
children: [
|
|
652
892
|
/* @__PURE__ */ jsx("option", {
|
|
653
893
|
value: "all",
|
|
@@ -663,10 +903,11 @@ function MediaToolbar({ search, onSearchChange, fileType, onFileTypeChange, sort
|
|
|
663
903
|
})
|
|
664
904
|
]
|
|
665
905
|
}),
|
|
666
|
-
/* @__PURE__ */ jsxs(
|
|
906
|
+
/* @__PURE__ */ jsxs(Select, {
|
|
907
|
+
size: "sm",
|
|
667
908
|
value: sort,
|
|
668
909
|
onChange: (e) => onSortChange(e.target.value),
|
|
669
|
-
className: "
|
|
910
|
+
className: "w-auto shrink-0",
|
|
670
911
|
children: [
|
|
671
912
|
/* @__PURE__ */ jsx("option", {
|
|
672
913
|
value: "date-newest",
|
|
@@ -694,21 +935,22 @@ function MediaToolbar({ search, onSearchChange, fileType, onFileTypeChange, sort
|
|
|
694
935
|
})
|
|
695
936
|
]
|
|
696
937
|
}),
|
|
697
|
-
isSelectMode ? /* @__PURE__ */ jsx(
|
|
698
|
-
|
|
938
|
+
isSelectMode ? /* @__PURE__ */ jsx(Button, {
|
|
939
|
+
variant: "primary",
|
|
940
|
+
size: "sm",
|
|
699
941
|
onClick: onExitSelectMode,
|
|
700
|
-
className: "px-3 py-2 bg-azure-04 text-white rounded text-sm hover:bg-azure-03 transition-colors",
|
|
701
942
|
children: "Done"
|
|
702
|
-
}) : onEnterSelectMode && /* @__PURE__ */ jsx(
|
|
703
|
-
|
|
943
|
+
}) : onEnterSelectMode && /* @__PURE__ */ jsx(Button, {
|
|
944
|
+
variant: "outline",
|
|
945
|
+
size: "sm",
|
|
704
946
|
onClick: onEnterSelectMode,
|
|
705
|
-
className: "px-3 py-2 border border-grey-09 rounded text-sm bg-white hover:bg-grey-11 transition-colors",
|
|
706
947
|
children: "Select"
|
|
707
948
|
}),
|
|
708
|
-
onUploadClick && /* @__PURE__ */ jsxs(
|
|
709
|
-
|
|
949
|
+
onUploadClick && /* @__PURE__ */ jsxs(Button, {
|
|
950
|
+
variant: "primary",
|
|
951
|
+
size: "sm",
|
|
710
952
|
onClick: onUploadClick,
|
|
711
|
-
className: "flex items-center gap-2
|
|
953
|
+
className: "flex items-center gap-2",
|
|
712
954
|
children: [/* @__PURE__ */ jsx(Upload, { className: "w-4 h-4" }), "Upload"]
|
|
713
955
|
})
|
|
714
956
|
]
|
|
@@ -842,23 +1084,23 @@ function UploadModal({ isOpen, onClose, folder, onUploadComplete }) {
|
|
|
842
1084
|
}, [isOpen, reset]);
|
|
843
1085
|
if (!isOpen) return null;
|
|
844
1086
|
return /* @__PURE__ */ jsx("div", {
|
|
845
|
-
className: "fixed inset-0 bg-black/50 flex items-center justify-center z-50",
|
|
1087
|
+
className: "fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50",
|
|
846
1088
|
onClick: (e) => {
|
|
847
1089
|
if (e.target === e.currentTarget) onClose();
|
|
848
1090
|
},
|
|
849
1091
|
children: /* @__PURE__ */ jsxs("div", {
|
|
850
|
-
className: "bg-
|
|
1092
|
+
className: "bg-overlay rounded-lg w-full max-w-md mx-4 shadow-xl",
|
|
851
1093
|
children: [
|
|
852
1094
|
/* @__PURE__ */ jsxs("div", {
|
|
853
|
-
className: "flex items-center justify-between px-6 py-4 border-b border-
|
|
1095
|
+
className: "flex items-center justify-between px-6 py-4 border-b border-line",
|
|
854
1096
|
children: [/* @__PURE__ */ jsx("h2", {
|
|
855
|
-
className: "text-lg font-semibold text-grey-01",
|
|
1097
|
+
className: "text-lg font-semibold text-grey-01 dark:text-grey-12",
|
|
856
1098
|
children: "Upload Assets"
|
|
857
|
-
}), /* @__PURE__ */ jsx(
|
|
858
|
-
|
|
1099
|
+
}), /* @__PURE__ */ jsx(IconButton, {
|
|
1100
|
+
icon: X,
|
|
1101
|
+
ariaLabel: "Close",
|
|
859
1102
|
onClick: onClose,
|
|
860
|
-
|
|
861
|
-
children: /* @__PURE__ */ jsx(X, { className: "w-5 h-5" })
|
|
1103
|
+
variant: "ghost"
|
|
862
1104
|
})]
|
|
863
1105
|
}),
|
|
864
1106
|
/* @__PURE__ */ jsxs("div", {
|
|
@@ -866,23 +1108,23 @@ function UploadModal({ isOpen, onClose, folder, onUploadComplete }) {
|
|
|
866
1108
|
children: [
|
|
867
1109
|
/* @__PURE__ */ jsxs("div", {
|
|
868
1110
|
className: "flex gap-2 mb-4",
|
|
869
|
-
children: [/* @__PURE__ */ jsx(
|
|
870
|
-
|
|
1111
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
1112
|
+
variant: activeTab === "file" ? "primary" : "outline",
|
|
1113
|
+
size: "sm",
|
|
871
1114
|
onClick: () => setActiveTab("file"),
|
|
872
|
-
className: cn$1("px-3 py-1.5 text-sm rounded transition-colors", activeTab === "file" ? "bg-azure-04 text-white" : "bg-white border border-grey-09 text-grey-04 hover:bg-grey-11"),
|
|
873
1115
|
children: "Upload File"
|
|
874
|
-
}), /* @__PURE__ */ jsx(
|
|
875
|
-
|
|
1116
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1117
|
+
variant: activeTab === "url" ? "primary" : "outline",
|
|
1118
|
+
size: "sm",
|
|
876
1119
|
onClick: () => setActiveTab("url"),
|
|
877
|
-
className: cn$1("px-3 py-1.5 text-sm rounded transition-colors", activeTab === "url" ? "bg-azure-04 text-white" : "bg-white border border-grey-09 text-grey-04 hover:bg-grey-11"),
|
|
878
1120
|
children: "Import URL"
|
|
879
1121
|
})]
|
|
880
1122
|
}),
|
|
881
1123
|
activeTab === "file" && /* @__PURE__ */ jsxs(Fragment, { children: [uploadProgress && /* @__PURE__ */ jsxs("div", {
|
|
882
|
-
className: "mb-4 p-3 bg-
|
|
1124
|
+
className: "mb-4 p-3 bg-subtle rounded-md border border-line",
|
|
883
1125
|
children: [
|
|
884
1126
|
/* @__PURE__ */ jsx("p", {
|
|
885
|
-
className: "text-sm font-medium text-grey-01",
|
|
1127
|
+
className: "text-sm font-medium text-grey-01 dark:text-grey-12",
|
|
886
1128
|
children: uploadProgress.inProgress ? `Uploading ${uploadProgress.total} files...` : `Upload complete: ${uploadProgress.completed}/${uploadProgress.total} succeeded`
|
|
887
1129
|
}),
|
|
888
1130
|
uploadProgress.failed > 0 && /* @__PURE__ */ jsxs("p", {
|
|
@@ -890,9 +1132,9 @@ function UploadModal({ isOpen, onClose, folder, onUploadComplete }) {
|
|
|
890
1132
|
children: [uploadProgress.failed, " file(s) failed to upload"]
|
|
891
1133
|
}),
|
|
892
1134
|
/* @__PURE__ */ jsx("div", {
|
|
893
|
-
className: "mt-2 h-2 bg-grey-09 rounded overflow-hidden",
|
|
1135
|
+
className: "mt-2 h-2 bg-grey-09 rounded-md overflow-hidden",
|
|
894
1136
|
children: /* @__PURE__ */ jsx("div", {
|
|
895
|
-
className: cn
|
|
1137
|
+
className: cn("h-full transition-all", uploadProgress.failed > 0 ? "bg-yellow-06" : "bg-azure-04"),
|
|
896
1138
|
style: { width: `${(uploadProgress.completed + uploadProgress.failed) / uploadProgress.total * 100}%` }
|
|
897
1139
|
})
|
|
898
1140
|
})
|
|
@@ -902,7 +1144,7 @@ function UploadModal({ isOpen, onClose, folder, onUploadComplete }) {
|
|
|
902
1144
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
903
1145
|
className: "flex items-center gap-3",
|
|
904
1146
|
children: [/* @__PURE__ */ jsx("div", {
|
|
905
|
-
className: "w-16 h-16 bg-grey-09 rounded overflow-hidden flex-shrink-0",
|
|
1147
|
+
className: "w-16 h-16 bg-grey-09 rounded-md overflow-hidden flex-shrink-0",
|
|
906
1148
|
children: /* @__PURE__ */ jsx("img", {
|
|
907
1149
|
src: previewUrl,
|
|
908
1150
|
alt: "Preview",
|
|
@@ -911,30 +1153,30 @@ function UploadModal({ isOpen, onClose, folder, onUploadComplete }) {
|
|
|
911
1153
|
}), /* @__PURE__ */ jsxs("div", {
|
|
912
1154
|
className: "flex-1 min-w-0",
|
|
913
1155
|
children: [/* @__PURE__ */ jsx("p", {
|
|
914
|
-
className: "text-sm font-medium text-grey-01 truncate",
|
|
1156
|
+
className: "text-sm font-medium text-grey-01 dark:text-grey-12 truncate",
|
|
915
1157
|
children: pendingFile.name
|
|
916
1158
|
}), /* @__PURE__ */ jsxs("p", {
|
|
917
|
-
className: "text-xs text-grey-04",
|
|
1159
|
+
className: "text-xs text-grey-04 dark:text-grey-07",
|
|
918
1160
|
children: [(pendingFile.size / 1024).toFixed(1), " KB"]
|
|
919
1161
|
})]
|
|
920
1162
|
})]
|
|
921
1163
|
}), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
|
|
922
1164
|
htmlFor: "alt-text",
|
|
923
|
-
className: "block text-xs text-grey-04 uppercase tracking-wide mb-1",
|
|
1165
|
+
className: "block text-xs text-grey-04 dark:text-grey-07 uppercase tracking-wide mb-1",
|
|
924
1166
|
children: "Alt Text"
|
|
925
|
-
}), /* @__PURE__ */ jsx(
|
|
1167
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
1168
|
+
size: "sm",
|
|
926
1169
|
id: "alt-text",
|
|
927
1170
|
type: "text",
|
|
928
1171
|
value: altText,
|
|
929
1172
|
onChange: (e) => setAltText(e.target.value),
|
|
930
|
-
placeholder: "Describe the image for accessibility"
|
|
931
|
-
className: "w-full px-3 py-2 border border-grey-09 rounded text-sm focus:outline-none focus:ring-2 focus:ring-azure-04 focus:border-azure-04"
|
|
1173
|
+
placeholder: "Describe the image for accessibility"
|
|
932
1174
|
})] })]
|
|
933
1175
|
}) : /* @__PURE__ */ jsxs("div", {
|
|
934
1176
|
onDragOver: handleDragOver,
|
|
935
1177
|
onDragLeave: handleDragLeave,
|
|
936
1178
|
onDrop: handleDrop,
|
|
937
|
-
className: cn
|
|
1179
|
+
className: cn("border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors bg-subtle", isDragOver ? "border-azure-04 bg-azure-11 dark:bg-azure-02" : "border-line hover:border-grey-07"),
|
|
938
1180
|
onClick: () => fileInputRef.current?.click(),
|
|
939
1181
|
onKeyDown: (e) => {
|
|
940
1182
|
if (e.key === "Enter" || e.key === " ") {
|
|
@@ -945,9 +1187,9 @@ function UploadModal({ isOpen, onClose, folder, onUploadComplete }) {
|
|
|
945
1187
|
role: "button",
|
|
946
1188
|
tabIndex: 0,
|
|
947
1189
|
children: [
|
|
948
|
-
/* @__PURE__ */ jsx(Upload, { className: "mx-auto h-10 w-10 text-grey-04" }),
|
|
1190
|
+
/* @__PURE__ */ jsx(Upload, { className: "mx-auto h-10 w-10 text-grey-04 dark:text-grey-07" }),
|
|
949
1191
|
/* @__PURE__ */ jsx("p", {
|
|
950
|
-
className: "mt-2 text-sm text-grey-04",
|
|
1192
|
+
className: "mt-2 text-sm text-grey-04 dark:text-grey-07",
|
|
951
1193
|
children: "Drag and drop images here, or click to browse"
|
|
952
1194
|
}),
|
|
953
1195
|
/* @__PURE__ */ jsx("p", {
|
|
@@ -968,26 +1210,26 @@ function UploadModal({ isOpen, onClose, folder, onUploadComplete }) {
|
|
|
968
1210
|
className: "space-y-4",
|
|
969
1211
|
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
|
|
970
1212
|
htmlFor: "import-url",
|
|
971
|
-
className: "block text-xs text-grey-04 uppercase tracking-wide mb-1",
|
|
1213
|
+
className: "block text-xs text-grey-04 dark:text-grey-07 uppercase tracking-wide mb-1",
|
|
972
1214
|
children: "Image URL"
|
|
973
|
-
}), /* @__PURE__ */ jsx(
|
|
1215
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
1216
|
+
size: "sm",
|
|
974
1217
|
id: "import-url",
|
|
975
1218
|
type: "url",
|
|
976
1219
|
value: importUrl,
|
|
977
1220
|
onChange: (e) => setImportUrl(e.target.value),
|
|
978
|
-
placeholder: "https://example.com/image.jpg"
|
|
979
|
-
className: "w-full px-3 py-2 border border-grey-09 rounded text-sm focus:outline-none focus:ring-2 focus:ring-azure-04 focus:border-azure-04"
|
|
1221
|
+
placeholder: "https://example.com/image.jpg"
|
|
980
1222
|
})] }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
|
|
981
1223
|
htmlFor: "url-alt-text",
|
|
982
|
-
className: "block text-xs text-grey-04 uppercase tracking-wide mb-1",
|
|
1224
|
+
className: "block text-xs text-grey-04 dark:text-grey-07 uppercase tracking-wide mb-1",
|
|
983
1225
|
children: "Alt Text"
|
|
984
|
-
}), /* @__PURE__ */ jsx(
|
|
1226
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
1227
|
+
size: "sm",
|
|
985
1228
|
id: "url-alt-text",
|
|
986
1229
|
type: "text",
|
|
987
1230
|
value: altText,
|
|
988
1231
|
onChange: (e) => setAltText(e.target.value),
|
|
989
|
-
placeholder: "Describe the image for accessibility"
|
|
990
|
-
className: "w-full px-3 py-2 border border-grey-09 rounded text-sm focus:outline-none focus:ring-2 focus:ring-azure-04 focus:border-azure-04"
|
|
1232
|
+
placeholder: "Describe the image for accessibility"
|
|
991
1233
|
})] })]
|
|
992
1234
|
}),
|
|
993
1235
|
error && /* @__PURE__ */ jsx("p", {
|
|
@@ -997,24 +1239,26 @@ function UploadModal({ isOpen, onClose, folder, onUploadComplete }) {
|
|
|
997
1239
|
]
|
|
998
1240
|
}),
|
|
999
1241
|
/* @__PURE__ */ jsxs("div", {
|
|
1000
|
-
className: "flex items-center justify-end gap-3 px-6 py-4 border-t border-
|
|
1001
|
-
children: [/* @__PURE__ */ jsx(
|
|
1002
|
-
|
|
1242
|
+
className: "flex items-center justify-end gap-3 px-6 py-4 border-t border-line bg-subtle rounded-b-lg",
|
|
1243
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
1244
|
+
variant: "outline",
|
|
1245
|
+
size: "sm",
|
|
1003
1246
|
onClick: pendingFile ? handleCancel : onClose,
|
|
1004
1247
|
disabled: isUploading,
|
|
1005
|
-
className: "px-4 py-2 bg-white border border-grey-09 text-grey-04 text-sm rounded hover:bg-grey-11 disabled:opacity-50 transition-colors",
|
|
1006
1248
|
children: pendingFile ? "Clear" : "Cancel"
|
|
1007
|
-
}), activeTab === "file" ? /* @__PURE__ */ jsxs(
|
|
1008
|
-
|
|
1249
|
+
}), activeTab === "file" ? /* @__PURE__ */ jsxs(Button, {
|
|
1250
|
+
variant: "primary",
|
|
1251
|
+
size: "sm",
|
|
1009
1252
|
onClick: handleUpload,
|
|
1010
1253
|
disabled: isUploading || !pendingFile,
|
|
1011
|
-
className: "flex items-center gap-2
|
|
1254
|
+
className: "flex items-center gap-2",
|
|
1012
1255
|
children: [/* @__PURE__ */ jsx(Upload, { className: "w-4 h-4" }), uploadMutationIsPending ? "Uploading..." : "Upload"]
|
|
1013
|
-
}) : /* @__PURE__ */ jsxs(
|
|
1014
|
-
|
|
1256
|
+
}) : /* @__PURE__ */ jsxs(Button, {
|
|
1257
|
+
variant: "primary",
|
|
1258
|
+
size: "sm",
|
|
1015
1259
|
onClick: handleImportUrl,
|
|
1016
1260
|
disabled: isUploading || !importUrl.trim(),
|
|
1017
|
-
className: "flex items-center gap-2
|
|
1261
|
+
className: "flex items-center gap-2",
|
|
1018
1262
|
children: [/* @__PURE__ */ jsx(Upload, { className: "w-4 h-4" }), importMutationIsPending ? "Importing..." : "Import"]
|
|
1019
1263
|
})]
|
|
1020
1264
|
})
|
|
@@ -1049,28 +1293,28 @@ function ImagePicker({ isOpen, onSelect, onClose }) {
|
|
|
1049
1293
|
if (e.target === e.currentTarget) onClose();
|
|
1050
1294
|
};
|
|
1051
1295
|
return /* @__PURE__ */ jsxs("div", {
|
|
1052
|
-
className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50",
|
|
1296
|
+
className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",
|
|
1053
1297
|
onClick: handleBackdropClick,
|
|
1054
1298
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
1055
|
-
className: "bg-
|
|
1299
|
+
className: "bg-overlay rounded-lg shadow-xl w-full max-w-5xl max-h-[85vh] mx-4 flex flex-col overflow-hidden",
|
|
1056
1300
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
1057
|
-
className: "flex items-center justify-between px-6 py-4 border-b border-
|
|
1301
|
+
className: "flex items-center justify-between px-6 py-4 border-b border-line flex-shrink-0",
|
|
1058
1302
|
children: [/* @__PURE__ */ jsx("h2", {
|
|
1059
|
-
className: "text-lg font-semibold text-grey-01",
|
|
1303
|
+
className: "text-lg font-semibold text-grey-01 dark:text-grey-12",
|
|
1060
1304
|
children: "Select Image"
|
|
1061
1305
|
}), /* @__PURE__ */ jsxs("div", {
|
|
1062
1306
|
className: "flex items-center gap-2",
|
|
1063
|
-
children: [/* @__PURE__ */ jsxs(
|
|
1064
|
-
|
|
1307
|
+
children: [/* @__PURE__ */ jsxs(Button, {
|
|
1308
|
+
variant: "primary",
|
|
1309
|
+
size: "sm",
|
|
1065
1310
|
onClick: () => setShowUpload(true),
|
|
1066
|
-
className: "flex items-center gap-2
|
|
1311
|
+
className: "flex items-center gap-2",
|
|
1067
1312
|
children: [/* @__PURE__ */ jsx(Upload, { className: "w-4 h-4" }), "Upload"]
|
|
1068
|
-
}), /* @__PURE__ */ jsx(
|
|
1069
|
-
|
|
1313
|
+
}), /* @__PURE__ */ jsx(IconButton, {
|
|
1314
|
+
icon: X,
|
|
1315
|
+
ariaLabel: "Close",
|
|
1070
1316
|
onClick: onClose,
|
|
1071
|
-
|
|
1072
|
-
"aria-label": "Close",
|
|
1073
|
-
children: /* @__PURE__ */ jsx(X, { className: "w-5 h-5" })
|
|
1317
|
+
variant: "ghost"
|
|
1074
1318
|
})]
|
|
1075
1319
|
})]
|
|
1076
1320
|
}), /* @__PURE__ */ jsxs("div", {
|
|
@@ -1123,283 +1367,85 @@ function ImagePickerDialog() {
|
|
|
1123
1367
|
|
|
1124
1368
|
//#endregion
|
|
1125
1369
|
//#region src/components/editor/CMSMDXEditor.tsx
|
|
1126
|
-
|
|
1127
|
-
* Error Boundary for catching React errors in MDXEditor.
|
|
1128
|
-
* Prevents editor crashes from breaking the entire CMS.
|
|
1129
|
-
*/
|
|
1130
|
-
var MDXEditorErrorBoundary = class extends React.Component {
|
|
1131
|
-
constructor(props) {
|
|
1132
|
-
super(props);
|
|
1133
|
-
this.state = { hasError: false };
|
|
1134
|
-
}
|
|
1135
|
-
static getDerivedStateFromError(error) {
|
|
1136
|
-
return {
|
|
1137
|
-
hasError: true,
|
|
1138
|
-
error
|
|
1139
|
-
};
|
|
1140
|
-
}
|
|
1141
|
-
componentDidCatch(error, errorInfo) {
|
|
1142
|
-
console.error("[CMSMDXEditor] Error boundary caught:", error, errorInfo);
|
|
1143
|
-
}
|
|
1144
|
-
render() {
|
|
1145
|
-
if (this.state.hasError) return /* @__PURE__ */ jsxs("div", {
|
|
1146
|
-
className: "p-4 bg-red-50 border border-red-200 rounded text-red-600",
|
|
1147
|
-
children: [
|
|
1148
|
-
/* @__PURE__ */ jsx("p", {
|
|
1149
|
-
className: "font-semibold mb-2",
|
|
1150
|
-
children: "MDXEditor Error"
|
|
1151
|
-
}),
|
|
1152
|
-
/* @__PURE__ */ jsx("p", {
|
|
1153
|
-
className: "text-sm mb-2",
|
|
1154
|
-
children: this.state.error?.message || "Unknown error occurred"
|
|
1155
|
-
}),
|
|
1156
|
-
/* @__PURE__ */ jsxs("details", {
|
|
1157
|
-
className: "text-xs",
|
|
1158
|
-
children: [/* @__PURE__ */ jsx("summary", {
|
|
1159
|
-
className: "cursor-pointer font-medium",
|
|
1160
|
-
children: "Stack Trace"
|
|
1161
|
-
}), /* @__PURE__ */ jsx("pre", {
|
|
1162
|
-
className: "mt-2 p-2 bg-red-100 rounded overflow-auto whitespace-pre-wrap",
|
|
1163
|
-
children: this.state.error?.stack
|
|
1164
|
-
})]
|
|
1165
|
-
})
|
|
1166
|
-
]
|
|
1167
|
-
});
|
|
1168
|
-
return this.props.children;
|
|
1169
|
-
}
|
|
1170
|
-
};
|
|
1171
|
-
/**
|
|
1172
|
-
* CMS-integrated MDX Editor with Media Library image picker.
|
|
1173
|
-
* This component wraps MDXEditor with ImagePickerDialog and keyboard shortcuts.
|
|
1174
|
-
*/
|
|
1175
|
-
const CMSMDXEditor = React.forwardRef(({ value, onChange, onSave, readOnly = false }, ref) => {
|
|
1370
|
+
const CMSMDXEditor = forwardRef((props, ref) => {
|
|
1176
1371
|
const insertImageRef = useRef(null);
|
|
1177
|
-
|
|
1178
|
-
const handleKeyDown = (e) => {
|
|
1179
|
-
if ((e.ctrlKey || e.metaKey) && e.key === "s") {
|
|
1180
|
-
e.preventDefault();
|
|
1181
|
-
if (onSave) onSave(value);
|
|
1182
|
-
}
|
|
1183
|
-
if ((e.ctrlKey || e.metaKey) && e.shiftKey && e.key.toLowerCase() === "i") {
|
|
1184
|
-
e.preventDefault();
|
|
1185
|
-
if (insertImageRef.current) insertImageRef.current.click();
|
|
1186
|
-
else console.warn("[CMSMDXEditor] InsertImage ref not attached — toolbar may not be rendered");
|
|
1187
|
-
}
|
|
1188
|
-
};
|
|
1189
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
1190
|
-
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
1191
|
-
}, [value, onSave]);
|
|
1192
|
-
return /* @__PURE__ */ jsx(MDXEditor, {
|
|
1372
|
+
return /* @__PURE__ */ jsx(BaseMDXEditor, {
|
|
1193
1373
|
ref,
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
thematicBreakPlugin(),
|
|
1206
|
-
frontmatterPlugin(),
|
|
1207
|
-
codeBlockPlugin({ defaultCodeBlockLanguage: "ts" }),
|
|
1208
|
-
codeMirrorPlugin({ codeBlockLanguages: {
|
|
1209
|
-
text: "Plain Text",
|
|
1210
|
-
js: "JavaScript",
|
|
1211
|
-
jsx: "JavaScript (React)",
|
|
1212
|
-
ts: "TypeScript",
|
|
1213
|
-
tsx: "TypeScript (React)",
|
|
1214
|
-
css: "CSS",
|
|
1215
|
-
html: "HTML",
|
|
1216
|
-
json: "JSON",
|
|
1217
|
-
md: "Markdown",
|
|
1218
|
-
mdx: "MDX",
|
|
1219
|
-
bash: "Bash",
|
|
1220
|
-
python: "Python"
|
|
1221
|
-
} }),
|
|
1222
|
-
diffSourcePlugin({ viewMode: "rich-text" }),
|
|
1223
|
-
markdownShortcutPlugin(),
|
|
1224
|
-
jsxPlugin(),
|
|
1225
|
-
imagePlugin({
|
|
1226
|
-
ImageDialog: ImagePickerDialog,
|
|
1227
|
-
disableImageSettingsButton: true
|
|
1228
|
-
}),
|
|
1229
|
-
toolbarPlugin({ toolbarContents: () => /* @__PURE__ */ jsxs(DiffSourceToggleWrapper, { children: [
|
|
1230
|
-
/* @__PURE__ */ jsx(UndoRedo, {}),
|
|
1231
|
-
/* @__PURE__ */ jsx(Separator, {}),
|
|
1232
|
-
/* @__PURE__ */ jsx(BoldItalicUnderlineToggles, {}),
|
|
1233
|
-
/* @__PURE__ */ jsx(Separator, {}),
|
|
1234
|
-
/* @__PURE__ */ jsx(ListsToggle, {}),
|
|
1235
|
-
/* @__PURE__ */ jsx(Separator, {}),
|
|
1236
|
-
/* @__PURE__ */ jsx(BlockTypeSelect, {}),
|
|
1237
|
-
/* @__PURE__ */ jsx(Separator, {}),
|
|
1238
|
-
/* @__PURE__ */ jsx(CreateLink, {}),
|
|
1239
|
-
React.createElement(InsertImage, { ref: insertImageRef }),
|
|
1240
|
-
/* @__PURE__ */ jsx(InsertTable, {}),
|
|
1241
|
-
/* @__PURE__ */ jsx(InsertThematicBreak, {}),
|
|
1242
|
-
/* @__PURE__ */ jsx(Separator, {}),
|
|
1243
|
-
/* @__PURE__ */ jsx(InsertCodeBlock, {})
|
|
1244
|
-
] }) })
|
|
1245
|
-
]
|
|
1374
|
+
...props,
|
|
1375
|
+
imageDialog: ImagePickerDialog,
|
|
1376
|
+
disableImageSettingsButton: true,
|
|
1377
|
+
imageButtonRef: insertImageRef,
|
|
1378
|
+
onImageShortcut: () => {
|
|
1379
|
+
if (insertImageRef.current) {
|
|
1380
|
+
insertImageRef.current.click();
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
console.warn("[CMSMDXEditor] InsertImage ref not attached - toolbar may not be rendered");
|
|
1384
|
+
}
|
|
1246
1385
|
});
|
|
1247
1386
|
});
|
|
1248
1387
|
CMSMDXEditor.displayName = "CMSMDXEditor";
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
}, 10);
|
|
1262
|
-
return () => clearTimeout(timer);
|
|
1263
|
-
}, []);
|
|
1264
|
-
if (!isReady) return /* @__PURE__ */ jsx("div", {
|
|
1265
|
-
className: "flex items-center justify-center h-full text-gray-500",
|
|
1266
|
-
"data-testid": "deferred-editor-loading",
|
|
1267
|
-
children: "Initializing editor..."
|
|
1268
|
-
});
|
|
1269
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1270
|
-
"data-testid": "deferred-editor-ready",
|
|
1271
|
-
children: /* @__PURE__ */ jsx(CMSMDXEditor, {
|
|
1272
|
-
ref: editorRef,
|
|
1273
|
-
value,
|
|
1274
|
-
onChange,
|
|
1275
|
-
onSave,
|
|
1276
|
-
readOnly
|
|
1277
|
-
})
|
|
1278
|
-
});
|
|
1279
|
-
};
|
|
1280
|
-
const Dialog = ({ open, onOpenChange, children }) => {
|
|
1281
|
-
if (!open) return null;
|
|
1282
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
1283
|
-
className: "fixed inset-0 z-50 flex items-center justify-center",
|
|
1284
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
1285
|
-
className: "fixed inset-0 bg-black/50",
|
|
1286
|
-
onClick: () => onOpenChange(false)
|
|
1287
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
1288
|
-
className: "relative z-50 bg-white rounded-lg shadow-lg max-w-[90vw] max-h-[90vh] overflow-hidden",
|
|
1289
|
-
children
|
|
1290
|
-
})]
|
|
1291
|
-
});
|
|
1292
|
-
};
|
|
1293
|
-
const DialogContent = ({ children, className = "" }) => {
|
|
1294
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1295
|
-
className: `p-6 ${className}`,
|
|
1296
|
-
children
|
|
1297
|
-
});
|
|
1298
|
-
};
|
|
1299
|
-
const DialogHeader = ({ children }) => {
|
|
1300
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1301
|
-
className: "mb-4",
|
|
1302
|
-
children
|
|
1303
|
-
});
|
|
1304
|
-
};
|
|
1305
|
-
const DialogTitle = ({ children }) => {
|
|
1306
|
-
return /* @__PURE__ */ jsx("h2", {
|
|
1307
|
-
className: "text-xl font-semibold",
|
|
1308
|
-
children
|
|
1309
|
-
});
|
|
1310
|
-
};
|
|
1311
|
-
/**
|
|
1312
|
-
* Modal wrapper for CMSMDXEditor with integrated Media Library image picker.
|
|
1313
|
-
* Use this instead of MDXEditorModal from @conloca/mdx when you need the image picker.
|
|
1314
|
-
*/
|
|
1315
|
-
const CMSMDXEditorModal = ({ isOpen, onClose, filePath, initialContent, onSave, headerExtra, onBeforeClose }) => {
|
|
1316
|
-
const [content, setContent] = useState(initialContent);
|
|
1317
|
-
const [isEditorReady, setIsEditorReady] = useState(false);
|
|
1318
|
-
const [isSaving, setIsSaving] = useState(false);
|
|
1319
|
-
useEffect(() => {
|
|
1320
|
-
setContent(initialContent);
|
|
1321
|
-
}, [initialContent]);
|
|
1322
|
-
const handleClose = () => {
|
|
1323
|
-
if (onBeforeClose && !onBeforeClose()) return;
|
|
1324
|
-
onClose();
|
|
1325
|
-
};
|
|
1326
|
-
useEffect(() => {
|
|
1327
|
-
if (isOpen) {
|
|
1328
|
-
const timer = setTimeout(() => {
|
|
1329
|
-
setIsEditorReady(true);
|
|
1330
|
-
}, 0);
|
|
1331
|
-
return () => clearTimeout(timer);
|
|
1332
|
-
}
|
|
1333
|
-
setIsEditorReady(false);
|
|
1334
|
-
}, [isOpen]);
|
|
1335
|
-
const handleSave = async () => {
|
|
1336
|
-
setIsSaving(true);
|
|
1337
|
-
try {
|
|
1338
|
-
await onSave(content);
|
|
1339
|
-
handleClose();
|
|
1340
|
-
} catch (error) {
|
|
1341
|
-
console.error("Save failed:", error);
|
|
1342
|
-
} finally {
|
|
1343
|
-
setIsSaving(false);
|
|
1344
|
-
}
|
|
1388
|
+
function CMSMDXHeaderTools({ setContent, editorRef, filePath, initialTemplateId }) {
|
|
1389
|
+
const [selectedSnippetId, setSelectedSnippetId] = useState(contentBlockSnippets[0]?.id || "");
|
|
1390
|
+
const selectedTemplate = useMemo(() => getContentBlockTemplate(initialTemplateId), [initialTemplateId]);
|
|
1391
|
+
const handleInsertSnippet = () => {
|
|
1392
|
+
const snippet = contentBlockSnippets.find((item) => item.id === selectedSnippetId);
|
|
1393
|
+
if (!snippet) return;
|
|
1394
|
+
setContent((current) => {
|
|
1395
|
+
const trimmed = current.trimEnd();
|
|
1396
|
+
const newContent = trimmed ? `${trimmed}\n\n${snippet.content}` : snippet.content;
|
|
1397
|
+
editorRef.current?.setMarkdown(newContent);
|
|
1398
|
+
return newContent;
|
|
1399
|
+
});
|
|
1345
1400
|
};
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
children: "Cancel"
|
|
1392
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
1393
|
-
onClick: handleSave,
|
|
1394
|
-
className: "px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed",
|
|
1395
|
-
disabled: isSaving,
|
|
1396
|
-
children: isSaving ? "Saving..." : "Save"
|
|
1397
|
-
})]
|
|
1398
|
-
})
|
|
1399
|
-
]
|
|
1401
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1402
|
+
/* @__PURE__ */ jsx("span", {
|
|
1403
|
+
className: "hidden text-xs text-grey-04 xl:inline",
|
|
1404
|
+
children: "Cmd/Ctrl+S to save"
|
|
1405
|
+
}),
|
|
1406
|
+
/* @__PURE__ */ jsx(Select, {
|
|
1407
|
+
size: "sm",
|
|
1408
|
+
value: selectedSnippetId,
|
|
1409
|
+
onChange: (event) => setSelectedSnippetId(event.target.value),
|
|
1410
|
+
className: "w-auto",
|
|
1411
|
+
children: contentBlockSnippets.map((snippet) => /* @__PURE__ */ jsx("option", {
|
|
1412
|
+
value: snippet.id,
|
|
1413
|
+
children: snippet.label
|
|
1414
|
+
}, snippet.id))
|
|
1415
|
+
}),
|
|
1416
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1417
|
+
variant: "outline",
|
|
1418
|
+
size: "sm",
|
|
1419
|
+
onClick: handleInsertSnippet,
|
|
1420
|
+
children: "Insert Pattern"
|
|
1421
|
+
}),
|
|
1422
|
+
selectedTemplate ? /* @__PURE__ */ jsx(Button, {
|
|
1423
|
+
variant: "outline",
|
|
1424
|
+
size: "sm",
|
|
1425
|
+
onClick: () => {
|
|
1426
|
+
const newContent = renderContentBlockTemplate(initialTemplateId, filePath || "Untitled Block");
|
|
1427
|
+
setContent(newContent);
|
|
1428
|
+
editorRef.current?.setMarkdown(newContent);
|
|
1429
|
+
},
|
|
1430
|
+
children: "Reset Template"
|
|
1431
|
+
}) : null
|
|
1432
|
+
] });
|
|
1433
|
+
}
|
|
1434
|
+
function CMSMDXEditorModal(props) {
|
|
1435
|
+
const { initialTemplateId, ...modalProps } = props;
|
|
1436
|
+
const { resolvedTheme } = useTheme();
|
|
1437
|
+
return /* @__PURE__ */ jsx(BaseMDXEditorModal, {
|
|
1438
|
+
...modalProps,
|
|
1439
|
+
EditorComponent: CMSMDXEditor,
|
|
1440
|
+
editorClassName: resolvedTheme === "dark" ? "dark-theme" : void 0,
|
|
1441
|
+
headerTools: ({ setContent, editorRef }) => /* @__PURE__ */ jsx(CMSMDXHeaderTools, {
|
|
1442
|
+
setContent,
|
|
1443
|
+
editorRef,
|
|
1444
|
+
filePath: modalProps.filePath,
|
|
1445
|
+
initialTemplateId
|
|
1400
1446
|
})
|
|
1401
1447
|
});
|
|
1402
|
-
}
|
|
1448
|
+
}
|
|
1403
1449
|
|
|
1404
1450
|
//#endregion
|
|
1405
1451
|
//#region src/components/puck/MDXContent.tsx
|
|
@@ -1422,7 +1468,7 @@ var MDXContentErrorBoundary = class extends React.Component {
|
|
|
1422
1468
|
}
|
|
1423
1469
|
render() {
|
|
1424
1470
|
if (this.state.hasError) return /* @__PURE__ */ jsxs("div", {
|
|
1425
|
-
className: "p-4 bg-red-
|
|
1471
|
+
className: "p-4 bg-red-11 dark:bg-red-02 border border-red-08 dark:border-red-03 rounded-md text-red-04 dark:text-red-08",
|
|
1426
1472
|
children: [
|
|
1427
1473
|
/* @__PURE__ */ jsx("p", {
|
|
1428
1474
|
className: "font-semibold mb-2",
|
|
@@ -1433,7 +1479,7 @@ var MDXContentErrorBoundary = class extends React.Component {
|
|
|
1433
1479
|
children: this.state.error?.message || "Unknown error occurred"
|
|
1434
1480
|
}),
|
|
1435
1481
|
/* @__PURE__ */ jsxs("p", {
|
|
1436
|
-
className: "text-xs text-red-
|
|
1482
|
+
className: "text-xs text-red-04 dark:text-red-08 mb-2",
|
|
1437
1483
|
children: ["Block ID: ", this.props.contentId]
|
|
1438
1484
|
}),
|
|
1439
1485
|
/* @__PURE__ */ jsxs("details", {
|
|
@@ -1442,7 +1488,7 @@ var MDXContentErrorBoundary = class extends React.Component {
|
|
|
1442
1488
|
className: "cursor-pointer font-medium",
|
|
1443
1489
|
children: "Stack Trace"
|
|
1444
1490
|
}), /* @__PURE__ */ jsx("pre", {
|
|
1445
|
-
className: "mt-2 p-2 bg-red-
|
|
1491
|
+
className: "mt-2 p-2 bg-red-08 dark:bg-red-03 rounded-md text-red-01 dark:text-red-11 overflow-auto whitespace-pre-wrap",
|
|
1446
1492
|
children: this.state.error?.stack
|
|
1447
1493
|
})]
|
|
1448
1494
|
})
|
|
@@ -1465,16 +1511,25 @@ function MDXContentInner({ entry }) {
|
|
|
1465
1511
|
if (!entry?.localized?.content) return null;
|
|
1466
1512
|
return entry.localized.content.mdx || null;
|
|
1467
1513
|
}, [entry]);
|
|
1468
|
-
const
|
|
1514
|
+
const cacheKey = entry.localized.etag;
|
|
1515
|
+
const { data: compiledResult, error: compileError, isLoading: isCompiling, refetch: retryCompile } = useCompileMDX({
|
|
1469
1516
|
mdxContent: actualMdxContent,
|
|
1470
|
-
cacheKey
|
|
1517
|
+
cacheKey
|
|
1518
|
+
});
|
|
1519
|
+
const { Component, error: evaluationError, isLoading: isEvaluating, retry: retryEvaluation } = useMDXEvaluation({
|
|
1520
|
+
compiledCode: compiledResult?.code || null,
|
|
1521
|
+
cacheKey
|
|
1471
1522
|
});
|
|
1472
|
-
|
|
1473
|
-
|
|
1523
|
+
const retry = () => {
|
|
1524
|
+
retryEvaluation();
|
|
1525
|
+
retryCompile();
|
|
1526
|
+
};
|
|
1527
|
+
if (isCompiling || isEvaluating) return /* @__PURE__ */ jsxs("div", {
|
|
1528
|
+
className: "flex items-center justify-center p-8 text-grey-04 dark:text-grey-07",
|
|
1474
1529
|
children: [/* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-6 w-6 border-b-2 border-azure-04 mr-3" }), "Loading content..."]
|
|
1475
1530
|
});
|
|
1476
|
-
if (compileError) return /* @__PURE__ */ jsxs("div", {
|
|
1477
|
-
className: "p-4 bg-red-
|
|
1531
|
+
if (compileError || evaluationError) return /* @__PURE__ */ jsxs("div", {
|
|
1532
|
+
className: "p-4 bg-red-11 dark:bg-red-02 border border-red-08 dark:border-red-03 rounded-md text-red-04 dark:text-red-08",
|
|
1478
1533
|
children: [
|
|
1479
1534
|
/* @__PURE__ */ jsx("p", {
|
|
1480
1535
|
className: "font-semibold mb-2",
|
|
@@ -1482,21 +1537,22 @@ function MDXContentInner({ entry }) {
|
|
|
1482
1537
|
}),
|
|
1483
1538
|
/* @__PURE__ */ jsx("p", {
|
|
1484
1539
|
className: "text-sm mb-2",
|
|
1485
|
-
children: compileError
|
|
1540
|
+
children: (compileError || evaluationError)?.message
|
|
1486
1541
|
}),
|
|
1487
1542
|
/* @__PURE__ */ jsx("p", {
|
|
1488
|
-
className: "text-xs text-red-
|
|
1543
|
+
className: "text-xs text-red-04 dark:text-red-08 mb-3",
|
|
1489
1544
|
children: "The block content contains invalid MDX syntax. Please edit the block to fix any syntax errors."
|
|
1490
1545
|
}),
|
|
1491
1546
|
/* @__PURE__ */ jsx("button", {
|
|
1547
|
+
type: "button",
|
|
1492
1548
|
onClick: retry,
|
|
1493
|
-
className: "px-3 py-1 text-sm bg-red-
|
|
1549
|
+
className: "px-3 py-1 text-sm bg-red-04 text-white rounded-md hover:bg-red-03 transition-colors",
|
|
1494
1550
|
children: "Retry"
|
|
1495
1551
|
})
|
|
1496
1552
|
]
|
|
1497
1553
|
});
|
|
1498
1554
|
if (!actualMdxContent) return /* @__PURE__ */ jsxs("div", {
|
|
1499
|
-
className: "p-4 bg-yellow-
|
|
1555
|
+
className: "p-4 bg-yellow-11 dark:bg-yellow-02 border border-yellow-08 dark:border-yellow-03 rounded-md text-yellow-02 dark:text-yellow-09",
|
|
1500
1556
|
children: [/* @__PURE__ */ jsx("p", {
|
|
1501
1557
|
className: "font-semibold mb-1",
|
|
1502
1558
|
children: "Empty Block Content"
|
|
@@ -1510,11 +1566,11 @@ function MDXContentInner({ entry }) {
|
|
|
1510
1566
|
})]
|
|
1511
1567
|
});
|
|
1512
1568
|
if (!Component) return /* @__PURE__ */ jsxs("div", {
|
|
1513
|
-
className: "flex items-center justify-center p-8 text-grey-04",
|
|
1569
|
+
className: "flex items-center justify-center p-8 text-grey-04 dark:text-grey-07",
|
|
1514
1570
|
children: [/* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-6 w-6 border-b-2 border-azure-04 mr-3" }), "Loading MDX..."]
|
|
1515
1571
|
});
|
|
1516
1572
|
return /* @__PURE__ */ jsx("div", {
|
|
1517
|
-
className: "mdx-content prose
|
|
1573
|
+
className: "mdx-content conloca-prose max-w-none",
|
|
1518
1574
|
children: /* @__PURE__ */ jsx(Component, {})
|
|
1519
1575
|
});
|
|
1520
1576
|
}
|
|
@@ -1529,5 +1585,5 @@ function MDXContent(props) {
|
|
|
1529
1585
|
}
|
|
1530
1586
|
|
|
1531
1587
|
//#endregion
|
|
1532
|
-
export {
|
|
1533
|
-
//# sourceMappingURL=puck-
|
|
1588
|
+
export { Button as A, renderContentBlockTemplate as C, Select as D, Separator as E, ThemeProvider as M, useTheme as N, Input as O, getContentBlockTemplate as S, Textarea as T, getUIConfig as _, MediaLibrary as a, useClickOutside as b, FolderTreeSidebar as c, useDeleteAsset as d, useFolderTree$1 as f, configureUI as g, useSiteBaseUrl as h, UploadModal as i, cn as j, IconButton as k, useAssetUsage as l, useUpdateAssetMetadata as m, CMSMDXEditorModal as n, MediaToolbar as o, useMoveAssets as p, ImagePicker as r, buildAssetServeUrl as s, MDXContent as t, useBulkDeleteAssets as u, useErrorModal as v, Tooltip as w, contentBlockTemplates as x, useDialogState as y };
|
|
1589
|
+
//# sourceMappingURL=puck-C9_F3_cJ.mjs.map
|