@perkyzz/emvb 1.0.0 → 1.2.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 +9 -0
- package/THIRD_PARTY_NOTICES.md +1 -0
- package/package.json +10 -9
- package/src/admin/agents-api.ts +5 -1
- package/src/admin/bulk-api.ts +67 -0
- package/src/admin/content-api.ts +39 -6
- package/src/admin/copy-rich-text.ts +119 -0
- package/src/admin/dialog-tab-wrap.ts +78 -0
- package/src/admin/editor/A11yCopilot.tsx +2 -0
- package/src/admin/editor/Editor.tsx +24 -7
- package/src/admin/editor/ScheduleDialog.tsx +167 -0
- package/src/admin/editor/Timeline.tsx +6 -2
- package/src/admin/editor/TopBar.tsx +60 -8
- package/src/admin/editor/canvas/CanvasFrame.tsx +7 -2
- package/src/admin/editor/canvas/DeviceBar.tsx +22 -9
- package/src/admin/editor/canvas/canvas-scale.ts +3 -3
- package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
- package/src/admin/editor/dnd/new-element.ts +68 -0
- package/src/admin/editor/editor-chrome.tsx +16 -5
- package/src/admin/editor/editor-commands.ts +10 -4
- package/src/admin/editor/editor-css.ts +2 -1
- package/src/admin/editor/element-chrome.ts +22 -0
- package/src/admin/editor/panels/ElementPanel.tsx +34 -17
- package/src/admin/editor/panels/SettingsPanel.tsx +2 -2
- package/src/admin/editor/panels/settings/DraftTextField.tsx +33 -1
- package/src/admin/editor/panels/settings/EffectsControls.tsx +79 -1
- package/src/admin/editor/panels/settings/FieldBindControl.tsx +6 -1
- package/src/admin/editor/panels/settings/FieldControl.tsx +10 -1
- package/src/admin/editor/panels/settings/IconControls.tsx +11 -0
- package/src/admin/editor/panels/settings/IconPicker.tsx +4 -1
- package/src/admin/editor/panels/settings/ItemList.tsx +36 -2
- package/src/admin/editor/panels/settings/LengthRow.tsx +36 -3
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +18 -0
- package/src/admin/editor/panels/settings/StyleRow.tsx +7 -0
- package/src/admin/editor/panels/settings/advanced-rules.ts +3 -0
- package/src/admin/editor/panels/settings/length-units.ts +15 -3
- package/src/admin/editor/panels/settings/style-sections.ts +1 -0
- package/src/admin/editor/panels/style-target.ts +17 -4
- package/src/admin/editor/section-templates.ts +26 -4
- package/src/admin/editor/store.ts +15 -3
- package/src/admin/editor/useEditorCommands.ts +7 -5
- package/src/admin/editor/useEditorData.ts +4 -0
- package/src/admin/editor/useNodeActions.ts +4 -2
- package/src/admin/editor/useSave.ts +47 -3
- package/src/admin/export-api.ts +238 -0
- package/src/admin/index.tsx +6 -1
- package/src/admin/menus-api.ts +113 -0
- package/src/admin/pages/ExportDialog.tsx +395 -0
- package/src/admin/pages/ImportElementorDialog.tsx +25 -1
- package/src/admin/pages/PageList.tsx +67 -2
- package/src/admin/pages/ThemePartList.tsx +37 -1
- package/src/admin/pages/bulk.tsx +303 -0
- package/src/admin/search.ts +20 -0
- package/src/admin/theme-api.ts +4 -0
- package/src/admin/ui.ts +11 -2
- package/src/admin/widgets/CanvasField.tsx +8 -0
- package/src/admin/widgets/ConvertToRichText.tsx +136 -0
- package/src/admin/widgets/ExportEntryHtml.tsx +92 -0
- package/src/admin/widgets/convert-body.ts +73 -2
- package/src/astro/EmVBPage.astro +3 -0
- package/src/astro/render.ts +47 -22
- package/src/astro/request-data.ts +3 -0
- package/src/astro/resolve-theme.ts +88 -51
- package/src/astro/tabs/runtime.ts +16 -6
- package/src/astro/visitor.ts +23 -4
- package/src/astro/widgets/EmVBAlertsRuntime.astro +8 -0
- package/src/astro/widgets/EmVBCarouselRuntime.astro +8 -0
- package/src/astro/widgets/EmVBLightboxRuntime.astro +8 -0
- package/src/astro/widgets/EmVBWidgetRuntimes.astro +19 -0
- package/src/astro/widgets/alerts.ts +37 -0
- package/src/astro/widgets/carousel.ts +167 -0
- package/src/astro/widgets/index.ts +1 -0
- package/src/astro/widgets/lightbox.ts +123 -0
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +103 -3
- package/src/core/arrange.ts +57 -1
- package/src/core/bounded-array.ts +16 -13
- package/src/core/contract.ts +26 -3
- package/src/core/css/generate.ts +83 -21
- package/src/core/css/scope.ts +10 -2
- package/src/core/css/trace.ts +33 -8
- package/src/core/design/classes.ts +25 -5
- package/src/core/design/devices.ts +78 -2
- package/src/core/design/variables.ts +14 -1
- package/src/core/elements/icon-svg.ts +135 -0
- package/src/core/elements/index.ts +33 -127
- package/src/core/elements/widgets.ts +907 -0
- package/src/core/export/runtimes.generated.ts +12 -0
- package/src/core/export/site.ts +579 -0
- package/src/core/export/zip.ts +95 -0
- package/src/core/extensions/schema.ts +2 -1
- package/src/core/geo-trust.ts +18 -0
- package/src/core/history/diff.ts +25 -0
- package/src/core/icons/social.generated.ts +29 -0
- package/src/core/image-edit/schema.ts +2 -1
- package/src/core/import/elementor/atomic.ts +22 -9
- package/src/core/import/elementor/context.ts +18 -0
- package/src/core/import/elementor/index.ts +72 -11
- package/src/core/import/elementor/style.ts +21 -1
- package/src/core/import/elementor/widgets.ts +394 -133
- package/src/core/index.ts +14 -0
- package/src/core/issue-cap.ts +19 -0
- package/src/core/json-schema.ts +8 -1
- package/src/core/limits.ts +6 -0
- package/src/core/loop-collections.ts +33 -0
- package/src/core/perf/meter.ts +37 -19
- package/src/core/portable-text-export.ts +243 -0
- package/src/core/proposals.ts +8 -2
- package/src/core/public-attributes.ts +30 -0
- package/src/core/render/index.ts +115 -13
- package/src/core/render/tabs.ts +18 -11
- package/src/core/render/vnode.ts +44 -6
- package/src/core/sanitize/css.ts +26 -0
- package/src/core/sanitize/svg-upload.ts +276 -23
- package/src/core/sanitize/svg.ts +3 -3
- package/src/core/schema/descriptors.ts +4 -0
- package/src/core/schema/design.ts +8 -7
- package/src/core/schema/layout.ts +406 -18
- package/src/core/schema/style.ts +49 -1
- package/src/core/search-text.ts +70 -0
- package/src/core/shadowing-ids.ts +41 -0
- package/src/core/theme/conditions.ts +2 -1
- package/src/core/theme/float.ts +1 -0
- package/src/core/theme/parse-doc.ts +10 -5
- package/src/core/theme/popup-rules.ts +16 -0
- package/src/core/theme/triggers.ts +3 -2
- package/src/core/validate.ts +3 -2
- package/src/index.ts +23 -2
- package/src/mcp/ports.ts +18 -7
- package/src/mcp/proposals.ts +36 -11
- package/src/mcp/read.ts +2 -3
- package/src/mcp/tools.ts +1 -1
- package/src/server/agent-settings.ts +12 -1
- package/src/server/hooks.ts +41 -6
- package/src/server/icon-routes.ts +52 -12
- package/src/server/mcp-routes.ts +11 -5
- package/src/server/plugin.ts +27 -2
- package/src/server/presence.ts +5 -1
- package/src/server/proposals.ts +16 -4
- package/src/server/requests.ts +60 -11
- package/src/server/site-origin.ts +13 -0
- package/src/server/targets.ts +26 -0
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import { Button, Checkbox, Dialog, Loader, Radio, Select } from "@cloudflare/kumo";
|
|
2
|
+
import { CopySimpleIcon, DownloadSimpleIcon } from "@phosphor-icons/react";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import type { Fetcher } from "../api.ts";
|
|
5
|
+
import type { PageSummary } from "../content-api.ts";
|
|
6
|
+
import { DialogCloseButton } from "../editor/DialogCloseButton.tsx";
|
|
7
|
+
import { useMediaQuery } from "../editor/useMediaQuery.ts";
|
|
8
|
+
import {
|
|
9
|
+
copyPagesAsRichText,
|
|
10
|
+
richTextTargets,
|
|
11
|
+
type CopyResult,
|
|
12
|
+
type RichTextTarget,
|
|
13
|
+
} from "../copy-rich-text.ts";
|
|
14
|
+
import {
|
|
15
|
+
canvasSources,
|
|
16
|
+
exportableEntries,
|
|
17
|
+
exportSite,
|
|
18
|
+
type CanvasSource,
|
|
19
|
+
type ExportResult,
|
|
20
|
+
} from "../export-api.ts";
|
|
21
|
+
import { downloadBlob } from "../image-editor/flatten.ts";
|
|
22
|
+
import { leftOutText } from "../widgets/ConvertToRichText.tsx";
|
|
23
|
+
import { BUTTON, FIELD, SOLID_PRIMARY, UI_CSS } from "../ui.ts";
|
|
24
|
+
|
|
25
|
+
const ALL = "__all__";
|
|
26
|
+
/** The "Export from" value for EmVB pages; a collection's slug otherwise (W-977). */
|
|
27
|
+
const PAGES = "__pages__";
|
|
28
|
+
/** W-978: the pages ticked in the list. */
|
|
29
|
+
const SELECTED = "__selected__";
|
|
30
|
+
|
|
31
|
+
/** Opens Export pages (W-963), next to Import on the Pages list. */
|
|
32
|
+
export function ExportButton({ onClick }: { onClick: () => void }) {
|
|
33
|
+
return (
|
|
34
|
+
<Button
|
|
35
|
+
variant="secondary"
|
|
36
|
+
className={BUTTON}
|
|
37
|
+
icon={<DownloadSimpleIcon aria-hidden="true" />}
|
|
38
|
+
onClick={onClick}
|
|
39
|
+
data-emvb-export-pages=""
|
|
40
|
+
>
|
|
41
|
+
Export pages
|
|
42
|
+
</Button>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const plural = (n: number, one: string, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
47
|
+
|
|
48
|
+
/** What the finished export holds, in a sentence or two. */
|
|
49
|
+
function exportSummary(result: ExportResult, noun = "page"): string {
|
|
50
|
+
const { report } = result.site;
|
|
51
|
+
const parts = [`Downloaded ${plural(report.pages.length, noun)}.`];
|
|
52
|
+
if (report.skipped.length > 0)
|
|
53
|
+
parts.push(
|
|
54
|
+
`${plural(report.skipped.length, "page")} couldn't be read and ${report.skipped.length === 1 ? "is" : "are"} left out.`,
|
|
55
|
+
);
|
|
56
|
+
const snapshotPages = new Set(report.snapshots.map((s) => s.path)).size;
|
|
57
|
+
if (snapshotPages > 0)
|
|
58
|
+
parts.push(
|
|
59
|
+
`${plural(snapshotPages, "page")} ${snapshotPages === 1 ? "has" : "have"} parts that need the live site, such as loops or forms.`,
|
|
60
|
+
);
|
|
61
|
+
if (result.copied > 0) parts.push(`${plural(result.copied, "media file")} copied.`);
|
|
62
|
+
if (result.failed > 0)
|
|
63
|
+
parts.push(
|
|
64
|
+
`${plural(result.failed, "media file")} couldn't be copied and stay${result.failed === 1 ? "s" : ""} linked.`,
|
|
65
|
+
);
|
|
66
|
+
parts.push("EXPORT-REPORT.md in the zip has the details.");
|
|
67
|
+
return parts.join(" ");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** What copying as rich text did, in a sentence or two. */
|
|
71
|
+
function copySummary(result: CopyResult, target: RichTextTarget): string {
|
|
72
|
+
const parts = [`Created ${plural(result.created.length, "draft")} in ${target.label}.`];
|
|
73
|
+
if (result.failed.length > 0)
|
|
74
|
+
parts.push(`Not copied: ${result.failed.map((f) => `${f.title} (${f.message})`).join("; ")}.`);
|
|
75
|
+
const left = leftOutText(result.skipped);
|
|
76
|
+
if (left) parts.push(`Left out, as rich text can't hold them: ${left}.`);
|
|
77
|
+
return parts.join(" ");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function ExportDialog({
|
|
81
|
+
fetcher,
|
|
82
|
+
open,
|
|
83
|
+
onOpenChange,
|
|
84
|
+
pages,
|
|
85
|
+
selectedIds = [],
|
|
86
|
+
}: {
|
|
87
|
+
fetcher: Fetcher;
|
|
88
|
+
open: boolean;
|
|
89
|
+
onOpenChange: (open: boolean) => void;
|
|
90
|
+
pages: readonly PageSummary[];
|
|
91
|
+
/** W-978: pages ticked in the list; the dialog starts with them. */
|
|
92
|
+
selectedIds?: readonly string[];
|
|
93
|
+
}) {
|
|
94
|
+
const published = pages.filter(
|
|
95
|
+
(page) => page.status === "published" || page.status === "changed",
|
|
96
|
+
);
|
|
97
|
+
const [pageId, setPageId] = React.useState(ALL);
|
|
98
|
+
// W-977: EmVB pages, or one of your collections with a canvas field.
|
|
99
|
+
const [from, setFrom] = React.useState(PAGES);
|
|
100
|
+
const [sources, setSources] = React.useState<CanvasSource[]>([]);
|
|
101
|
+
const [entries, setEntries] = React.useState<{ id: string; title: string }[] | null>(null);
|
|
102
|
+
const source = sources.find((s) => s.collection === from);
|
|
103
|
+
const [copyMedia, setCopyMedia] = React.useState(true);
|
|
104
|
+
const [format, setFormat] = React.useState<"html" | "rich">("html");
|
|
105
|
+
const [targets, setTargets] = React.useState<RichTextTarget[] | null>(null);
|
|
106
|
+
const [targetSlug, setTargetSlug] = React.useState("");
|
|
107
|
+
const target = targets?.find((t) => t.slug === targetSlug);
|
|
108
|
+
const [state, setState] = React.useState<
|
|
109
|
+
| { kind: "idle" }
|
|
110
|
+
| { kind: "busy" }
|
|
111
|
+
| { kind: "done"; text: string }
|
|
112
|
+
| { kind: "error"; text: string }
|
|
113
|
+
>({ kind: "idle" });
|
|
114
|
+
const reducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)");
|
|
115
|
+
const busy = state.kind === "busy";
|
|
116
|
+
|
|
117
|
+
React.useEffect(() => {
|
|
118
|
+
if (open) setState({ kind: "idle" });
|
|
119
|
+
}, [open]);
|
|
120
|
+
const selectedKey = selectedIds.join(" ");
|
|
121
|
+
React.useEffect(() => {
|
|
122
|
+
if (open && selectedKey) {
|
|
123
|
+
setFrom(PAGES);
|
|
124
|
+
setPageId(SELECTED);
|
|
125
|
+
}
|
|
126
|
+
}, [open, selectedKey]);
|
|
127
|
+
|
|
128
|
+
React.useEffect(() => {
|
|
129
|
+
if (!open) return;
|
|
130
|
+
let active = true;
|
|
131
|
+
canvasSources(fetcher).then(
|
|
132
|
+
(found) => active && setSources(found),
|
|
133
|
+
() => active && setSources([]),
|
|
134
|
+
);
|
|
135
|
+
return () => {
|
|
136
|
+
active = false;
|
|
137
|
+
};
|
|
138
|
+
}, [open, fetcher]);
|
|
139
|
+
|
|
140
|
+
React.useEffect(() => {
|
|
141
|
+
setEntries(null);
|
|
142
|
+
setPageId((current) => (current === SELECTED && !source ? current : ALL));
|
|
143
|
+
if (!source) return;
|
|
144
|
+
let active = true;
|
|
145
|
+
exportableEntries(fetcher, source).then(
|
|
146
|
+
(found) => active && setEntries(found),
|
|
147
|
+
() => active && setEntries([]),
|
|
148
|
+
);
|
|
149
|
+
return () => {
|
|
150
|
+
active = false;
|
|
151
|
+
};
|
|
152
|
+
}, [source, fetcher]);
|
|
153
|
+
|
|
154
|
+
React.useEffect(() => {
|
|
155
|
+
if (!open || format !== "rich" || targets) return;
|
|
156
|
+
let active = true;
|
|
157
|
+
richTextTargets(fetcher).then(
|
|
158
|
+
(found) => {
|
|
159
|
+
if (!active) return;
|
|
160
|
+
setTargets(found);
|
|
161
|
+
setTargetSlug((current) => current || found[0]?.slug || "");
|
|
162
|
+
},
|
|
163
|
+
() => active && setTargets([]),
|
|
164
|
+
);
|
|
165
|
+
return () => {
|
|
166
|
+
active = false;
|
|
167
|
+
};
|
|
168
|
+
}, [open, format, targets, fetcher]);
|
|
169
|
+
|
|
170
|
+
const copy = async () => {
|
|
171
|
+
if (busy || !target) return;
|
|
172
|
+
setState({ kind: "busy" });
|
|
173
|
+
try {
|
|
174
|
+
const result = await copyPagesAsRichText(
|
|
175
|
+
fetcher,
|
|
176
|
+
target,
|
|
177
|
+
pageId === ALL ? undefined : pageId === SELECTED ? selectedIds : pageId,
|
|
178
|
+
);
|
|
179
|
+
setState({
|
|
180
|
+
kind: result.created.length > 0 ? "done" : "error",
|
|
181
|
+
text: copySummary(result, target),
|
|
182
|
+
});
|
|
183
|
+
} catch (error) {
|
|
184
|
+
setState({
|
|
185
|
+
kind: "error",
|
|
186
|
+
text: `Copying didn't finish: ${error instanceof Error ? error.message : String(error)}. Try again.`,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
// Entries of your own collections already have Convert to rich text on their Canvas card.
|
|
191
|
+
const rich = format === "rich" && !source;
|
|
192
|
+
const choices = source ? (entries ?? []) : published;
|
|
193
|
+
const noun = source ? "entry" : "page";
|
|
194
|
+
const nouns = source ? "entries" : "pages";
|
|
195
|
+
const unavailable = choices.length === 0 || (rich && !target);
|
|
196
|
+
|
|
197
|
+
const run = async () => {
|
|
198
|
+
if (busy) return;
|
|
199
|
+
setState({ kind: "busy" });
|
|
200
|
+
try {
|
|
201
|
+
const date = new Date().toISOString().slice(0, 10);
|
|
202
|
+
const result = await exportSite(fetcher, {
|
|
203
|
+
...(pageId === ALL ? {} : { onlyPageId: pageId === SELECTED ? selectedIds : pageId }),
|
|
204
|
+
...(source ? { source } : {}),
|
|
205
|
+
copyMedia,
|
|
206
|
+
origin: window.location.origin,
|
|
207
|
+
date,
|
|
208
|
+
});
|
|
209
|
+
if (result.site.report.pages.length === 0) {
|
|
210
|
+
setState({ kind: "error", text: "There's nothing published to export yet." });
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const name =
|
|
214
|
+
pageId === ALL || pageId === SELECTED
|
|
215
|
+
? `emvb-export-${source ? `${source.collection}-` : ""}${date}.zip`
|
|
216
|
+
: `emvb-export-${result.site.report.pages[0]?.path.replace("/", "") ?? "page"}-${date}.zip`;
|
|
217
|
+
downloadBlob(
|
|
218
|
+
new Blob([result.zip as Uint8Array<ArrayBuffer>], { type: "application/zip" }),
|
|
219
|
+
name,
|
|
220
|
+
);
|
|
221
|
+
setState({ kind: "done", text: exportSummary(result, noun) });
|
|
222
|
+
} catch (error) {
|
|
223
|
+
setState({
|
|
224
|
+
kind: "error",
|
|
225
|
+
text: `The export didn't finish: ${error instanceof Error ? error.message : String(error)}. Try again.`,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
return (
|
|
231
|
+
<Dialog.Root
|
|
232
|
+
open={open}
|
|
233
|
+
onOpenChange={(next) => {
|
|
234
|
+
if (!next && busy) return;
|
|
235
|
+
onOpenChange(next);
|
|
236
|
+
}}
|
|
237
|
+
>
|
|
238
|
+
<Dialog size="base" className="p-6">
|
|
239
|
+
<style>{UI_CSS}</style>
|
|
240
|
+
<div data-emvb-dialog="export-pages" className="emvb-dialog">
|
|
241
|
+
<Dialog.Title>Export pages</Dialog.Title>
|
|
242
|
+
<Dialog.Description>
|
|
243
|
+
Take your published pages elsewhere. Drafts and unpublished changes aren't included, and
|
|
244
|
+
your EmVB pages aren't changed.
|
|
245
|
+
</Dialog.Description>
|
|
246
|
+
<div className="emvb-export-fields">
|
|
247
|
+
{sources.length > 0 && (
|
|
248
|
+
<Select
|
|
249
|
+
label="Export from"
|
|
250
|
+
className={FIELD}
|
|
251
|
+
value={from}
|
|
252
|
+
onValueChange={(value) => {
|
|
253
|
+
setFrom(typeof value === "string" ? value : PAGES);
|
|
254
|
+
setState({ kind: "idle" });
|
|
255
|
+
}}
|
|
256
|
+
renderValue={(value: unknown) =>
|
|
257
|
+
sources.find((s) => s.collection === value)?.label ?? "EmVB pages"
|
|
258
|
+
}
|
|
259
|
+
data-emvb-export-from=""
|
|
260
|
+
>
|
|
261
|
+
<Select.Option value={PAGES}>EmVB pages</Select.Option>
|
|
262
|
+
{sources.map((s) => (
|
|
263
|
+
<Select.Option key={s.collection} value={s.collection}>
|
|
264
|
+
{s.label}
|
|
265
|
+
</Select.Option>
|
|
266
|
+
))}
|
|
267
|
+
</Select>
|
|
268
|
+
)}
|
|
269
|
+
{source && (
|
|
270
|
+
<p className="emvb-helper" data-emvb-export-entries-note="">
|
|
271
|
+
Published entries with an EmVB layout, as HTML and CSS. Entries without a layout use
|
|
272
|
+
your site's own template, so they aren't included.
|
|
273
|
+
</p>
|
|
274
|
+
)}
|
|
275
|
+
{!source && (
|
|
276
|
+
<Radio.Group
|
|
277
|
+
legend="Export as"
|
|
278
|
+
appearance="card"
|
|
279
|
+
value={format}
|
|
280
|
+
onValueChange={(value) => {
|
|
281
|
+
setFormat(value === "rich" ? "rich" : "html");
|
|
282
|
+
setState({ kind: "idle" });
|
|
283
|
+
}}
|
|
284
|
+
disabled={busy}
|
|
285
|
+
>
|
|
286
|
+
<Radio.Item
|
|
287
|
+
value="html"
|
|
288
|
+
label="HTML and CSS files"
|
|
289
|
+
description="A zip you can host anywhere, with the header, footer and popups each page shows."
|
|
290
|
+
/>
|
|
291
|
+
<Radio.Item
|
|
292
|
+
value="rich"
|
|
293
|
+
label="Rich text in a collection"
|
|
294
|
+
description="A draft entry per page in one of your collections, with its words, headings, lists, links and images. The design doesn't come across."
|
|
295
|
+
/>
|
|
296
|
+
</Radio.Group>
|
|
297
|
+
)}
|
|
298
|
+
{source && entries === null && <p className="emvb-helper">Finding entries…</p>}
|
|
299
|
+
<Select
|
|
300
|
+
label={source ? "Entries" : "Pages"}
|
|
301
|
+
className={FIELD}
|
|
302
|
+
value={pageId}
|
|
303
|
+
onValueChange={(value) => setPageId(typeof value === "string" ? value : ALL)}
|
|
304
|
+
renderValue={(value: unknown) =>
|
|
305
|
+
value === SELECTED
|
|
306
|
+
? `Selected pages (${selectedIds.length})`
|
|
307
|
+
: value === ALL || !value
|
|
308
|
+
? `All published ${nouns} (${choices.length})`
|
|
309
|
+
: (choices.find((page) => page.id === value)?.title ??
|
|
310
|
+
(source ? "Entry" : "Page"))
|
|
311
|
+
}
|
|
312
|
+
>
|
|
313
|
+
<Select.Option value={ALL}>
|
|
314
|
+
All published {nouns} ({choices.length})
|
|
315
|
+
</Select.Option>
|
|
316
|
+
{!source && selectedIds.length > 0 && (
|
|
317
|
+
<Select.Option value={SELECTED}>
|
|
318
|
+
Selected pages ({selectedIds.length})
|
|
319
|
+
</Select.Option>
|
|
320
|
+
)}
|
|
321
|
+
{choices.map((page) => (
|
|
322
|
+
<Select.Option key={page.id} value={page.id}>
|
|
323
|
+
{page.title}
|
|
324
|
+
</Select.Option>
|
|
325
|
+
))}
|
|
326
|
+
</Select>
|
|
327
|
+
{!rich && (
|
|
328
|
+
<Checkbox
|
|
329
|
+
label="Copy this site's images and files into the export"
|
|
330
|
+
checked={copyMedia}
|
|
331
|
+
onCheckedChange={(checked: boolean) => setCopyMedia(checked)}
|
|
332
|
+
/>
|
|
333
|
+
)}
|
|
334
|
+
{rich && targets === null && <p className="emvb-helper">Finding collections…</p>}
|
|
335
|
+
{rich && targets?.length === 0 && (
|
|
336
|
+
<p className="emvb-helper" data-emvb-no-targets="">
|
|
337
|
+
None of your collections has a rich-text field to copy into.
|
|
338
|
+
</p>
|
|
339
|
+
)}
|
|
340
|
+
{rich && targets && targets.length > 0 && (
|
|
341
|
+
<Select
|
|
342
|
+
label="Collection"
|
|
343
|
+
className={FIELD}
|
|
344
|
+
value={targetSlug}
|
|
345
|
+
onValueChange={(value) => setTargetSlug(typeof value === "string" ? value : "")}
|
|
346
|
+
renderValue={(value: unknown) =>
|
|
347
|
+
targets.find((t) => t.slug === value)?.label ?? "Choose a collection"
|
|
348
|
+
}
|
|
349
|
+
>
|
|
350
|
+
{targets.map((t) => (
|
|
351
|
+
<Select.Option key={t.slug} value={t.slug}>
|
|
352
|
+
{t.label}
|
|
353
|
+
</Select.Option>
|
|
354
|
+
))}
|
|
355
|
+
</Select>
|
|
356
|
+
)}
|
|
357
|
+
</div>
|
|
358
|
+
<p
|
|
359
|
+
className={state.kind === "error" ? "emvb-helper emvb-danger-text" : "emvb-helper"}
|
|
360
|
+
role="status"
|
|
361
|
+
data-emvb-export-status=""
|
|
362
|
+
>
|
|
363
|
+
{state.kind === "busy" && (rich ? "Copying…" : "Exporting…")}
|
|
364
|
+
{(state.kind === "done" || state.kind === "error") && state.text}
|
|
365
|
+
</p>
|
|
366
|
+
<div className="emvb-dialog-actions">
|
|
367
|
+
<DialogCloseButton>{state.kind === "done" ? "Close" : "Cancel"}</DialogCloseButton>
|
|
368
|
+
<Button
|
|
369
|
+
variant="primary"
|
|
370
|
+
className={BUTTON}
|
|
371
|
+
style={SOLID_PRIMARY}
|
|
372
|
+
icon={
|
|
373
|
+
busy && !reducedMotion ? (
|
|
374
|
+
<Loader size={14} />
|
|
375
|
+
) : rich ? (
|
|
376
|
+
<CopySimpleIcon aria-hidden="true" />
|
|
377
|
+
) : (
|
|
378
|
+
<DownloadSimpleIcon aria-hidden="true" />
|
|
379
|
+
)
|
|
380
|
+
}
|
|
381
|
+
aria-disabled={busy || unavailable}
|
|
382
|
+
aria-busy={busy}
|
|
383
|
+
onClick={() => {
|
|
384
|
+
if (unavailable) return;
|
|
385
|
+
void (rich ? copy() : run());
|
|
386
|
+
}}
|
|
387
|
+
>
|
|
388
|
+
{busy ? (rich ? "Copying…" : "Exporting…") : rich ? "Copy pages" : "Export"}
|
|
389
|
+
</Button>
|
|
390
|
+
</div>
|
|
391
|
+
</div>
|
|
392
|
+
</Dialog>
|
|
393
|
+
</Dialog.Root>
|
|
394
|
+
);
|
|
395
|
+
}
|
|
@@ -16,6 +16,8 @@ import { THEME_PARTS_COLLECTION } from "../../constants.ts";
|
|
|
16
16
|
import { ApiError, type Fetcher } from "../api.ts";
|
|
17
17
|
import { createPage, listPages, type PageSummary } from "../content-api.ts";
|
|
18
18
|
import { uploadImage } from "../media-api.ts";
|
|
19
|
+
import { loadSiteMenus } from "../menus-api.ts";
|
|
20
|
+
import type { MenuLink } from "../../core/import/elementor/context.ts";
|
|
19
21
|
import { editorUrl } from "../editor/exit.ts";
|
|
20
22
|
import { loadIconSet } from "../editor/icons/library.ts";
|
|
21
23
|
import { createThemePart } from "../theme-api.ts";
|
|
@@ -214,6 +216,9 @@ export function ImportElementorDialog({
|
|
|
214
216
|
const [imageStatus, setImageStatus] = React.useState<string>();
|
|
215
217
|
const [copying, setCopying] = React.useState(false);
|
|
216
218
|
const imageRef = React.useRef<HTMLInputElement>(null);
|
|
219
|
+
// W-1026: the site's own menus (from its WordPress import) for imported Nav Menus, by name.
|
|
220
|
+
// A menu the site doesn't have is kept as no links, so it is asked for once.
|
|
221
|
+
const [siteMenus, setSiteMenus] = React.useState<ReadonlyMap<string, MenuLink[]>>(new Map());
|
|
217
222
|
const iconsLoad = React.useRef<Promise<IconMap> | undefined>(undefined);
|
|
218
223
|
const fileRef = React.useRef<HTMLInputElement>(null);
|
|
219
224
|
const kitRef = React.useRef<HTMLInputElement>(null);
|
|
@@ -236,6 +241,7 @@ export function ImportElementorDialog({
|
|
|
236
241
|
setPageLinks(readPageLinks());
|
|
237
242
|
setCopies(new Map());
|
|
238
243
|
setImageStatus(undefined);
|
|
244
|
+
setSiteMenus(new Map());
|
|
239
245
|
}
|
|
240
246
|
}
|
|
241
247
|
|
|
@@ -260,8 +266,9 @@ export function ImportElementorDialog({
|
|
|
260
266
|
svg: (url: string) => svgs.get(url),
|
|
261
267
|
pageLink: (id: number) => pageLinks[id],
|
|
262
268
|
media: (url: string) => copies.get(url),
|
|
269
|
+
menu: (name: string) => siteMenus.get(name),
|
|
263
270
|
}),
|
|
264
|
-
[kit, defaults, useClasses, svgs, pageLinks, copies],
|
|
271
|
+
[kit, defaults, useClasses, svgs, pageLinks, copies, siteMenus],
|
|
265
272
|
);
|
|
266
273
|
const result = React.useMemo(
|
|
267
274
|
() => (json.trim() ? importElementor(json, options(icons)) : undefined),
|
|
@@ -320,6 +327,23 @@ export function ImportElementorDialog({
|
|
|
320
327
|
);
|
|
321
328
|
setCopying(false);
|
|
322
329
|
};
|
|
330
|
+
// W-1026: fetch each menu the export's Nav Menus name once; the import re-runs with them.
|
|
331
|
+
const wantedMenus = (result?.ok ? result.menus : []).filter((name) => !siteMenus.has(name));
|
|
332
|
+
const wantedKey = wantedMenus.join("\u0000");
|
|
333
|
+
React.useEffect(() => {
|
|
334
|
+
if (!wantedKey) return;
|
|
335
|
+
const names = wantedKey.split("\u0000");
|
|
336
|
+
let live = true;
|
|
337
|
+
void loadSiteMenus(fetcher, names).then((found) => {
|
|
338
|
+
if (!live) return;
|
|
339
|
+
setSiteMenus(
|
|
340
|
+
(current) => new Map([...current, ...names.map((n) => [n, found.get(n) ?? []] as const)]),
|
|
341
|
+
);
|
|
342
|
+
});
|
|
343
|
+
return () => {
|
|
344
|
+
live = false;
|
|
345
|
+
};
|
|
346
|
+
}, [wantedKey, fetcher]);
|
|
323
347
|
const needsPages = linkedPages.length > 0 && pages === undefined;
|
|
324
348
|
React.useEffect(() => {
|
|
325
349
|
if (!needsPages) return;
|
|
@@ -4,7 +4,9 @@ import * as React from "react";
|
|
|
4
4
|
import type { Fetcher } from "../api.ts";
|
|
5
5
|
import { listPages } from "../content-api.ts";
|
|
6
6
|
import { editorUrl } from "../editor/exit.ts";
|
|
7
|
-
import { matchesSearch } from "../search.ts";
|
|
7
|
+
import { contentSnippet, matchesSearch } from "../search.ts";
|
|
8
|
+
import { PAGES_COLLECTION } from "../../constants.ts";
|
|
9
|
+
import { BulkBar, SelectAll, SelectRow, useSelection } from "./bulk.tsx";
|
|
8
10
|
import {
|
|
9
11
|
EditedTime,
|
|
10
12
|
ListError,
|
|
@@ -17,22 +19,51 @@ import {
|
|
|
17
19
|
} from "./list-kit.tsx";
|
|
18
20
|
import { ImportElementorDialog } from "./ImportElementorDialog.tsx";
|
|
19
21
|
import { ImportButton } from "./ImportButton.tsx";
|
|
22
|
+
import { ExportButton, ExportDialog } from "./ExportDialog.tsx";
|
|
20
23
|
import { NewPageDialog } from "./NewPageDialog.tsx";
|
|
21
24
|
|
|
25
|
+
/** W-978: why a row matches when only its content does. */
|
|
26
|
+
export function FoundIn({
|
|
27
|
+
query,
|
|
28
|
+
text,
|
|
29
|
+
fields,
|
|
30
|
+
}: {
|
|
31
|
+
query: string;
|
|
32
|
+
text: string | undefined;
|
|
33
|
+
fields: string[];
|
|
34
|
+
}) {
|
|
35
|
+
const snippet = contentSnippet(query, text, ...fields);
|
|
36
|
+
return snippet ? (
|
|
37
|
+
<div className="emvb-row-found" data-emvb-found-in="">
|
|
38
|
+
Found in content: {snippet}
|
|
39
|
+
</div>
|
|
40
|
+
) : null;
|
|
41
|
+
}
|
|
42
|
+
|
|
22
43
|
/** The Visual pages list (IA): title and slug, status, last edited; New page. */
|
|
23
44
|
export function PageList({ fetcher }: { fetcher: Fetcher }) {
|
|
24
45
|
const list = useList(fetcher, listPages);
|
|
25
46
|
const [creating, setCreating] = React.useState(false);
|
|
26
47
|
const [importing, setImporting] = React.useState(false);
|
|
48
|
+
const [exporting, setExporting] = React.useState(false);
|
|
27
49
|
const [query, setQuery] = React.useState("");
|
|
28
50
|
const searchRef = React.useRef<HTMLInputElement>(null);
|
|
29
51
|
const shown =
|
|
30
52
|
list.state === "ready"
|
|
31
|
-
? list.items.filter((page) =>
|
|
53
|
+
? list.items.filter((page) =>
|
|
54
|
+
// W-978: titles, addresses and the words on the page.
|
|
55
|
+
matchesSearch(query, page.title, `/${page.slug}`, page.text ?? ""),
|
|
56
|
+
)
|
|
32
57
|
: [];
|
|
58
|
+
const selection = useSelection(list.state === "ready" ? list.items.map((p) => p.id) : []);
|
|
59
|
+
const [exportIds, setExportIds] = React.useState<string[]>([]);
|
|
60
|
+
const titles = new Map(list.state === "ready" ? list.items.map((p) => [p.id, p.title]) : []);
|
|
33
61
|
|
|
34
62
|
const newPage = (
|
|
35
63
|
<div className="emvb-list-actions">
|
|
64
|
+
{list.state === "ready" && list.items.length > 0 && (
|
|
65
|
+
<ExportButton onClick={() => setExporting(true)} />
|
|
66
|
+
)}
|
|
36
67
|
<ImportButton onClick={() => setImporting(true)} />
|
|
37
68
|
<NewButton label="New page" onClick={() => setCreating(true)} />
|
|
38
69
|
</div>
|
|
@@ -61,6 +92,19 @@ export function PageList({ fetcher }: { fetcher: Fetcher }) {
|
|
|
61
92
|
{list.state === "ready" && list.items.length > 0 && (
|
|
62
93
|
<ListSearch value={query} onChange={setQuery} label="Search pages" inputRef={searchRef} />
|
|
63
94
|
)}
|
|
95
|
+
<BulkBar
|
|
96
|
+
fetcher={fetcher}
|
|
97
|
+
collection={PAGES_COLLECTION}
|
|
98
|
+
selection={selection}
|
|
99
|
+
titles={titles}
|
|
100
|
+
noun="page"
|
|
101
|
+
nouns="pages"
|
|
102
|
+
onChanged={list.retry}
|
|
103
|
+
onExport={(ids) => {
|
|
104
|
+
setExportIds(ids);
|
|
105
|
+
setExporting(true);
|
|
106
|
+
}}
|
|
107
|
+
/>
|
|
64
108
|
{list.state === "ready" && list.items.length > 0 && shown.length === 0 && (
|
|
65
109
|
<NoMatches
|
|
66
110
|
query={query}
|
|
@@ -75,6 +119,9 @@ export function PageList({ fetcher }: { fetcher: Fetcher }) {
|
|
|
75
119
|
<Table data-emvb-list="pages">
|
|
76
120
|
<Table.Header>
|
|
77
121
|
<Table.Row>
|
|
122
|
+
<Table.Head className="emvb-row-select">
|
|
123
|
+
<SelectAll shown={shown.map((p) => p.id)} selection={selection} noun="pages" />
|
|
124
|
+
</Table.Head>
|
|
78
125
|
<Table.Head>Title</Table.Head>
|
|
79
126
|
<Table.Head>Status</Table.Head>
|
|
80
127
|
<Table.Head>Last edited</Table.Head>
|
|
@@ -83,11 +130,19 @@ export function PageList({ fetcher }: { fetcher: Fetcher }) {
|
|
|
83
130
|
<Table.Body>
|
|
84
131
|
{shown.map((page) => (
|
|
85
132
|
<Table.Row key={page.id} data-emvb-row={page.id}>
|
|
133
|
+
<Table.Cell className="emvb-row-select">
|
|
134
|
+
<SelectRow id={page.id} title={page.title} selection={selection} />
|
|
135
|
+
</Table.Cell>
|
|
86
136
|
<Table.Cell>
|
|
87
137
|
<a className="emvb-row-title" href={editorUrl(page.id)}>
|
|
88
138
|
{page.title}
|
|
89
139
|
</a>
|
|
90
140
|
<div className="emvb-row-slug">/{page.slug}</div>
|
|
141
|
+
<FoundIn
|
|
142
|
+
query={query}
|
|
143
|
+
text={page.text}
|
|
144
|
+
fields={[page.title, `/${page.slug}`]}
|
|
145
|
+
/>
|
|
91
146
|
</Table.Cell>
|
|
92
147
|
<Table.Cell>
|
|
93
148
|
<StatusBadge status={page.status} />
|
|
@@ -102,6 +157,16 @@ export function PageList({ fetcher }: { fetcher: Fetcher }) {
|
|
|
102
157
|
</div>
|
|
103
158
|
)}
|
|
104
159
|
<NewPageDialog fetcher={fetcher} open={creating} onOpenChange={setCreating} />
|
|
160
|
+
<ExportDialog
|
|
161
|
+
fetcher={fetcher}
|
|
162
|
+
open={exporting}
|
|
163
|
+
onOpenChange={(open) => {
|
|
164
|
+
setExporting(open);
|
|
165
|
+
if (!open) setExportIds([]);
|
|
166
|
+
}}
|
|
167
|
+
pages={list.state === "ready" ? list.items : []}
|
|
168
|
+
selectedIds={exportIds}
|
|
169
|
+
/>
|
|
105
170
|
<ImportElementorDialog
|
|
106
171
|
fetcher={fetcher}
|
|
107
172
|
open={importing}
|
|
@@ -7,6 +7,9 @@ import type { Fetcher } from "../api.ts";
|
|
|
7
7
|
import { listThemeParts, partTypeLabel } from "../theme-api.ts";
|
|
8
8
|
import { editorUrl } from "../editor/exit.ts";
|
|
9
9
|
import { matchesSearch } from "../search.ts";
|
|
10
|
+
import { BulkBar, SelectAll, SelectRow, useSelection } from "./bulk.tsx";
|
|
11
|
+
import { partsInUse } from "../bulk-api.ts";
|
|
12
|
+
import { FoundIn } from "./PageList.tsx";
|
|
10
13
|
import {
|
|
11
14
|
EditedTime,
|
|
12
15
|
ListError,
|
|
@@ -143,8 +146,11 @@ export function ThemePartList({ fetcher }: { fetcher: Fetcher }) {
|
|
|
143
146
|
: list.items.filter((p) => p.partType === filter)
|
|
144
147
|
: [];
|
|
145
148
|
const shown = visible.filter((p) =>
|
|
146
|
-
|
|
149
|
+
// W-978: and the words in the part.
|
|
150
|
+
matchesSearch(query, p.title, partTypeLabel(p.partType), p.conditionsSummary, p.text ?? ""),
|
|
147
151
|
);
|
|
152
|
+
const selection = useSelection(list.state === "ready" ? list.items.map((p) => p.id) : []);
|
|
153
|
+
const titles = new Map(list.state === "ready" ? list.items.map((p) => [p.id, p.title]) : []);
|
|
148
154
|
|
|
149
155
|
const emptyFilterLabel =
|
|
150
156
|
filter === "all" ? "theme parts" : FILTERS.find((f) => f.value === filter)?.label.toLowerCase();
|
|
@@ -166,6 +172,17 @@ export function ThemePartList({ fetcher }: { fetcher: Fetcher }) {
|
|
|
166
172
|
/>
|
|
167
173
|
</>
|
|
168
174
|
)}
|
|
175
|
+
<BulkBar
|
|
176
|
+
fetcher={fetcher}
|
|
177
|
+
collection={THEME_PARTS_COLLECTION}
|
|
178
|
+
selection={selection}
|
|
179
|
+
titles={titles}
|
|
180
|
+
noun="theme part"
|
|
181
|
+
nouns="theme parts"
|
|
182
|
+
onChanged={list.retry}
|
|
183
|
+
deleteNote="Pages that use a deleted synced section or loop item show nothing in its place until you restore it."
|
|
184
|
+
usage={(ids) => partsInUse(fetcher, ids)}
|
|
185
|
+
/>
|
|
169
186
|
{list.state === "loading" && <ListLoading label="Loading theme parts…" />}
|
|
170
187
|
{list.state === "error" && (
|
|
171
188
|
<ListError title="Couldn't load theme parts" message={list.message} onRetry={list.retry} />
|
|
@@ -204,6 +221,13 @@ export function ThemePartList({ fetcher }: { fetcher: Fetcher }) {
|
|
|
204
221
|
<Table data-emvb-list="theme-parts">
|
|
205
222
|
<Table.Header>
|
|
206
223
|
<Table.Row>
|
|
224
|
+
<Table.Head className="emvb-row-select">
|
|
225
|
+
<SelectAll
|
|
226
|
+
shown={shown.map((p) => p.id)}
|
|
227
|
+
selection={selection}
|
|
228
|
+
noun="theme parts"
|
|
229
|
+
/>
|
|
230
|
+
</Table.Head>
|
|
207
231
|
<Table.Head>Title</Table.Head>
|
|
208
232
|
<Table.Head>Type</Table.Head>
|
|
209
233
|
<Table.Head>Conditions</Table.Head>
|
|
@@ -214,6 +238,9 @@ export function ThemePartList({ fetcher }: { fetcher: Fetcher }) {
|
|
|
214
238
|
<Table.Body>
|
|
215
239
|
{shown.map((part) => (
|
|
216
240
|
<Table.Row key={part.id} data-emvb-row={part.id}>
|
|
241
|
+
<Table.Cell className="emvb-row-select">
|
|
242
|
+
<SelectRow id={part.id} title={part.title} selection={selection} />
|
|
243
|
+
</Table.Cell>
|
|
217
244
|
<Table.Cell>
|
|
218
245
|
<a
|
|
219
246
|
className="emvb-row-title"
|
|
@@ -221,6 +248,15 @@ export function ThemePartList({ fetcher }: { fetcher: Fetcher }) {
|
|
|
221
248
|
>
|
|
222
249
|
{part.title}
|
|
223
250
|
</a>
|
|
251
|
+
<FoundIn
|
|
252
|
+
query={query}
|
|
253
|
+
text={part.text}
|
|
254
|
+
fields={[
|
|
255
|
+
part.title,
|
|
256
|
+
partTypeLabel(part.partType),
|
|
257
|
+
part.conditionsSummary,
|
|
258
|
+
]}
|
|
259
|
+
/>
|
|
224
260
|
</Table.Cell>
|
|
225
261
|
<Table.Cell>{partTypeLabel(part.partType)}</Table.Cell>
|
|
226
262
|
<Table.Cell>
|