@perkyzz/emvb 1.0.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.
Files changed (80) hide show
  1. package/README.md +9 -0
  2. package/package.json +2 -2
  3. package/src/admin/bulk-api.ts +67 -0
  4. package/src/admin/content-api.ts +10 -6
  5. package/src/admin/copy-rich-text.ts +119 -0
  6. package/src/admin/dialog-tab-wrap.ts +78 -0
  7. package/src/admin/editor/A11yCopilot.tsx +2 -0
  8. package/src/admin/editor/Editor.tsx +18 -6
  9. package/src/admin/editor/Timeline.tsx +6 -2
  10. package/src/admin/editor/TopBar.tsx +27 -7
  11. package/src/admin/editor/canvas/CanvasFrame.tsx +7 -2
  12. package/src/admin/editor/canvas/DeviceBar.tsx +22 -9
  13. package/src/admin/editor/canvas/canvas-scale.ts +3 -3
  14. package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
  15. package/src/admin/editor/dnd/new-element.ts +22 -0
  16. package/src/admin/editor/editor-chrome.tsx +7 -5
  17. package/src/admin/editor/editor-commands.ts +10 -4
  18. package/src/admin/editor/editor-css.ts +2 -1
  19. package/src/admin/editor/panels/ElementPanel.tsx +29 -16
  20. package/src/admin/editor/panels/SettingsPanel.tsx +2 -2
  21. package/src/admin/editor/panels/settings/EffectsControls.tsx +79 -1
  22. package/src/admin/editor/panels/settings/IconControls.tsx +11 -0
  23. package/src/admin/editor/panels/settings/LengthRow.tsx +36 -3
  24. package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +18 -0
  25. package/src/admin/editor/panels/settings/StyleRow.tsx +7 -0
  26. package/src/admin/editor/panels/settings/length-units.ts +15 -3
  27. package/src/admin/editor/panels/settings/style-sections.ts +1 -0
  28. package/src/admin/editor/panels/style-target.ts +17 -4
  29. package/src/admin/editor/section-templates.ts +26 -4
  30. package/src/admin/editor/store.ts +8 -2
  31. package/src/admin/editor/useEditorCommands.ts +7 -5
  32. package/src/admin/editor/useNodeActions.ts +4 -2
  33. package/src/admin/export-api.ts +221 -0
  34. package/src/admin/index.tsx +6 -1
  35. package/src/admin/pages/ExportDialog.tsx +395 -0
  36. package/src/admin/pages/PageList.tsx +67 -2
  37. package/src/admin/pages/ThemePartList.tsx +37 -1
  38. package/src/admin/pages/bulk.tsx +303 -0
  39. package/src/admin/search.ts +20 -0
  40. package/src/admin/theme-api.ts +4 -0
  41. package/src/admin/ui.ts +11 -2
  42. package/src/admin/widgets/CanvasField.tsx +8 -0
  43. package/src/admin/widgets/ConvertToRichText.tsx +136 -0
  44. package/src/admin/widgets/ExportEntryHtml.tsx +92 -0
  45. package/src/admin/widgets/convert-body.ts +73 -2
  46. package/src/astro/render.ts +6 -6
  47. package/src/astro/resolve-theme.ts +11 -7
  48. package/src/astro/tabs/runtime.ts +16 -6
  49. package/src/constants.ts +1 -1
  50. package/src/core/a11y/audit.ts +2 -1
  51. package/src/core/contract.ts +22 -2
  52. package/src/core/css/generate.ts +83 -21
  53. package/src/core/css/scope.ts +10 -2
  54. package/src/core/css/trace.ts +33 -8
  55. package/src/core/design/classes.ts +25 -5
  56. package/src/core/design/devices.ts +78 -2
  57. package/src/core/design/variables.ts +14 -1
  58. package/src/core/export/runtimes.generated.ts +9 -0
  59. package/src/core/export/site.ts +562 -0
  60. package/src/core/export/zip.ts +95 -0
  61. package/src/core/history/diff.ts +25 -0
  62. package/src/core/import/elementor/atomic.ts +22 -9
  63. package/src/core/import/elementor/index.ts +22 -4
  64. package/src/core/import/elementor/style.ts +21 -1
  65. package/src/core/index.ts +14 -0
  66. package/src/core/json-schema.ts +8 -1
  67. package/src/core/perf/meter.ts +37 -19
  68. package/src/core/portable-text-export.ts +243 -0
  69. package/src/core/public-attributes.ts +30 -0
  70. package/src/core/render/index.ts +88 -9
  71. package/src/core/render/tabs.ts +18 -11
  72. package/src/core/sanitize/css.ts +26 -0
  73. package/src/core/schema/design.ts +2 -2
  74. package/src/core/schema/layout.ts +11 -3
  75. package/src/core/schema/style.ts +47 -0
  76. package/src/core/search-text.ts +70 -0
  77. package/src/core/theme/float.ts +1 -0
  78. package/src/core/theme/popup-rules.ts +16 -0
  79. package/src/mcp/read.ts +2 -3
  80. package/src/server/icon-routes.ts +52 -12
@@ -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&apos;s own template, so they aren&apos;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
+ }
@@ -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) => matchesSearch(query, page.title, `/${page.slug}`))
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
- matchesSearch(query, p.title, partTypeLabel(p.partType), p.conditionsSummary),
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>