@perkyzz/emvb 1.4.0 → 1.4.2

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 (57) hide show
  1. package/README.md +2 -2
  2. package/package.json +6 -6
  3. package/src/admin/content-item.ts +3 -0
  4. package/src/admin/copy-rich-text.ts +99 -9
  5. package/src/admin/editor/Editor.tsx +7 -2
  6. package/src/admin/editor/collection-previews.ts +7 -8
  7. package/src/admin/editor/extensions/ExtensionPanels.tsx +33 -1
  8. package/src/admin/editor/extensions-context.tsx +16 -1
  9. package/src/admin/editor/feature-css.ts +5 -0
  10. package/src/admin/editor/panels/ConditionsEditor.tsx +18 -0
  11. package/src/admin/editor/panels/ElementPanel.tsx +2 -2
  12. package/src/admin/editor/panels/settings/FieldControl.tsx +15 -0
  13. package/src/admin/editor/panels/settings/FormBindControl.tsx +27 -31
  14. package/src/admin/editor/panels/settings/ImageFieldControl.tsx +106 -0
  15. package/src/admin/editor/panels/settings/loop-context.ts +34 -3
  16. package/src/admin/export-api.ts +2 -0
  17. package/src/admin/extension-outputs.ts +57 -0
  18. package/src/admin/import-forms.ts +133 -0
  19. package/src/admin/pages/ImportElementorDialog.tsx +32 -0
  20. package/src/admin/pages/ImportForms.tsx +71 -0
  21. package/src/admin/setup/plan.ts +2 -0
  22. package/src/admin/ui.ts +7 -0
  23. package/src/admin/widgets/ConvertToRichText.tsx +3 -2
  24. package/src/astro/render.ts +11 -0
  25. package/src/astro/resolve-theme.ts +11 -15
  26. package/src/astro/resolve.ts +2 -0
  27. package/src/astro/theme-posts.ts +17 -23
  28. package/src/astro/visitor.ts +14 -5
  29. package/src/astro/widgets/sticky.ts +4 -1
  30. package/src/constants.ts +1 -1
  31. package/src/core/css/generate.ts +6 -1
  32. package/src/core/css/trace.ts +8 -0
  33. package/src/core/data/bindings.ts +7 -4
  34. package/src/core/elements/dynamic-elements.ts +1 -1
  35. package/src/core/elements/element-nouns.ts +48 -0
  36. package/src/core/export/runtimes.generated.ts +1 -1
  37. package/src/core/export/site.ts +7 -11
  38. package/src/core/extensions/index.ts +2 -0
  39. package/src/core/extensions/placeholder.ts +7 -2
  40. package/src/core/extensions/render-ext.ts +49 -15
  41. package/src/core/import/elementor/context.ts +29 -0
  42. package/src/core/import/elementor/index.ts +23 -2
  43. package/src/core/import/elementor/widgets.ts +137 -17
  44. package/src/core/index.ts +11 -0
  45. package/src/core/render/index.ts +30 -2
  46. package/src/core/schema/layout.ts +4 -1
  47. package/src/core/theme/media-value.ts +88 -0
  48. package/src/core/theme/part-wrapper.ts +100 -0
  49. package/src/core/visitor-cookie.ts +91 -0
  50. package/src/index.ts +28 -1
  51. package/src/mcp/agent-defaults.ts +40 -0
  52. package/src/mcp/extensions.ts +138 -0
  53. package/src/mcp/read.ts +55 -19
  54. package/src/mcp/tools.ts +3 -3
  55. package/src/mcp/write.ts +83 -8
  56. package/src/server/extension-routes.ts +37 -0
  57. package/src/server/plugin.ts +7 -1
package/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
  [![Website](https://img.shields.io/badge/website-emvb.dev-1f6feb)](https://emvb.dev) [![npm](https://img.shields.io/npm/v/@perkyzz/emvb)](https://www.npmjs.com/package/@perkyzz/emvb)
13
13
 
14
- A visual page builder plugin for [EmDash CMS](https://github.com/emdash-cms/emdash) 1.4 and 1.5 (built and tested on 1.5.0, tested on 1.4.0). Pages are built in a full-screen editor inside the EmDash admin and published as plain HTML and CSS. It runs on Node (SQLite) and Cloudflare Workers (D1).
14
+ A visual page builder plugin for [EmDash CMS](https://github.com/emdash-cms/emdash) 1.4, 1.5 and 1.6. Pages are built in a full-screen editor inside the EmDash admin and published as plain HTML and CSS. It runs on Node (SQLite) and Cloudflare Workers (D1).
15
15
 
16
16
  ![The EmVB editor](https://raw.githubusercontent.com/PerkyZZ999/EmVB/main/site/public/screenshots/editor-1600.webp)
17
17
 
@@ -25,7 +25,7 @@ Library pictures can be cropped, adjusted, filtered and saved as a new media ite
25
25
  npm i @perkyzz/emvb
26
26
  ```
27
27
 
28
- Peers, which an EmDash 1.4 or 1.5 site already has: `emdash` >=1.4.0 <2, `astro` ^7, `react` and `react-dom` ^19, `@cloudflare/kumo` 2.6.0 (EmDash 1.4) or 2.15.0 (EmDash 1.5) and `@phosphor-icons/react` ^2.1.10. `@emdash-cms/plugin-forms` is optional and enables forms: 0.2.13 on EmDash 1.5, 0.2.9 to 0.2.12 on EmDash 1.4. Use the Astro version your EmDash site already has: each release is installed on stock `create-emdash` sites of EmDash 1.4.0 and 1.5.0.
28
+ EmDash 1.4–1.6 sites provide the required peers: `emdash` >=1.4.0 <2, `astro` ^7, `react` and `react-dom` ^19, `@phosphor-icons/react` ^2.1.10 and the exact `@cloudflare/kumo` version each EmDash release pins (2.6.0, 2.15.0 and 2.19.0 respectively). For forms, install `@emdash-cms/plugin-forms` 0.2.9–0.2.12 on 1.4, 0.2.13 on 1.5 or 0.2.14 on 1.6. Keep the Astro version your site's scaffold installs. Releases get stock-install smoke tests on 1.4.0, 1.5.0 and 1.6.0.
29
29
 
30
30
  Dependencies installed with it: `zod` and [`@perkyzz/emvb-icons`](https://www.npmjs.com/package/@perkyzz/emvb-icons), the icon sets for the editor's Icon library. Only the editor loads them; a placed icon is saved into the page as SVG.
31
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perkyzz/emvb",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "Visual page builder plugin for EmDash CMS",
5
5
  "keywords": [
6
6
  "astro",
@@ -50,24 +50,24 @@
50
50
  "test:astro": "bun --bun vitest run"
51
51
  },
52
52
  "dependencies": {
53
- "@perkyzz/emvb-icons": "1.4.0",
53
+ "@perkyzz/emvb-icons": "1.4.2",
54
54
  "photocn": "0.1.2",
55
55
  "zod": ">=4.5.4 <5"
56
56
  },
57
57
  "devDependencies": {
58
- "@cloudflare/kumo": "2.15.0",
59
- "@emdash-cms/plugin-forms": "0.2.13",
58
+ "@cloudflare/kumo": "2.19.0",
59
+ "@emdash-cms/plugin-forms": "0.2.14",
60
60
  "@phosphor-icons/react": "2.1.10",
61
61
  "@types/react": "19.3.0",
62
62
  "@types/react-dom": "19.3.0",
63
63
  "astro": "7.4.12",
64
- "emdash": "1.5.0",
64
+ "emdash": "1.6.0",
65
65
  "react": "19.3.1",
66
66
  "react-dom": "19.3.1",
67
67
  "vitest": "5.1.0"
68
68
  },
69
69
  "peerDependencies": {
70
- "@cloudflare/kumo": "2.6.0 || 2.15.0",
70
+ "@cloudflare/kumo": "2.6.0 || 2.15.0 || 2.19.0",
71
71
  "@emdash-cms/plugin-forms": "^0.2.9",
72
72
  "@phosphor-icons/react": "^2.1.10",
73
73
  "astro": "^7.0.0",
@@ -6,6 +6,9 @@ export type ContentItem = {
6
6
  draftRevisionId?: string | null;
7
7
  updatedAt?: string;
8
8
  data?: Record<string, unknown>;
9
+ /** W-1091: EmDash i18n: the entry's language, and the group its translations share. */
10
+ locale?: string | null;
11
+ translationGroup?: string | null;
9
12
  seo?: {
10
13
  title?: string | null;
11
14
  description?: string | null;
@@ -4,6 +4,7 @@ import { THEME_PARTS_COLLECTION } from "../constants.ts";
4
4
  import { ApiError, listAllItems, requestJson, type Fetcher } from "./api.ts";
5
5
  import type { ContentItem } from "./content-item.ts";
6
6
  import { loadExportData } from "./export-api.ts";
7
+ import { siteLocales } from "./languages-api.ts";
7
8
  import { readCollection } from "./setup/run.ts";
8
9
 
9
10
  export type RichTextTarget = {
@@ -13,6 +14,13 @@ export type RichTextTarget = {
13
14
  field: string;
14
15
  /** The collection has a `title` field for the page title. */
15
16
  hasTitle: boolean;
17
+ /**
18
+ * W-1091: false when the rich-text field is shared by every language of an entry (EmDash's
19
+ * per-field `translatable`); then only the default language is copied.
20
+ */
21
+ translatable?: boolean;
22
+ /** W-1091: false when the title is shared by every language (a translation must not send it). */
23
+ titleTranslatable?: boolean;
16
24
  };
17
25
 
18
26
  /** Visible collections with a rich-text field: where EmVB pages can be copied as rich text. */
@@ -29,12 +37,15 @@ export async function richTextTargets(fetcher: Fetcher): Promise<RichTextTarget[
29
37
  const rich = fields.filter((f) => f.type === "portableText");
30
38
  const field = rich.find((f) => f.slug === "content") ?? rich[0];
31
39
  if (!field) return null;
40
+ const title = fields.find((f) => f.slug === "title");
32
41
  const target: RichTextTarget = {
33
42
  slug: c.slug,
34
43
  label: c.label?.trim() || c.slug,
35
44
  field: field.slug,
36
- hasTitle: fields.some((f) => f.slug === "title"),
45
+ hasTitle: !!title,
37
46
  };
47
+ if (field.translatable === false) target.translatable = false;
48
+ if (title?.translatable === false) target.titleTranslatable = false;
38
49
  return target;
39
50
  }),
40
51
  );
@@ -42,25 +53,66 @@ export async function richTextTargets(fetcher: Fetcher): Promise<RichTextTarget[
42
53
  }
43
54
 
44
55
  export type CopyResult = {
45
- created: { title: string; id: string }[];
56
+ /** W-1091: `locale` is set when the site has languages; the title then names it. */
57
+ created: { title: string; id: string; locale?: string }[];
46
58
  failed: { title: string; message: string }[];
47
59
  /** Elements left out across all pages, by type. */
48
60
  skipped: Record<string, number>;
49
61
  };
50
62
 
63
+ type Page = Awaited<ReturnType<typeof loadExportData>>["pages"][number];
64
+
65
+ /**
66
+ * W-1091 (#26): the pages in the order they are copied, grouped by translation: in each group the
67
+ * default language first, so the others can be created as its translations. With `onlyDefault`,
68
+ * the other languages are set aside (returned in `rest`).
69
+ */
70
+ function translationOrder(
71
+ pages: readonly Page[],
72
+ defaultLocale: string,
73
+ onlyDefault: boolean,
74
+ ): { copy: Page[]; rest: Page[] } {
75
+ const groups = new Map<string, Page[]>();
76
+ for (const page of pages) {
77
+ const group = page.translationGroup || page.id;
78
+ groups.set(group, [...(groups.get(group) ?? []), page]);
79
+ }
80
+ const copy: Page[] = [];
81
+ const rest: Page[] = [];
82
+ for (const [group, members] of groups) {
83
+ const rank = (p: Page) => (p.locale === defaultLocale ? 0 : p.id === group ? 1 : 2);
84
+ const ordered = members.toSorted(
85
+ (a, b) => rank(a) - rank(b) || (a.locale ?? "").localeCompare(b.locale ?? ""),
86
+ );
87
+ if (onlyDefault) {
88
+ const [first, ...others] = ordered;
89
+ if (first) copy.push(first);
90
+ rest.push(...others);
91
+ } else copy.push(...ordered);
92
+ }
93
+ return { copy, rest };
94
+ }
95
+
51
96
  /**
52
97
  * W-963: published EmVB pages (all or one) become draft entries in another collection, their
53
98
  * words, headings, lists, links and images as rich text. EmVB pages are only read; nothing is
54
99
  * published. A page whose entry can't be created (a slug in use) is reported and the rest go on.
100
+ *
101
+ * W-1091 (#26): on a site with languages each page keeps its own: one entry per language, in that
102
+ * locale, with that language's words, created as a translation of the default language's entry
103
+ * (slugs are unique per language in EmDash, so translations share theirs). When the target's
104
+ * rich-text field is shared across languages, or the site has no languages set up, only one
105
+ * language per page is copied and the others are reported, never written under another locale.
55
106
  */
56
107
  export async function copyPagesAsRichText(
57
108
  fetcher: Fetcher,
58
109
  target: RichTextTarget,
59
110
  onlyPageId?: string | readonly string[],
60
111
  ): Promise<CopyResult> {
61
- const [{ pages }, partItems] = await Promise.all([
112
+ const [{ pages }, partItems, languages] = await Promise.all([
62
113
  loadExportData(fetcher, onlyPageId),
63
114
  listAllItems<ContentItem>(fetcher, `/_emdash/api/content/${THEME_PARTS_COLLECTION}`),
115
+ siteLocales(fetcher).catch(() => null),
64
116
  ]);
65
117
  const sectionTemplates: Record<string, Layout> = {};
66
118
  for (const part of partItems) {
@@ -69,7 +121,33 @@ export async function copyPagesAsRichText(
69
121
  if (checked.ok) sectionTemplates[part.id] = checked.layout;
70
122
  }
71
123
  const result: CopyResult = { created: [], failed: [], skipped: {} };
72
- for (const page of pages) {
124
+ const defaultLocale = languages?.defaultLocale ?? "en";
125
+ const perLanguage = !!languages && target.translatable !== false;
126
+ const { copy, rest } = translationOrder(pages, defaultLocale, !perLanguage);
127
+ // A page's title names its language when the pages have more than one.
128
+ const multilingual = new Set(pages.map((p) => p.locale ?? defaultLocale)).size > 1;
129
+ const named = (page: Page) =>
130
+ multilingual && page.locale ? `${page.title} (${page.locale})` : page.title;
131
+ for (const page of rest) {
132
+ result.failed.push({
133
+ title: named(page),
134
+ message: languages
135
+ ? `${target.label} shares its ${target.field} field across languages, so only the ${defaultLocale} page was copied`
136
+ : "this site has no languages set up, so only one language of each page was copied",
137
+ });
138
+ }
139
+ // Translation group → the entry its first language became.
140
+ const sources = new Map<string, string>();
141
+ for (const page of copy) {
142
+ const group = page.translationGroup || page.id;
143
+ const locale = languages ? page.locale || defaultLocale : undefined;
144
+ if (locale && languages && !languages.locales.includes(locale)) {
145
+ result.failed.push({
146
+ title: named(page),
147
+ message: `its language (${locale}) isn't set up on this site`,
148
+ });
149
+ continue;
150
+ }
73
151
  let raw = page.layout;
74
152
  if (typeof raw === "string") {
75
153
  try {
@@ -80,12 +158,15 @@ export async function copyPagesAsRichText(
80
158
  }
81
159
  const checked = validateLayout(raw);
82
160
  if (!checked.ok) {
83
- result.failed.push({ title: page.title, message: "its layout couldn't be read" });
161
+ result.failed.push({ title: named(page), message: "its layout couldn't be read" });
84
162
  continue;
85
163
  }
86
164
  const converted = layoutToPortableText(checked.layout, { sectionTemplates });
87
165
  for (const [type, n] of Object.entries(converted.skipped))
88
166
  result.skipped[type] = (result.skipped[type] ?? 0) + n;
167
+ const source = sources.get(group);
168
+ // A title shared by every language comes from the entry it translates.
169
+ const sendTitle = target.hasTitle && !(source && target.titleTranslatable === false);
89
170
  try {
90
171
  // oxlint-disable-next-line no-await-in-loop -- one entry at a time; failures are per page
91
172
  const body = await requestJson<{ item: { id: string } }>(
@@ -95,20 +176,29 @@ export async function copyPagesAsRichText(
95
176
  method: "POST",
96
177
  body: {
97
178
  data: {
98
- ...(target.hasTitle ? { title: page.title } : {}),
179
+ ...(sendTitle ? { title: page.title } : {}),
99
180
  [target.field]: converted.body,
100
181
  },
101
182
  ...(page.slug ? { slug: page.slug } : {}),
183
+ ...(locale ? { locale } : {}),
184
+ ...(locale && source ? { translationOf: source } : {}),
102
185
  },
103
186
  },
104
187
  );
105
- result.created.push({ title: page.title, id: body.item.id });
188
+ if (!sources.has(group)) sources.set(group, body.item.id);
189
+ result.created.push({
190
+ title: named(page),
191
+ id: body.item.id,
192
+ ...(locale ? { locale } : {}),
193
+ });
106
194
  } catch (error) {
107
195
  result.failed.push({
108
- title: page.title,
196
+ title: named(page),
109
197
  message:
110
198
  error instanceof ApiError && error.status === 409
111
- ? "its address is already used there"
199
+ ? locale && multilingual
200
+ ? `its address is already used there in ${locale}`
201
+ : "its address is already used there"
112
202
  : error instanceof Error
113
203
  ? error.message
114
204
  : String(error),
@@ -63,7 +63,7 @@ import {
63
63
  import { EDITOR_MIN_WIDTH_QUERY, useMediaQuery } from "./useMediaQuery.ts";
64
64
  import { partDraftLabel, usePartTemplates } from "./section-templates.ts";
65
65
  import { useCollectionPreviews, withPartLayouts } from "./collection-previews.ts";
66
- import { useExtensionOutputs } from "../extension-outputs.ts";
66
+ import { useExtensionOutputs, useExtensionSourceValues } from "../extension-outputs.ts";
67
67
  import { useEditorPresence } from "./presence.ts";
68
68
  import { useCoDesign } from "./useCoDesign.ts";
69
69
  import { useRemoteChange } from "./remote-change.ts";
@@ -162,6 +162,8 @@ function EditorApp({
162
162
  const host = useEditorHost();
163
163
  const canvasStyles = useCanvasStyles(fetcher);
164
164
  const extensionManifests = useExtensionManifests(fetcher);
165
+ // W-1088 (#36): the values of the sources extension panels name, listed read-only.
166
+ const extensionSources = useExtensionSourceValues(fetcher, extensionManifests);
165
167
  const inlinedStyles = useInlinedStyles(canvasStyles);
166
168
  const { exit } = host;
167
169
  const saver = useSave(fetcher, state, dispatch, collection);
@@ -344,6 +346,9 @@ function EditorApp({
344
346
  },
345
347
  previewDevice,
346
348
  extensionOutputs,
349
+ // W-1088 (#37): visitors get nothing for an extension that can't render; this preview
350
+ // keeps the note so the editor knows something is missing.
351
+ extensionPlaceholders: true,
347
352
  });
348
353
  return previewDocument({
349
354
  html: result.html,
@@ -455,7 +460,7 @@ function EditorApp({
455
460
  })[0];
456
461
 
457
462
  return (
458
- <ExtensionsProvider extensions={extensionManifests}>
463
+ <ExtensionsProvider extensions={extensionManifests} sourceValues={extensionSources}>
459
464
  <EditorOverlay
460
465
  label={`EmVB editor: ${state.page.title || "Untitled page"}`}
461
466
  dirty={dirty && !chrome.leaving}
@@ -1,7 +1,9 @@
1
1
  import * as React from "react";
2
2
  import {
3
3
  collectCollectionLoops,
4
+ entryImageValue,
4
5
  loopPermalink,
6
+ mediaUrlOf,
5
7
  type CollectionLoop,
6
8
  type Layout,
7
9
  type ThemePostFields,
@@ -13,16 +15,13 @@ type ContentItem = { id: string; slug?: string | null; data?: Record<string, unk
13
15
  const text = (value: unknown): string => (typeof value === "string" ? value : "");
14
16
 
15
17
  /** A content API item as Loop fields; the host's mapping covers images and plain fields. */
16
- function previewPost(item: ContentItem, loop: CollectionLoop): ThemePostFields {
18
+ export function previewPost(item: ContentItem, loop: CollectionLoop): ThemePostFields {
17
19
  const data = item.data ?? {};
18
20
  const slug = item.slug || text(data["slug"]);
19
- const image = loop.imageField ? data[loop.imageField] : (data["featured_image"] ?? data["image"]);
20
- const src =
21
- typeof image === "string"
22
- ? image
23
- : image && typeof image === "object" && "src" in image
24
- ? text((image as { src?: unknown }).src)
25
- : "";
21
+ // W-1090 (#32): as published pages read it: a picked upload has no `src`, only a storage key,
22
+ // and unset falls back from featured_image to the entry's first image field.
23
+ const image = entryImageValue(data, loop.imageField);
24
+ const src = typeof image === "string" ? image : (mediaUrlOf(image) ?? "");
26
25
  const fields: Record<string, string> = {};
27
26
  for (const [key, value] of Object.entries(data).slice(0, 100)) {
28
27
  if (typeof value === "string" && value.length <= 2000) fields[key] = value;
@@ -1,8 +1,10 @@
1
- import { useExtensions } from "../extensions-context.tsx";
1
+ import type { ExtensionManifest } from "../../../core/index.ts";
2
+ import { useExtensions, useExtensionSourceValuesContext } from "../extensions-context.tsx";
2
3
 
3
4
  /**
4
5
  * W-927 / D-067: Kumo-slot area for declarative extension panels. EmVB renders the
5
6
  * panel copy with existing EmVB/Kumo tokens; extensions may not inject global admin CSS.
7
+ * W-1088 (#36): a panel that names a source lists that source's values read-only, as plain text.
6
8
  */
7
9
  export function ExtensionPanels() {
8
10
  const extensions = useExtensions();
@@ -19,8 +21,38 @@ export function ExtensionPanels() {
19
21
  From {ext.label}
20
22
  {panel.source ? ` · source “${panel.source}”` : ""}
21
23
  </p>
24
+ {panel.source ? <SourceValues ext={ext} name={panel.source} /> : null}
22
25
  </div>
23
26
  ))}
24
27
  </div>
25
28
  );
26
29
  }
30
+
31
+ /** One source's values as a read-only list of labels and values. */
32
+ function SourceValues({ ext, name }: { ext: ExtensionManifest; name: string }) {
33
+ const all = useExtensionSourceValuesContext();
34
+ const source = ext.sources.find((s) => s.name === name);
35
+ if (!source) return null;
36
+ const id = `ext:${ext.id}/${name}`;
37
+ if (!all) return <p className="emvb-helper">Loading values…</p>;
38
+ const values = all.get(id);
39
+ if (!values) {
40
+ return (
41
+ <p className="emvb-helper" data-emvb-ext-source-unavailable="">
42
+ This source&apos;s values couldn&apos;t be read on this server.
43
+ </p>
44
+ );
45
+ }
46
+ const entries = Object.entries(values);
47
+ if (entries.length === 0) return <p className="emvb-helper">This source has no values.</p>;
48
+ return (
49
+ <dl className="emvb-ext-source" data-emvb-ext-source={id} aria-label={`${source.label} values`}>
50
+ {entries.map(([key, value]) => (
51
+ <div key={key}>
52
+ <dt>{key}</dt>
53
+ <dd>{value}</dd>
54
+ </div>
55
+ ))}
56
+ </dl>
57
+ );
58
+ }
@@ -1,17 +1,32 @@
1
1
  import * as React from "react";
2
2
  import type { ExtensionManifest } from "../../core/index.ts";
3
+ import type { ExtensionSourceValues } from "../extension-outputs.ts";
3
4
  import { extensionElementManifests } from "./useExtensions.ts";
4
5
 
5
6
  const ExtensionsContext = React.createContext<readonly ExtensionManifest[]>([]);
7
+ /** W-1088: the values of the sources extension panels name; undefined while loading. */
8
+ const ExtensionSourcesContext = React.createContext<ExtensionSourceValues | undefined>(undefined);
6
9
 
7
10
  export function ExtensionsProvider({
8
11
  extensions,
12
+ sourceValues,
9
13
  children,
10
14
  }: {
11
15
  extensions: readonly ExtensionManifest[];
16
+ sourceValues?: ExtensionSourceValues;
12
17
  children: React.ReactNode;
13
18
  }) {
14
- return <ExtensionsContext.Provider value={extensions}>{children}</ExtensionsContext.Provider>;
19
+ return (
20
+ <ExtensionsContext.Provider value={extensions}>
21
+ <ExtensionSourcesContext.Provider value={sourceValues}>
22
+ {children}
23
+ </ExtensionSourcesContext.Provider>
24
+ </ExtensionsContext.Provider>
25
+ );
26
+ }
27
+
28
+ export function useExtensionSourceValuesContext(): ExtensionSourceValues | undefined {
29
+ return React.useContext(ExtensionSourcesContext);
15
30
  }
16
31
 
17
32
  export function useExtensions(): readonly ExtensionManifest[] {
@@ -26,6 +26,11 @@ export const FEATURE_CSS = `
26
26
  .emvb-bind-row > .emvb-bind-label + .emvb-field:last-child { grid-column: 1 / -1; }
27
27
  .emvb-bind-live { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--text-color-kumo-default); overflow-wrap: anywhere; }
28
28
  .emvb-bind-live > b { font-weight: 600; }
29
+ /* W-1088: an extension panel's source values, read-only. */
30
+ .emvb-ext-source { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 2px 12px; margin: 4px 0 0; font-size: 12px; line-height: 16px; }
31
+ .emvb-ext-source > div { display: contents; }
32
+ .emvb-ext-source dt { font-weight: 600; color: var(--text-color-kumo-default); overflow-wrap: anywhere; }
33
+ .emvb-ext-source dd { margin: 0; color: var(--text-color-kumo-default); overflow-wrap: anywhere; white-space: pre-line; }
29
34
  .emvb-bind-outside { grid-column: 1 / -1; display: grid; gap: 4px; }
30
35
  .emvb-bind-outside > label { display: flex; gap: 6px; align-items: center; font-size: 12px; }
31
36
  .emvb-bind-warning { margin: 0; padding: 6px 8px; border-radius: 6px; font-size: 12px; background: var(--color-kumo-warning-tint); color: var(--text-color-kumo-default); }
@@ -111,6 +111,10 @@ export function ruleFromOption(
111
111
  };
112
112
  }
113
113
 
114
+ /** W-1090 (#40): the install guide's section on theme parts for the site's own routes. */
115
+ const OTHER_ROUTES_DOCS =
116
+ "https://github.com/PerkyZZ999/EmVB/blob/main/docs/guides/install-in-a-host-site.md#theme-parts-on-your-sites-other-routes";
117
+
114
118
  let ruleSeq = 0;
115
119
  const newConditionId = () => `r-${Date.now().toString(36)}-${(++ruleSeq).toString(36)}`;
116
120
 
@@ -121,6 +125,10 @@ export function ConditionsEditor({ conditions, onChange }: Props) {
121
125
 
122
126
  /** The schema allows at most 20 rules, so a 21st would make the part unsavable (W-092). */
123
127
  const full = doc.rules.length >= MAX_CONDITION_RULES;
128
+ // W-1090 (#40): routes that don't call resolveThemeParts never show the part.
129
+ const entireSite = doc.rules.some(
130
+ (rule) => rule.op === "include" && rule.group === "general" && rule.name === "entire_site",
131
+ );
124
132
  const fullReason = `${MAX_CONDITION_RULES} conditions is the most one part can have. Remove one to add another.`;
125
133
 
126
134
  const add = (op: "include" | "exclude") => {
@@ -190,6 +198,16 @@ export function ConditionsEditor({ conditions, onChange }: Props) {
190
198
  </li>
191
199
  ))}
192
200
  </ul>
201
+ {entireSite && (
202
+ <p className="emvb-helper" data-emvb-entire-site-hint="">
203
+ Entire site means every page that renders EmVB theme parts: EmVB pages and the routes
204
+ whose layout adds them. A blog home or post list from your site&apos;s own templates may
205
+ not.{" "}
206
+ <a href={OTHER_ROUTES_DOCS} target="_blank" rel="noopener noreferrer">
207
+ Add theme parts to other routes
208
+ </a>
209
+ </p>
210
+ )}
193
211
  {/* UX-051: sentence case; the plus says "add", so both fit on one row at 264 px. */}
194
212
  <div className="emvb-condition-actions">
195
213
  <Button
@@ -674,9 +674,9 @@ function KnownElementPanel({
674
674
  {buttonUrlNote(node)}
675
675
  </p>
676
676
  )}
677
- {loopContextNote(node, partType) && (
677
+ {loopContextNote(node, partType, layout) && (
678
678
  <p className="emvb-helper" data-emvb-loop-note>
679
- {loopContextNote(node, partType)}
679
+ {loopContextNote(node, partType, layout)}
680
680
  </p>
681
681
  )}
682
682
  {imageAltNote(node) && (
@@ -10,6 +10,7 @@ import { HintedSwitch } from "./HintedSwitch.tsx";
10
10
  import { RequiredFieldsNotice } from "./RequiredFieldsNotice.tsx";
11
11
  import { LoopItemBindControl } from "./LoopItemBindControl.tsx";
12
12
  import { IconPicker } from "./IconPicker.tsx";
13
+ import { ImageFieldControl } from "./ImageFieldControl.tsx";
13
14
  import { ImageSourcesField } from "./ImageSourcesField.tsx";
14
15
  import { MediaPicker } from "./MediaPicker.tsx";
15
16
  import { propsOf, withProp } from "./node-props.ts";
@@ -53,6 +54,20 @@ export function FieldControl({
53
54
  );
54
55
  }
55
56
 
57
+ if (field.key === "imageField" && node.type === "loop" && fetcher) {
58
+ // W-1090 (#32): picked from the collection's image fields.
59
+ return (
60
+ <ImageFieldControl
61
+ key={field.key}
62
+ field={field}
63
+ node={node}
64
+ collection={typeof props["collection"] === "string" ? props["collection"] : undefined}
65
+ fetcher={fetcher}
66
+ onChange={onChange}
67
+ />
68
+ );
69
+ }
70
+
56
71
  if (field.key === "partId" && node.type === "loop" && fetcher) {
57
72
  return (
58
73
  <LoopItemBindControl
@@ -48,11 +48,15 @@ export function FormBindControl({
48
48
  );
49
49
  }
50
50
 
51
- if (capability?.status === "ready" && capability.forms.length > 0) {
52
- const known = capability.forms.some((form) => form.id === value);
53
- const placeholder = !known && value ? "Current id (not in list)" : "Choose a form…";
54
- return (
55
- <div className="emvb-field-group" data-emvb-form-bind="list">
51
+ // W-1094: one tree for both states, so the Form id input stays the same element when the forms
52
+ // list arrives. Swapping trees remounted it, so a person typing there lost focus and the next
53
+ // Delete or Backspace reached the editor, which offered to delete the selected Form.
54
+ const listed = capability?.status === "ready" && capability.forms.length > 0;
55
+ const known = listed && capability.forms.some((form) => form.id === value);
56
+ const placeholder = !known && value ? "Current id (not in list)" : "Choose a form…";
57
+ return (
58
+ <div className="emvb-field-group" data-emvb-form-bind={listed ? "list" : "manual"}>
59
+ {listed && (
56
60
  <Select
57
61
  label="Form"
58
62
  className={FIELD}
@@ -73,38 +77,30 @@ export function FormBindControl({
73
77
  </Select.Option>
74
78
  ))}
75
79
  </Select>
76
- <Input
77
- label="Form id"
78
- className={`${FIELD} emvb-mono`}
79
- value={value}
80
- onChange={(event) => onChange(event.target.value.trim())}
81
- />
82
- {adminLinks && (
83
- <p className="emvb-helper">
84
- <a href="/_emdash/admin/plugins/emdash-forms/pages">Create or edit forms</a>
85
- </p>
86
- )}
87
- </div>
88
- );
89
- }
90
-
91
- return (
92
- <div className="emvb-field-group" data-emvb-form-bind="manual">
80
+ )}
93
81
  <Input
94
82
  label="Form id"
95
83
  className={`${FIELD} emvb-mono`}
96
84
  value={value}
97
85
  onChange={(event) => onChange(event.target.value.trim())}
98
86
  />
99
- <p className="emvb-helper">
100
- Paste a forms-plugin form id.
101
- {adminLinks && (
102
- <>
103
- {" "}
104
- <a href="/_emdash/admin/plugins/emdash-forms/pages">Open Forms</a>
105
- </>
106
- )}
107
- </p>
87
+ {listed ? (
88
+ adminLinks && (
89
+ <p className="emvb-helper">
90
+ <a href="/_emdash/admin/plugins/emdash-forms/pages">Create or edit forms</a>
91
+ </p>
92
+ )
93
+ ) : (
94
+ <p className="emvb-helper">
95
+ Paste a forms-plugin form id.
96
+ {adminLinks && (
97
+ <>
98
+ {" "}
99
+ <a href="/_emdash/admin/plugins/emdash-forms/pages">Open Forms</a>
100
+ </>
101
+ )}
102
+ </p>
103
+ )}
108
104
  </div>
109
105
  );
110
106
  }