@marktiderman/genesis-sites 0.7.6 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +202 -19
- package/SKILL.md +15 -0
- package/dist/analytics.d.ts +184 -0
- package/dist/analytics.js +3 -0
- package/dist/analytics.js.map +1 -0
- package/dist/assets/form-island.da6c662a73.js +51 -0
- package/dist/assets/islands.399b13ea6f.js +1 -0
- package/dist/assets/sites-forms.b64c156079.css +10 -0
- package/dist/assets/sites-forms.css +1 -1
- package/dist/assets/sites.2fac65f96a.css +2 -0
- package/dist/assets/sites.css +1 -1
- package/dist/assets.generated-ZBFSP23U.js +3 -0
- package/dist/{assets.generated-LLUGUUWZ.js.map → assets.generated-ZBFSP23U.js.map} +1 -1
- package/dist/blocks.js +2 -1
- package/dist/blocks.js.map +1 -1
- package/dist/chunk-5G2H6EZ2.js +19 -0
- package/dist/chunk-5G2H6EZ2.js.map +1 -0
- package/dist/chunk-5RYCQEEE.js +256 -0
- package/dist/chunk-5RYCQEEE.js.map +1 -0
- package/dist/{chunk-7E3YGYVH.js → chunk-ATRS5GSD.js} +77 -22
- package/dist/chunk-ATRS5GSD.js.map +1 -0
- package/dist/{chunk-MU2Z2C4F.js → chunk-CXBBUKGB.js} +14 -4
- package/dist/chunk-CXBBUKGB.js.map +1 -0
- package/dist/{chunk-IU6AI75R.js → chunk-QGU6FDH5.js} +413 -162
- package/dist/chunk-QGU6FDH5.js.map +1 -0
- package/dist/{chunk-SMJMXQ3T.js → chunk-SBONYMUC.js} +294 -73
- package/dist/chunk-SBONYMUC.js.map +1 -0
- package/dist/{chunk-VJ4HOFBA.js → chunk-UOKNFG5O.js} +144 -20
- package/dist/chunk-UOKNFG5O.js.map +1 -0
- package/dist/{chunk-KY4ALBVH.js → chunk-UUC5USJH.js} +58 -37
- package/dist/chunk-UUC5USJH.js.map +1 -0
- package/dist/editor.d.ts +76 -19
- package/dist/editor.js +1217 -245
- package/dist/editor.js.map +1 -1
- package/dist/handler-OR554RTS.js +11 -0
- package/dist/{handler-UMGSZY33.js.map → handler-OR554RTS.js.map} +1 -1
- package/dist/import.d.ts +3 -3
- package/dist/import.js +1 -1
- package/dist/index.d.ts +66 -11
- package/dist/index.js +4 -4
- package/dist/redirects-LcCNIJHQ.d.ts +43 -0
- package/dist/{registry-BIijndsq.d.ts → registry-Cw7NF_le.d.ts} +92 -1
- package/dist/sections.d.ts +86 -4
- package/dist/sections.js +3 -3
- package/dist/{store-BImtGmoF.d.ts → store-BNYD5NAQ.d.ts} +30 -4
- package/dist/supabase.d.ts +4 -4
- package/dist/supabase.js +4 -4
- package/dist/{templates-kA-jrnWA.d.ts → templates-DPv0OYLl.d.ts} +2 -2
- package/dist/templates.d.ts +3 -3
- package/dist/templates.js +7 -3
- package/dist/templates.js.map +1 -1
- package/dist/{theme-Cg-inpk5.d.ts → theme-HJzN2tOm.d.ts} +2 -2
- package/dist/web.d.ts +64 -18
- package/dist/web.js +7 -6
- package/migrations/0003_genesis_sites_post_dates.sql +117 -0
- package/migrations/tests/0003_genesis_sites_post_dates.test.sql +76 -0
- package/package.json +12 -4
- package/dist/assets/form-island.defb8daccc.js +0 -51
- package/dist/assets/islands.33a445f34e.js +0 -1
- package/dist/assets/sites-forms.aff23b5617.css +0 -10
- package/dist/assets/sites.5b3f64c627.css +0 -2
- package/dist/assets.generated-LLUGUUWZ.js +0 -3
- package/dist/chunk-7E3YGYVH.js.map +0 -1
- package/dist/chunk-IU6AI75R.js.map +0 -1
- package/dist/chunk-KY4ALBVH.js.map +0 -1
- package/dist/chunk-MU2Z2C4F.js.map +0 -1
- package/dist/chunk-RLYO6VVP.js +0 -19
- package/dist/chunk-RLYO6VVP.js.map +0 -1
- package/dist/chunk-SMJMXQ3T.js.map +0 -1
- package/dist/chunk-VJ4HOFBA.js.map +0 -1
- package/dist/handler-UMGSZY33.js +0 -10
package/dist/editor.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { starterSite, exampleBrands,
|
|
2
|
-
import './chunk-
|
|
1
|
+
import { starterSite, exampleBrands, redirectDestinations, landingPage, removeRedirect, redirectFromProblems, redirectToProblems, upsertRedirect } from './chunk-UUC5USJH.js';
|
|
2
|
+
import './chunk-SBONYMUC.js';
|
|
3
3
|
import './chunk-VZUDRPFG.js';
|
|
4
|
-
import { stableHash, isConflict, prepareRelease, PublishBlockedError, SiteConflictError, siteTheme, brandDisplayName, themeCss, migrateNode, migratePage, migrateSite } from './chunk-
|
|
5
|
-
import { getSection, sectionJsonSchema, listSections, SECTION_CATEGORIES, PageDoc, SiteDoc, newSectionId } from './chunk-
|
|
6
|
-
import { isSafeImageSrc, DEFAULT_RESERVED_PATHS, pagePathProblems, isSafeHref } from './chunk-
|
|
7
|
-
import * as
|
|
4
|
+
import { stableHash, isConflict, prepareRelease, PublishBlockedError, applyCheckLevels, landingDirectory, landingPath, landingSlugProblems, landingDirectoryProblems, landingMoves, SiteConflictError, siteTheme, brandDisplayName, themeCss, isLandingPage, migrateNode, landingPages, migratePage, migrateSite, landingSlugOf, pageWindowProblems } from './chunk-UOKNFG5O.js';
|
|
5
|
+
import { getSection, sectionJsonSchema, listSections, SECTION_CATEGORIES, NOT_FOUND_PATH, PageDoc, SiteDoc, notFoundPageDoc, newSectionId, isNotFoundPage, SeoDefaults, sampleImage } from './chunk-QGU6FDH5.js';
|
|
6
|
+
import { isSafeImageSrc, DEFAULT_RESERVED_PATHS, pagePathProblems, isSafeHref } from './chunk-CXBBUKGB.js';
|
|
7
|
+
import * as React11 from 'react';
|
|
8
8
|
import { createContext, useContext } from 'react';
|
|
9
9
|
import { createUsePuck, Puck } from '@puckeditor/core';
|
|
10
10
|
export { createUsePuck, usePuck } from '@puckeditor/core';
|
|
11
|
-
import { Undo2, Redo2, Monitor, Tablet, Smartphone, Plus,
|
|
11
|
+
import { Undo2, Redo2, Monitor, Tablet, Smartphone, Plus, ArrowRight, Trash2, Megaphone, CheckCircle2, Eye, ExternalLink, RotateCcw, Home, FileText, ArrowUp, ArrowDown, FileQuestion, AlertCircle, AlertTriangle } from 'lucide-react';
|
|
12
12
|
import { AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, AlertDialogAction } from '@marktiderman/genesis-ui/alert-dialog';
|
|
13
13
|
import { Alert, AlertTitle, AlertDescription } from '@marktiderman/genesis-ui/alert';
|
|
14
14
|
import { Button } from '@marktiderman/genesis-ui/button';
|
|
@@ -22,11 +22,13 @@ import { Label } from '@marktiderman/genesis-ui/label';
|
|
|
22
22
|
import { Switch } from '@marktiderman/genesis-ui/switch';
|
|
23
23
|
import { Textarea } from '@marktiderman/genesis-ui/textarea';
|
|
24
24
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
25
|
+
import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '@marktiderman/genesis-ui/select';
|
|
25
26
|
import { RichTextEditor } from '@marktiderman/genesis-ui/rich-text-editor';
|
|
26
27
|
import { Badge } from '@marktiderman/genesis-ui/badge';
|
|
27
28
|
import { RadioGroup, RadioGroupItem } from '@marktiderman/genesis-ui/radio-group';
|
|
28
|
-
import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '@marktiderman/genesis-ui/select';
|
|
29
29
|
import { Separator } from '@marktiderman/genesis-ui/separator';
|
|
30
|
+
import { Checkbox } from '@marktiderman/genesis-ui/checkbox';
|
|
31
|
+
import { Combobox } from '@marktiderman/genesis-ui/combobox';
|
|
30
32
|
|
|
31
33
|
var IMAGE_TYPES = ["image/png", "image/jpeg", "image/webp", "image/avif", "image/gif"];
|
|
32
34
|
async function dimensions(file) {
|
|
@@ -47,18 +49,18 @@ function uploadProblem(file, maxBytes = 10 * 1024 * 1024) {
|
|
|
47
49
|
}
|
|
48
50
|
function AssetPicker({ open, siteId, store, assets, current, altElsewhere = false, onDone }) {
|
|
49
51
|
const canUpload = Boolean(assets?.upload || store.putAsset);
|
|
50
|
-
const [tab, setTab] =
|
|
51
|
-
const [file, setFile] =
|
|
52
|
-
const [url, setUrl] =
|
|
53
|
-
const [chosen, setChosen] =
|
|
54
|
-
const [alt, setAlt] =
|
|
55
|
-
const [decorative, setDecorative] =
|
|
56
|
-
const [library, setLibrary] =
|
|
57
|
-
const [uploaded, setUploaded] =
|
|
58
|
-
const [busy, setBusy] =
|
|
59
|
-
const [error, setError] =
|
|
60
|
-
const id =
|
|
61
|
-
|
|
52
|
+
const [tab, setTab] = React11.useState(canUpload ? "upload" : "link");
|
|
53
|
+
const [file, setFile] = React11.useState(null);
|
|
54
|
+
const [url, setUrl] = React11.useState(current?.src ?? "");
|
|
55
|
+
const [chosen, setChosen] = React11.useState(null);
|
|
56
|
+
const [alt, setAlt] = React11.useState(current?.alt ?? "");
|
|
57
|
+
const [decorative, setDecorative] = React11.useState(current?.decorative === true);
|
|
58
|
+
const [library, setLibrary] = React11.useState(null);
|
|
59
|
+
const [uploaded, setUploaded] = React11.useState([]);
|
|
60
|
+
const [busy, setBusy] = React11.useState(false);
|
|
61
|
+
const [error, setError] = React11.useState(null);
|
|
62
|
+
const id = React11.useId();
|
|
63
|
+
React11.useEffect(() => {
|
|
62
64
|
if (!open) return;
|
|
63
65
|
setFile(null);
|
|
64
66
|
setChosen(null);
|
|
@@ -110,39 +112,73 @@ function AssetPicker({ open, siteId, store, assets, current, altElsewhere = fals
|
|
|
110
112
|
return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: (o) => o ? null : onDone(null), children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-lg", children: [
|
|
111
113
|
/* @__PURE__ */ jsxs(DialogHeader, { children: [
|
|
112
114
|
/* @__PURE__ */ jsx(DialogTitle, { children: "Choose an image" }),
|
|
113
|
-
/* @__PURE__ */ jsx(DialogDescription, { children: "Upload one, pick one the site has, or link one.
|
|
115
|
+
/* @__PURE__ */ jsx(DialogDescription, { children: altElsewhere ? "Upload one, pick one the site has, or link one. You describe it in its Alt text field after." : "Upload one, pick one the site has, or link one, and describe it for people who can't see it." })
|
|
114
116
|
] }),
|
|
115
|
-
/* @__PURE__ */ jsxs(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
/* @__PURE__ */ jsx(Input, { id: `${id}-file`, type: "file", accept: IMAGE_TYPES.join(","), onChange: (e) => setFile(e.currentTarget.files?.[0] ?? null) }),
|
|
124
|
-
!canUpload ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "This site's store doesn't take uploads; link an image instead." }) : null
|
|
125
|
-
] }),
|
|
126
|
-
/* @__PURE__ */ jsx(TabsContent, { value: "library", className: "pt-2", children: all.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: library === null && assets?.list ? "Loading\u2026" : "No images yet. Upload one first." }) : /* @__PURE__ */ jsx("div", { role: "group", "aria-label": "Site images", className: "grid max-h-64 grid-cols-3 gap-2 overflow-y-auto", children: all.map((a) => /* @__PURE__ */ jsx(
|
|
127
|
-
"button",
|
|
128
|
-
{
|
|
129
|
-
type: "button",
|
|
130
|
-
"aria-pressed": chosen?.id === a.id,
|
|
131
|
-
"aria-label": a.alt?.trim() || a.path.split("/").pop() || "Image",
|
|
132
|
-
onClick: () => {
|
|
133
|
-
setChosen(a);
|
|
134
|
-
if (a.alt && !alt) setAlt(a.alt);
|
|
135
|
-
},
|
|
136
|
-
className: cn("overflow-hidden rounded-md border-2 focus-visible:outline-2 focus-visible:outline-ring", chosen?.id === a.id ? "border-primary" : "border-transparent"),
|
|
137
|
-
children: isSafeImageSrc(a.url) ? /* @__PURE__ */ jsx("img", { src: a.url, alt: a.alt ?? "", className: "h-20 w-full object-cover" }) : /* @__PURE__ */ jsx("span", { className: "p-2 text-xs", children: a.path })
|
|
117
|
+
/* @__PURE__ */ jsxs(
|
|
118
|
+
Tabs,
|
|
119
|
+
{
|
|
120
|
+
defaultValue: "upload",
|
|
121
|
+
value: tab,
|
|
122
|
+
onValueChange: (t) => {
|
|
123
|
+
setError(null);
|
|
124
|
+
setTab(t);
|
|
138
125
|
},
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
126
|
+
children: [
|
|
127
|
+
/* @__PURE__ */ jsxs(TabsList, { className: "grid w-full grid-cols-3", children: [
|
|
128
|
+
/* @__PURE__ */ jsx(TabsTrigger, { value: "upload", disabled: !canUpload, children: "Upload" }),
|
|
129
|
+
/* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: "Library" }),
|
|
130
|
+
/* @__PURE__ */ jsx(TabsTrigger, { value: "link", children: "Link" })
|
|
131
|
+
] }),
|
|
132
|
+
/* @__PURE__ */ jsxs(TabsContent, { value: "upload", className: "flex flex-col gap-2 pt-2", children: [
|
|
133
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-file`, children: "Image file" }),
|
|
134
|
+
/* @__PURE__ */ jsx(
|
|
135
|
+
Input,
|
|
136
|
+
{
|
|
137
|
+
id: `${id}-file`,
|
|
138
|
+
type: "file",
|
|
139
|
+
accept: IMAGE_TYPES.join(","),
|
|
140
|
+
onChange: (e) => {
|
|
141
|
+
setError(null);
|
|
142
|
+
setFile(e.currentTarget.files?.[0] ?? null);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
),
|
|
146
|
+
!canUpload ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "This site's store doesn't take uploads; link an image instead." }) : null
|
|
147
|
+
] }),
|
|
148
|
+
/* @__PURE__ */ jsx(TabsContent, { value: "library", className: "pt-2", children: all.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: library === null && assets?.list ? "Loading\u2026" : "No images yet. Upload one first." }) : /* @__PURE__ */ jsx("div", { role: "group", "aria-label": "Site images", className: "grid max-h-64 grid-cols-3 gap-2 overflow-y-auto", children: all.map((a) => /* @__PURE__ */ jsx(
|
|
149
|
+
"button",
|
|
150
|
+
{
|
|
151
|
+
type: "button",
|
|
152
|
+
"aria-pressed": chosen?.id === a.id,
|
|
153
|
+
"aria-label": a.alt?.trim() || a.path.split("/").pop() || "Image",
|
|
154
|
+
onClick: () => {
|
|
155
|
+
setError(null);
|
|
156
|
+
setChosen(a);
|
|
157
|
+
if (a.alt && !alt) setAlt(a.alt);
|
|
158
|
+
},
|
|
159
|
+
className: cn("overflow-hidden rounded-md border-2 focus-visible:outline-2 focus-visible:outline-ring", chosen?.id === a.id ? "border-primary" : "border-transparent"),
|
|
160
|
+
children: isSafeImageSrc(a.url) ? /* @__PURE__ */ jsx("img", { src: a.url, alt: a.alt ?? "", className: "h-20 w-full object-cover" }) : /* @__PURE__ */ jsx("span", { className: "flex h-20 items-center justify-center break-all p-2 text-xs text-muted-foreground", children: a.path.split("/").pop() })
|
|
161
|
+
},
|
|
162
|
+
a.id
|
|
163
|
+
)) }) }),
|
|
164
|
+
/* @__PURE__ */ jsxs(TabsContent, { value: "link", className: "flex flex-col gap-2 pt-2", children: [
|
|
165
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-url`, children: "Image address" }),
|
|
166
|
+
/* @__PURE__ */ jsx(
|
|
167
|
+
Input,
|
|
168
|
+
{
|
|
169
|
+
id: `${id}-url`,
|
|
170
|
+
value: url,
|
|
171
|
+
placeholder: "https://\u2026 or /images/photo.jpg",
|
|
172
|
+
onChange: (e) => {
|
|
173
|
+
setError(null);
|
|
174
|
+
setUrl(e.currentTarget.value);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
)
|
|
178
|
+
] })
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
),
|
|
146
182
|
altElsewhere ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Describe the image in the item's Alt text field, after you choose it." }) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
147
183
|
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-alt`, children: "Alt text" }),
|
|
148
184
|
/* @__PURE__ */ jsx(Textarea, { id: `${id}-alt`, rows: 2, maxLength: 300, value: alt, disabled: decorative, "aria-invalid": altInvalid || void 0, "aria-describedby": `${id}-alt-hint`, onChange: (e) => setAlt(e.currentTarget.value), placeholder: "Two people stretching on mats by a window" }),
|
|
@@ -371,6 +407,12 @@ function currentProps(node) {
|
|
|
371
407
|
}
|
|
372
408
|
return { props, v: def.version };
|
|
373
409
|
}
|
|
410
|
+
function componentNameOf(node) {
|
|
411
|
+
const def = getSection(node.type);
|
|
412
|
+
if (!def || !node.variant) return node.type;
|
|
413
|
+
const index = def.presets.findIndex((p) => p.variant === node.variant);
|
|
414
|
+
return index > 0 ? presetComponentName(node.type, index) : node.type;
|
|
415
|
+
}
|
|
374
416
|
function nodeToItem(node, slotKeys = noSlots) {
|
|
375
417
|
const current = currentProps(node);
|
|
376
418
|
const props = { ...current.props };
|
|
@@ -378,16 +420,21 @@ function nodeToItem(node, slotKeys = noSlots) {
|
|
|
378
420
|
const nested = props[key];
|
|
379
421
|
if (Array.isArray(nested)) props[key] = nested.map((n) => nodeToItem(n, slotKeys));
|
|
380
422
|
}
|
|
423
|
+
const unset = {};
|
|
424
|
+
for (const preset of getSection(node.type)?.presets ?? []) {
|
|
425
|
+
for (const key of Object.keys(preset.props ?? {})) if (!(key in props)) unset[key] = void 0;
|
|
426
|
+
}
|
|
381
427
|
return {
|
|
382
|
-
type: node
|
|
428
|
+
type: componentNameOf(node),
|
|
383
429
|
props: {
|
|
430
|
+
...unset,
|
|
384
431
|
...props,
|
|
385
432
|
id: node.id,
|
|
386
433
|
_v: current.v,
|
|
387
|
-
|
|
434
|
+
_variant: node.variant,
|
|
388
435
|
_hidden: node.hidden === true,
|
|
389
436
|
_hideOn: node.hideOn?.length ? hideOnValue(node.hideOn) : "none",
|
|
390
|
-
|
|
437
|
+
_placeholder: node.placeholder ? structuredClone(current.props) : void 0
|
|
391
438
|
}
|
|
392
439
|
};
|
|
393
440
|
}
|
|
@@ -436,8 +483,7 @@ function itemToNode(item, options2 = {}) {
|
|
|
436
483
|
props[key] = Array.isArray(nested) ? nested.map((n) => itemToNode(n, options2)) : [];
|
|
437
484
|
}
|
|
438
485
|
const hideOn = _hideOn === "both" ? ["mobile", "desktop"] : _hideOn === "mobile" || _hideOn === "desktop" ? [_hideOn] : void 0;
|
|
439
|
-
const
|
|
440
|
-
const placeholder = _placeholder === true && original !== void 0 && original === placeholderHash(props);
|
|
486
|
+
const placeholder = isSample(_placeholder, props, options2.placeholders?.get(String(id)));
|
|
441
487
|
return {
|
|
442
488
|
id: safeSectionId(String(id)),
|
|
443
489
|
type,
|
|
@@ -450,6 +496,14 @@ function itemToNode(item, options2 = {}) {
|
|
|
450
496
|
};
|
|
451
497
|
}
|
|
452
498
|
var placeholderHash = (props) => stableHash(stripArrayIds(pruneEmpty(props)) ?? {});
|
|
499
|
+
function isSample(marker, props, snapshot) {
|
|
500
|
+
if (marker && typeof marker === "object" && !Array.isArray(marker)) return placeholderHash(marker) === placeholderHash(props);
|
|
501
|
+
return marker === true && snapshot !== void 0 && snapshot === placeholderHash(props);
|
|
502
|
+
}
|
|
503
|
+
function isUneditedSample(item, options2 = {}) {
|
|
504
|
+
if (!item?.props._placeholder) return false;
|
|
505
|
+
return itemToNode(item, options2).placeholder === true;
|
|
506
|
+
}
|
|
453
507
|
function placeholderSnapshot(nodes, into = /* @__PURE__ */ new Map()) {
|
|
454
508
|
for (const n of nodes) if (n.placeholder) into.set(n.id, placeholderHash(n.props));
|
|
455
509
|
return into;
|
|
@@ -512,6 +566,8 @@ function useEditorServices() {
|
|
|
512
566
|
}
|
|
513
567
|
function Thumb({ src, alt }) {
|
|
514
568
|
if (!src) return /* @__PURE__ */ jsx("div", { className: "flex h-24 w-full items-center justify-center rounded-md border border-dashed border-border text-sm text-muted-foreground", children: "No image" });
|
|
569
|
+
const sample = sampleImage(src);
|
|
570
|
+
if (sample) return /* @__PURE__ */ jsx("img", { src: sample.src, alt, className: "h-24 w-full rounded-md border border-border object-cover" });
|
|
515
571
|
if (!isSafeImageSrc(src)) return /* @__PURE__ */ jsx("div", { className: "rounded-md border border-destructive p-2 text-sm text-destructive", children: "This address can't be used for an image: use a site path or an https link." });
|
|
516
572
|
return /* @__PURE__ */ jsx("img", { src, alt, className: "h-24 w-full rounded-md border border-border object-cover" });
|
|
517
573
|
}
|
|
@@ -584,9 +640,9 @@ function RichTextField({ field, id, value, onChange, readOnly }) {
|
|
|
584
640
|
}
|
|
585
641
|
function LinesField({ field, id, value, onChange, readOnly }) {
|
|
586
642
|
const max = field.metadata?.maxItems;
|
|
587
|
-
const [text, setText] =
|
|
588
|
-
const lastSent =
|
|
589
|
-
|
|
643
|
+
const [text, setText] = React11.useState(() => (value ?? []).join("\n"));
|
|
644
|
+
const lastSent = React11.useRef(value);
|
|
645
|
+
React11.useEffect(() => {
|
|
590
646
|
if (JSON.stringify(value ?? []) !== JSON.stringify(lastSent.current ?? [])) setText((value ?? []).join("\n"));
|
|
591
647
|
}, [value]);
|
|
592
648
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
@@ -602,9 +658,9 @@ function LinesField({ field, id, value, onChange, readOnly }) {
|
|
|
602
658
|
onChange: (e) => {
|
|
603
659
|
const next = e.currentTarget.value;
|
|
604
660
|
setText(next);
|
|
605
|
-
const
|
|
606
|
-
lastSent.current =
|
|
607
|
-
onChange(
|
|
661
|
+
const lines2 = next.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
662
|
+
lastSent.current = lines2;
|
|
663
|
+
onChange(lines2);
|
|
608
664
|
}
|
|
609
665
|
}
|
|
610
666
|
),
|
|
@@ -621,6 +677,44 @@ function UnsupportedField({ field }) {
|
|
|
621
677
|
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "This can't be edited here yet; it's kept as it is." })
|
|
622
678
|
] });
|
|
623
679
|
}
|
|
680
|
+
function FormField({ field, id, value, onChange, readOnly }) {
|
|
681
|
+
const services = useEditorServices();
|
|
682
|
+
const [list, setList] = React11.useState(null);
|
|
683
|
+
const [failed, setFailed] = React11.useState(false);
|
|
684
|
+
React11.useEffect(() => {
|
|
685
|
+
if (!services.listForms) return;
|
|
686
|
+
let live = true;
|
|
687
|
+
services.listForms().then((forms) => live && setList(forms)).catch(() => live && setFailed(true));
|
|
688
|
+
return () => {
|
|
689
|
+
live = false;
|
|
690
|
+
};
|
|
691
|
+
}, [services]);
|
|
692
|
+
const label = /* @__PURE__ */ jsx(Label, { htmlFor: id, id: `${id}-label`, children: field.label });
|
|
693
|
+
if (!services.listForms || failed) {
|
|
694
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
695
|
+
label,
|
|
696
|
+
/* @__PURE__ */ jsx(Input, { id, value: value ?? "", placeholder: "contact", readOnly, onChange: (e) => onChange(e.currentTarget.value.trim().toLowerCase()) }),
|
|
697
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: failed ? "Your forms couldn't load: type the form's short name." : "The form's short name, as your forms list shows it." })
|
|
698
|
+
] });
|
|
699
|
+
}
|
|
700
|
+
if (!list) return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
701
|
+
label,
|
|
702
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Loading your forms\u2026" })
|
|
703
|
+
] });
|
|
704
|
+
const known = !value || list.some((f) => f.slug === value);
|
|
705
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
706
|
+
label,
|
|
707
|
+
list.length ? /* @__PURE__ */ jsxs(Select, { value: known ? value ?? "" : "", onValueChange: (v) => onChange(v), disabled: readOnly, children: [
|
|
708
|
+
/* @__PURE__ */ jsx(SelectTrigger, { id, "aria-labelledby": `${id}-label`, children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Choose a form" }) }),
|
|
709
|
+
/* @__PURE__ */ jsx(SelectContent, { children: list.map((f) => /* @__PURE__ */ jsx(SelectItem, { value: f.slug, children: f.title }, f.slug)) })
|
|
710
|
+
] }) : /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "You have no forms yet. Make one, then choose it here." }),
|
|
711
|
+
known ? null : /* @__PURE__ */ jsxs("p", { role: "alert", className: "text-xs text-destructive", children: [
|
|
712
|
+
"There's no form \u201C",
|
|
713
|
+
value,
|
|
714
|
+
"\u201D. Choose one of yours."
|
|
715
|
+
] })
|
|
716
|
+
] });
|
|
717
|
+
}
|
|
624
718
|
|
|
625
719
|
// src/editor/fields.ts
|
|
626
720
|
var GENERIC_TITLES = /* @__PURE__ */ new Set(["Link", "Image", "Rich text"]);
|
|
@@ -673,6 +767,7 @@ function fieldFor(key, schema, required, ctx) {
|
|
|
673
767
|
return { type: "slot", label, ...schema["x-genesis-allow"] ?? ctx.slotAllow ? { allow: schema["x-genesis-allow"] ?? ctx.slotAllow } : {} };
|
|
674
768
|
}
|
|
675
769
|
if (kind === "rich-text") return { type: "custom", label, render: RichTextField };
|
|
770
|
+
if (kind === "form") return { type: "custom", label, render: FormField };
|
|
676
771
|
if (isImageSchema(schema)) return { type: "custom", label, render: ImageField, metadata: { required } };
|
|
677
772
|
const union = schema.anyOf ?? schema.oneOf;
|
|
678
773
|
if (union) {
|
|
@@ -754,7 +849,7 @@ function objectFields(schema, ctx) {
|
|
|
754
849
|
function imageItemFields(schema, ctx) {
|
|
755
850
|
const out = {
|
|
756
851
|
src: { type: "custom", label: "Image", render: ImageSrcField },
|
|
757
|
-
alt: { type: "textarea", label: "Alt text (what the image shows)" },
|
|
852
|
+
alt: { type: "textarea", label: "Alt text (what the image shows)", placeholder: "Describe what the photo shows" },
|
|
758
853
|
decorative: {
|
|
759
854
|
type: "radio",
|
|
760
855
|
label: "Decorative (no alt text needed)",
|
|
@@ -818,7 +913,7 @@ var CATEGORY_TITLES = {
|
|
|
818
913
|
footer: "Footer"
|
|
819
914
|
};
|
|
820
915
|
var META = /* @__PURE__ */ new Set(["puck", "editMode", "id"]);
|
|
821
|
-
var SectionBoundary = class extends
|
|
916
|
+
var SectionBoundary = class extends React11.Component {
|
|
822
917
|
state = { error: null };
|
|
823
918
|
static getDerivedStateFromError(error) {
|
|
824
919
|
return { error };
|
|
@@ -831,28 +926,74 @@ var SectionBoundary = class extends React8.Component {
|
|
|
831
926
|
return this.props.children;
|
|
832
927
|
}
|
|
833
928
|
};
|
|
834
|
-
function Problem({ title, lines }) {
|
|
929
|
+
function Problem({ title, lines: lines2 }) {
|
|
835
930
|
return /* @__PURE__ */ jsxs("div", { role: "alert", style: { margin: "1rem", padding: "1rem 1.25rem", border: "2px dashed currentColor", borderRadius: "0.5rem", fontFamily: "system-ui, sans-serif", fontSize: "0.875rem", lineHeight: 1.5 }, children: [
|
|
836
931
|
/* @__PURE__ */ jsx("strong", { children: title }),
|
|
837
|
-
/* @__PURE__ */ jsx("ul", { style: { margin: "0.5rem 0 0", paddingLeft: "1.25rem" }, children:
|
|
932
|
+
/* @__PURE__ */ jsx("ul", { style: { margin: "0.5rem 0 0", paddingLeft: "1.25rem" }, children: lines2.map((l, i) => /* @__PURE__ */ jsx("li", { children: l }, i)) })
|
|
838
933
|
] });
|
|
839
934
|
}
|
|
840
935
|
function Tag({ children }) {
|
|
841
936
|
return /* @__PURE__ */ jsx("span", { style: { position: "absolute", top: "0.5rem", right: "0.5rem", zIndex: 5, padding: "0.125rem 0.5rem", borderRadius: "999px", background: "hsl(var(--foreground))", color: "hsl(var(--background))", fontFamily: "system-ui, sans-serif", fontSize: "0.75rem", fontWeight: 600 }, children });
|
|
842
937
|
}
|
|
938
|
+
function issuePlace(path) {
|
|
939
|
+
return path.map((p) => typeof p === "number" ? String(p + 1) : humanize(String(p))).join(" \u203A ");
|
|
940
|
+
}
|
|
941
|
+
function friendlyIssue(issue) {
|
|
942
|
+
const place = issuePlace(issue.path) || "This section";
|
|
943
|
+
const missing = issue.code === "invalid_type" && ("input" in issue ? issue.input === void 0 : /received undefined$/.test(issue.message));
|
|
944
|
+
const blank2 = issue.code === "too_small" && issue.origin === "string" && ("input" in issue ? issue.input === "" : Number(issue.minimum) === 1);
|
|
945
|
+
if (missing || blank2) return `${place}: fill this in.`;
|
|
946
|
+
if (issue.code === "too_small" && issue.origin === "string") return `${place}: too short (at least ${issue.minimum} characters).`;
|
|
947
|
+
if (issue.code === "too_small" && issue.origin === "array") return `${place}: add at least ${issue.minimum}.`;
|
|
948
|
+
if (issue.code === "too_big" && issue.origin === "string") return `${place}: too long (at most ${issue.maximum} characters).`;
|
|
949
|
+
if (issue.code === "too_big" && issue.origin === "array") return `${place}: at most ${issue.maximum}.`;
|
|
950
|
+
return `${place}: ${issue.message.replace(/^Invalid input: /, "")}`;
|
|
951
|
+
}
|
|
952
|
+
function withoutUnfinishedItems(def, node) {
|
|
953
|
+
if (node.v !== def.version) return null;
|
|
954
|
+
const parsed = def.schema.safeParse(node.props);
|
|
955
|
+
if (parsed.success) return null;
|
|
956
|
+
const drop = /* @__PURE__ */ new Map();
|
|
957
|
+
for (const issue of parsed.error.issues) {
|
|
958
|
+
const [key, index] = issue.path;
|
|
959
|
+
if (typeof key !== "string" || typeof index !== "number" || issue.path.length < 3 || !Array.isArray(node.props[key])) return null;
|
|
960
|
+
drop.set(key, (drop.get(key) ?? /* @__PURE__ */ new Set()).add(index));
|
|
961
|
+
}
|
|
962
|
+
const props = { ...node.props };
|
|
963
|
+
const unfinished = [];
|
|
964
|
+
for (const [key, indexes] of drop) {
|
|
965
|
+
props[key] = node.props[key].filter((_, i) => !indexes.has(i));
|
|
966
|
+
for (const i of [...indexes].sort((a, b) => a - b)) unfinished.push(`${humanize(key)} \u203A ${i + 1}`);
|
|
967
|
+
}
|
|
968
|
+
const repaired = { ...node, props };
|
|
969
|
+
return migrateNode(repaired).node ? { node: repaired, unfinished } : null;
|
|
970
|
+
}
|
|
971
|
+
function sectionProblems(def, node, fallback) {
|
|
972
|
+
if (node.v !== def.version) return fallback;
|
|
973
|
+
const parsed = def.schema.safeParse(node.props);
|
|
974
|
+
return parsed.success ? fallback : parsed.error.issues.map(friendlyIssue);
|
|
975
|
+
}
|
|
843
976
|
function CanvasSection({ def, componentName, input, slotKeys }) {
|
|
844
977
|
const meta = input.puck?.metadata ?? {};
|
|
845
978
|
const id = String(input.id);
|
|
846
979
|
const props = { id };
|
|
847
980
|
for (const [k, v] of Object.entries(input)) if (!META.has(k) && !slotKeys.includes(k)) props[k] = v;
|
|
848
981
|
const node = itemToNode({ type: componentName, props }, { ...meta.placeholders ? { placeholders: new Map(Object.entries(meta.placeholders)) } : {} });
|
|
849
|
-
|
|
982
|
+
let migrated = migrateNode(node);
|
|
983
|
+
let unfinished = [];
|
|
984
|
+
if (!migrated.node) {
|
|
985
|
+
const partial = withoutUnfinishedItems(def, node);
|
|
986
|
+
if (partial) {
|
|
987
|
+
migrated = migrateNode(partial.node);
|
|
988
|
+
unfinished = partial.unfinished;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
850
991
|
const slots = slotKeys.map((key) => {
|
|
851
992
|
const Slot = input[key];
|
|
852
993
|
return typeof Slot === "function" ? /* @__PURE__ */ jsx("div", { "aria-label": `${def.label}: ${key}`, style: { padding: "0.5rem" }, children: /* @__PURE__ */ jsx(Slot, { minEmptyHeight: 64 }) }, key) : null;
|
|
853
994
|
});
|
|
854
995
|
if (!migrated.node) {
|
|
855
|
-
return /* @__PURE__ */ jsx(Problem, { title: `Fix the ${def.label} section to show it`, lines: migrated.issues.map((i) => i.message.replace(/^Section \S+ \([^)]*\): /, "")) });
|
|
996
|
+
return /* @__PURE__ */ jsx(Problem, { title: `Fix the ${def.label} section to show it`, lines: sectionProblems(def, node, migrated.issues.map((i) => i.message.replace(/^Section \S+ \([^)]*\): /, ""))) });
|
|
856
997
|
}
|
|
857
998
|
const ctx = {
|
|
858
999
|
headingLevel: meta.h1Id === id ? 1 : 2,
|
|
@@ -863,7 +1004,7 @@ function CanvasSection({ def, componentName, input, slotKeys }) {
|
|
|
863
1004
|
mode: "preview",
|
|
864
1005
|
idPrefix: `gs-${id}`
|
|
865
1006
|
};
|
|
866
|
-
const tags = [node.hidden ? "Hidden: not published" : null, node.hideOn?.includes("mobile") ? "Hidden on phones" : null, node.hideOn?.includes("desktop") ? "Phones only" : null, node.placeholder ? "Sample content: replace it" : null].filter(Boolean);
|
|
1007
|
+
const tags = [node.hidden ? "Hidden: not published" : null, node.hideOn?.includes("mobile") ? "Hidden on phones" : null, node.hideOn?.includes("desktop") ? "Phones only" : null, node.placeholder ? "Sample content: replace it" : null, unfinished.length ? `Not shown until filled in: ${unfinished.join(", ")}` : null].filter(Boolean);
|
|
867
1008
|
return /* @__PURE__ */ jsxs("div", { style: { position: "relative", ...node.hidden ? { opacity: 0.45 } : {} }, "data-gs-section": def.type, children: [
|
|
868
1009
|
tags.length ? /* @__PURE__ */ jsx(Tag, { children: tags.join(" \xB7 ") }) : null,
|
|
869
1010
|
/* @__PURE__ */ jsx(SectionBoundary, { label: def.label, children: def.render({ props: migrated.node.props, variant: migrated.node.variant, node: migrated.node, ctx }) }),
|
|
@@ -892,7 +1033,17 @@ function createEditorConfig(options2 = {}) {
|
|
|
892
1033
|
components[name] = {
|
|
893
1034
|
label: i === 0 ? def.label : `${def.label}: ${preset.name}`,
|
|
894
1035
|
fields,
|
|
895
|
-
|
|
1036
|
+
// What an added section starts with. A `sample` preset's section starts as a placeholder, carrying the props it
|
|
1037
|
+
// started with (data.ts): the publish check holds it until it's edited. Puck also draws existing items over these
|
|
1038
|
+
// defaults, so `nodeToItem` sets every key an item lacks to undefined.
|
|
1039
|
+
defaultProps: {
|
|
1040
|
+
...structuredClone(preset.props),
|
|
1041
|
+
_v: def.version,
|
|
1042
|
+
_variant: preset.variant,
|
|
1043
|
+
_hidden: false,
|
|
1044
|
+
_hideOn: "none",
|
|
1045
|
+
_placeholder: preset.sample ? structuredClone(preset.props) : void 0
|
|
1046
|
+
},
|
|
896
1047
|
// Read each time Puck asks (the Add picker), so a section at its limit can't be dragged in.
|
|
897
1048
|
permissions: {
|
|
898
1049
|
get insert() {
|
|
@@ -936,7 +1087,16 @@ function createEditorConfig(options2 = {}) {
|
|
|
936
1087
|
return { config, components: info, slotKeys: (type) => slots.get(sectionTypeOf(type)) ?? [] };
|
|
937
1088
|
}
|
|
938
1089
|
var usePuck = createUsePuck();
|
|
939
|
-
|
|
1090
|
+
function sampleHint(value, sample) {
|
|
1091
|
+
return sample && typeof value === "string" && value !== "" ? value : void 0;
|
|
1092
|
+
}
|
|
1093
|
+
function useSampleHint(value) {
|
|
1094
|
+
const selected = usePuck((s) => s.selectedItem);
|
|
1095
|
+
const sample = React11.useMemo(() => isUneditedSample(selected), [selected]);
|
|
1096
|
+
return sampleHint(value, sample);
|
|
1097
|
+
}
|
|
1098
|
+
var usePuck2 = createUsePuck();
|
|
1099
|
+
var EditorLockContext = React11.createContext(false);
|
|
940
1100
|
var fieldId = (p) => p.id ?? `gs-field-${p.name.replace(/[^a-zA-Z0-9_-]/g, "-")}`;
|
|
941
1101
|
function FieldShell({ id, label, children }) {
|
|
942
1102
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5 py-1", children: [
|
|
@@ -946,11 +1106,13 @@ function FieldShell({ id, label, children }) {
|
|
|
946
1106
|
}
|
|
947
1107
|
function TextInput(p) {
|
|
948
1108
|
const id = fieldId(p);
|
|
949
|
-
|
|
1109
|
+
const hint = useSampleHint(p.value);
|
|
1110
|
+
return /* @__PURE__ */ jsx(FieldShell, { id, label: p.field.label, children: /* @__PURE__ */ jsx(Input, { id, name: p.name, value: hint !== void 0 ? "" : typeof p.value === "string" ? p.value : "", placeholder: hint ?? p.field.placeholder, disabled: p.readOnly, onChange: (e) => p.onChange(e.currentTarget.value) }) });
|
|
950
1111
|
}
|
|
951
1112
|
function TextareaInput(p) {
|
|
952
1113
|
const id = fieldId(p);
|
|
953
|
-
|
|
1114
|
+
const hint = useSampleHint(p.value);
|
|
1115
|
+
return /* @__PURE__ */ jsx(FieldShell, { id, label: p.field.label, children: /* @__PURE__ */ jsx(Textarea, { id, name: p.name, rows: 3, value: hint !== void 0 ? "" : typeof p.value === "string" ? p.value : "", placeholder: hint ?? p.field.placeholder, disabled: p.readOnly, onChange: (e) => p.onChange(e.currentTarget.value) }) });
|
|
954
1116
|
}
|
|
955
1117
|
function NumberInput(p) {
|
|
956
1118
|
const id = fieldId(p);
|
|
@@ -999,13 +1161,13 @@ function RadioInput(p) {
|
|
|
999
1161
|
] });
|
|
1000
1162
|
}
|
|
1001
1163
|
function ComponentItem({ name, info, announce }) {
|
|
1002
|
-
const data =
|
|
1164
|
+
const data = usePuck2((s) => s.appState.data);
|
|
1003
1165
|
const meta = info.get(name);
|
|
1004
1166
|
const type = sectionTypeOf(name);
|
|
1005
|
-
const used =
|
|
1167
|
+
const used = React11.useMemo(() => countTypes(data).get(type) ?? 0, [data, type]);
|
|
1006
1168
|
const full = meta?.limit !== void 0 && used >= meta.limit;
|
|
1007
|
-
const dispatch =
|
|
1008
|
-
const locked =
|
|
1169
|
+
const dispatch = usePuck2((s) => s.dispatch);
|
|
1170
|
+
const locked = React11.useContext(EditorLockContext);
|
|
1009
1171
|
const label = meta?.label ?? name;
|
|
1010
1172
|
const add = () => {
|
|
1011
1173
|
if (locked) return;
|
|
@@ -1018,13 +1180,24 @@ function ComponentItem({ name, info, announce }) {
|
|
|
1018
1180
|
scrollCanvasTo(id, ref.current?.ownerDocument);
|
|
1019
1181
|
announce?.(`${label} added at the end of the ${zone === "root:header" ? "header" : zone === "root:footer" ? "footer" : "page"}. Its fields are open; Up and Down move it.`);
|
|
1020
1182
|
};
|
|
1021
|
-
const ref =
|
|
1022
|
-
|
|
1183
|
+
const ref = React11.useRef(null);
|
|
1184
|
+
React11.useEffect(() => {
|
|
1023
1185
|
const copy = ref.current?.closest('[class*="draggableBg"]');
|
|
1024
1186
|
if (copy) {
|
|
1025
1187
|
copy.setAttribute("aria-hidden", "true");
|
|
1026
1188
|
copy.inert = true;
|
|
1027
1189
|
}
|
|
1190
|
+
const item = ref.current?.closest("[data-puck-drawer-item]");
|
|
1191
|
+
if (!item || item === copy?.querySelector("[data-puck-drawer-item]")) return;
|
|
1192
|
+
const plain = () => {
|
|
1193
|
+
for (const name2 of ["role", "tabindex", "aria-roledescription", "aria-describedby", "aria-pressed", "aria-disabled"]) {
|
|
1194
|
+
if (item.hasAttribute(name2)) item.removeAttribute(name2);
|
|
1195
|
+
}
|
|
1196
|
+
};
|
|
1197
|
+
plain();
|
|
1198
|
+
const observer = new MutationObserver(plain);
|
|
1199
|
+
observer.observe(item, { attributes: true, attributeFilter: ["role", "tabindex", "aria-roledescription", "aria-describedby", "aria-pressed", "aria-disabled"] });
|
|
1200
|
+
return () => observer.disconnect();
|
|
1028
1201
|
}, []);
|
|
1029
1202
|
return /* @__PURE__ */ jsxs(
|
|
1030
1203
|
"div",
|
|
@@ -1032,7 +1205,7 @@ function ComponentItem({ name, info, announce }) {
|
|
|
1032
1205
|
ref,
|
|
1033
1206
|
className: cn(
|
|
1034
1207
|
"flex w-full items-center justify-between gap-2 rounded-md border border-border bg-background px-3 py-2 text-left text-sm text-foreground",
|
|
1035
|
-
full ? "cursor-not-allowed
|
|
1208
|
+
full ? "cursor-not-allowed bg-muted" : "cursor-grab hover:border-primary"
|
|
1036
1209
|
),
|
|
1037
1210
|
title: full ? `A page has at most ${meta?.limit} of these` : `Drag onto the page, or press Add: ${label}`,
|
|
1038
1211
|
children: [
|
|
@@ -1040,19 +1213,19 @@ function ComponentItem({ name, info, announce }) {
|
|
|
1040
1213
|
/* @__PURE__ */ jsx("span", { className: "font-medium", children: label }),
|
|
1041
1214
|
meta && meta.label !== meta.sectionLabel ? /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: meta.sectionLabel }) : null
|
|
1042
1215
|
] }),
|
|
1043
|
-
full ? /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "shrink-0", children: "Limit reached" }) : /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "outline", className: "h-7 shrink-0 px-2", "aria-label": `Add ${label}`, disabled: locked, onPointerDown: (e) => e.stopPropagation(), onClick: add, children: "Add" })
|
|
1216
|
+
full ? /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "shrink-0", children: "Limit reached" }) : /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "outline", className: "h-7 min-w-11 shrink-0 px-2", "aria-label": `Add ${label}`, disabled: locked, onPointerDown: (e) => e.stopPropagation(), onClick: add, children: "Add" })
|
|
1044
1217
|
]
|
|
1045
1218
|
}
|
|
1046
1219
|
);
|
|
1047
1220
|
}
|
|
1048
1221
|
function SectionActions({ info, announce }) {
|
|
1049
|
-
const selected =
|
|
1050
|
-
const getSelectorForId =
|
|
1051
|
-
const getItemBySelector =
|
|
1052
|
-
const dispatch =
|
|
1053
|
-
const locked =
|
|
1054
|
-
const upRef =
|
|
1055
|
-
const downRef =
|
|
1222
|
+
const selected = usePuck2((s) => s.selectedItem);
|
|
1223
|
+
const getSelectorForId = usePuck2((s) => s.getSelectorForId);
|
|
1224
|
+
const getItemBySelector = usePuck2((s) => s.getItemBySelector);
|
|
1225
|
+
const dispatch = usePuck2((s) => s.dispatch);
|
|
1226
|
+
const locked = React11.useContext(EditorLockContext);
|
|
1227
|
+
const upRef = React11.useRef(null);
|
|
1228
|
+
const downRef = React11.useRef(null);
|
|
1056
1229
|
if (!selected) return null;
|
|
1057
1230
|
const id = String(selected.props.id);
|
|
1058
1231
|
const selector = getSelectorForId(id);
|
|
@@ -1098,6 +1271,42 @@ function SectionActions({ info, announce }) {
|
|
|
1098
1271
|
] })
|
|
1099
1272
|
] });
|
|
1100
1273
|
}
|
|
1274
|
+
var OUTLINE_AREAS = {
|
|
1275
|
+
header: { label: "Header", order: 0 },
|
|
1276
|
+
"default-zone": { label: "Page", order: 1 },
|
|
1277
|
+
footer: { label: "Footer", order: 2 }
|
|
1278
|
+
};
|
|
1279
|
+
function OutlineAreas({ children }) {
|
|
1280
|
+
const ref = React11.useRef(null);
|
|
1281
|
+
React11.useEffect(() => {
|
|
1282
|
+
const root = ref.current;
|
|
1283
|
+
if (!root) return;
|
|
1284
|
+
const apply = () => {
|
|
1285
|
+
for (const title of root.querySelectorAll('[class*="LayerTree-zoneTitle"]')) {
|
|
1286
|
+
const list = title.parentElement;
|
|
1287
|
+
if (!list) continue;
|
|
1288
|
+
const text = [...title.childNodes].find((n) => n.nodeType === Node.TEXT_NODE && n.textContent?.trim());
|
|
1289
|
+
const key = title.dataset.gsArea ?? text?.textContent?.trim() ?? "";
|
|
1290
|
+
const area = OUTLINE_AREAS[key];
|
|
1291
|
+
if (!area) continue;
|
|
1292
|
+
title.dataset.gsArea = key;
|
|
1293
|
+
if (text && text.textContent !== area.label) text.textContent = area.label;
|
|
1294
|
+
list.style.display = "flex";
|
|
1295
|
+
list.style.flexDirection = "column";
|
|
1296
|
+
let el = title;
|
|
1297
|
+
while (el && (el === title || !el.matches('[class*="LayerTree-zoneTitle"]'))) {
|
|
1298
|
+
el.style.order = String(area.order);
|
|
1299
|
+
el = el.nextElementSibling;
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
};
|
|
1303
|
+
apply();
|
|
1304
|
+
const observer = new MutationObserver(apply);
|
|
1305
|
+
observer.observe(root, { childList: true, subtree: true, characterData: true });
|
|
1306
|
+
return () => observer.disconnect();
|
|
1307
|
+
}, []);
|
|
1308
|
+
return /* @__PURE__ */ jsx("div", { ref, className: "contents", children });
|
|
1309
|
+
}
|
|
1101
1310
|
function genesisOverrides(info, extra = {}, options2 = {}) {
|
|
1102
1311
|
return {
|
|
1103
1312
|
fields: ({ children }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -1119,6 +1328,7 @@ function genesisOverrides(info, extra = {}, options2 = {}) {
|
|
|
1119
1328
|
] });
|
|
1120
1329
|
},
|
|
1121
1330
|
drawerItem: ({ name }) => /* @__PURE__ */ jsx(ComponentItem, { name, info, announce: options2.announce }),
|
|
1331
|
+
outline: ({ children }) => /* @__PURE__ */ jsx(OutlineAreas, { children }),
|
|
1122
1332
|
...extra
|
|
1123
1333
|
};
|
|
1124
1334
|
}
|
|
@@ -1138,21 +1348,57 @@ async function checkSite(store, siteId, options2 = {}) {
|
|
|
1138
1348
|
issues = prepareRelease(draft.site, pages, {
|
|
1139
1349
|
reserved: options2.reserved ?? DEFAULT_RESERVED_PATHS,
|
|
1140
1350
|
...options2.brand ? { brand: options2.brand } : {},
|
|
1141
|
-
...store.assetOrigin ? { assetOrigins: [store.assetOrigin] } : {}
|
|
1351
|
+
...store.assetOrigin ? { assetOrigins: [store.assetOrigin] } : {},
|
|
1352
|
+
...options2.checks ? { checks: options2.checks } : {}
|
|
1142
1353
|
}).issues;
|
|
1143
1354
|
} catch (err) {
|
|
1144
1355
|
if (!(err instanceof PublishBlockedError)) {
|
|
1145
1356
|
issues = [{ severity: "error", code: "invalid-draft", message: `The drafts can't be checked: ${err.message}` }];
|
|
1146
1357
|
} else issues = err.issues;
|
|
1147
1358
|
}
|
|
1359
|
+
if ((options2.forms || options2.listForms) && options2.checks?.missingForms !== "off") {
|
|
1360
|
+
issues = [...issues, ...applyCheckLevels(await formIssues(options2, siteId, draft.site, pages), options2.checks)];
|
|
1361
|
+
}
|
|
1148
1362
|
const sorted = [...issues].sort((a, b) => a.severity === b.severity ? 0 : a.severity === "error" ? -1 : 1);
|
|
1149
1363
|
return { issues: sorted, publishable: !sorted.some((i) => i.severity === "error") };
|
|
1150
1364
|
}
|
|
1365
|
+
async function formIssues({ forms, listForms }, siteId, site, pages) {
|
|
1366
|
+
const found = [];
|
|
1367
|
+
const collect = (nodes, at, page) => {
|
|
1368
|
+
for (const node of nodes) if (!node.hidden && node.type === "form-embed") found.push({ node, at, ...page ? { page } : {} });
|
|
1369
|
+
};
|
|
1370
|
+
collect(site.header, "the site header");
|
|
1371
|
+
collect(site.footer, "the site footer");
|
|
1372
|
+
for (const p of pages) collect(p.doc.content, p.path, p);
|
|
1373
|
+
if (!found.length) return [];
|
|
1374
|
+
const listed = listForms ? await listForms().then((l) => new Set(l.map((f) => f.slug)), () => null) : null;
|
|
1375
|
+
const results = await Promise.all(
|
|
1376
|
+
found.map(async ({ node, at, page }) => {
|
|
1377
|
+
const slug = typeof node.props.form === "string" ? node.props.form : "";
|
|
1378
|
+
const known = !slug ? false : listed ? listed.has(slug) : forms ? Boolean(await Promise.resolve(forms(slug, { siteId, pagePath: page?.path ?? "/", mode: "live" })).catch(() => null)) : true;
|
|
1379
|
+
if (known) return null;
|
|
1380
|
+
const issue = {
|
|
1381
|
+
severity: "error",
|
|
1382
|
+
code: "form-missing",
|
|
1383
|
+
sectionId: node.id,
|
|
1384
|
+
...page ? { pageId: page.id, path: page.path } : {},
|
|
1385
|
+
message: slug ? `${at}: the form section shows \u201C${slug}\u201D, and there's no form by that name. Pick one of your forms in it.` : `${at}: the form section has no form. Pick one of your forms in it.`
|
|
1386
|
+
};
|
|
1387
|
+
return issue;
|
|
1388
|
+
})
|
|
1389
|
+
);
|
|
1390
|
+
return results.filter((i) => i !== null);
|
|
1391
|
+
}
|
|
1151
1392
|
async function publishSite(store, siteId, options2) {
|
|
1152
1393
|
const check = await checkSite(store, siteId, options2);
|
|
1153
1394
|
if (!check.publishable) return { blocked: check.issues };
|
|
1154
1395
|
try {
|
|
1155
|
-
const release = await store.publish(siteId, {
|
|
1396
|
+
const release = await store.publish(siteId, {
|
|
1397
|
+
brand: options2.brand,
|
|
1398
|
+
...options2.note?.trim() ? { note: options2.note.trim() } : {},
|
|
1399
|
+
...options2.reserved ? { reserved: options2.reserved } : {},
|
|
1400
|
+
...options2.checks ? { checks: options2.checks } : {}
|
|
1401
|
+
});
|
|
1156
1402
|
return { release };
|
|
1157
1403
|
} catch (err) {
|
|
1158
1404
|
if (err instanceof PublishBlockedError) return { blocked: err.issues };
|
|
@@ -1161,6 +1407,7 @@ async function publishSite(store, siteId, options2) {
|
|
|
1161
1407
|
}
|
|
1162
1408
|
function pathProblems(path, pages, options2 = {}) {
|
|
1163
1409
|
const problems = pagePathProblems(path, options2.reserved ?? DEFAULT_RESERVED_PATHS);
|
|
1410
|
+
if (path === NOT_FOUND_PATH && !options2.notFoundPage) problems.push(`${NOT_FOUND_PATH} is the site's 404 page: make it under Page not found.`);
|
|
1164
1411
|
if (pages.some((p) => p.path === path && p.id !== options2.except)) problems.push(`A page is already at ${path}.`);
|
|
1165
1412
|
return problems;
|
|
1166
1413
|
}
|
|
@@ -1190,8 +1437,29 @@ function pageTemplates() {
|
|
|
1190
1437
|
const doc = landingPage({ brand, message: { headline: title } }).pages[0].doc;
|
|
1191
1438
|
return { ...doc, root: { props: { ...doc.root.props, title } } };
|
|
1192
1439
|
}
|
|
1440
|
+
},
|
|
1441
|
+
{
|
|
1442
|
+
id: "not-found",
|
|
1443
|
+
label: "404 page",
|
|
1444
|
+
description: "What a visitor sees at an address the site doesn't have.",
|
|
1445
|
+
kind: "page",
|
|
1446
|
+
doc: ({ title }) => notFoundPageDoc({ title })
|
|
1193
1447
|
}
|
|
1194
1448
|
];
|
|
1449
|
+
templates.push({
|
|
1450
|
+
id: "blog",
|
|
1451
|
+
label: "Blog",
|
|
1452
|
+
description: "The page your posts live on: their list here, and each post at its own address below it. A site has one.",
|
|
1453
|
+
kind: "post",
|
|
1454
|
+
doc: ({ title }) => ({
|
|
1455
|
+
schemaVersion: 1,
|
|
1456
|
+
root: { props: { title } },
|
|
1457
|
+
content: [
|
|
1458
|
+
{ id: "post", type: "post-body", v: 1, variant: "article", props: {} },
|
|
1459
|
+
{ id: "posts", type: "blog-list", v: 1, variant: "grid", props: { heading: "Latest posts", perPage: 9 } }
|
|
1460
|
+
]
|
|
1461
|
+
})
|
|
1462
|
+
});
|
|
1195
1463
|
const starter = starterSite({ brand: exampleBrands.riverside, message: { headline: "Your headline" } });
|
|
1196
1464
|
for (const page of starter.pages.slice(1)) {
|
|
1197
1465
|
const name = page.doc.root.props.title;
|
|
@@ -1225,7 +1493,7 @@ async function createLandingPage(store, siteId, input) {
|
|
|
1225
1493
|
if (!title) throw new Error("Give the landing page a title.");
|
|
1226
1494
|
const draft = await store.getDraft(siteId);
|
|
1227
1495
|
if (!draft) throw new Error(`There's no site ${siteId}, or you can't edit it.`);
|
|
1228
|
-
const directory = landingDirectory(draft.site);
|
|
1496
|
+
const directory = landingDirectory(draft.site, input.defaultDirectory);
|
|
1229
1497
|
const path = landingPath(directory, input.slug);
|
|
1230
1498
|
const problems = landingSlugProblems(directory, input.slug, input.reserved ?? DEFAULT_RESERVED_PATHS);
|
|
1231
1499
|
if ((await store.listPages(siteId)).some((p) => p.path === path)) problems.push(`A page is already at ${path}.`);
|
|
@@ -1238,10 +1506,10 @@ async function moveLandingPage(store, pageId, slug, options2 = {}) {
|
|
|
1238
1506
|
if (!current) throw new Error("That page no longer exists.");
|
|
1239
1507
|
const draft = await store.getDraft(current.siteId);
|
|
1240
1508
|
if (!draft) throw new Error("You can't edit this site.");
|
|
1241
|
-
const directory = landingDirectory(draft.site);
|
|
1509
|
+
const directory = landingDirectory(draft.site, options2.defaultDirectory);
|
|
1242
1510
|
const problems = landingSlugProblems(directory, slug, options2.reserved ?? DEFAULT_RESERVED_PATHS);
|
|
1243
1511
|
if (problems.length) throw new Error(problems.join(" "));
|
|
1244
|
-
return renamePage(store, pageId, landingPath(directory, slug), options2);
|
|
1512
|
+
return renamePage(store, pageId, landingPath(directory, slug), options2.reserved ? { reserved: options2.reserved } : {});
|
|
1245
1513
|
}
|
|
1246
1514
|
async function setLandingDirectory(store, siteId, directory, options2 = {}) {
|
|
1247
1515
|
const reserved = options2.reserved ?? DEFAULT_RESERVED_PATHS;
|
|
@@ -1253,7 +1521,7 @@ async function setLandingDirectory(store, siteId, directory, options2 = {}) {
|
|
|
1253
1521
|
const partly = (err) => moved.length ? new LandingDirectoryError(moved, err) : err;
|
|
1254
1522
|
if (options2.movePages) {
|
|
1255
1523
|
const pages = await store.listPages(siteId);
|
|
1256
|
-
const moves = landingMoves(pages, landingDirectory(before.site), directory);
|
|
1524
|
+
const moves = landingMoves(pages, landingDirectory(before.site, options2.defaultDirectory), directory);
|
|
1257
1525
|
const moving = new Set(moves.map((m) => m.page.id));
|
|
1258
1526
|
const staying = pages.filter((p) => !moving.has(p.id));
|
|
1259
1527
|
const errors = moves.flatMap((m) => pathProblems(m.path, staying, { reserved }));
|
|
@@ -1302,13 +1570,13 @@ function SlugField({ id, directory, slug, problems, onChange, autoFocus }) {
|
|
|
1302
1570
|
] });
|
|
1303
1571
|
}
|
|
1304
1572
|
function NewLandingDialog({ open, onOpenChange, pages, directory, reserved, onCreate }) {
|
|
1305
|
-
const [title, setTitle] =
|
|
1306
|
-
const [slug, setSlug] =
|
|
1307
|
-
const [slugEdited, setSlugEdited] =
|
|
1308
|
-
const [error, setError] =
|
|
1309
|
-
const [busy, setBusy] =
|
|
1310
|
-
const id =
|
|
1311
|
-
|
|
1573
|
+
const [title, setTitle] = React11.useState("");
|
|
1574
|
+
const [slug, setSlug] = React11.useState("");
|
|
1575
|
+
const [slugEdited, setSlugEdited] = React11.useState(false);
|
|
1576
|
+
const [error, setError] = React11.useState(null);
|
|
1577
|
+
const [busy, setBusy] = React11.useState(false);
|
|
1578
|
+
const id = React11.useId();
|
|
1579
|
+
React11.useEffect(() => {
|
|
1312
1580
|
if (open) {
|
|
1313
1581
|
setTitle("");
|
|
1314
1582
|
setSlug("");
|
|
@@ -1381,12 +1649,12 @@ function NewLandingDialog({ open, onOpenChange, pages, directory, reserved, onCr
|
|
|
1381
1649
|
) }) });
|
|
1382
1650
|
}
|
|
1383
1651
|
function MoveLandingDialog({ page, pages, directory, reserved, onClose, onMove }) {
|
|
1384
|
-
const [slug, setSlug] =
|
|
1385
|
-
const [error, setError] =
|
|
1386
|
-
const [busy, setBusy] =
|
|
1387
|
-
const id =
|
|
1652
|
+
const [slug, setSlug] = React11.useState("");
|
|
1653
|
+
const [error, setError] = React11.useState(null);
|
|
1654
|
+
const [busy, setBusy] = React11.useState(false);
|
|
1655
|
+
const id = React11.useId();
|
|
1388
1656
|
const initial = page ? landingSlugOf(directory, page.path) ?? page.path.split("/").pop() ?? "" : "";
|
|
1389
|
-
|
|
1657
|
+
React11.useEffect(() => {
|
|
1390
1658
|
setSlug(initial);
|
|
1391
1659
|
setError(null);
|
|
1392
1660
|
}, [initial]);
|
|
@@ -1439,12 +1707,12 @@ function MoveLandingDialog({ page, pages, directory, reserved, onClose, onMove }
|
|
|
1439
1707
|
) }) });
|
|
1440
1708
|
}
|
|
1441
1709
|
function DirectoryDialog({ open, onOpenChange, pages, directory, reserved, onSave }) {
|
|
1442
|
-
const [value, setValue] =
|
|
1443
|
-
const [movePages, setMovePages] =
|
|
1444
|
-
const [error, setError] =
|
|
1445
|
-
const [busy, setBusy] =
|
|
1446
|
-
const id =
|
|
1447
|
-
|
|
1710
|
+
const [value, setValue] = React11.useState(directory);
|
|
1711
|
+
const [movePages, setMovePages] = React11.useState(true);
|
|
1712
|
+
const [error, setError] = React11.useState(null);
|
|
1713
|
+
const [busy, setBusy] = React11.useState(false);
|
|
1714
|
+
const id = React11.useId();
|
|
1715
|
+
React11.useEffect(() => {
|
|
1448
1716
|
if (open) {
|
|
1449
1717
|
setValue(directory);
|
|
1450
1718
|
setMovePages(true);
|
|
@@ -1508,12 +1776,12 @@ function DirectoryDialog({ open, onOpenChange, pages, directory, reserved, onSav
|
|
|
1508
1776
|
) }) });
|
|
1509
1777
|
}
|
|
1510
1778
|
function LandingPanel(props) {
|
|
1511
|
-
const [adding, setAdding] =
|
|
1512
|
-
const [moving, setMoving] =
|
|
1513
|
-
const [deleting, setDeleting] =
|
|
1514
|
-
const [editingDir, setEditingDir] =
|
|
1779
|
+
const [adding, setAdding] = React11.useState(false);
|
|
1780
|
+
const [moving, setMoving] = React11.useState(null);
|
|
1781
|
+
const [deleting, setDeleting] = React11.useState(null);
|
|
1782
|
+
const [editingDir, setEditingDir] = React11.useState(false);
|
|
1515
1783
|
const list = landingPages(props.pages);
|
|
1516
|
-
const headingId =
|
|
1784
|
+
const headingId = React11.useId();
|
|
1517
1785
|
return /* @__PURE__ */ jsxs("section", { "aria-labelledby": headingId, className: "flex flex-col gap-2", "data-gs-landing": "", children: [
|
|
1518
1786
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
1519
1787
|
/* @__PURE__ */ jsx("h2", { id: headingId, className: "text-sm font-semibold", children: "Landing pages" }),
|
|
@@ -1579,16 +1847,17 @@ function LandingPanel(props) {
|
|
|
1579
1847
|
] });
|
|
1580
1848
|
}
|
|
1581
1849
|
function AddPageDialog({ open, onOpenChange, pages, reserved, onCreate }) {
|
|
1582
|
-
const
|
|
1583
|
-
const
|
|
1584
|
-
const [
|
|
1585
|
-
const [
|
|
1586
|
-
const [
|
|
1587
|
-
const [
|
|
1588
|
-
const [
|
|
1589
|
-
const [
|
|
1590
|
-
const
|
|
1591
|
-
|
|
1850
|
+
const hasBlog = pages.some((p) => p.kind === "post");
|
|
1851
|
+
const templates = React11.useMemo(() => pageTemplates().filter((t) => t.kind !== "landing" && t.id !== "not-found" && !(t.kind === "post" && hasBlog)), [hasBlog]);
|
|
1852
|
+
const [title, setTitle] = React11.useState("");
|
|
1853
|
+
const [path, setPath] = React11.useState("");
|
|
1854
|
+
const [pathEdited, setPathEdited] = React11.useState(false);
|
|
1855
|
+
const [templateId, setTemplateId] = React11.useState("blank");
|
|
1856
|
+
const [addToMenu, setAddToMenu] = React11.useState(true);
|
|
1857
|
+
const [error, setError] = React11.useState(null);
|
|
1858
|
+
const [busy, setBusy] = React11.useState(false);
|
|
1859
|
+
const id = React11.useId();
|
|
1860
|
+
React11.useEffect(() => {
|
|
1592
1861
|
if (open) {
|
|
1593
1862
|
setTitle("");
|
|
1594
1863
|
setPath("");
|
|
@@ -1675,11 +1944,11 @@ function AddPageDialog({ open, onOpenChange, pages, reserved, onCreate }) {
|
|
|
1675
1944
|
] }) }) });
|
|
1676
1945
|
}
|
|
1677
1946
|
function RenameDialog({ page, pages, reserved, onClose, onRename }) {
|
|
1678
|
-
const [path, setPath] =
|
|
1679
|
-
const [error, setError] =
|
|
1680
|
-
const [busy, setBusy] =
|
|
1681
|
-
const id =
|
|
1682
|
-
|
|
1947
|
+
const [path, setPath] = React11.useState("");
|
|
1948
|
+
const [error, setError] = React11.useState(null);
|
|
1949
|
+
const [busy, setBusy] = React11.useState(false);
|
|
1950
|
+
const id = React11.useId();
|
|
1951
|
+
React11.useEffect(() => {
|
|
1683
1952
|
setPath(page?.path ?? "");
|
|
1684
1953
|
setError(null);
|
|
1685
1954
|
}, [page]);
|
|
@@ -1739,8 +2008,8 @@ function menuItemProblems(item) {
|
|
|
1739
2008
|
}
|
|
1740
2009
|
function MenuEditor({ nav, pages, busy, onChange }) {
|
|
1741
2010
|
const items = nav;
|
|
1742
|
-
const id =
|
|
1743
|
-
const list =
|
|
2011
|
+
const id = React11.useId();
|
|
2012
|
+
const list = React11.useRef(null);
|
|
1744
2013
|
const commit = (next) => onChange(next);
|
|
1745
2014
|
const move = (i, by) => {
|
|
1746
2015
|
const next = [...items];
|
|
@@ -1753,7 +2022,7 @@ function MenuEditor({ nav, pages, busy, onChange }) {
|
|
|
1753
2022
|
(same && !same.disabled ? same : list.current?.querySelector(`[data-menu-move="${j}:${-by}"]`))?.focus();
|
|
1754
2023
|
});
|
|
1755
2024
|
};
|
|
1756
|
-
const unlinked = pages.filter((p) => !isLandingPage(p) && !items.some((i) => i.href === p.path));
|
|
2025
|
+
const unlinked = pages.filter((p) => !isLandingPage(p) && !isNotFoundPage(p) && !items.some((i) => i.href === p.path));
|
|
1757
2026
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
1758
2027
|
items.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "The menu is empty." }) : null,
|
|
1759
2028
|
/* @__PURE__ */ jsx("ol", { ref: list, className: "flex flex-col gap-3", children: items.map((item, i) => {
|
|
@@ -1779,23 +2048,38 @@ function MenuEditor({ nav, pages, busy, onChange }) {
|
|
|
1779
2048
|
] }, i);
|
|
1780
2049
|
}) }),
|
|
1781
2050
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
1782
|
-
unlinked.slice(0, 4).map((p) => /* @__PURE__ */ jsxs(Button, { type: "button", size: "sm", variant: "outline", disabled: busy || items.length >= 12, onClick: () => commit([...items, { label: p.title.slice(0, 40), href: p.path }]), children: [
|
|
1783
|
-
/* @__PURE__ */ jsx(Plus, { className: "mr-1 h-3 w-3" }),
|
|
2051
|
+
unlinked.slice(0, 4).map((p) => /* @__PURE__ */ jsxs(Button, { type: "button", size: "sm", variant: "outline", "aria-label": `Add ${p.title} to the menu`, disabled: busy || items.length >= 12, onClick: () => commit([...items, { label: p.title.slice(0, 40), href: p.path }]), children: [
|
|
2052
|
+
/* @__PURE__ */ jsx(Plus, { className: "mr-1 h-3 w-3", "aria-hidden": true }),
|
|
1784
2053
|
" ",
|
|
1785
2054
|
p.title
|
|
1786
2055
|
] }, p.id)),
|
|
1787
|
-
/* @__PURE__ */ jsxs(Button, { type: "button", size: "sm", variant: "outline", disabled: busy || items.length >= 12, onClick: () => commit([...items, { label: "", href: "" }]), children: [
|
|
1788
|
-
/* @__PURE__ */ jsx(Plus, { className: "mr-1 h-3 w-3" }),
|
|
2056
|
+
/* @__PURE__ */ jsxs(Button, { type: "button", size: "sm", variant: "outline", disabled: busy || items.length >= 12, "aria-label": "Add a link to the menu", onClick: () => commit([...items, { label: "", href: "" }]), children: [
|
|
2057
|
+
/* @__PURE__ */ jsx(Plus, { className: "mr-1 h-3 w-3", "aria-hidden": true }),
|
|
1789
2058
|
" Link"
|
|
1790
2059
|
] })
|
|
1791
2060
|
] })
|
|
1792
2061
|
] });
|
|
1793
2062
|
}
|
|
1794
2063
|
function PagesPanel(props) {
|
|
1795
|
-
const [adding, setAdding] =
|
|
1796
|
-
const [renaming, setRenaming] =
|
|
1797
|
-
const [deleting, setDeleting] =
|
|
1798
|
-
const ordinary = props.pages.filter((p) => !isLandingPage(p));
|
|
2064
|
+
const [adding, setAdding] = React11.useState(false);
|
|
2065
|
+
const [renaming, setRenaming] = React11.useState(null);
|
|
2066
|
+
const [deleting, setDeleting] = React11.useState(null);
|
|
2067
|
+
const ordinary = props.pages.filter((p) => !isLandingPage(p) && !isNotFoundPage(p));
|
|
2068
|
+
const notFoundPage = props.pages.find(isNotFoundPage) ?? null;
|
|
2069
|
+
const notFoundTemplate = React11.useMemo(() => pageTemplates().find((t) => t.id === "not-found"), []);
|
|
2070
|
+
const [makingNotFound, setMakingNotFound] = React11.useState(false);
|
|
2071
|
+
const [notFoundError, setNotFoundError] = React11.useState(null);
|
|
2072
|
+
const makeNotFound = async () => {
|
|
2073
|
+
setNotFoundError(null);
|
|
2074
|
+
setMakingNotFound(true);
|
|
2075
|
+
try {
|
|
2076
|
+
await props.onCreate({ title: "Page not found", path: NOT_FOUND_PATH, template: notFoundTemplate, addToMenu: false });
|
|
2077
|
+
} catch (err) {
|
|
2078
|
+
setNotFoundError(err.message);
|
|
2079
|
+
} finally {
|
|
2080
|
+
setMakingNotFound(false);
|
|
2081
|
+
}
|
|
2082
|
+
};
|
|
1799
2083
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 p-3", children: [
|
|
1800
2084
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
1801
2085
|
/* @__PURE__ */ jsx("h2", { className: "text-sm font-semibold", children: "Pages" }),
|
|
@@ -1824,10 +2108,40 @@ function PagesPanel(props) {
|
|
|
1824
2108
|
] })
|
|
1825
2109
|
] }, p.id);
|
|
1826
2110
|
}) }),
|
|
2111
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
2112
|
+
/* @__PURE__ */ jsxs("section", { "aria-labelledby": "gs-not-found-heading", className: "flex flex-col gap-2", children: [
|
|
2113
|
+
/* @__PURE__ */ jsx("h2", { id: "gs-not-found-heading", className: "text-sm font-semibold", children: "Page not found" }),
|
|
2114
|
+
/* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground", children: [
|
|
2115
|
+
"What a visitor sees at an address the site doesn't have. ",
|
|
2116
|
+
notFoundPage ? null : "Without one, they see a short built-in message."
|
|
2117
|
+
] }),
|
|
2118
|
+
notFoundPage ? /* @__PURE__ */ jsxs("div", { className: cn("flex items-center gap-1 rounded-md border p-2", notFoundPage.id === props.currentId ? "border-primary bg-muted" : "border-transparent hover:border-border"), children: [
|
|
2119
|
+
/* @__PURE__ */ jsxs("button", { type: "button", className: "flex min-w-0 flex-1 items-center gap-2 text-left text-sm focus-visible:outline-2 focus-visible:outline-ring", "aria-current": notFoundPage.id === props.currentId ? "page" : void 0, onClick: () => props.onOpen(notFoundPage.id), disabled: props.busy, children: [
|
|
2120
|
+
/* @__PURE__ */ jsx(FileQuestion, { "aria-hidden": true, className: "h-4 w-4 shrink-0" }),
|
|
2121
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-col", children: [
|
|
2122
|
+
/* @__PURE__ */ jsx("span", { className: "truncate font-medium", children: notFoundPage.title }),
|
|
2123
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: notFoundPage.path })
|
|
2124
|
+
] })
|
|
2125
|
+
] }),
|
|
2126
|
+
props.readOnly ? null : /* @__PURE__ */ jsx(Button, { type: "button", size: "icon", variant: "ghost", disabled: props.busy, "aria-label": `Delete ${notFoundPage.title}`, onClick: () => setDeleting(notFoundPage), children: /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" }) })
|
|
2127
|
+
] }) : props.readOnly ? null : /* @__PURE__ */ jsxs(Button, { type: "button", size: "sm", variant: "outline", className: "self-start", loading: makingNotFound, disabled: props.busy, onClick: () => void makeNotFound(), children: [
|
|
2128
|
+
/* @__PURE__ */ jsx(Plus, { className: "mr-1 h-4 w-4" }),
|
|
2129
|
+
" Make a 404 page"
|
|
2130
|
+
] }),
|
|
2131
|
+
notFoundError ? /* @__PURE__ */ jsx("p", { role: "alert", className: "text-sm text-destructive", children: notFoundError }) : null
|
|
2132
|
+
] }),
|
|
1827
2133
|
props.landing ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1828
2134
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
1829
2135
|
props.landing
|
|
1830
2136
|
] }) : null,
|
|
2137
|
+
props.redirects ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2138
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
2139
|
+
props.redirects
|
|
2140
|
+
] }) : null,
|
|
2141
|
+
props.search ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2142
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
2143
|
+
props.search
|
|
2144
|
+
] }) : null,
|
|
1831
2145
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
1832
2146
|
/* @__PURE__ */ jsxs("section", { "aria-labelledby": "gs-menu-heading", className: "flex flex-col gap-2", children: [
|
|
1833
2147
|
/* @__PURE__ */ jsx("h2", { id: "gs-menu-heading", className: "text-sm font-semibold", children: "Menu" }),
|
|
@@ -1848,6 +2162,12 @@ function PagesPanel(props) {
|
|
|
1848
2162
|
/* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "outline", onClick: props.onEditFooter, children: "Edit the footer" })
|
|
1849
2163
|
] })
|
|
1850
2164
|
] }),
|
|
2165
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
2166
|
+
/* @__PURE__ */ jsxs("section", { "aria-labelledby": "gs-look-heading", className: "flex flex-col gap-2", children: [
|
|
2167
|
+
/* @__PURE__ */ jsx("h2", { id: "gs-look-heading", className: "text-sm font-semibold", children: "Look" }),
|
|
2168
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Fonts, colours and the logo come from the brand, so the site matches everything else it makes. A change goes live with the next publish." }),
|
|
2169
|
+
props.brandSettingsHref ? /* @__PURE__ */ jsx(Button, { asChild: true, size: "sm", variant: "outline", children: /* @__PURE__ */ jsx("a", { href: props.brandSettingsHref, children: "Change the brand's look" }) }) : null
|
|
2170
|
+
] }),
|
|
1851
2171
|
/* @__PURE__ */ jsx(AddPageDialog, { open: adding, onOpenChange: setAdding, pages: props.pages, reserved: props.reserved, onCreate: props.onCreate }),
|
|
1852
2172
|
/* @__PURE__ */ jsx(RenameDialog, { page: renaming, pages: props.pages, reserved: props.reserved, onClose: () => setRenaming(null), onRename: props.onRename }),
|
|
1853
2173
|
/* @__PURE__ */ jsx(AlertDialog, { open: deleting !== null, onOpenChange: (o) => o ? null : setDeleting(null), children: /* @__PURE__ */ jsxs(AlertDialogContent, { children: [
|
|
@@ -1875,20 +2195,473 @@ function PagesPanel(props) {
|
|
|
1875
2195
|
] }) })
|
|
1876
2196
|
] });
|
|
1877
2197
|
}
|
|
2198
|
+
var OTHER = "\0other";
|
|
2199
|
+
function describe(to, destinations) {
|
|
2200
|
+
const d = destinations.find((x) => x.path === to);
|
|
2201
|
+
return d ? `${d.label} (${to})` : to;
|
|
2202
|
+
}
|
|
2203
|
+
function RedirectDialog({
|
|
2204
|
+
editing,
|
|
2205
|
+
open,
|
|
2206
|
+
onClose,
|
|
2207
|
+
props
|
|
2208
|
+
}) {
|
|
2209
|
+
const [from, setFrom] = React11.useState("");
|
|
2210
|
+
const [choice, setChoice] = React11.useState(void 0);
|
|
2211
|
+
const [other, setOther] = React11.useState("");
|
|
2212
|
+
const [status, setStatus] = React11.useState("301");
|
|
2213
|
+
const [prefix, setPrefix] = React11.useState(false);
|
|
2214
|
+
const [keepRest, setKeepRest] = React11.useState(false);
|
|
2215
|
+
const [touched, setTouched] = React11.useState(false);
|
|
2216
|
+
const [error, setError] = React11.useState(null);
|
|
2217
|
+
const id = React11.useId();
|
|
2218
|
+
React11.useEffect(() => {
|
|
2219
|
+
if (!open) return;
|
|
2220
|
+
setFrom(editing?.from ?? "");
|
|
2221
|
+
const known = editing && props.destinations.some((d) => d.path === editing.to);
|
|
2222
|
+
setChoice(editing ? known ? editing.to : OTHER : void 0);
|
|
2223
|
+
setOther(editing && !known ? editing.to : "");
|
|
2224
|
+
setStatus(editing?.status === 302 ? "302" : "301");
|
|
2225
|
+
setPrefix(editing?.match === "prefix");
|
|
2226
|
+
setKeepRest(Boolean(editing?.keepRest));
|
|
2227
|
+
setTouched(false);
|
|
2228
|
+
setError(null);
|
|
2229
|
+
}, [open, editing]);
|
|
2230
|
+
const to = choice === OTHER ? other.trim() : choice ?? "";
|
|
2231
|
+
const ctx = { redirects: props.redirects, pages: props.pages, reserved: props.reserved, editing: editing?.from };
|
|
2232
|
+
const how = prefix ? { match: "prefix", keepRest: keepRest || void 0 } : {};
|
|
2233
|
+
const fromProblems = from ? redirectFromProblems(from, ctx, how) : [];
|
|
2234
|
+
const toProblems = touched || to ? redirectToProblems(from, to, ctx, how) : [];
|
|
2235
|
+
const options2 = [
|
|
2236
|
+
...props.destinations.map((d) => ({ value: d.path, label: d.label, description: `${d.group} \xB7 ${d.path}` })),
|
|
2237
|
+
{ value: OTHER, label: "Another address\u2026", description: "A site path or a full https link" }
|
|
2238
|
+
];
|
|
2239
|
+
return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: (o) => o ? null : onClose(), children: /* @__PURE__ */ jsx(DialogContent, { className: "sm:max-w-lg", children: /* @__PURE__ */ jsxs(
|
|
2240
|
+
"form",
|
|
2241
|
+
{
|
|
2242
|
+
className: "flex flex-col gap-4",
|
|
2243
|
+
onSubmit: (e) => {
|
|
2244
|
+
e.preventDefault();
|
|
2245
|
+
setTouched(true);
|
|
2246
|
+
if (!from) return setError("Give the old address.");
|
|
2247
|
+
const problems = [...redirectFromProblems(from, ctx, how), ...redirectToProblems(from, to, ctx, how)];
|
|
2248
|
+
if (problems.length) return setError(problems.join(" "));
|
|
2249
|
+
const next = { from, to, status: status === "302" ? 302 : 301, ...how.match ? { match: how.match } : {}, ...how.keepRest ? { keepRest: true } : {} };
|
|
2250
|
+
const failed = props.onChange(upsertRedirect(props.redirects, next, editing?.from));
|
|
2251
|
+
if (failed) return setError(failed);
|
|
2252
|
+
onClose();
|
|
2253
|
+
},
|
|
2254
|
+
children: [
|
|
2255
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [
|
|
2256
|
+
/* @__PURE__ */ jsx(DialogTitle, { children: editing ? "Edit redirect" : "New redirect" }),
|
|
2257
|
+
/* @__PURE__ */ jsx(DialogDescription, { children: "Visitors to the old address go to the one you choose. It goes live at the next publish." })
|
|
2258
|
+
] }),
|
|
2259
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
2260
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-from`, children: "Old address" }),
|
|
2261
|
+
/* @__PURE__ */ jsx(
|
|
2262
|
+
Input,
|
|
2263
|
+
{
|
|
2264
|
+
id: `${id}-from`,
|
|
2265
|
+
value: from,
|
|
2266
|
+
placeholder: "/feedback",
|
|
2267
|
+
autoFocus: true,
|
|
2268
|
+
"aria-invalid": fromProblems.length > 0 || void 0,
|
|
2269
|
+
"aria-describedby": `${id}-from-hint`,
|
|
2270
|
+
onChange: (e) => setFrom(e.currentTarget.value.trim().toLowerCase())
|
|
2271
|
+
}
|
|
2272
|
+
),
|
|
2273
|
+
/* @__PURE__ */ jsx("p", { id: `${id}-from-hint`, className: fromProblems.length ? "text-sm text-destructive" : "text-sm text-muted-foreground", children: fromProblems.length ? fromProblems.join(" ") : "A path on this site that has no page, like /feedback." })
|
|
2274
|
+
] }),
|
|
2275
|
+
/* @__PURE__ */ jsxs("fieldset", { className: "flex flex-col gap-2", children: [
|
|
2276
|
+
/* @__PURE__ */ jsx("legend", { className: "mb-2 text-sm font-medium", children: "Matches" }),
|
|
2277
|
+
/* @__PURE__ */ jsxs(RadioGroup, { value: prefix ? "prefix" : "exact", onValueChange: (v) => setPrefix(v === "prefix"), className: "flex flex-col gap-2", children: [
|
|
2278
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
2279
|
+
/* @__PURE__ */ jsx(RadioGroupItem, { id: `${id}-exact`, value: "exact", className: "mt-0.5" }),
|
|
2280
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-exact`, className: "font-normal", children: "Only this address" })
|
|
2281
|
+
] }),
|
|
2282
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
2283
|
+
/* @__PURE__ */ jsx(RadioGroupItem, { id: `${id}-prefix`, value: "prefix", className: "mt-0.5" }),
|
|
2284
|
+
/* @__PURE__ */ jsxs(Label, { htmlFor: `${id}-prefix`, className: "font-normal", children: [
|
|
2285
|
+
"This address and everything under it (",
|
|
2286
|
+
from || "/old",
|
|
2287
|
+
"/\u2026). Pages there still show."
|
|
2288
|
+
] })
|
|
2289
|
+
] })
|
|
2290
|
+
] }),
|
|
2291
|
+
prefix ? /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2 pl-6", children: [
|
|
2292
|
+
/* @__PURE__ */ jsx(Checkbox, { id: `${id}-rest`, checked: keepRest, onCheckedChange: (v) => setKeepRest(v === true), className: "mt-0.5" }),
|
|
2293
|
+
/* @__PURE__ */ jsxs(Label, { htmlFor: `${id}-rest`, className: "font-normal", children: [
|
|
2294
|
+
"Keep the rest of the address (",
|
|
2295
|
+
from || "/old",
|
|
2296
|
+
"/ana goes to ",
|
|
2297
|
+
(choice === OTHER ? other.trim() : choice) || "/new",
|
|
2298
|
+
"/ana)"
|
|
2299
|
+
] })
|
|
2300
|
+
] }) : null
|
|
2301
|
+
] }),
|
|
2302
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
2303
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-to`, children: "Goes to" }),
|
|
2304
|
+
/* @__PURE__ */ jsx(
|
|
2305
|
+
Combobox,
|
|
2306
|
+
{
|
|
2307
|
+
id: `${id}-to`,
|
|
2308
|
+
options: options2,
|
|
2309
|
+
value: choice,
|
|
2310
|
+
onChange: (v) => {
|
|
2311
|
+
setChoice(v);
|
|
2312
|
+
setTouched(true);
|
|
2313
|
+
},
|
|
2314
|
+
placeholder: "Choose a page, a landing page or another place",
|
|
2315
|
+
searchPlaceholder: "Search",
|
|
2316
|
+
emptyText: "Nothing matches.",
|
|
2317
|
+
contentClassName: "w-[var(--radix-popover-trigger-width)]"
|
|
2318
|
+
}
|
|
2319
|
+
),
|
|
2320
|
+
choice === OTHER ? /* @__PURE__ */ jsx(Input, { "aria-label": "Other address", value: other, placeholder: "https://example.com/page or /about", onChange: (e) => setOther(e.currentTarget.value) }) : null,
|
|
2321
|
+
toProblems.length ? /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: toProblems.join(" ") }) : null
|
|
2322
|
+
] }),
|
|
2323
|
+
/* @__PURE__ */ jsxs("fieldset", { className: "flex flex-col gap-2", children: [
|
|
2324
|
+
/* @__PURE__ */ jsx("legend", { className: "mb-2 text-sm font-medium", children: "Kind" }),
|
|
2325
|
+
/* @__PURE__ */ jsxs(RadioGroup, { value: status, onValueChange: (v) => setStatus(v), className: "flex flex-col gap-2", children: [
|
|
2326
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
2327
|
+
/* @__PURE__ */ jsx(RadioGroupItem, { id: `${id}-301`, value: "301", className: "mt-0.5" }),
|
|
2328
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-301`, className: "font-normal", children: "Permanent (301): the address has moved for good; search engines follow it." })
|
|
2329
|
+
] }),
|
|
2330
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
2331
|
+
/* @__PURE__ */ jsx(RadioGroupItem, { id: `${id}-302`, value: "302", className: "mt-0.5" }),
|
|
2332
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-302`, className: "font-normal", children: "Temporary (302): a short link, or for now." })
|
|
2333
|
+
] })
|
|
2334
|
+
] })
|
|
2335
|
+
] }),
|
|
2336
|
+
error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "text-sm text-destructive", children: error }) : null,
|
|
2337
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [
|
|
2338
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: onClose, children: "Cancel" }),
|
|
2339
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", children: "Save" })
|
|
2340
|
+
] })
|
|
2341
|
+
]
|
|
2342
|
+
}
|
|
2343
|
+
) }) });
|
|
2344
|
+
}
|
|
2345
|
+
function RedirectsPanel(props) {
|
|
2346
|
+
const [editing, setEditing] = React11.useState(null);
|
|
2347
|
+
const [adding, setAdding] = React11.useState(false);
|
|
2348
|
+
const [removing, setRemoving] = React11.useState(null);
|
|
2349
|
+
const [error, setError] = React11.useState(null);
|
|
2350
|
+
const headingId = React11.useId();
|
|
2351
|
+
return /* @__PURE__ */ jsxs("section", { "aria-labelledby": headingId, className: "flex flex-col gap-2", "data-gs-redirects": "", children: [
|
|
2352
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2353
|
+
/* @__PURE__ */ jsx("h2", { id: headingId, className: "text-sm font-semibold", children: "Redirects" }),
|
|
2354
|
+
props.readOnly ? null : /* @__PURE__ */ jsxs(Button, { type: "button", size: "sm", onClick: () => setAdding(true), disabled: props.busy, children: [
|
|
2355
|
+
/* @__PURE__ */ jsx(Plus, { className: "mr-1 h-4 w-4" }),
|
|
2356
|
+
" New redirect"
|
|
2357
|
+
] })
|
|
2358
|
+
] }),
|
|
2359
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Send an old or short address to a page, a landing page, a form or anywhere else. Moving a page adds one for you." }),
|
|
2360
|
+
props.redirects.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "No redirects yet." }) : null,
|
|
2361
|
+
/* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-1", "aria-label": "Redirects", children: props.redirects.map((r) => /* @__PURE__ */ jsxs("li", { className: "flex flex-col gap-1 rounded-md border border-transparent p-2 hover:border-border", children: [
|
|
2362
|
+
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2 text-sm", children: [
|
|
2363
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1 truncate font-medium", children: [
|
|
2364
|
+
r.from,
|
|
2365
|
+
r.match === "prefix" ? /* @__PURE__ */ jsx("span", { className: "font-normal text-muted-foreground", children: " and everything under it" }) : null
|
|
2366
|
+
] }),
|
|
2367
|
+
/* @__PURE__ */ jsx(Badge, { variant: "secondary", children: r.status === 301 ? "Permanent" : "Temporary" })
|
|
2368
|
+
] }),
|
|
2369
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-center gap-1 text-xs text-muted-foreground", children: [
|
|
2370
|
+
/* @__PURE__ */ jsx(ArrowRight, { "aria-label": "goes to", className: "h-3 w-3 shrink-0" }),
|
|
2371
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0 break-all", children: [
|
|
2372
|
+
describe(r.to, props.destinations),
|
|
2373
|
+
r.keepRest ? " (keeping the rest of the address)" : null
|
|
2374
|
+
] })
|
|
2375
|
+
] }),
|
|
2376
|
+
props.readOnly ? null : /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
|
|
2377
|
+
/* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "ghost", disabled: props.busy, "aria-label": `Edit the redirect from ${r.from}`, onClick: () => setEditing(r), children: "Edit" }),
|
|
2378
|
+
/* @__PURE__ */ jsx(Button, { type: "button", size: "icon", variant: "ghost", disabled: props.busy, "aria-label": `Remove the redirect from ${r.from}`, onClick: () => setRemoving(r), children: /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" }) })
|
|
2379
|
+
] })
|
|
2380
|
+
] }, r.from)) }),
|
|
2381
|
+
error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "text-sm text-destructive", children: error }) : null,
|
|
2382
|
+
/* @__PURE__ */ jsx(RedirectDialog, { open: adding || editing !== null, editing, props, onClose: () => (setAdding(false), setEditing(null)) }),
|
|
2383
|
+
/* @__PURE__ */ jsx(AlertDialog, { open: removing !== null, onOpenChange: (o) => o ? null : setRemoving(null), children: /* @__PURE__ */ jsxs(AlertDialogContent, { children: [
|
|
2384
|
+
/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
|
|
2385
|
+
/* @__PURE__ */ jsxs(AlertDialogTitle, { children: [
|
|
2386
|
+
"Remove the redirect from ",
|
|
2387
|
+
removing?.from,
|
|
2388
|
+
"?"
|
|
2389
|
+
] }),
|
|
2390
|
+
/* @__PURE__ */ jsxs(AlertDialogDescription, { children: [
|
|
2391
|
+
"From the next publish, visitors to ",
|
|
2392
|
+
removing?.from,
|
|
2393
|
+
" see the page-not-found page."
|
|
2394
|
+
] })
|
|
2395
|
+
] }),
|
|
2396
|
+
/* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
|
|
2397
|
+
/* @__PURE__ */ jsx(AlertDialogCancel, { children: "Keep it" }),
|
|
2398
|
+
/* @__PURE__ */ jsx(
|
|
2399
|
+
AlertDialogAction,
|
|
2400
|
+
{
|
|
2401
|
+
onClick: () => {
|
|
2402
|
+
if (removing) setError(props.onChange(removeRedirect(props.redirects, removing.from)));
|
|
2403
|
+
setRemoving(null);
|
|
2404
|
+
},
|
|
2405
|
+
children: "Remove redirect"
|
|
2406
|
+
}
|
|
2407
|
+
)
|
|
2408
|
+
] })
|
|
2409
|
+
] }) })
|
|
2410
|
+
] });
|
|
2411
|
+
}
|
|
2412
|
+
var lines = (text) => text.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
2413
|
+
function searchForm(seo) {
|
|
2414
|
+
const b = seo.localBusiness;
|
|
2415
|
+
return {
|
|
2416
|
+
titleTemplate: seo.titleTemplate ?? "",
|
|
2417
|
+
description: seo.description ?? "",
|
|
2418
|
+
noindex: seo.noindex === true,
|
|
2419
|
+
orgName: seo.organization?.name ?? "",
|
|
2420
|
+
sameAs: (seo.organization?.sameAs ?? []).join("\n"),
|
|
2421
|
+
business: Boolean(b),
|
|
2422
|
+
type: b?.type ?? "LocalBusiness",
|
|
2423
|
+
name: b?.name ?? "",
|
|
2424
|
+
about: b?.description ?? "",
|
|
2425
|
+
telephone: b?.telephone ?? "",
|
|
2426
|
+
email: b?.email ?? "",
|
|
2427
|
+
foundingDate: b?.foundingDate ?? "",
|
|
2428
|
+
priceRange: b?.priceRange ?? "",
|
|
2429
|
+
street: b?.address.streetAddress ?? "",
|
|
2430
|
+
locality: b?.address.addressLocality ?? "",
|
|
2431
|
+
region: b?.address.addressRegion ?? "",
|
|
2432
|
+
postalCode: b?.address.postalCode ?? "",
|
|
2433
|
+
country: b?.address.addressCountry ?? "",
|
|
2434
|
+
latitude: b?.geo ? String(b.geo.latitude) : "",
|
|
2435
|
+
longitude: b?.geo ? String(b.geo.longitude) : "",
|
|
2436
|
+
hours: (b?.openingHours ?? []).join("\n"),
|
|
2437
|
+
pages: [...b?.pages ?? []]
|
|
2438
|
+
};
|
|
2439
|
+
}
|
|
2440
|
+
function seoFromForm(form, current) {
|
|
2441
|
+
const opt = (v) => v.trim() ? v.trim() : void 0;
|
|
2442
|
+
const { titleTemplate: _t, description: _d, noindex: _n, organization: currentOrg, localBusiness: currentBusiness, ...kept } = current;
|
|
2443
|
+
const sameAs = lines(form.sameAs);
|
|
2444
|
+
const organization = form.orgName.trim() ? { ...currentOrg?.logo ? { logo: currentOrg.logo } : {}, name: form.orgName.trim(), ...sameAs.length ? { sameAs } : {} } : void 0;
|
|
2445
|
+
if (!organization && sameAs.length) return { error: "Give the organization's name for its profile links." };
|
|
2446
|
+
let localBusiness;
|
|
2447
|
+
if (form.business) {
|
|
2448
|
+
if (!form.street.trim() || !form.locality.trim()) return { error: "The business needs a street address and a town or city." };
|
|
2449
|
+
const lat = opt(form.latitude);
|
|
2450
|
+
const lng = opt(form.longitude);
|
|
2451
|
+
if (Boolean(lat) !== Boolean(lng)) return { error: "Give both latitude and longitude, or neither." };
|
|
2452
|
+
if (lat && !Number.isFinite(Number(lat)) || lng && !Number.isFinite(Number(lng))) return { error: "Latitude and longitude are numbers, such as 40.7128 and -74.006." };
|
|
2453
|
+
const hours = lines(form.hours);
|
|
2454
|
+
localBusiness = {
|
|
2455
|
+
type: opt(form.type) ?? "LocalBusiness",
|
|
2456
|
+
...opt(form.name) ? { name: opt(form.name) } : {},
|
|
2457
|
+
...opt(form.about) ? { description: opt(form.about) } : {},
|
|
2458
|
+
...opt(form.telephone) ? { telephone: opt(form.telephone) } : {},
|
|
2459
|
+
...opt(form.email) ? { email: opt(form.email) } : {},
|
|
2460
|
+
...opt(form.foundingDate) ? { foundingDate: opt(form.foundingDate) } : {},
|
|
2461
|
+
...opt(form.priceRange) ? { priceRange: opt(form.priceRange) } : {},
|
|
2462
|
+
...currentBusiness?.image ? { image: currentBusiness.image } : {},
|
|
2463
|
+
address: {
|
|
2464
|
+
streetAddress: form.street.trim(),
|
|
2465
|
+
addressLocality: form.locality.trim(),
|
|
2466
|
+
...opt(form.region) ? { addressRegion: opt(form.region) } : {},
|
|
2467
|
+
...opt(form.postalCode) ? { postalCode: opt(form.postalCode) } : {},
|
|
2468
|
+
...opt(form.country) ? { addressCountry: opt(form.country).toUpperCase() } : {}
|
|
2469
|
+
},
|
|
2470
|
+
...lat && lng ? { geo: { latitude: Number(lat), longitude: Number(lng) } } : {},
|
|
2471
|
+
...hours.length ? { openingHours: hours } : {},
|
|
2472
|
+
...form.pages.length ? { pages: form.pages } : {}
|
|
2473
|
+
};
|
|
2474
|
+
}
|
|
2475
|
+
const next = {
|
|
2476
|
+
...kept,
|
|
2477
|
+
...opt(form.titleTemplate) ? { titleTemplate: opt(form.titleTemplate) } : {},
|
|
2478
|
+
...opt(form.description) ? { description: opt(form.description) } : {},
|
|
2479
|
+
...form.noindex ? { noindex: true } : {},
|
|
2480
|
+
...organization ? { organization } : {},
|
|
2481
|
+
...localBusiness ? { localBusiness } : {}
|
|
2482
|
+
};
|
|
2483
|
+
const parsed = SeoDefaults.safeParse(next);
|
|
2484
|
+
if (!parsed.success) {
|
|
2485
|
+
const issue = parsed.error.issues[0];
|
|
2486
|
+
const key = String([...issue.path].reverse().find((p) => typeof p === "string") ?? "");
|
|
2487
|
+
const field = FIELD_NAMES[key] ?? issue.path.join(".");
|
|
2488
|
+
const message = issue.code === "invalid_format" ? FORMATS[key] ?? "isn't in the right form." : issue.message;
|
|
2489
|
+
return { error: `${field}: ${message}` };
|
|
2490
|
+
}
|
|
2491
|
+
return { seo: parsed.data };
|
|
2492
|
+
}
|
|
2493
|
+
var FORMATS = {
|
|
2494
|
+
type: "a schema.org type, such as LocalBusiness or Store.",
|
|
2495
|
+
telephone: "digits, spaces and + ( ) . -, such as +1 555 010 0200.",
|
|
2496
|
+
email: "an email address.",
|
|
2497
|
+
foundingDate: "a year, or a date as 2012-05-01.",
|
|
2498
|
+
addressCountry: "a two-letter country code, such as US.",
|
|
2499
|
+
openingHours: "days and times, such as Mo-Fr 06:00-20:00.",
|
|
2500
|
+
sameAs: "https links."
|
|
2501
|
+
};
|
|
2502
|
+
var FIELD_NAMES = {
|
|
2503
|
+
titleTemplate: "Title pattern",
|
|
2504
|
+
description: "Description",
|
|
2505
|
+
name: "Name",
|
|
2506
|
+
sameAs: "Profile links",
|
|
2507
|
+
type: "Kind of business",
|
|
2508
|
+
telephone: "Phone",
|
|
2509
|
+
email: "Email",
|
|
2510
|
+
foundingDate: "Founded",
|
|
2511
|
+
priceRange: "Price range",
|
|
2512
|
+
addressCountry: "Country",
|
|
2513
|
+
openingHours: "Opening hours",
|
|
2514
|
+
pages: "Pages"
|
|
2515
|
+
};
|
|
2516
|
+
function Field({ id, label, hint, children }) {
|
|
2517
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2518
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: id, children: label }),
|
|
2519
|
+
children,
|
|
2520
|
+
hint ? /* @__PURE__ */ jsx("p", { id: `${id}-hint`, className: "text-xs text-muted-foreground", children: hint }) : null
|
|
2521
|
+
] });
|
|
2522
|
+
}
|
|
2523
|
+
function SearchDialog({ open, onClose, props }) {
|
|
2524
|
+
const [form, setForm] = React11.useState(() => searchForm(props.seo));
|
|
2525
|
+
const [error, setError] = React11.useState(null);
|
|
2526
|
+
const id = React11.useId();
|
|
2527
|
+
React11.useEffect(() => {
|
|
2528
|
+
if (!open) return;
|
|
2529
|
+
setForm(searchForm(props.seo));
|
|
2530
|
+
setError(null);
|
|
2531
|
+
}, [open]);
|
|
2532
|
+
const set = (key) => (value) => setForm((f) => ({ ...f, [key]: value }));
|
|
2533
|
+
const text = (key, label, hint, extra = {}) => /* @__PURE__ */ jsx(Field, { id: `${id}-${key}`, label, ...hint ? { hint } : {}, children: /* @__PURE__ */ jsx(Input, { id: `${id}-${key}`, value: form[key], ...hint ? { "aria-describedby": `${id}-${key}-hint` } : {}, ...extra, onChange: (e) => set(key)(e.currentTarget.value) }) });
|
|
2534
|
+
const pages = props.pages.filter((p) => p.path !== "/" && !isNotFoundPage(p) && p.kind !== "post");
|
|
2535
|
+
return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: (o) => o ? null : onClose(), children: /* @__PURE__ */ jsx(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-xl", children: /* @__PURE__ */ jsxs(
|
|
2536
|
+
"form",
|
|
2537
|
+
{
|
|
2538
|
+
className: "flex flex-col gap-5",
|
|
2539
|
+
onSubmit: (e) => {
|
|
2540
|
+
e.preventDefault();
|
|
2541
|
+
const result = seoFromForm(form, props.seo);
|
|
2542
|
+
if ("error" in result) return setError(result.error);
|
|
2543
|
+
const failed = props.onChange(result.seo);
|
|
2544
|
+
if (failed) return setError(failed);
|
|
2545
|
+
onClose();
|
|
2546
|
+
},
|
|
2547
|
+
children: [
|
|
2548
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [
|
|
2549
|
+
/* @__PURE__ */ jsx(DialogTitle, { children: "Search and sharing" }),
|
|
2550
|
+
/* @__PURE__ */ jsx(DialogDescription, { children: "How the site shows in search results and link previews. Changes go live at the next publish." })
|
|
2551
|
+
] }),
|
|
2552
|
+
/* @__PURE__ */ jsxs("fieldset", { className: "flex flex-col gap-3", children: [
|
|
2553
|
+
/* @__PURE__ */ jsx("legend", { className: "mb-1 text-sm font-semibold", children: "Every page" }),
|
|
2554
|
+
text("titleTemplate", "Title pattern", "%s is the page's title: \u201C%s \xB7 Your business\u201D.", { placeholder: "%s \xB7 Your business" }),
|
|
2555
|
+
/* @__PURE__ */ jsx(Field, { id: `${id}-description`, label: "Description", hint: "For pages without their own: a sentence or two, up to 200 characters.", children: /* @__PURE__ */ jsx(Textarea, { id: `${id}-description`, value: form.description, rows: 2, maxLength: 200, "aria-describedby": `${id}-description-hint`, onChange: (e) => set("description")(e.currentTarget.value) }) }),
|
|
2556
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
2557
|
+
/* @__PURE__ */ jsx(Checkbox, { id: `${id}-noindex`, checked: form.noindex, onCheckedChange: (c) => set("noindex")(c === true) }),
|
|
2558
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-noindex`, className: "font-normal", children: "Keep the whole site out of search results" })
|
|
2559
|
+
] })
|
|
2560
|
+
] }),
|
|
2561
|
+
/* @__PURE__ */ jsxs("fieldset", { className: "flex flex-col gap-3", children: [
|
|
2562
|
+
/* @__PURE__ */ jsx("legend", { className: "mb-1 text-sm font-semibold", children: "Organization" }),
|
|
2563
|
+
text("orgName", "Name", "The name search engines show for the site's owner."),
|
|
2564
|
+
/* @__PURE__ */ jsx(Field, { id: `${id}-sameAs`, label: "Profile links", hint: "The organization's pages elsewhere (social profiles), one https link per line, up to 10.", children: /* @__PURE__ */ jsx(Textarea, { id: `${id}-sameAs`, value: form.sameAs, rows: 2, "aria-describedby": `${id}-sameAs-hint`, onChange: (e) => set("sameAs")(e.currentTarget.value) }) })
|
|
2565
|
+
] }),
|
|
2566
|
+
/* @__PURE__ */ jsxs("fieldset", { className: "flex flex-col gap-3", children: [
|
|
2567
|
+
/* @__PURE__ */ jsx("legend", { className: "mb-1 text-sm font-semibold", children: "Business at an address" }),
|
|
2568
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
2569
|
+
/* @__PURE__ */ jsx(Checkbox, { id: `${id}-business`, checked: form.business, onCheckedChange: (c) => set("business")(c === true) }),
|
|
2570
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-business`, className: "font-normal", children: "Tell search engines about a place visitors can come to" })
|
|
2571
|
+
] }),
|
|
2572
|
+
form.business ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2573
|
+
text("type", "Kind of business", "A schema.org type: LocalBusiness, or a more specific one such as Store."),
|
|
2574
|
+
text("name", "Name", "Leave empty to use the site's name."),
|
|
2575
|
+
/* @__PURE__ */ jsx(Field, { id: `${id}-about`, label: "About", children: /* @__PURE__ */ jsx(Textarea, { id: `${id}-about`, value: form.about, rows: 2, maxLength: 300, onChange: (e) => set("about")(e.currentTarget.value) }) }),
|
|
2576
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
2577
|
+
text("telephone", "Phone", void 0, { type: "tel", autoComplete: "off" }),
|
|
2578
|
+
text("email", "Email", void 0, { type: "email", autoComplete: "off" })
|
|
2579
|
+
] }),
|
|
2580
|
+
text("street", "Street address"),
|
|
2581
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
2582
|
+
text("locality", "Town or city"),
|
|
2583
|
+
text("region", "State or region"),
|
|
2584
|
+
text("postalCode", "Postal code"),
|
|
2585
|
+
text("country", "Country", "Two letters, such as US.", { maxLength: 2 })
|
|
2586
|
+
] }),
|
|
2587
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
2588
|
+
text("latitude", "Latitude", void 0, { inputMode: "decimal" }),
|
|
2589
|
+
text("longitude", "Longitude", void 0, { inputMode: "decimal" })
|
|
2590
|
+
] }),
|
|
2591
|
+
/* @__PURE__ */ jsx(Field, { id: `${id}-hours`, label: "Opening hours", hint: "One line each, as days and times: Mo-Fr 06:00-20:00, Sa 08:00-12:00.", children: /* @__PURE__ */ jsx(Textarea, { id: `${id}-hours`, value: form.hours, rows: 3, "aria-describedby": `${id}-hours-hint`, onChange: (e) => set("hours")(e.currentTarget.value) }) }),
|
|
2592
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
2593
|
+
text("foundingDate", "Founded", "A year, or YYYY-MM-DD."),
|
|
2594
|
+
text("priceRange", "Price range", "Such as $$.")
|
|
2595
|
+
] }),
|
|
2596
|
+
pages.length ? /* @__PURE__ */ jsxs("fieldset", { className: "flex flex-col gap-2", children: [
|
|
2597
|
+
/* @__PURE__ */ jsx("legend", { className: "text-sm font-medium", children: "Also on these pages" }),
|
|
2598
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "The home page always carries it." }),
|
|
2599
|
+
pages.map((p) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
2600
|
+
/* @__PURE__ */ jsx(
|
|
2601
|
+
Checkbox,
|
|
2602
|
+
{
|
|
2603
|
+
id: `${id}-page-${p.path}`,
|
|
2604
|
+
checked: form.pages.includes(p.path),
|
|
2605
|
+
onCheckedChange: (c) => set("pages")(c === true ? [...form.pages, p.path] : form.pages.filter((x) => x !== p.path))
|
|
2606
|
+
}
|
|
2607
|
+
),
|
|
2608
|
+
/* @__PURE__ */ jsxs(Label, { htmlFor: `${id}-page-${p.path}`, className: "font-normal", children: [
|
|
2609
|
+
p.title,
|
|
2610
|
+
" ",
|
|
2611
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
2612
|
+
"(",
|
|
2613
|
+
p.path,
|
|
2614
|
+
")"
|
|
2615
|
+
] })
|
|
2616
|
+
] })
|
|
2617
|
+
] }, p.path))
|
|
2618
|
+
] }) : null
|
|
2619
|
+
] }) : null
|
|
2620
|
+
] }),
|
|
2621
|
+
error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "text-sm text-destructive", children: error }) : null,
|
|
2622
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [
|
|
2623
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: onClose, children: "Cancel" }),
|
|
2624
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", disabled: props.busy, children: "Save" })
|
|
2625
|
+
] })
|
|
2626
|
+
]
|
|
2627
|
+
}
|
|
2628
|
+
) }) });
|
|
2629
|
+
}
|
|
2630
|
+
function SearchPanel(props) {
|
|
2631
|
+
const [open, setOpen] = React11.useState(false);
|
|
2632
|
+
const headingId = React11.useId();
|
|
2633
|
+
const b = props.seo.localBusiness;
|
|
2634
|
+
const summary = [
|
|
2635
|
+
props.seo.noindex ? "Hidden from search" : props.seo.description ? "Description set" : "No description",
|
|
2636
|
+
props.seo.organization ? props.seo.organization.name : null,
|
|
2637
|
+
b ? `${b.address.addressLocality} business` : null
|
|
2638
|
+
].filter(Boolean);
|
|
2639
|
+
return /* @__PURE__ */ jsxs("section", { "aria-labelledby": headingId, className: "flex flex-col gap-2", "data-gs-search": "", children: [
|
|
2640
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2641
|
+
/* @__PURE__ */ jsx("h2", { id: headingId, className: "text-sm font-semibold", children: "Search and sharing" }),
|
|
2642
|
+
props.readOnly ? null : /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "ghost", disabled: props.busy, onClick: () => setOpen(true), children: "Edit" })
|
|
2643
|
+
] }),
|
|
2644
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: summary.join(" \xB7 ") }),
|
|
2645
|
+
/* @__PURE__ */ jsx(SearchDialog, { open, onClose: () => setOpen(false), props })
|
|
2646
|
+
] });
|
|
2647
|
+
}
|
|
1878
2648
|
|
|
1879
2649
|
// src/editor/preview.ts
|
|
1880
2650
|
async function loadSiteCss() {
|
|
1881
|
-
const { ASSETS } = await import('./assets.generated-
|
|
2651
|
+
const { ASSETS } = await import('./assets.generated-ZBFSP23U.js');
|
|
1882
2652
|
return ASSETS.css.body;
|
|
1883
2653
|
}
|
|
1884
2654
|
var styleText = (css) => css.replace(/<\/style/gi, "<\\/style");
|
|
1885
2655
|
async function renderPreview(input) {
|
|
1886
|
-
const [{ renderSitePageToString }, { ASSETS }] = await Promise.all([import('./handler-
|
|
2656
|
+
const [{ renderSitePageToString }, { ASSETS }] = await Promise.all([import('./handler-OR554RTS.js'), import('./assets.generated-ZBFSP23U.js')]);
|
|
1887
2657
|
const result = await renderSitePageToString(new Request(`https://preview.invalid${input.path}`), {
|
|
1888
2658
|
store: input.store,
|
|
1889
2659
|
brand: { getBrand: () => input.brand },
|
|
1890
2660
|
siteId: input.siteId,
|
|
1891
2661
|
mode: input.mode,
|
|
2662
|
+
// The editor is the viewer: its store is the one it edits with, signed in as it, so the
|
|
2663
|
+
// database still decides which drafts come back. (The handler's own rule is for anonymous requests.)
|
|
2664
|
+
viewer: "editor",
|
|
1892
2665
|
unknownPath: "not-found",
|
|
1893
2666
|
csp: false,
|
|
1894
2667
|
...input.forms ? { forms: input.forms } : {}
|
|
@@ -1900,13 +2673,13 @@ async function renderPreview(input) {
|
|
|
1900
2673
|
const html = result.html.replace(/<link rel="stylesheet" href="[^"]*\/_gs\/([^"]+)"\/>/g, (_m, name) => name === ASSETS.css.name ? css : name === ASSETS.formsCss.name ? formsCss : "").replace(/<script type="module" src="[^"]*\/_gs\/[^"]*"><\/script>/g, "");
|
|
1901
2674
|
return { status: result.status, html };
|
|
1902
2675
|
}
|
|
1903
|
-
var
|
|
2676
|
+
var usePuck3 = createUsePuck();
|
|
1904
2677
|
function SeoFields({ siteName, pagePath, pageTitle, readOnly }) {
|
|
1905
|
-
const seo =
|
|
1906
|
-
const root =
|
|
1907
|
-
const dispatch =
|
|
2678
|
+
const seo = usePuck3((s) => s.appState.data.root.props?.seo);
|
|
2679
|
+
const root = usePuck3((s) => s.appState.data.root);
|
|
2680
|
+
const dispatch = usePuck3((s) => s.dispatch);
|
|
1908
2681
|
const services = useEditorServices();
|
|
1909
|
-
const id =
|
|
2682
|
+
const id = React11.useId();
|
|
1910
2683
|
const set = (patch) => {
|
|
1911
2684
|
const next = { ...seo ?? {}, ...patch };
|
|
1912
2685
|
for (const k of Object.keys(next)) if (next[k] === void 0 || next[k] === "" || next[k] === false) delete next[k];
|
|
@@ -1970,11 +2743,53 @@ function SeoFields({ siteName, pagePath, pageTitle, readOnly }) {
|
|
|
1970
2743
|
] })
|
|
1971
2744
|
] });
|
|
1972
2745
|
}
|
|
2746
|
+
function toLocalInput(iso) {
|
|
2747
|
+
if (typeof iso !== "string") return "";
|
|
2748
|
+
const t = new Date(iso);
|
|
2749
|
+
if (Number.isNaN(t.getTime())) return "";
|
|
2750
|
+
const local = new Date(t.getTime() - t.getTimezoneOffset() * 6e4);
|
|
2751
|
+
return local.toISOString().slice(0, 16);
|
|
2752
|
+
}
|
|
2753
|
+
function ShowDates({ pagePath, readOnly }) {
|
|
2754
|
+
const root = usePuck3((s) => s.appState.data.root);
|
|
2755
|
+
const dispatch = usePuck3((s) => s.dispatch);
|
|
2756
|
+
const id = React11.useId();
|
|
2757
|
+
const props = root.props ?? {};
|
|
2758
|
+
const set = (key, value) => {
|
|
2759
|
+
const next = { ...props };
|
|
2760
|
+
const t = value ? new Date(value) : null;
|
|
2761
|
+
if (t && !Number.isNaN(t.getTime())) next[key] = t.toISOString();
|
|
2762
|
+
else delete next[key];
|
|
2763
|
+
dispatch({ type: "replaceRoot", root: { ...root, props: next } });
|
|
2764
|
+
};
|
|
2765
|
+
const problems = pageWindowProblems({ root: { props } }, pagePath);
|
|
2766
|
+
const zone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
2767
|
+
return /* @__PURE__ */ jsxs("section", { "aria-labelledby": `${id}-h`, className: "flex flex-col gap-3", "data-gs-show-dates": "", children: [
|
|
2768
|
+
/* @__PURE__ */ jsxs("h3", { id: `${id}-h`, className: "text-sm font-semibold", children: [
|
|
2769
|
+
"Show dates for ",
|
|
2770
|
+
pagePath
|
|
2771
|
+
] }),
|
|
2772
|
+
/* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground", children: [
|
|
2773
|
+
"Before the start and from the end, visitors get the page-not-found page and the page leaves the sitemap. It switches on time, with no publish. Times are in ",
|
|
2774
|
+
zone,
|
|
2775
|
+
"."
|
|
2776
|
+
] }),
|
|
2777
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
2778
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-from`, children: "Show from" }),
|
|
2779
|
+
/* @__PURE__ */ jsx(Input, { id: `${id}-from`, type: "datetime-local", value: toLocalInput(props.showFrom), disabled: readOnly, onChange: (e) => set("showFrom", e.currentTarget.value) })
|
|
2780
|
+
] }),
|
|
2781
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
2782
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-until`, children: "Show until" }),
|
|
2783
|
+
/* @__PURE__ */ jsx(Input, { id: `${id}-until`, type: "datetime-local", value: toLocalInput(props.showUntil), disabled: readOnly, "aria-describedby": `${id}-until-hint`, onChange: (e) => set("showUntil", e.currentTarget.value) }),
|
|
2784
|
+
/* @__PURE__ */ jsx("p", { id: `${id}-until-hint`, className: problems.length ? "text-xs text-destructive" : "text-xs text-muted-foreground", children: problems.length ? problems.join(" ") : "Leave either empty: no start, or no end." })
|
|
2785
|
+
] })
|
|
2786
|
+
] });
|
|
2787
|
+
}
|
|
1973
2788
|
function IssueList({ issues, currentPageId, onOpenPage, onShown }) {
|
|
1974
|
-
const getSelectorForId =
|
|
1975
|
-
const dispatch =
|
|
2789
|
+
const getSelectorForId = usePuck3((s) => s.getSelectorForId);
|
|
2790
|
+
const dispatch = usePuck3((s) => s.dispatch);
|
|
1976
2791
|
const show = (issue) => {
|
|
1977
|
-
if (issue.pageId && issue.pageId !== currentPageId) return onOpenPage(issue.pageId);
|
|
2792
|
+
if (issue.pageId && issue.pageId !== currentPageId) return onOpenPage(issue.pageId, issue.sectionId);
|
|
1978
2793
|
if (!issue.sectionId) return;
|
|
1979
2794
|
const selector = getSelectorForId(issue.sectionId);
|
|
1980
2795
|
if (!selector) return;
|
|
@@ -1988,12 +2803,13 @@ function IssueList({ issues, currentPageId, onOpenPage, onShown }) {
|
|
|
1988
2803
|
] }, i)) });
|
|
1989
2804
|
}
|
|
1990
2805
|
function PublishPanel(props) {
|
|
1991
|
-
const [note, setNote] =
|
|
1992
|
-
const [rollingBack, setRollingBack] =
|
|
1993
|
-
const id =
|
|
2806
|
+
const [note, setNote] = React11.useState("");
|
|
2807
|
+
const [rollingBack, setRollingBack] = React11.useState(null);
|
|
2808
|
+
const id = React11.useId();
|
|
1994
2809
|
const errors = props.issues?.filter((i) => i.severity === "error") ?? [];
|
|
1995
2810
|
const warnings = props.issues?.filter((i) => i.severity === "warning") ?? [];
|
|
1996
2811
|
const live = props.releases.find((r) => r.id === props.liveReleaseId);
|
|
2812
|
+
const lookChanged = Boolean(live?.brandHash && props.brandHash && live.brandHash !== props.brandHash);
|
|
1997
2813
|
const canPublish = props.issues !== null && errors.length === 0 && !props.blockedReason && !props.checking;
|
|
1998
2814
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 p-3", children: [
|
|
1999
2815
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
@@ -2003,6 +2819,11 @@ function PublishPanel(props) {
|
|
|
2003
2819
|
live.number
|
|
2004
2820
|
] }) : /* @__PURE__ */ jsx(Badge, { variant: "muted", children: "Not published" })
|
|
2005
2821
|
] }),
|
|
2822
|
+
lookChanged ? /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", "data-gs-look-changed": "", children: [
|
|
2823
|
+
"The brand or the site's look changed since release ",
|
|
2824
|
+
live.number,
|
|
2825
|
+
". Publish to put the new look live."
|
|
2826
|
+
] }) : null,
|
|
2006
2827
|
/* @__PURE__ */ jsxs("section", { "aria-labelledby": `${id}-checks`, "aria-busy": props.checking, className: "flex flex-col gap-2", children: [
|
|
2007
2828
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2008
2829
|
/* @__PURE__ */ jsx("h3", { id: `${id}-checks`, className: "text-sm font-semibold", children: "Checks" }),
|
|
@@ -2051,6 +2872,7 @@ function PublishPanel(props) {
|
|
|
2051
2872
|
),
|
|
2052
2873
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
2053
2874
|
/* @__PURE__ */ jsx(SeoFields, { siteName: props.siteName, pagePath: props.pagePath, pageTitle: props.pageTitle, readOnly: props.readOnly === true || props.publishing }),
|
|
2875
|
+
props.pagePath !== "/" && props.pagePath !== NOT_FOUND_PATH && props.pageKind !== "post" ? /* @__PURE__ */ jsx(ShowDates, { pagePath: props.pagePath, readOnly: props.readOnly === true || props.publishing }) : null,
|
|
2054
2876
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
2055
2877
|
/* @__PURE__ */ jsxs("section", { "aria-labelledby": `${id}-history`, className: "flex flex-col gap-2", children: [
|
|
2056
2878
|
/* @__PURE__ */ jsx("h3", { id: `${id}-history`, className: "text-sm font-semibold", children: "Release history" }),
|
|
@@ -2100,12 +2922,73 @@ function PublishPanel(props) {
|
|
|
2100
2922
|
] }) })
|
|
2101
2923
|
] });
|
|
2102
2924
|
}
|
|
2103
|
-
var
|
|
2925
|
+
var usePuck4 = createUsePuck();
|
|
2104
2926
|
var VIEWPORTS = {
|
|
2105
|
-
desktop: { width:
|
|
2927
|
+
desktop: { width: 1280, label: "Desktop" },
|
|
2106
2928
|
tablet: { width: 768, label: "Tablet" },
|
|
2107
2929
|
phone: { width: 390, label: "Phone" }
|
|
2108
2930
|
};
|
|
2931
|
+
function SizedCanvas({ viewport, children }) {
|
|
2932
|
+
const outer = React11.useRef(null);
|
|
2933
|
+
const [box, setBox] = React11.useState(null);
|
|
2934
|
+
React11.useLayoutEffect(() => {
|
|
2935
|
+
const el = outer.current;
|
|
2936
|
+
if (!el) return;
|
|
2937
|
+
const measure = () => setBox({ width: el.clientWidth, height: el.clientHeight });
|
|
2938
|
+
measure();
|
|
2939
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
2940
|
+
const ro = new ResizeObserver(measure);
|
|
2941
|
+
ro.observe(el);
|
|
2942
|
+
return () => ro.disconnect();
|
|
2943
|
+
}, []);
|
|
2944
|
+
const width = VIEWPORTS[viewport].width;
|
|
2945
|
+
const gutter = 16;
|
|
2946
|
+
const scale = box && box.width > 0 ? Math.min(1, (box.width - gutter * 2) / width) : 1;
|
|
2947
|
+
React11.useEffect(() => {
|
|
2948
|
+
const doc = outer.current?.querySelector("iframe")?.contentDocument;
|
|
2949
|
+
doc?.documentElement?.style.setProperty("--gs-canvas-unzoom", String(1 / scale));
|
|
2950
|
+
});
|
|
2951
|
+
return /* @__PURE__ */ jsx("div", { ref: outer, className: "absolute inset-0 overflow-hidden", "data-gs-viewport": viewport, "data-gs-canvas-scale": scale.toFixed(3), children: /* @__PURE__ */ jsx(
|
|
2952
|
+
"div",
|
|
2953
|
+
{
|
|
2954
|
+
style: {
|
|
2955
|
+
width,
|
|
2956
|
+
height: box ? Math.max(0, box.height - gutter) / scale : "100%",
|
|
2957
|
+
transform: scale === 1 ? void 0 : `scale(${scale})`,
|
|
2958
|
+
transformOrigin: "top left",
|
|
2959
|
+
marginLeft: box ? Math.max(gutter, (box.width - width * scale) / 2) : void 0,
|
|
2960
|
+
marginTop: gutter / 2
|
|
2961
|
+
},
|
|
2962
|
+
className: "bg-background shadow-sm",
|
|
2963
|
+
children
|
|
2964
|
+
}
|
|
2965
|
+
) });
|
|
2966
|
+
}
|
|
2967
|
+
var token = (name) => `hsl(var(--${name}))`;
|
|
2968
|
+
var PUCK_THEME = {
|
|
2969
|
+
"--puck-color-surface": token("background"),
|
|
2970
|
+
"--puck-color-surface-muted": token("muted"),
|
|
2971
|
+
"--puck-color-surface-subtle": token("muted"),
|
|
2972
|
+
"--puck-color-surface-inverse": token("foreground"),
|
|
2973
|
+
"--puck-color-border": token("border"),
|
|
2974
|
+
"--puck-color-border-hover": token("muted-foreground"),
|
|
2975
|
+
"--puck-color-border-muted": token("border"),
|
|
2976
|
+
"--puck-color-border-inverse": token("muted-foreground"),
|
|
2977
|
+
"--puck-color-text": token("foreground"),
|
|
2978
|
+
"--puck-color-text-secondary": token("muted-foreground"),
|
|
2979
|
+
"--puck-color-text-muted": token("muted-foreground"),
|
|
2980
|
+
"--puck-color-text-subtle": token("muted-foreground"),
|
|
2981
|
+
"--puck-color-text-inverse": token("background"),
|
|
2982
|
+
"--puck-color-interactive": token("primary"),
|
|
2983
|
+
"--puck-color-interactive-hover": token("primary"),
|
|
2984
|
+
"--puck-color-interactive-active": token("primary"),
|
|
2985
|
+
"--puck-color-interactive-subtle": token("accent"),
|
|
2986
|
+
"--puck-color-interactive-soft": token("accent"),
|
|
2987
|
+
"--puck-color-interactive-soft-hover": token("accent"),
|
|
2988
|
+
"--puck-color-interactive-neutral-hover": token("accent"),
|
|
2989
|
+
"--puck-color-focus-ring": token("ring"),
|
|
2990
|
+
"--puck-color-selection-border": token("ring")
|
|
2991
|
+
};
|
|
2109
2992
|
var LOCKED = { drag: false, duplicate: false, delete: false, edit: false, insert: false };
|
|
2110
2993
|
var UNLOCKED = { drag: true, duplicate: true, delete: true, edit: true, insert: true };
|
|
2111
2994
|
function saveAndDispose(saver) {
|
|
@@ -2128,9 +3011,9 @@ function worst(...states) {
|
|
|
2128
3011
|
return "saved";
|
|
2129
3012
|
}
|
|
2130
3013
|
function useCanvasFrame(css, href, theme, dark, lang) {
|
|
2131
|
-
return
|
|
3014
|
+
return React11.useCallback(
|
|
2132
3015
|
({ children, document: document2 }) => {
|
|
2133
|
-
|
|
3016
|
+
React11.useEffect(() => {
|
|
2134
3017
|
if (!document2) return;
|
|
2135
3018
|
const nodes = [];
|
|
2136
3019
|
if (href) {
|
|
@@ -2147,7 +3030,10 @@ function useCanvasFrame(css, href, theme, dark, lang) {
|
|
|
2147
3030
|
}
|
|
2148
3031
|
const vars = document2.createElement("style");
|
|
2149
3032
|
vars.dataset.gsTheme = "";
|
|
2150
|
-
vars.textContent = styleText(
|
|
3033
|
+
vars.textContent = styleText(
|
|
3034
|
+
theme.replace(/:root/g, "html:root") + // The section toolbar stays its own size when the canvas scales the frame down (SizedCanvas).
|
|
3035
|
+
'\n[class*="DraggableComponent-actions"]{transform:scale(var(--gs-canvas-unzoom,1))!important;transform-origin:top right}\n[data-puck-entry]{padding-top:calc(52px * var(--gs-canvas-unzoom,1))}'
|
|
3036
|
+
);
|
|
2151
3037
|
nodes.push(vars);
|
|
2152
3038
|
for (const n of nodes) document2.head.appendChild(n);
|
|
2153
3039
|
const keepLast = new MutationObserver(() => {
|
|
@@ -2170,12 +3056,30 @@ function useCanvasFrame(css, href, theme, dark, lang) {
|
|
|
2170
3056
|
[css, href, theme, dark, lang]
|
|
2171
3057
|
);
|
|
2172
3058
|
}
|
|
3059
|
+
function HistoryKeeper({ pageId, store }) {
|
|
3060
|
+
const histories = usePuck4((s) => s.history.histories);
|
|
3061
|
+
const index = usePuck4((s) => s.history.index);
|
|
3062
|
+
React11.useEffect(() => {
|
|
3063
|
+
store.set(pageId, { histories, index });
|
|
3064
|
+
}, [pageId, store, histories, index]);
|
|
3065
|
+
return null;
|
|
3066
|
+
}
|
|
3067
|
+
function initialHistoryFor(store, pageId, data, options2) {
|
|
3068
|
+
const kept = store.get(pageId);
|
|
3069
|
+
const current = kept?.histories[kept.index]?.state;
|
|
3070
|
+
if (!kept || !current?.data) return void 0;
|
|
3071
|
+
const saved = (d) => stableJson(fromEditorData(d, options2));
|
|
3072
|
+
return saved(current.data) === saved(data) ? kept : void 0;
|
|
3073
|
+
}
|
|
3074
|
+
function stableJson(value) {
|
|
3075
|
+
return JSON.stringify(value, (_k, v) => v && typeof v === "object" && !Array.isArray(v) ? Object.fromEntries(Object.entries(v).sort(([a], [b]) => a.localeCompare(b))) : v);
|
|
3076
|
+
}
|
|
2173
3077
|
function Toolbar({ siteName, pageTitle, titleId, saveStatus, mode, viewport, onViewport, onPreview }) {
|
|
2174
|
-
const history =
|
|
2175
|
-
const dispatch =
|
|
3078
|
+
const history = usePuck4((s) => s.history);
|
|
3079
|
+
const dispatch = usePuck4((s) => s.dispatch);
|
|
2176
3080
|
const choose = (v) => {
|
|
2177
3081
|
onViewport(v);
|
|
2178
|
-
dispatch({ type: "setUi", ui: (ui) => ({ viewports: { ...ui.viewports, current: { width: VIEWPORTS[v].width, height: "auto" } } }) });
|
|
3082
|
+
dispatch({ type: "setUi", ui: (ui) => ({ viewports: { ...ui.viewports, current: { width: VIEWPORTS[v].width, height: "auto" } } }), recordHistory: false });
|
|
2179
3083
|
};
|
|
2180
3084
|
return /* @__PURE__ */ jsxs("header", { className: "flex flex-wrap items-center justify-between gap-2 border-b border-border bg-background px-3 py-2", children: [
|
|
2181
3085
|
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col", children: [
|
|
@@ -2198,18 +3102,32 @@ function Toolbar({ siteName, pageTitle, titleId, saveStatus, mode, viewport, onV
|
|
|
2198
3102
|
] });
|
|
2199
3103
|
}
|
|
2200
3104
|
function useSelectFooter() {
|
|
2201
|
-
const dispatch =
|
|
2202
|
-
const getSelectorForId =
|
|
2203
|
-
const footer =
|
|
3105
|
+
const dispatch = usePuck4((s) => s.dispatch);
|
|
3106
|
+
const getSelectorForId = usePuck4((s) => s.getSelectorForId);
|
|
3107
|
+
const footer = usePuck4((s) => s.appState.data.root.props?.footer);
|
|
2204
3108
|
return () => {
|
|
2205
3109
|
const first = footer?.[0];
|
|
2206
3110
|
const selector = first ? getSelectorForId(first.props.id) : void 0;
|
|
2207
3111
|
if (selector) dispatch({ type: "setUi", ui: { itemSelector: selector, rightSideBarVisible: true } });
|
|
2208
3112
|
};
|
|
2209
3113
|
}
|
|
3114
|
+
function PendingShow({ pending }) {
|
|
3115
|
+
const dispatch = usePuck4((s) => s.dispatch);
|
|
3116
|
+
const getSelectorForId = usePuck4((s) => s.getSelectorForId);
|
|
3117
|
+
React11.useEffect(() => {
|
|
3118
|
+
const id = pending.current;
|
|
3119
|
+
if (!id) return;
|
|
3120
|
+
const selector = getSelectorForId(id);
|
|
3121
|
+
if (!selector) return;
|
|
3122
|
+
pending.current = null;
|
|
3123
|
+
dispatch({ type: "setUi", ui: { itemSelector: selector, rightSideBarVisible: true } });
|
|
3124
|
+
scrollCanvasTo(id);
|
|
3125
|
+
});
|
|
3126
|
+
return null;
|
|
3127
|
+
}
|
|
2210
3128
|
function SelectionWatcher({ onSelect }) {
|
|
2211
|
-
const selected =
|
|
2212
|
-
|
|
3129
|
+
const selected = usePuck4((s) => s.selectedItem?.props.id);
|
|
3130
|
+
React11.useEffect(() => {
|
|
2213
3131
|
if (selected) onSelect();
|
|
2214
3132
|
}, [selected]);
|
|
2215
3133
|
return null;
|
|
@@ -2227,46 +3145,48 @@ function PagesTab(props) {
|
|
|
2227
3145
|
}
|
|
2228
3146
|
);
|
|
2229
3147
|
}
|
|
2230
|
-
function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved, previewUrl, autosaveDelay, initialPageId, siteStylesheet, readOnly = false, onDirtyChange, className }) {
|
|
2231
|
-
const [loadError, setLoadError] =
|
|
2232
|
-
const [site, setSite] =
|
|
2233
|
-
const [pages, setPages] =
|
|
2234
|
-
const [open, setOpen] =
|
|
2235
|
-
const [editorKey, setEditorKey] =
|
|
2236
|
-
const
|
|
2237
|
-
const [
|
|
2238
|
-
const [
|
|
2239
|
-
const [
|
|
2240
|
-
const [
|
|
2241
|
-
const [
|
|
2242
|
-
const [
|
|
2243
|
-
const [
|
|
2244
|
-
const [
|
|
2245
|
-
const [
|
|
2246
|
-
const [
|
|
2247
|
-
const [
|
|
2248
|
-
const [
|
|
2249
|
-
const [
|
|
2250
|
-
const [
|
|
2251
|
-
const [
|
|
2252
|
-
const [
|
|
2253
|
-
const [
|
|
2254
|
-
const [
|
|
2255
|
-
const
|
|
2256
|
-
const
|
|
2257
|
-
const
|
|
2258
|
-
const
|
|
2259
|
-
const
|
|
2260
|
-
const
|
|
2261
|
-
const
|
|
2262
|
-
const
|
|
3148
|
+
function SiteEditor({ siteId, store, brand, forms, listForms, checks, assets, onPublish, brandSettingsHref, reserved, landingDirectory: defaultLanding, destinations, previewUrl, autosaveDelay, initialPageId, siteStylesheet, readOnly = false, onDirtyChange, className }) {
|
|
3149
|
+
const [loadError, setLoadError] = React11.useState(null);
|
|
3150
|
+
const [site, setSite] = React11.useState(null);
|
|
3151
|
+
const [pages, setPages] = React11.useState([]);
|
|
3152
|
+
const [open, setOpen] = React11.useState(null);
|
|
3153
|
+
const [editorKey, setEditorKey] = React11.useState(0);
|
|
3154
|
+
const histories = React11.useRef(/* @__PURE__ */ new Map()).current;
|
|
3155
|
+
const [siteState, setSiteState] = React11.useState(null);
|
|
3156
|
+
const [pageState, setPageState] = React11.useState(null);
|
|
3157
|
+
const [invalid, setInvalid] = React11.useState(null);
|
|
3158
|
+
const [busy, setBusy] = React11.useState(false);
|
|
3159
|
+
const [notice, setNotice] = React11.useState(null);
|
|
3160
|
+
const [css, setCss] = React11.useState(null);
|
|
3161
|
+
const [h1Id, setH1Id] = React11.useState(null);
|
|
3162
|
+
const [formMap, setFormMap] = React11.useState(/* @__PURE__ */ new Map());
|
|
3163
|
+
const [issues, setIssues] = React11.useState(null);
|
|
3164
|
+
const [checking, setChecking] = React11.useState(false);
|
|
3165
|
+
const [publishing, setPublishing] = React11.useState(false);
|
|
3166
|
+
const [releases, setReleases] = React11.useState([]);
|
|
3167
|
+
const [liveId, setLiveId] = React11.useState(null);
|
|
3168
|
+
const [liveIds, setLiveIds] = React11.useState(null);
|
|
3169
|
+
const [leftTab, setLeftTab] = React11.useState(readOnly ? "outline" : "add");
|
|
3170
|
+
const [rightTab, setRightTab] = React11.useState("edit");
|
|
3171
|
+
const [viewport, setViewport] = React11.useState("desktop");
|
|
3172
|
+
const [picker, setPicker] = React11.useState(null);
|
|
3173
|
+
const [preview, setPreview] = React11.useState(null);
|
|
3174
|
+
const pendingShow = React11.useRef(null);
|
|
3175
|
+
const siteSaver = React11.useRef(null);
|
|
3176
|
+
const pageSaver = React11.useRef(null);
|
|
3177
|
+
const pageSaverFor = React11.useRef(null);
|
|
3178
|
+
const counts = React11.useRef(/* @__PURE__ */ new Map());
|
|
3179
|
+
const focusTitle = React11.useRef(false);
|
|
3180
|
+
const titleId = React11.useId();
|
|
3181
|
+
const [announcement, setAnnouncement] = React11.useState("");
|
|
3182
|
+
const [menuDraft, setMenuDraft] = React11.useState(null);
|
|
2263
3183
|
const locked = readOnly || publishing;
|
|
2264
|
-
const lockedRef =
|
|
3184
|
+
const lockedRef = React11.useRef(locked);
|
|
2265
3185
|
lockedRef.current = locked;
|
|
2266
3186
|
const kind = open?.kind ?? "page";
|
|
2267
|
-
const editor =
|
|
2268
|
-
const slotKeys =
|
|
2269
|
-
const theme =
|
|
3187
|
+
const editor = React11.useMemo(() => createEditorConfig({ kind, counts: () => counts.current, readOnly: () => lockedRef.current }), [kind]);
|
|
3188
|
+
const slotKeys = React11.useMemo(() => createEditorConfig().slotKeys, []);
|
|
3189
|
+
const theme = React11.useMemo(() => {
|
|
2270
3190
|
try {
|
|
2271
3191
|
return siteTheme(brand, site?.theme ?? {});
|
|
2272
3192
|
} catch (err) {
|
|
@@ -2275,7 +3195,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2275
3195
|
}
|
|
2276
3196
|
}, [brand, site?.theme]);
|
|
2277
3197
|
const iframe = useCanvasFrame(css, siteStylesheet, themeCss(theme), theme.colorScheme === "dark", site?.lang ?? "en");
|
|
2278
|
-
const loadPage =
|
|
3198
|
+
const loadPage = React11.useCallback(
|
|
2279
3199
|
async (pageId, siteDoc) => {
|
|
2280
3200
|
const draft = await store.getPageDraft(pageId);
|
|
2281
3201
|
if (!draft) throw new Error("That page no longer exists, or you can't edit it.");
|
|
@@ -2304,13 +3224,13 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2304
3224
|
},
|
|
2305
3225
|
[store, autosaveDelay, slotKeys, readOnly]
|
|
2306
3226
|
);
|
|
2307
|
-
const refreshPublishing =
|
|
3227
|
+
const refreshPublishing = React11.useCallback(async () => {
|
|
2308
3228
|
const [list, live] = await Promise.all([store.listReleases(siteId), store.getLive(siteId)]);
|
|
2309
3229
|
setReleases(list);
|
|
2310
3230
|
setLiveId(live?.id ?? null);
|
|
2311
3231
|
setLiveIds(new Set(live?.snapshot.pages.map((p) => p.id) ?? []));
|
|
2312
3232
|
}, [store, siteId]);
|
|
2313
|
-
|
|
3233
|
+
React11.useEffect(() => {
|
|
2314
3234
|
let cancelled = false;
|
|
2315
3235
|
(async () => {
|
|
2316
3236
|
try {
|
|
@@ -2341,7 +3261,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2341
3261
|
};
|
|
2342
3262
|
}, [siteId, store, readOnly]);
|
|
2343
3263
|
const menuInvalid = menuDraft !== null && !menuDraft.every((i) => menuItemProblems(i).length === 0);
|
|
2344
|
-
|
|
3264
|
+
React11.useEffect(() => {
|
|
2345
3265
|
const guard = (e) => {
|
|
2346
3266
|
if (siteSaver.current?.dirty || pageSaver.current?.dirty || invalid || menuInvalid) {
|
|
2347
3267
|
e.preventDefault();
|
|
@@ -2352,20 +3272,20 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2352
3272
|
return () => window.removeEventListener("beforeunload", guard);
|
|
2353
3273
|
}, [invalid, menuInvalid]);
|
|
2354
3274
|
const dirty = !readOnly && (worst(siteState, pageState) !== "saved" || Boolean(invalid) || menuInvalid);
|
|
2355
|
-
const dirtyReported =
|
|
2356
|
-
const onDirtyChangeRef =
|
|
3275
|
+
const dirtyReported = React11.useRef(false);
|
|
3276
|
+
const onDirtyChangeRef = React11.useRef(onDirtyChange);
|
|
2357
3277
|
onDirtyChangeRef.current = onDirtyChange;
|
|
2358
|
-
|
|
3278
|
+
React11.useEffect(() => {
|
|
2359
3279
|
if (dirty === dirtyReported.current) return;
|
|
2360
3280
|
dirtyReported.current = dirty;
|
|
2361
3281
|
onDirtyChangeRef.current?.(dirty);
|
|
2362
3282
|
}, [dirty]);
|
|
2363
|
-
const formSlugs =
|
|
3283
|
+
const formSlugs = React11.useMemo(() => {
|
|
2364
3284
|
const slugs = /* @__PURE__ */ new Set();
|
|
2365
3285
|
for (const item of open?.data.content ?? []) if (item.type.startsWith("form-embed") && typeof item.props.form === "string") slugs.add(item.props.form);
|
|
2366
3286
|
return [...slugs].sort().join(",");
|
|
2367
3287
|
}, [open]);
|
|
2368
|
-
|
|
3288
|
+
React11.useEffect(() => {
|
|
2369
3289
|
if (!forms || !formSlugs) return;
|
|
2370
3290
|
let cancelled = false;
|
|
2371
3291
|
Promise.all(formSlugs.split(",").map(async (slug) => [slug, await Promise.resolve(forms(slug, { siteId, pagePath: open?.path ?? "/", mode: "preview" })).catch(() => null)])).then((entries) => {
|
|
@@ -2375,7 +3295,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2375
3295
|
cancelled = true;
|
|
2376
3296
|
};
|
|
2377
3297
|
}, [forms, formSlugs, siteId, open?.path]);
|
|
2378
|
-
const onChange =
|
|
3298
|
+
const onChange = React11.useCallback(
|
|
2379
3299
|
(data) => {
|
|
2380
3300
|
if (!open || !site || readOnly || pageSaverFor.current !== open.id) return;
|
|
2381
3301
|
const editorData = data;
|
|
@@ -2386,8 +3306,8 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2386
3306
|
const current = siteSaver.current?.latest ?? site;
|
|
2387
3307
|
const nextSite = SiteDoc.safeParse({ ...current, header: result.header, footer: result.footer });
|
|
2388
3308
|
const problems = [
|
|
2389
|
-
...page.success ? [] : page.error.issues.map((i) => i.path.join(".") === "root.props.title" ? "The page needs a title." :
|
|
2390
|
-
...nextSite.success ? [] : nextSite.error.issues.map((i) => `Site ${i
|
|
3309
|
+
...page.success ? [] : page.error.issues.map((i) => i.path.join(".") === "root.props.title" ? "The page needs a title." : friendlyIssue(i)),
|
|
3310
|
+
...nextSite.success ? [] : nextSite.error.issues.map((i) => `Site ${friendlyIssue(i)}`)
|
|
2391
3311
|
];
|
|
2392
3312
|
setInvalid(problems.length ? problems.join(" ") : null);
|
|
2393
3313
|
if (page.success) {
|
|
@@ -2402,7 +3322,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2402
3322
|
},
|
|
2403
3323
|
[open, site, slotKeys, readOnly]
|
|
2404
3324
|
);
|
|
2405
|
-
const onNavChange =
|
|
3325
|
+
const onNavChange = React11.useCallback(
|
|
2406
3326
|
(nav) => {
|
|
2407
3327
|
const current = siteSaver.current?.latest ?? site;
|
|
2408
3328
|
if (!current || readOnly) return;
|
|
@@ -2413,14 +3333,38 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2413
3333
|
},
|
|
2414
3334
|
[site, readOnly]
|
|
2415
3335
|
);
|
|
2416
|
-
const
|
|
3336
|
+
const onRedirectsChange = React11.useCallback(
|
|
3337
|
+
(redirects) => {
|
|
3338
|
+
const current = siteSaver.current?.latest ?? site;
|
|
3339
|
+
if (!current || readOnly) return "This site can't be changed here.";
|
|
3340
|
+
const next = SiteDoc.safeParse({ ...current, redirects });
|
|
3341
|
+
if (!next.success) return `The redirects can't be saved: ${next.error.issues[0]?.message ?? "invalid"}`;
|
|
3342
|
+
siteSaver.current?.update(next.data);
|
|
3343
|
+
setSite(next.data);
|
|
3344
|
+
return null;
|
|
3345
|
+
},
|
|
3346
|
+
[site, readOnly]
|
|
3347
|
+
);
|
|
3348
|
+
const onSeoChange = React11.useCallback(
|
|
3349
|
+
(seo) => {
|
|
3350
|
+
const current = siteSaver.current?.latest ?? site;
|
|
3351
|
+
if (!current || readOnly) return "This site can't be changed here.";
|
|
3352
|
+
const next = SiteDoc.safeParse({ ...current, seo });
|
|
3353
|
+
if (!next.success) return `The settings can't be saved: ${next.error.issues[0]?.message ?? "invalid"}`;
|
|
3354
|
+
siteSaver.current?.update(next.data);
|
|
3355
|
+
setSite(next.data);
|
|
3356
|
+
return null;
|
|
3357
|
+
},
|
|
3358
|
+
[site, readOnly]
|
|
3359
|
+
);
|
|
3360
|
+
const onMenuEdit = React11.useCallback(
|
|
2417
3361
|
(items) => {
|
|
2418
3362
|
setMenuDraft(items);
|
|
2419
3363
|
if (items.every((i) => menuItemProblems(i).length === 0)) onNavChange(items.map((i) => ({ label: i.label.trim(), href: i.href.trim() })));
|
|
2420
3364
|
},
|
|
2421
3365
|
[onNavChange]
|
|
2422
3366
|
);
|
|
2423
|
-
const flushAll =
|
|
3367
|
+
const flushAll = React11.useCallback(async () => {
|
|
2424
3368
|
if (invalid) {
|
|
2425
3369
|
setNotice({ tone: "error", text: `Fix this first: ${invalid}` });
|
|
2426
3370
|
return false;
|
|
@@ -2437,7 +3381,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2437
3381
|
return false;
|
|
2438
3382
|
}
|
|
2439
3383
|
}, [invalid, menuInvalid]);
|
|
2440
|
-
const resync =
|
|
3384
|
+
const resync = React11.useCallback(async (options2 = {}) => {
|
|
2441
3385
|
const [draft, list] = await Promise.all([store.getDraft(siteId), store.listPages(siteId)]);
|
|
2442
3386
|
setPages(list);
|
|
2443
3387
|
let redraw = false;
|
|
@@ -2471,20 +3415,20 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2471
3415
|
}
|
|
2472
3416
|
return { draft, list };
|
|
2473
3417
|
}, [store, siteId, open, site, slotKeys]);
|
|
2474
|
-
const runCheck =
|
|
3418
|
+
const runCheck = React11.useCallback(async () => {
|
|
2475
3419
|
if (!await flushAll()) return;
|
|
2476
3420
|
setChecking(true);
|
|
2477
3421
|
try {
|
|
2478
|
-
const result = await checkSite(store, siteId, { brand, ...reserved ? { reserved } : {} });
|
|
3422
|
+
const result = await checkSite(store, siteId, { brand, ...reserved ? { reserved } : {}, ...forms ? { forms } : {}, ...listForms ? { listForms } : {}, ...checks ? { checks } : {} });
|
|
2479
3423
|
setIssues(result.issues);
|
|
2480
3424
|
} catch (err) {
|
|
2481
3425
|
setIssues([{ severity: "error", code: "check-failed", message: `The checks couldn't run: ${err.message}` }]);
|
|
2482
3426
|
} finally {
|
|
2483
3427
|
setChecking(false);
|
|
2484
3428
|
}
|
|
2485
|
-
}, [flushAll, store, siteId, brand, reserved]);
|
|
3429
|
+
}, [flushAll, store, siteId, brand, reserved, forms, listForms, checks]);
|
|
2486
3430
|
const settled = worst(siteState, pageState) === "saved" && !invalid;
|
|
2487
|
-
|
|
3431
|
+
React11.useEffect(() => {
|
|
2488
3432
|
if (rightTab !== "publish" || !settled) return;
|
|
2489
3433
|
const t = setTimeout(() => void runCheck(), 600);
|
|
2490
3434
|
return () => clearTimeout(t);
|
|
@@ -2513,6 +3457,8 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2513
3457
|
const createPage = (request) => holding(() => createPageNow(request));
|
|
2514
3458
|
const createPageNow = async (request) => {
|
|
2515
3459
|
if (!await flushAll()) throw new Error("Save your changes first.");
|
|
3460
|
+
const problems = pathProblems(request.path, pages, { ...reserved ? { reserved } : {}, notFoundPage: request.template.id === "not-found" });
|
|
3461
|
+
if (problems.length) throw new Error(problems.join(" "));
|
|
2516
3462
|
const doc = request.template.doc({ title: request.title, brand });
|
|
2517
3463
|
const meta = await store.createPage(siteId, { path: request.path, kind: request.template.kind, doc });
|
|
2518
3464
|
const { draft } = await resync();
|
|
@@ -2559,7 +3505,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2559
3505
|
};
|
|
2560
3506
|
const createLanding = (request) => holding(async () => {
|
|
2561
3507
|
if (!await flushAll()) throw new Error("Save your changes first.");
|
|
2562
|
-
const meta = await createLandingPage(store, siteId, { ...request, brand, ...reserved ? { reserved } : {} });
|
|
3508
|
+
const meta = await createLandingPage(store, siteId, { ...request, brand, ...reserved ? { reserved } : {}, ...defaultLanding ? { defaultDirectory: defaultLanding } : {} });
|
|
2563
3509
|
const { draft } = await resync();
|
|
2564
3510
|
focusTitle.current = true;
|
|
2565
3511
|
await loadPage(meta.id, siteSaver.current?.latest ?? draft?.site ?? site);
|
|
@@ -2568,7 +3514,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2568
3514
|
const moveLanding = (pageId, slug) => holding(async () => {
|
|
2569
3515
|
if (!await flushAll()) throw new Error("Save your changes first.");
|
|
2570
3516
|
const before = pages.find((p) => p.id === pageId)?.path;
|
|
2571
|
-
const moved = await moveLandingPage(store, pageId, slug, reserved ? { reserved } : {});
|
|
3517
|
+
const moved = await moveLandingPage(store, pageId, slug, { ...reserved ? { reserved } : {}, ...defaultLanding ? { defaultDirectory: defaultLanding } : {} });
|
|
2572
3518
|
const { draft } = await resync();
|
|
2573
3519
|
if (draft && before && draft.site.nav.some((n) => n.href === before)) onNavChange(draft.site.nav.map((n) => n.href === before ? { ...n, href: moved.path } : n));
|
|
2574
3520
|
setNotice({ tone: "info", text: `Moved to ${moved.path}. ${before} now redirects there.` });
|
|
@@ -2583,7 +3529,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2583
3529
|
if (draft && draft.nav.some((n) => to.has(n.href))) onNavChange(draft.nav.map((n) => to.has(n.href) ? { ...n, href: to.get(n.href) } : n));
|
|
2584
3530
|
};
|
|
2585
3531
|
try {
|
|
2586
|
-
result = await setLandingDirectory(store, siteId, directory, { movePages, ...reserved ? { reserved } : {} });
|
|
3532
|
+
result = await setLandingDirectory(store, siteId, directory, { movePages, ...reserved ? { reserved } : {}, ...defaultLanding ? { defaultDirectory: defaultLanding } : {} });
|
|
2587
3533
|
} catch (err) {
|
|
2588
3534
|
await resync().catch(() => void 0);
|
|
2589
3535
|
if (err instanceof LandingDirectoryError) followMoves(err.moved);
|
|
@@ -2622,7 +3568,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2622
3568
|
for (const s of savers) s?.pause();
|
|
2623
3569
|
held = true;
|
|
2624
3570
|
published = await publishedDrafts();
|
|
2625
|
-
const result = await publishSite(store, siteId, { brand, note, ...reserved ? { reserved } : {} });
|
|
3571
|
+
const result = await publishSite(store, siteId, { brand, note, ...reserved ? { reserved } : {}, ...forms ? { forms } : {}, ...listForms ? { listForms } : {}, ...checks ? { checks } : {} });
|
|
2626
3572
|
if ("blocked" in result) {
|
|
2627
3573
|
setIssues(result.blocked);
|
|
2628
3574
|
setNotice({ tone: "error", text: "Not published: fix the problems the checks list." });
|
|
@@ -2702,13 +3648,13 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2702
3648
|
function focusPageTitle() {
|
|
2703
3649
|
requestAnimationFrame(() => document.getElementById(titleId)?.focus());
|
|
2704
3650
|
}
|
|
2705
|
-
|
|
2706
|
-
|
|
3651
|
+
React11.useEffect(() => setViewport("desktop"), [editorKey]);
|
|
3652
|
+
React11.useEffect(() => {
|
|
2707
3653
|
if (!focusTitle.current) return;
|
|
2708
3654
|
focusTitle.current = false;
|
|
2709
3655
|
focusPageTitle();
|
|
2710
3656
|
}, [editorKey]);
|
|
2711
|
-
const announce =
|
|
3657
|
+
const announce = React11.useCallback((message) => {
|
|
2712
3658
|
setAnnouncement("");
|
|
2713
3659
|
requestAnimationFrame(() => setAnnouncement(message));
|
|
2714
3660
|
}, []);
|
|
@@ -2718,16 +3664,17 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2718
3664
|
const textEntry = target.closest("textarea, [contenteditable=''], [contenteditable='true']") || target instanceof HTMLInputElement && !["button", "checkbox", "radio", "submit", "reset", "file", "range", "color"].includes(target.type);
|
|
2719
3665
|
if (!textEntry) e.preventDefault();
|
|
2720
3666
|
};
|
|
2721
|
-
const services =
|
|
3667
|
+
const services = React11.useMemo(
|
|
2722
3668
|
() => ({
|
|
2723
3669
|
siteId,
|
|
2724
3670
|
store,
|
|
2725
3671
|
...assets ? { assets } : {},
|
|
3672
|
+
...listForms ? { listForms } : {},
|
|
2726
3673
|
pickImage: (opts) => new Promise((resolve) => setPicker({ ...opts?.current ? { current: opts.current } : {}, ...opts?.altElsewhere ? { altElsewhere: true } : {}, resolve }))
|
|
2727
3674
|
}),
|
|
2728
|
-
[siteId, store, assets]
|
|
3675
|
+
[siteId, store, assets, listForms]
|
|
2729
3676
|
);
|
|
2730
|
-
const metadata =
|
|
3677
|
+
const metadata = React11.useMemo(
|
|
2731
3678
|
() => ({
|
|
2732
3679
|
site: { name: site?.name ?? "", lang: site?.lang ?? "en", nav: site?.nav ?? [], ...brand && "logo" in brand && brand.logo ? { logo: { src: brand.logo.src, alt: brand.logo.alt?.trim() || brandDisplayName(brand) } } : {} },
|
|
2733
3680
|
pagePath: open?.path ?? "/",
|
|
@@ -2737,7 +3684,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2737
3684
|
}),
|
|
2738
3685
|
[site?.name, site?.lang, site?.nav, brand, open?.path, open?.placeholders, formMap, h1Id]
|
|
2739
3686
|
);
|
|
2740
|
-
const overrides =
|
|
3687
|
+
const overrides = React11.useMemo(() => genesisOverrides(editor.components, { iframe }, { announce }), [editor.components, iframe, announce]);
|
|
2741
3688
|
const permissions = locked ? LOCKED : UNLOCKED;
|
|
2742
3689
|
if (loadError) {
|
|
2743
3690
|
return /* @__PURE__ */ jsxs(Alert, { variant: "destructive", className, children: [
|
|
@@ -2755,12 +3702,16 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2755
3702
|
const pageMeta = pages.find((p) => p.id === open.id);
|
|
2756
3703
|
const pageTitle = pageMeta?.title ?? open.data.root.props.title;
|
|
2757
3704
|
const blockedReason = invalid ? `Fix this first: ${invalid}` : conflict ? "Choose a version in the conflict first." : null;
|
|
2758
|
-
return /* @__PURE__ */ jsx(EditorServicesContext.Provider, { value: services, children: /* @__PURE__ */ jsx(EditorLockContext.Provider, { value: locked, children: /* @__PURE__ */ jsxs("div", { className: cn("flex h-full min-h-0 flex-col bg-background text-foreground", className), "data-gs-editor": "", children: [
|
|
3705
|
+
return /* @__PURE__ */ jsx(EditorServicesContext.Provider, { value: services, children: /* @__PURE__ */ jsx(EditorLockContext.Provider, { value: locked, children: /* @__PURE__ */ jsxs("div", { className: cn("flex h-full min-h-0 flex-col bg-background text-foreground", className), style: PUCK_THEME, "data-gs-editor": "", children: [
|
|
2759
3706
|
/* @__PURE__ */ jsx(
|
|
2760
3707
|
Puck,
|
|
2761
3708
|
{
|
|
2762
3709
|
config: editor.config,
|
|
2763
3710
|
data: open.data,
|
|
3711
|
+
...(() => {
|
|
3712
|
+
const kept = initialHistoryFor(histories, open.id, open.data, { slotKeys, placeholders: open.placeholders });
|
|
3713
|
+
return kept ? { initialHistory: { histories: kept.histories, index: kept.index, appendData: false } } : {};
|
|
3714
|
+
})(),
|
|
2764
3715
|
onChange,
|
|
2765
3716
|
permissions,
|
|
2766
3717
|
overrides,
|
|
@@ -2769,11 +3720,13 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2769
3720
|
viewports: [
|
|
2770
3721
|
{ width: 390, label: "Phone", icon: "Smartphone" },
|
|
2771
3722
|
{ width: 768, label: "Tablet", icon: "Tablet" },
|
|
2772
|
-
{ width:
|
|
3723
|
+
{ width: 1280, label: "Desktop", icon: "Monitor" }
|
|
2773
3724
|
],
|
|
2774
3725
|
headerTitle: site.name,
|
|
2775
3726
|
children: /* @__PURE__ */ jsxs("div", { className: "flex h-full min-h-0 flex-col", children: [
|
|
2776
3727
|
/* @__PURE__ */ jsx(SelectionWatcher, { onSelect: () => setRightTab("edit") }),
|
|
3728
|
+
/* @__PURE__ */ jsx(HistoryKeeper, { pageId: open.id, store: histories }),
|
|
3729
|
+
/* @__PURE__ */ jsx(PendingShow, { pending: pendingShow }),
|
|
2777
3730
|
/* @__PURE__ */ jsx("p", { role: "status", className: "sr-only", children: announcement }),
|
|
2778
3731
|
/* @__PURE__ */ jsx(Toolbar, { siteName: site.name, pageTitle: `${pageTitle} (${open.path})`, titleId, saveStatus, mode: readOnly ? "view" : publishing ? "publishing" : "edit", viewport, onViewport: setViewport, onPreview: () => void showPreview("preview") }),
|
|
2779
3732
|
readOnly ? /* @__PURE__ */ jsx("p", { role: "note", className: "border-b border-border bg-muted px-3 py-2 text-sm", "data-gs-view-only": "", children: "View only: you can look through this site's pages, but not change or publish them." }) : null,
|
|
@@ -2788,7 +3741,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2788
3741
|
] }) : null
|
|
2789
3742
|
] }) : null,
|
|
2790
3743
|
/* @__PURE__ */ jsxs("div", { className: "grid min-h-0 flex-1 grid-cols-1 overflow-y-auto lg:grid-cols-[17rem_minmax(0,1fr)_20rem] lg:overflow-visible", inert: busy || void 0, "aria-busy": busy || void 0, children: [
|
|
2791
|
-
/* @__PURE__ */ jsx("aside", { className: "flex flex-col border-b border-border lg:min-h-0 lg:border-b-0 lg:border-r", "aria-label": "Sections and pages", onKeyDown: keepDeleteInPanel, children: /* @__PURE__ */ jsxs(Tabs, { defaultValue: "add", value: leftTab, onValueChange: setLeftTab, className: "flex min-h-0 flex-1 flex-col", children: [
|
|
3744
|
+
/* @__PURE__ */ jsx("aside", { className: "flex max-h-[45vh] flex-col border-b border-border lg:max-h-none lg:min-h-0 lg:border-b-0 lg:border-r", "aria-label": "Sections and pages", onKeyDown: keepDeleteInPanel, children: /* @__PURE__ */ jsxs(Tabs, { defaultValue: "add", value: leftTab, onValueChange: setLeftTab, className: "flex min-h-0 flex-1 flex-col", children: [
|
|
2792
3745
|
/* @__PURE__ */ jsxs(TabsList, { className: cn("m-2 grid", readOnly ? "grid-cols-2" : "grid-cols-3"), children: [
|
|
2793
3746
|
readOnly ? null : /* @__PURE__ */ jsx(TabsTrigger, { value: "add", children: "Add" }),
|
|
2794
3747
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "outline", children: "Outline" }),
|
|
@@ -2816,11 +3769,12 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2816
3769
|
onReorder: reorder,
|
|
2817
3770
|
onNavChange: onMenuEdit,
|
|
2818
3771
|
onFooter: () => setRightTab("edit"),
|
|
3772
|
+
brandSettingsHref,
|
|
2819
3773
|
landing: /* @__PURE__ */ jsx(
|
|
2820
3774
|
LandingPanel,
|
|
2821
3775
|
{
|
|
2822
3776
|
pages,
|
|
2823
|
-
directory: landingDirectory(site),
|
|
3777
|
+
directory: landingDirectory(site, defaultLanding),
|
|
2824
3778
|
liveIds,
|
|
2825
3779
|
currentId: open.id,
|
|
2826
3780
|
reserved,
|
|
@@ -2832,11 +3786,24 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2832
3786
|
onDelete: remove,
|
|
2833
3787
|
onSetDirectory: changeLandingDirectory
|
|
2834
3788
|
}
|
|
2835
|
-
)
|
|
3789
|
+
),
|
|
3790
|
+
redirects: /* @__PURE__ */ jsx(
|
|
3791
|
+
RedirectsPanel,
|
|
3792
|
+
{
|
|
3793
|
+
redirects: site.redirects,
|
|
3794
|
+
pages,
|
|
3795
|
+
destinations: redirectDestinations(pages, destinations),
|
|
3796
|
+
reserved,
|
|
3797
|
+
busy: busy || publishing,
|
|
3798
|
+
readOnly,
|
|
3799
|
+
onChange: onRedirectsChange
|
|
3800
|
+
}
|
|
3801
|
+
),
|
|
3802
|
+
search: /* @__PURE__ */ jsx(SearchPanel, { seo: site.seo, pages, busy: busy || publishing, readOnly, onChange: onSeoChange })
|
|
2836
3803
|
}
|
|
2837
3804
|
) })
|
|
2838
3805
|
] }) }),
|
|
2839
|
-
/* @__PURE__ */ jsx("section", { className: "relative min-h-[28rem] min-w-0 bg-muted", "aria-label": "Page canvas", "data-gs-canvas": "", children: /* @__PURE__ */ jsx(Puck.Preview, {}) }),
|
|
3806
|
+
/* @__PURE__ */ jsx("section", { className: "relative min-h-[28rem] min-w-0 bg-muted", "aria-label": "Page canvas", "data-gs-canvas": "", children: /* @__PURE__ */ jsx(SizedCanvas, { viewport, children: /* @__PURE__ */ jsx(Puck.Preview, {}) }) }),
|
|
2840
3807
|
/* @__PURE__ */ jsx("aside", { className: "flex flex-col border-t border-border lg:min-h-0 lg:border-l lg:border-t-0", "aria-label": "Section settings and publishing", onKeyDown: keepDeleteInPanel, children: /* @__PURE__ */ jsxs(Tabs, { defaultValue: "edit", value: rightTab, onValueChange: setRightTab, className: "flex min-h-0 flex-1 flex-col", children: [
|
|
2841
3808
|
/* @__PURE__ */ jsxs(TabsList, { className: "m-2 grid grid-cols-2", children: [
|
|
2842
3809
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "edit", children: "Edit" }),
|
|
@@ -2847,6 +3814,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2847
3814
|
PublishPanel,
|
|
2848
3815
|
{
|
|
2849
3816
|
pagePath: open.path,
|
|
3817
|
+
pageKind: open.kind,
|
|
2850
3818
|
pageTitle,
|
|
2851
3819
|
siteName: site.name,
|
|
2852
3820
|
issues,
|
|
@@ -2855,6 +3823,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2855
3823
|
blockedReason,
|
|
2856
3824
|
releases,
|
|
2857
3825
|
liveReleaseId: liveId,
|
|
3826
|
+
brandHash: theme.brandHash,
|
|
2858
3827
|
previewUrl,
|
|
2859
3828
|
currentPageId: open.id,
|
|
2860
3829
|
readOnly,
|
|
@@ -2862,7 +3831,10 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2862
3831
|
onPublish: publish,
|
|
2863
3832
|
onRollback: rollback,
|
|
2864
3833
|
onPreview: (mode) => void showPreview(mode),
|
|
2865
|
-
onOpenPage: (id) =>
|
|
3834
|
+
onOpenPage: (id, sectionId) => {
|
|
3835
|
+
pendingShow.current = sectionId ?? null;
|
|
3836
|
+
void openPage(id);
|
|
3837
|
+
},
|
|
2866
3838
|
onShowSection: (id) => {
|
|
2867
3839
|
setRightTab("edit");
|
|
2868
3840
|
scrollCanvasTo(id);
|
|
@@ -2913,6 +3885,6 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
|
|
|
2913
3885
|
] }) }) });
|
|
2914
3886
|
}
|
|
2915
3887
|
|
|
2916
|
-
export { AssetPicker, AutosaveBlockedError, Autosaver, IMAGE_TYPES, LandingDirectoryError, NODE_KEYS, SiteEditor, checkSite, countTypes, createEditorConfig, createLandingPage, fromEditorData, genesisOverrides, h1SectionId, humanize, itemToNode, moveLandingPage, movePageInList, nodeToItem, pageTemplates, pathProblems, placeholderSnapshot, presetComponentName, pruneEmpty, publishSite, renamePage, renderPreview, safeSectionId, sectionFields, sectionTypeOf, setLandingDirectory, slugify, toEditorData, uploadProblem };
|
|
3888
|
+
export { AssetPicker, AutosaveBlockedError, Autosaver, IMAGE_TYPES, LandingDirectoryError, NODE_KEYS, SiteEditor, checkSite, countTypes, createEditorConfig, createLandingPage, fromEditorData, genesisOverrides, h1SectionId, humanize, isUneditedSample, itemToNode, moveLandingPage, movePageInList, nodeToItem, pageTemplates, pathProblems, placeholderSnapshot, presetComponentName, pruneEmpty, publishSite, renamePage, renderPreview, safeSectionId, sectionFields, sectionTypeOf, setLandingDirectory, slugify, toEditorData, uploadProblem };
|
|
2917
3889
|
//# sourceMappingURL=editor.js.map
|
|
2918
3890
|
//# sourceMappingURL=editor.js.map
|