@perkyzz/emvb 0.9.0 → 1.1.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 +10 -1
- package/package.json +2 -2
- package/src/admin/agents-api.ts +45 -0
- package/src/admin/bulk-api.ts +67 -0
- package/src/admin/content-api.ts +10 -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 +3 -1
- package/src/admin/editor/Editor.tsx +311 -250
- package/src/admin/editor/Timeline.tsx +8 -3
- package/src/admin/editor/TopBar.tsx +29 -7
- package/src/admin/editor/canvas/CanvasFrame.tsx +7 -2
- package/src/admin/editor/canvas/DeviceBar.tsx +31 -10
- 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/co-design.ts +190 -0
- package/src/admin/editor/dnd/new-element.ts +48 -4
- package/src/admin/editor/editor-chrome.tsx +8 -6
- package/src/admin/editor/editor-commands.ts +15 -4
- package/src/admin/editor/editor-css.ts +2 -1
- package/src/admin/editor/element-chrome.ts +3 -1
- package/src/admin/editor/extension-manifests.ts +20 -0
- package/src/admin/editor/extensions/ExtensionPanels.tsx +26 -0
- package/src/admin/editor/extensions-context.tsx +27 -0
- package/src/admin/editor/feature-css.ts +17 -0
- package/src/admin/editor/palette-items.ts +2 -2
- package/src/admin/editor/panels/AddPanel.tsx +31 -1
- package/src/admin/editor/panels/AgentRequestBox.tsx +116 -0
- package/src/admin/editor/panels/ClassesSection.tsx +9 -6
- package/src/admin/editor/panels/CoDesignPanel.tsx +170 -0
- package/src/admin/editor/panels/ColorControl.tsx +2 -2
- package/src/admin/editor/panels/ElementPanel.tsx +68 -20
- package/src/admin/editor/panels/LanguagesSection.tsx +152 -0
- package/src/admin/editor/panels/LayersPanel.tsx +10 -6
- package/src/admin/editor/panels/LeftPanel.tsx +33 -5
- package/src/admin/editor/panels/PageSettings.tsx +4 -0
- package/src/admin/editor/panels/SettingsPanel.tsx +21 -2
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +7 -7
- package/src/admin/editor/panels/settings/BackgroundControls.tsx +72 -15
- package/src/admin/editor/panels/settings/BackgroundFill.tsx +8 -6
- package/src/admin/editor/panels/settings/BoxControl.tsx +5 -5
- package/src/admin/editor/panels/settings/EffectsControls.tsx +183 -10
- package/src/admin/editor/panels/settings/FieldControl.tsx +9 -3
- package/src/admin/editor/panels/settings/IconControls.tsx +25 -11
- package/src/admin/editor/panels/settings/LengthRow.tsx +63 -19
- package/src/admin/editor/panels/settings/LoopControl.tsx +269 -0
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +19 -1
- package/src/admin/editor/panels/settings/MotionControl.tsx +12 -11
- package/src/admin/editor/panels/settings/QueryStyleRows.tsx +7 -4
- package/src/admin/editor/panels/settings/StyleRow.tsx +120 -13
- package/src/admin/editor/panels/settings/TextMarksControl.tsx +247 -0
- package/src/admin/editor/panels/settings/VariableBinding.tsx +2 -2
- package/src/admin/editor/panels/settings/background-mode.ts +14 -11
- package/src/admin/editor/panels/settings/box-link-name.ts +1 -1
- package/src/admin/editor/panels/settings/box-sides.ts +22 -14
- package/src/admin/editor/panels/settings/heading-warning.ts +5 -1
- package/src/admin/editor/panels/settings/length-units.ts +68 -4
- package/src/admin/editor/panels/settings/query-style.ts +3 -3
- package/src/admin/editor/panels/settings/style-sections.ts +52 -10
- package/src/admin/editor/panels/style-target.ts +22 -7
- package/src/admin/editor/presence.ts +60 -0
- package/src/admin/editor/section-templates.ts +26 -4
- package/src/admin/editor/store.ts +14 -4
- package/src/admin/editor/useCoDesign.ts +177 -0
- package/src/admin/editor/useEditorCommands.ts +7 -5
- package/src/admin/editor/useExtensions.ts +45 -0
- package/src/admin/editor/useNodeActions.ts +18 -7
- package/src/admin/editor/useProposals.ts +81 -0
- package/src/admin/export-api.ts +221 -0
- package/src/admin/index.tsx +6 -1
- package/src/admin/languages-api.ts +61 -0
- package/src/admin/pages/AgentSetup.tsx +148 -0
- package/src/admin/pages/AgentsPage.tsx +9 -26
- package/src/admin/pages/CreateDialog.tsx +15 -0
- package/src/admin/pages/ExportDialog.tsx +395 -0
- package/src/admin/pages/ImportButton.tsx +18 -0
- package/src/admin/pages/ImportElementorDialog.tsx +669 -0
- package/src/admin/pages/ImportPageLinks.tsx +86 -0
- package/src/admin/pages/PageList.tsx +82 -3
- package/src/admin/pages/ThemePartList.tsx +52 -2
- package/src/admin/pages/bulk.tsx +303 -0
- package/src/admin/pages/section-head.tsx +27 -0
- package/src/admin/proposals-api.ts +91 -0
- package/src/admin/search.ts +20 -0
- package/src/admin/theme-api.ts +4 -0
- package/src/admin/ui.ts +50 -4
- 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/content-port.ts +14 -1
- package/src/astro/render.ts +6 -6
- package/src/astro/resolve-theme.ts +25 -8
- package/src/astro/resolve.ts +89 -2
- package/src/astro/tabs/runtime.ts +16 -6
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +45 -14
- package/src/core/arrange.ts +5 -1
- package/src/core/bounded-array.ts +31 -0
- package/src/core/clipboard.ts +9 -0
- package/src/core/contract.ts +305 -0
- package/src/core/css/generate.ts +151 -20
- package/src/core/css/scope.ts +10 -2
- package/src/core/css/trace.ts +47 -13
- package/src/core/css-keywords.ts +51 -1
- package/src/core/design/cascade.ts +12 -9
- package/src/core/design/classes.ts +28 -9
- package/src/core/design/devices.ts +89 -13
- package/src/core/design/states.ts +5 -3
- package/src/core/design/transfer.ts +5 -0
- package/src/core/design/variables.ts +31 -5
- package/src/core/elements/dynamic-elements.ts +3 -3
- package/src/core/elements/index.ts +73 -9
- package/src/core/export/runtimes.generated.ts +9 -0
- package/src/core/export/site.ts +562 -0
- package/src/core/export/zip.ts +95 -0
- package/src/core/extensions/define.ts +13 -0
- package/src/core/extensions/index.ts +41 -0
- package/src/core/extensions/namespace.ts +82 -0
- package/src/core/extensions/normalize.ts +141 -0
- package/src/core/extensions/placeholder.ts +41 -0
- package/src/core/extensions/registry.ts +94 -0
- package/src/core/extensions/render-ext.ts +118 -0
- package/src/core/extensions/safe-nodes.ts +93 -0
- package/src/core/extensions/schema.ts +112 -0
- package/src/core/extensions/types.ts +159 -0
- package/src/core/forms/binding.ts +1 -1
- package/src/core/history/diff.ts +26 -1
- package/src/core/import/elementor/atomic.ts +1608 -0
- package/src/core/import/elementor/classes.ts +127 -0
- package/src/core/import/elementor/context.ts +429 -0
- package/src/core/import/elementor/counter-steps.ts +72 -0
- package/src/core/import/elementor/css.ts +445 -0
- package/src/core/import/elementor/html.ts +500 -0
- package/src/core/import/elementor/index.ts +967 -0
- package/src/core/import/elementor/inline-marks.ts +81 -0
- package/src/core/import/elementor/snapshots.ts +48 -0
- package/src/core/import/elementor/style.ts +429 -0
- package/src/core/import/elementor/values.ts +241 -0
- package/src/core/import/elementor/widgets.ts +1897 -0
- package/src/core/index.ts +96 -0
- package/src/core/json-schema.ts +114 -0
- package/src/core/limits.ts +19 -0
- package/src/core/migrate/index.ts +6 -1
- package/src/core/migrate/v18.ts +222 -0
- package/src/core/perf/meter.ts +42 -24
- package/src/core/portable-text-export.ts +243 -0
- package/src/core/proposals-safety.ts +102 -0
- package/src/core/proposals.ts +357 -0
- package/src/core/public-attributes.ts +30 -0
- package/src/core/recipes/index.ts +2 -2
- package/src/core/render/extras.ts +3 -3
- package/src/core/render/index.ts +222 -23
- package/src/core/render/loop.ts +1 -1
- package/src/core/render/section.ts +4 -4
- package/src/core/render/tabs.ts +18 -11
- package/src/core/render/vnode.ts +1 -1
- package/src/core/sanitize/css.ts +151 -10
- package/src/core/sanitize/motion.ts +116 -0
- package/src/core/saved-sections.ts +6 -0
- package/src/core/schema/descriptors.ts +3 -1
- package/src/core/schema/design.ts +4 -3
- package/src/core/schema/layout.ts +92 -16
- package/src/core/schema/style.ts +296 -112
- package/src/core/search-text.ts +70 -0
- package/src/core/text-marks.ts +227 -0
- package/src/core/theme/dynamic.ts +9 -4
- package/src/core/theme/float.ts +2 -0
- package/src/core/theme/popup-rules.ts +33 -1
- package/src/core/translatable.ts +34 -0
- package/src/core/validate.ts +13 -1
- package/src/index.ts +24 -0
- package/src/mcp/errors.ts +3 -1
- package/src/mcp/ports.ts +67 -0
- package/src/mcp/prompts.ts +1 -11
- package/src/mcp/proposals.ts +281 -0
- package/src/mcp/read.ts +10 -10
- package/src/mcp/tools.ts +71 -3
- package/src/mcp/write.ts +66 -11
- package/src/server/agent-settings.ts +5 -1
- package/src/server/icon-routes.ts +52 -12
- package/src/server/mcp-routes.ts +15 -0
- package/src/server/plugin.ts +35 -2
- package/src/server/presence.ts +78 -0
- package/src/server/proposals.ts +261 -0
- package/src/server/requests.ts +196 -0
- package/src/server/tools-served.ts +45 -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
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Button } from "@cloudflare/kumo";
|
|
2
|
+
import { FileArrowUpIcon } from "@phosphor-icons/react";
|
|
3
|
+
import { BUTTON } from "../ui.ts";
|
|
4
|
+
|
|
5
|
+
/** Opens Import from Elementor (W-945), next to the list's New button. */
|
|
6
|
+
export function ImportButton({ onClick }: { onClick: () => void }) {
|
|
7
|
+
return (
|
|
8
|
+
<Button
|
|
9
|
+
variant="secondary"
|
|
10
|
+
className={BUTTON}
|
|
11
|
+
icon={<FileArrowUpIcon aria-hidden="true" />}
|
|
12
|
+
onClick={onClick}
|
|
13
|
+
data-emvb-import-elementor=""
|
|
14
|
+
>
|
|
15
|
+
Import from Elementor
|
|
16
|
+
</Button>
|
|
17
|
+
);
|
|
18
|
+
}
|