@perkyzz/emvb 0.4.0 → 0.6.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 +23 -3
- package/THIRD_PARTY_NOTICES.md +23 -1
- package/licenses/exif-js.LICENSE +21 -0
- package/licenses/fflate.LICENSE +21 -0
- package/licenses/glfx.js.LICENSE +19 -0
- package/licenses/mini-photo-editor.LICENSE +21 -0
- package/licenses/photocn.LICENSE +21 -0
- package/package.json +5 -3
- package/src/admin/agents-api.ts +39 -0
- package/src/admin/editor/CommandPalette.tsx +43 -2
- package/src/admin/editor/Editor.tsx +33 -0
- package/src/admin/editor/Timeline.tsx +108 -6
- package/src/admin/editor/collection-previews.ts +6 -1
- package/src/admin/editor/editor-chrome.tsx +49 -0
- package/src/admin/editor/editor-commands.ts +13 -0
- package/src/admin/editor/editor-css.ts +7 -0
- package/src/admin/editor/feature-css.ts +22 -3
- package/src/admin/editor/palette.ts +6 -2
- package/src/admin/editor/panels/ColorControl.tsx +24 -12
- package/src/admin/editor/panels/ElementPanel.tsx +1 -1
- package/src/admin/editor/panels/LayersPanel.tsx +13 -3
- package/src/admin/editor/panels/TokenScales.tsx +4 -2
- package/src/admin/editor/panels/VariableSection.tsx +5 -3
- package/src/admin/editor/panels/color-space.ts +12 -1
- package/src/admin/editor/panels/settings/AdvancedFields.tsx +84 -28
- package/src/admin/editor/panels/settings/AudienceEditor.tsx +42 -4
- package/src/admin/editor/panels/settings/DraftTextField.tsx +38 -9
- package/src/admin/editor/panels/settings/FieldControl.tsx +24 -7
- package/src/admin/editor/panels/settings/IconPicker.tsx +21 -1
- package/src/admin/editor/panels/settings/ImageSourcesField.tsx +111 -0
- package/src/admin/editor/panels/settings/MediaPicker.tsx +156 -7
- package/src/admin/editor/panels/settings/QueryStyleRows.tsx +178 -0
- package/src/admin/editor/panels/settings/RequiredFieldsNotice.tsx +76 -0
- package/src/admin/editor/panels/settings/advanced-rules.ts +3 -0
- package/src/admin/editor/panels/settings/link-rules.ts +19 -0
- package/src/admin/editor/panels/settings/number-input.ts +11 -0
- package/src/admin/editor/panels/settings/query-style.ts +65 -0
- package/src/admin/editor/panels/variable-values.ts +18 -2
- package/src/admin/editor/remote-change.ts +67 -0
- package/src/admin/editor/store.ts +7 -3
- package/src/admin/image-editor/BlurFocus.tsx +112 -0
- package/src/admin/image-editor/Canvas.tsx +261 -0
- package/src/admin/image-editor/CropOverlay.tsx +390 -0
- package/src/admin/image-editor/CurvesPanel.tsx +394 -0
- package/src/admin/image-editor/ExportDialog.tsx +354 -0
- package/src/admin/image-editor/ImageEditButton.tsx +83 -0
- package/src/admin/image-editor/ImageEditorDialog.tsx +786 -0
- package/src/admin/image-editor/MetadataPanel.tsx +183 -0
- package/src/admin/image-editor/announce.tsx +65 -0
- package/src/admin/image-editor/crop-geometry.ts +161 -0
- package/src/admin/image-editor/curve-math.ts +177 -0
- package/src/admin/image-editor/data-url-fetch.ts +59 -0
- package/src/admin/image-editor/engine.ts +55 -0
- package/src/admin/image-editor/exif.ts +82 -0
- package/src/admin/image-editor/flatten.ts +54 -0
- package/src/admin/image-editor/gpu-fit.ts +81 -0
- package/src/admin/image-editor/image-editor-css.ts +398 -0
- package/src/admin/image-editor/load.ts +109 -0
- package/src/admin/image-editor/panels.tsx +287 -0
- package/src/admin/image-editor/parts.tsx +565 -0
- package/src/admin/image-editor/save.ts +125 -0
- package/src/admin/image-editor/tone-panels.tsx +338 -0
- package/src/admin/image-editor/tools.ts +59 -0
- package/src/admin/image-editor/worker.ts +111 -0
- package/src/admin/index.tsx +3 -1
- package/src/admin/media-api.ts +132 -2
- package/src/admin/pages/AgentsPage.tsx +274 -0
- package/src/admin/ui.ts +33 -0
- package/src/astro/EmVBPage.astro +11 -2
- package/src/astro/floats/runtime.ts +10 -0
- package/src/astro/popups/runtime.ts +15 -0
- package/src/astro/render.ts +3 -0
- package/src/astro/resolve-theme.ts +15 -4
- package/src/astro/tabs/runtime.ts +60 -1
- package/src/astro/visitor.ts +4 -3
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +202 -26
- package/src/core/arrange.ts +13 -3
- package/src/core/css/generate.ts +9 -1
- package/src/core/data/bindings.ts +12 -6
- package/src/core/design/classes.ts +5 -3
- package/src/core/design/diff.ts +3 -1
- package/src/core/design/merge.ts +3 -1
- package/src/core/design/transfer.ts +13 -2
- package/src/core/design/variables.ts +2 -1
- package/src/core/elements/dynamic-elements.ts +9 -1
- package/src/core/elements/form-elements.ts +18 -3
- package/src/core/elements/index.ts +39 -11
- package/src/core/elements/plain-text.ts +2 -2
- package/src/core/forms/binding.ts +148 -1
- package/src/core/history/diff.ts +32 -4
- package/src/core/image-edit/schema.ts +145 -0
- package/src/core/image-edit/summary.ts +58 -0
- package/src/core/index.ts +14 -0
- package/src/core/limits.ts +10 -0
- package/src/core/migrate/index.ts +3 -1
- package/src/core/perf/meter.ts +9 -1
- package/src/core/render/dynamic-post.ts +23 -6
- package/src/core/render/form.ts +36 -11
- package/src/core/render/index.ts +75 -15
- package/src/core/render/pagination.ts +21 -2
- package/src/core/sanitize/embed-url.ts +7 -1
- package/src/core/sanitize/href.ts +13 -1
- package/src/core/schema/descriptors.ts +4 -1
- package/src/core/schema/layout.ts +21 -4
- package/src/core/share/link.ts +9 -3
- package/src/core/stable-json.ts +15 -0
- package/src/core/theme/dynamic.ts +32 -24
- package/src/core/theme/pagination.ts +30 -3
- package/src/core/theme/popup-rules.ts +10 -5
- package/src/mcp/errors.ts +44 -0
- package/src/mcp/index.ts +4 -0
- package/src/mcp/ports.ts +85 -0
- package/src/mcp/prompts.ts +76 -0
- package/src/mcp/publish.ts +60 -0
- package/src/mcp/queue.ts +19 -0
- package/src/mcp/rate-limit.ts +80 -0
- package/src/mcp/read.ts +486 -0
- package/src/mcp/refs.ts +84 -0
- package/src/mcp/settings.ts +18 -0
- package/src/mcp/tools.ts +265 -0
- package/src/mcp/write.ts +664 -0
- package/src/server/agent-settings.ts +159 -0
- package/src/server/design-routes.ts +71 -17
- package/src/server/icon-routes.ts +13 -6
- package/src/server/mcp-routes.ts +323 -0
- package/src/server/plugin.ts +32 -2
package/README.md
CHANGED
|
@@ -6,13 +6,19 @@ A visual page builder plugin for [EmDash CMS](https://github.com/emdash-cms/emda
|
|
|
6
6
|
|
|
7
7
|

|
|
8
8
|
|
|
9
|
+
## Image editor
|
|
10
|
+
|
|
11
|
+
Library pictures can be cropped, adjusted, filtered and saved as a new media item from Image settings, the media library and the command palette. See [the image editor guide](../../docs/guides/image-editor.md). Third-party notices for the editor engine are in [`THIRD_PARTY_NOTICES.md`](THIRD_PARTY_NOTICES.md).
|
|
12
|
+
|
|
9
13
|
## Install
|
|
10
14
|
|
|
11
15
|
```bash
|
|
12
16
|
npm i @perkyzz/emvb
|
|
13
17
|
```
|
|
14
18
|
|
|
15
|
-
Peers, which an EmDash 1.x site already has: `emdash` ^1.0.0, `astro` ^7, `react` and `react-dom` ^19, `@cloudflare/kumo` 2.6.0 and `@phosphor-icons/react` ^2.1.10. `@emdash-cms/plugin-forms` is optional and enables forms.
|
|
19
|
+
Peers, which an EmDash 1.x site already has: `emdash` ^1.0.0, `astro` ^7, `react` and `react-dom` ^19, `@cloudflare/kumo` 2.6.0 and `@phosphor-icons/react` ^2.1.10. `@emdash-cms/plugin-forms` ^0.2.9 is optional and enables forms.
|
|
20
|
+
|
|
21
|
+
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.
|
|
16
22
|
|
|
17
23
|
## Register the plugin
|
|
18
24
|
|
|
@@ -39,6 +45,8 @@ import { getEmDashEntry, decodeSlug } from "emdash";
|
|
|
39
45
|
import { EmVBPage, resolveEmVBPage } from "@perkyzz/emvb/astro";
|
|
40
46
|
// With @emdash-cms/plugin-forms installed and registered:
|
|
41
47
|
import { EmVBFormsRuntime } from "@perkyzz/emvb/astro/forms/client";
|
|
48
|
+
import { EmVBMenuRuntime } from "@perkyzz/emvb/astro/menu";
|
|
49
|
+
import { EmVBTabsRuntime } from "@perkyzz/emvb/astro/tabs";
|
|
42
50
|
|
|
43
51
|
const emvb = await resolveEmVBPage(Astro);
|
|
44
52
|
if (!emvb && !(await getEmDashEntry("pages", decodeSlug(Astro.params.slug)))) {
|
|
@@ -46,15 +54,27 @@ if (!emvb && !(await getEmDashEntry("pages", decodeSlug(Astro.params.slug)))) {
|
|
|
46
54
|
}
|
|
47
55
|
---
|
|
48
56
|
|
|
49
|
-
{emvb &&
|
|
57
|
+
{emvb && (
|
|
58
|
+
<EmVBPage page={emvb}>
|
|
59
|
+
{emvb.needsFormsRuntime && <EmVBFormsRuntime />}
|
|
60
|
+
{emvb.needsTabsRuntime && <EmVBTabsRuntime />}
|
|
61
|
+
{emvb.needsMenuRuntime && <EmVBMenuRuntime />}
|
|
62
|
+
</EmVBPage>
|
|
63
|
+
)}
|
|
50
64
|
```
|
|
51
65
|
|
|
66
|
+
Each runtime is a small script mounted only on pages that need it; the rest of the page is plain HTML and CSS. Theme parts (`resolveThemeParts`) also report popups and floats, served from `@perkyzz/emvb/astro/popups` and `@perkyzz/emvb/astro/floats`.
|
|
67
|
+
|
|
52
68
|
Without the forms plugin, import `EmVBFormsRuntime` from `@perkyzz/emvb/astro/forms` (it renders nothing and does not import the plugin) or leave the element out. The `/client` subpath is the one that calls `initForms`.
|
|
53
69
|
|
|
54
|
-
A fixed route has no slug parameter. Pass the page's slug: `await resolveEmVBPage(Astro, { slug: "home" })`. Visitor rules can use the same call's `visitor` option (`{ segments: ["member"] }`, and country, device or returning when the site knows better); `resolveThemeParts` takes it too. The [install guide](https://github.com/PerkyZZ999/EmVB/blob/main/docs/guides/install-in-a-host-site.md) shows both.
|
|
70
|
+
A fixed route has no slug parameter. Pass the page's slug: `await resolveEmVBPage(Astro, { slug: "home" })`. Visitor rules can use the same call's `visitor` option (`{ segments: ["member"] }`, and country, device or returning when the site knows better); `resolveThemeParts` takes it too. The [install guide](https://github.com/PerkyZZ999/EmVB/blob/main/docs/guides/install-in-a-host-site.md) shows both, and the `canvasStyles` option that loads your site's stylesheets into the editor canvas: `emvb({ canvasStyles: ["/styles/site.css"] })`.
|
|
55
71
|
|
|
56
72
|
Then sign in as an admin, open **Pages VisualBuilder** and click **Set up EmVB** once.
|
|
57
73
|
|
|
74
|
+
## AI agents (MCP)
|
|
75
|
+
|
|
76
|
+
On EmDash 1.2+ with `emdash({ mcp: true, … })`, AI agents can build and edit draft EmVB pages. An admin turns them on in **Pages VisualBuilder → AI agents** (off by default) and approves the EmVB tools on EmDash's Plugins screen. Agents connect to EmDash's own endpoint (`/_emdash/api/mcp`) or through the local bridge, `npx -y @perkyzz/emvb-mcp --site https://your.site` with the token in `EMVB_TOKEN`. Tokens need the `mcp:tools:emvb` scope and an editor (not an admin) user. Agents only change drafts unless an admin allows publishing; each token may make 300 reads and 60 changes a minute and 10 publishes an hour. Every agent change shows in the version timeline with an **Agent** badge. See the [MCP guide](https://github.com/PerkyZZ999/EmVB/blob/main/docs/guides/mcp.md).
|
|
77
|
+
|
|
58
78
|
Website: <https://emvb.dev>. The full guide, the demos and the source are on GitHub: <https://github.com/PerkyZZ999/EmVB>.
|
|
59
79
|
|
|
60
80
|
## License
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Third-party notices
|
|
2
2
|
|
|
3
|
-
EmVB (<https://emvb.dev>) is MIT licensed.
|
|
3
|
+
EmVB (<https://emvb.dev>) is MIT licensed. It includes or depends on the projects below, which keep their own licenses, copied in full in [`licenses/`](licenses/): the icon sets (Lucide, Font Awesome Free, Tabler, Remix) and the image editor's engine (photocn and the code photocn includes: mini-photo-editor, glfx.js and exif-js; and its dependency fflate).
|
|
4
|
+
|
|
5
|
+
The editor's **Icon library** (`@perkyzz/emvb-icons`, the JSON sets) contains icons from the projects below. They keep their own licenses, copied in full in [`licenses/`](licenses/). `scripts/build-icon-sets.ts` in the EmVB repository builds the set files from the pinned npm packages. It refuses to build when a package's license file changes.
|
|
4
6
|
|
|
5
7
|
Changes made to every set: the SVG markup is reformatted into compact JSON, and only elements and attributes in EmVB's SVG allowlist are kept. Class attributes and comments are removed. Shared presentation attributes (stroke or fill, viewBox) move to the root `<svg>`. Set-specific changes are listed with each set.
|
|
6
8
|
|
|
@@ -30,3 +32,23 @@ When an editor picks an icon, its SVG is stored with the page and shown inline o
|
|
|
30
32
|
- Package: `remixicon` 4.8.0, <https://remixicon.com>. 4.8.0 is the last release under Apache-2.0; 4.9.0 moved to the custom "Remix Icon License v1.0", which forbids competing icon libraries, so EmVB stays on 4.8.0.
|
|
31
33
|
- License: Apache License 2.0, Copyright (c) Remix Design. Full text: [`licenses/remixicon.LICENSE`](licenses/remixicon.LICENSE).
|
|
32
34
|
- Changes (Apache-2.0 §4(b)): path coordinates are rounded to two decimals. All Remix paths use absolute commands, so the error stays under 0.005 units on the 24-unit grid. The icon files are not otherwise modified.
|
|
35
|
+
|
|
36
|
+
## photocn
|
|
37
|
+
|
|
38
|
+
- Package: `photocn` 0.1.2 (the image editor's engine, loaded only when the image editor opens), <https://photocn.dev>, <https://github.com/rbbydotdev/photocn>
|
|
39
|
+
- License: MIT, Copyright (c) 2026 rbbydotdev. Full text: [`licenses/photocn.LICENSE`](licenses/photocn.LICENSE).
|
|
40
|
+
- The image editor's layout and interactions are ported from photocn's shadcn editor components (`apps/www/src/registry/image-editor`: the editor, desktop and compact layouts, toolbar, canvas, crop overlay, crop panel, adjustments, filters, curves and blur panels, blur center overlay, panel header, histogram, the perspective icon, the export dialog and the metadata panel). Changes: rebuilt with Kumo components, Phosphor icons and EmVB's CSS tokens instead of shadcn/ui, Tailwind and Lucide; opening files and recipes left out; typed slider values, curve-point Input/Output fields and keyboard control of curve points and the blur spot added; the export dialog gets EmVB defaults (WebP 85 %, a 2560 px cap, removing a JPEG's GPS location) and saves to the media library. Each ported file names its source.
|
|
41
|
+
- The quarter-turn icons in the crop panel are Lucide's `rotate-ccw-square` and `rotate-cw-square` (ISC, see Lucide above).
|
|
42
|
+
|
|
43
|
+
### Included in photocn
|
|
44
|
+
|
|
45
|
+
photocn's own [`THIRD_PARTY_NOTICES.md`](https://github.com/rbbydotdev/photocn) lists code it carries from these MIT projects. EmVB ships them only inside the lazy image editor chunk and its worker; published pages never load them.
|
|
46
|
+
|
|
47
|
+
- **mini-photo-editor**, <https://github.com/xdadda/mini-photo-editor>: photocn's WebGL renderer and filters, EXIF/ICC reading and the filter LUT textures, and the perspective "adjust corners" icon EmVB uses (`parts.tsx`). MIT, Copyright (c) 2025 xdadda. Full text: [`licenses/mini-photo-editor.LICENSE`](licenses/mini-photo-editor.LICENSE).
|
|
48
|
+
- **glfx.js**, <https://github.com/evanw/glfx.js>: the texture and shader core of photocn's renderer (via mini-photo-editor). MIT, Copyright (C) 2011 by Evan Wallace. Full text: [`licenses/glfx.js.LICENSE`](licenses/glfx.js.LICENSE).
|
|
49
|
+
- **exif-js**, <https://github.com/exif-js/exif-js>: EXIF parsing (via mini-photo-editor), shown in the Metadata tool. MIT, Copyright (c) 2008 Jacob Seidelin. Full text: [`licenses/exif-js.LICENSE`](licenses/exif-js.LICENSE).
|
|
50
|
+
|
|
51
|
+
### fflate
|
|
52
|
+
|
|
53
|
+
- Package: `fflate` 0.8.3 (a dependency of photocn, installed with it), <https://github.com/101arrowz/fflate>
|
|
54
|
+
- License: MIT, Copyright (c) 2026 Arjun Barrett. Full text: [`licenses/fflate.LICENSE`](licenses/fflate.LICENSE).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2008 Jacob Seidelin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Arjun Barrett
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (C) 2011 by Evan Wallace
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 xdadda
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 rbbydotdev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perkyzz/emvb",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Visual page builder plugin for EmDash CMS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astro",
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
"./astro/popups": "./src/astro/popups/index.ts",
|
|
40
40
|
"./astro/floats": "./src/astro/floats/index.ts",
|
|
41
41
|
"./astro/tabs": "./src/astro/tabs/index.ts",
|
|
42
|
-
"./astro/menu": "./src/astro/menu/index.ts"
|
|
42
|
+
"./astro/menu": "./src/astro/menu/index.ts",
|
|
43
|
+
"./mcp": "./src/mcp/index.ts"
|
|
43
44
|
},
|
|
44
45
|
"publishConfig": {
|
|
45
46
|
"access": "public"
|
|
@@ -48,7 +49,8 @@
|
|
|
48
49
|
"test:astro": "bun --bun vitest run"
|
|
49
50
|
},
|
|
50
51
|
"dependencies": {
|
|
51
|
-
"@perkyzz/emvb-icons": "0.1.
|
|
52
|
+
"@perkyzz/emvb-icons": "0.1.1",
|
|
53
|
+
"photocn": "0.1.2",
|
|
52
54
|
"zod": "~4.5.4"
|
|
53
55
|
},
|
|
54
56
|
"devDependencies": {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { PLUGIN_ID } from "../constants.ts";
|
|
2
|
+
import type { AgentSettings } from "../mcp/settings.ts";
|
|
3
|
+
import { requestJson, type Fetcher } from "./api.ts";
|
|
4
|
+
|
|
5
|
+
export type AgentActivity = {
|
|
6
|
+
id: string;
|
|
7
|
+
at: string;
|
|
8
|
+
tool: string;
|
|
9
|
+
target: "page" | "styles" | "settings";
|
|
10
|
+
pageId?: string;
|
|
11
|
+
revisionId?: string;
|
|
12
|
+
summary: string;
|
|
13
|
+
userId: string | null;
|
|
14
|
+
client?: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type AgentsState = {
|
|
18
|
+
settings: AgentSettings;
|
|
19
|
+
revision: string | null;
|
|
20
|
+
endpoint: string;
|
|
21
|
+
activity: AgentActivity[];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const base = `/_emdash/api/plugins/${PLUGIN_ID}`;
|
|
25
|
+
|
|
26
|
+
export const loadAgents = (fetcher: Fetcher) => requestJson<AgentsState>(fetcher, `${base}/agents`);
|
|
27
|
+
|
|
28
|
+
/** Saves the agent settings; the returned revision is the one the next save must send. */
|
|
29
|
+
export async function saveAgentSettings(
|
|
30
|
+
fetcher: Fetcher,
|
|
31
|
+
settings: AgentSettings,
|
|
32
|
+
revision: string | null,
|
|
33
|
+
): Promise<string> {
|
|
34
|
+
const body = await requestJson<{ revision: string }>(fetcher, `${base}/agents/save`, {
|
|
35
|
+
method: "POST",
|
|
36
|
+
body: { settings, revision },
|
|
37
|
+
});
|
|
38
|
+
return body.revision;
|
|
39
|
+
}
|
|
@@ -18,6 +18,44 @@ export function CommandPalette({
|
|
|
18
18
|
const [query, setQuery] = React.useState("");
|
|
19
19
|
const [active, setActive] = React.useState(0);
|
|
20
20
|
const listRef = React.useRef<HTMLUListElement>(null);
|
|
21
|
+
// W-399: opened from a shortcut there is no trigger to return to, so focus fell to <body> on
|
|
22
|
+
// close. Remember what had focus and go back to it when nothing else took focus.
|
|
23
|
+
const wasOpen = React.useRef(false);
|
|
24
|
+
const returnTo = React.useRef<HTMLElement | null>(null);
|
|
25
|
+
if (open && !wasOpen.current && typeof document !== "undefined") {
|
|
26
|
+
const focused = document.activeElement;
|
|
27
|
+
returnTo.current = focused instanceof HTMLElement && focused !== document.body ? focused : null;
|
|
28
|
+
}
|
|
29
|
+
wasOpen.current = open;
|
|
30
|
+
/** After a command, the selected layer first (it may have changed); after Esc, where we were. */
|
|
31
|
+
const restoreFocus = (afterCommand = false) => {
|
|
32
|
+
// The dialog lets go of focus only once its close animation ends, so wait for that.
|
|
33
|
+
const started = Date.now();
|
|
34
|
+
const settle = () => {
|
|
35
|
+
const now = document.activeElement;
|
|
36
|
+
// Kumo's Dialog doesn't pass data attributes through; find the palette by its input.
|
|
37
|
+
const stillOpen = document.querySelector("[data-emvb-palette-input]") !== null;
|
|
38
|
+
const inPalette = now?.closest('[role="dialog"]')?.querySelector("[data-emvb-palette-input]");
|
|
39
|
+
if (now && now !== document.body && !inPalette) return;
|
|
40
|
+
if (stillOpen && Date.now() - started < 2000) {
|
|
41
|
+
setTimeout(settle, 30);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const selected = document.querySelector<HTMLElement>(
|
|
45
|
+
'.emvb-layer-select[aria-current="true"]',
|
|
46
|
+
);
|
|
47
|
+
const back = returnTo.current?.isConnected ? returnTo.current : null;
|
|
48
|
+
const target =
|
|
49
|
+
(afterCommand ? (selected ?? back) : (back ?? selected)) ??
|
|
50
|
+
document.querySelector<HTMLElement>("iframe[data-emvb-canvas]");
|
|
51
|
+
target?.focus({ preventScroll: true });
|
|
52
|
+
};
|
|
53
|
+
setTimeout(settle, 30);
|
|
54
|
+
};
|
|
55
|
+
const close = (next: boolean) => {
|
|
56
|
+
onOpenChange(next);
|
|
57
|
+
if (!next) restoreFocus();
|
|
58
|
+
};
|
|
21
59
|
React.useEffect(() => {
|
|
22
60
|
if (open) {
|
|
23
61
|
setQuery("");
|
|
@@ -35,7 +73,10 @@ export function CommandPalette({
|
|
|
35
73
|
if (!item) return;
|
|
36
74
|
onOpenChange(false);
|
|
37
75
|
// After the dialog closes, so focus moves where the command wants it.
|
|
38
|
-
setTimeout(
|
|
76
|
+
setTimeout(() => {
|
|
77
|
+
item.run();
|
|
78
|
+
restoreFocus(true);
|
|
79
|
+
}, 0);
|
|
39
80
|
};
|
|
40
81
|
const onKeyDown = (event: React.KeyboardEvent) => {
|
|
41
82
|
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
@@ -51,7 +92,7 @@ export function CommandPalette({
|
|
|
51
92
|
};
|
|
52
93
|
let lastGroup = "";
|
|
53
94
|
return (
|
|
54
|
-
<Dialog.Root open={open} onOpenChange={
|
|
95
|
+
<Dialog.Root open={open} onOpenChange={close}>
|
|
55
96
|
<Dialog size="base" className="emvb-palette" data-emvb-palette="">
|
|
56
97
|
<Dialog.Title className="sr-only">Command palette</Dialog.Title>
|
|
57
98
|
<input
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Banner, Button, createKumoToastManager, Empty, Loader, Toasty } from "@cloudflare/kumo";
|
|
2
2
|
import {
|
|
3
|
+
ArrowsClockwiseIcon,
|
|
3
4
|
ClockCounterClockwiseIcon,
|
|
4
5
|
GaugeIcon,
|
|
6
|
+
RobotIcon,
|
|
5
7
|
ShareNetworkIcon,
|
|
6
8
|
WarningCircleIcon,
|
|
7
9
|
} from "@phosphor-icons/react";
|
|
@@ -50,9 +52,11 @@ import {
|
|
|
50
52
|
import { EDITOR_MIN_WIDTH_QUERY, useMediaQuery } from "./useMediaQuery.ts";
|
|
51
53
|
import { useSectionTemplates } from "./section-templates.ts";
|
|
52
54
|
import { useCollectionPreviews } from "./collection-previews.ts";
|
|
55
|
+
import { useRemoteChange } from "./remote-change.ts";
|
|
53
56
|
import { A11yScoreButton } from "./A11yCopilot.tsx";
|
|
54
57
|
import { restoreOnUndo, type Deletion } from "./restore-deleted.ts";
|
|
55
58
|
import { useEditorCommands } from "./useEditorCommands.ts";
|
|
59
|
+
import { editableSource } from "../image-editor/load.ts";
|
|
56
60
|
import { useSave } from "./useSave.ts";
|
|
57
61
|
import { type ShortcutHandlers, useEditorShortcuts } from "./useEditorShortcuts.ts";
|
|
58
62
|
import { useNodeActions } from "./useNodeActions.ts";
|
|
@@ -123,6 +127,8 @@ function EditorApp({
|
|
|
123
127
|
const canvasStyles = useCanvasStyles(fetcher);
|
|
124
128
|
const { exit } = host;
|
|
125
129
|
const saver = useSave(fetcher, state, dispatch, collection);
|
|
130
|
+
// W-466: tell the person when an agent (or anyone) changed the page while they were idle.
|
|
131
|
+
const remoteChange = useRemoteChange(fetcher, collection, entry.id, state.rev, !dirty);
|
|
126
132
|
const toasts = React.useMemo(() => createKumoToastManager(), []);
|
|
127
133
|
const chrome = useChromeFlags();
|
|
128
134
|
const [device, setDevice] = React.useState<PopupDevice>("desktop");
|
|
@@ -298,6 +304,11 @@ function EditorApp({
|
|
|
298
304
|
setDevice,
|
|
299
305
|
openShortcuts: () => chrome.open("shortcuts"),
|
|
300
306
|
toggleHidden: () => hideSelectedOnDevice(state, device, dispatch),
|
|
307
|
+
// W-486: "Edit image" in the palette, for an Image element the editor can open.
|
|
308
|
+
...(selectedNode?.type === "image" &&
|
|
309
|
+
editableSource(selectedNode.props as Record<string, unknown>, window.location.origin).ok
|
|
310
|
+
? { editImage: () => chrome.open("imageEditor") }
|
|
311
|
+
: {}),
|
|
301
312
|
};
|
|
302
313
|
const paletteActions = editorCommands({
|
|
303
314
|
surface: "palette",
|
|
@@ -328,6 +339,28 @@ function EditorApp({
|
|
|
328
339
|
onPalette={() => chrome.open("palette")}
|
|
329
340
|
>
|
|
330
341
|
<Toasty toastManager={toasts}>
|
|
342
|
+
{remoteChange && (
|
|
343
|
+
<div className="emvb-remote-change" role="status" data-emvb-remote-change={remoteChange}>
|
|
344
|
+
<span className="emvb-remote-change-icon" aria-hidden="true">
|
|
345
|
+
{remoteChange === "agent" ? (
|
|
346
|
+
<RobotIcon size={16} />
|
|
347
|
+
) : (
|
|
348
|
+
<ArrowsClockwiseIcon size={16} />
|
|
349
|
+
)}
|
|
350
|
+
</span>
|
|
351
|
+
<span className="emvb-remote-change-text">
|
|
352
|
+
<strong>
|
|
353
|
+
{remoteChange === "agent"
|
|
354
|
+
? "An AI agent changed this page."
|
|
355
|
+
: "This page was changed somewhere else."}
|
|
356
|
+
</strong>{" "}
|
|
357
|
+
<span>Reload to see the latest draft. Its changes are in the version timeline.</span>
|
|
358
|
+
</span>
|
|
359
|
+
<Button size="sm" variant="primary" onClick={() => window.location.reload()}>
|
|
360
|
+
Reload
|
|
361
|
+
</Button>
|
|
362
|
+
</div>
|
|
363
|
+
)}
|
|
331
364
|
{wideEnough ? (
|
|
332
365
|
<>
|
|
333
366
|
<TopBar
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Button, Dialog } from "@cloudflare/kumo";
|
|
2
|
+
import { RobotIcon, SquaresFourIcon, UserIcon, type Icon } from "@phosphor-icons/react";
|
|
2
3
|
import * as React from "react";
|
|
3
4
|
import {
|
|
4
5
|
canvasStyleUrls,
|
|
@@ -13,6 +14,7 @@ import {
|
|
|
13
14
|
type SectionChange,
|
|
14
15
|
} from "../../core/index.ts";
|
|
15
16
|
import { ApiError, requestJson, type Fetcher } from "../api.ts";
|
|
17
|
+
import { PLUGIN_ID } from "../../constants.ts";
|
|
16
18
|
import { ELEMENT_NAMES } from "./element-chrome.ts";
|
|
17
19
|
|
|
18
20
|
type RevisionItem = {
|
|
@@ -22,7 +24,33 @@ type RevisionItem = {
|
|
|
22
24
|
data?: Record<string, unknown>;
|
|
23
25
|
};
|
|
24
26
|
|
|
25
|
-
type TimelineVersion = {
|
|
27
|
+
type TimelineVersion = {
|
|
28
|
+
id: string;
|
|
29
|
+
at: string;
|
|
30
|
+
layout: Layout | null;
|
|
31
|
+
/** Set when an AI agent saved this version (W-460). */
|
|
32
|
+
agent?: { tool: string; summary: string };
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
type AgentVersion = { revisionId: string; tool: string; summary: string };
|
|
36
|
+
|
|
37
|
+
/** Which versions an agent saved; none when the site has no agent log (older EmVB). */
|
|
38
|
+
const agentVersions = (fetcher: Fetcher, entryId: string) =>
|
|
39
|
+
requestJson<{ versions: AgentVersion[] }>(
|
|
40
|
+
fetcher,
|
|
41
|
+
`/_emdash/api/plugins/${PLUGIN_ID}/agents/page`,
|
|
42
|
+
{
|
|
43
|
+
method: "POST",
|
|
44
|
+
body: { pageId: entryId },
|
|
45
|
+
},
|
|
46
|
+
).then(
|
|
47
|
+
(body) => new Map((body.versions ?? []).map((v) => [v.revisionId, v])),
|
|
48
|
+
() => new Map<string, AgentVersion>(),
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
type Who = "all" | "people" | "agents";
|
|
52
|
+
const WHO_LABELS: Record<Who, string> = { all: "All", people: "People", agents: "Agents" };
|
|
53
|
+
const WHO_ICONS: Record<Who, Icon> = { all: SquaresFourIcon, people: UserIcon, agents: RobotIcon };
|
|
26
54
|
|
|
27
55
|
/** A revision's layout, or null when it has none or it doesn't validate (W-315). */
|
|
28
56
|
export function revisionLayout(data: Record<string, unknown> | undefined): Layout | null {
|
|
@@ -57,10 +85,20 @@ function useRevisions(fetcher: Fetcher, collection: string, entryId: string, ope
|
|
|
57
85
|
fetcher,
|
|
58
86
|
`/_emdash/api/content/${encodeURIComponent(collection)}/${encodeURIComponent(entryId)}/revisions?limit=50`,
|
|
59
87
|
)
|
|
60
|
-
.then((body) => {
|
|
88
|
+
.then(async (body) => ({ body, agents: await agentVersions(fetcher, entryId) }))
|
|
89
|
+
.then(({ body, agents }) => {
|
|
61
90
|
if (cancelled) return;
|
|
62
91
|
const versions = (body?.items ?? [])
|
|
63
|
-
.map((item) =>
|
|
92
|
+
.map((item): TimelineVersion => {
|
|
93
|
+
const agent = agents.get(item.id);
|
|
94
|
+
const version: TimelineVersion = {
|
|
95
|
+
id: item.id,
|
|
96
|
+
at: item.createdAt,
|
|
97
|
+
layout: revisionLayout(item.data),
|
|
98
|
+
};
|
|
99
|
+
if (agent) version.agent = { tool: agent.tool, summary: agent.summary };
|
|
100
|
+
return version;
|
|
101
|
+
})
|
|
64
102
|
.toSorted((a, b) => (a.at < b.at ? 1 : -1));
|
|
65
103
|
setState({ kind: "ready", versions });
|
|
66
104
|
})
|
|
@@ -101,6 +139,20 @@ const when = (iso: string) => {
|
|
|
101
139
|
return Number.isNaN(date.getTime()) ? iso : date.toLocaleString();
|
|
102
140
|
};
|
|
103
141
|
|
|
142
|
+
/** A version's day and time on two short lines, so the list doesn't wrap mid-time (W-477). */
|
|
143
|
+
const whenParts = (iso: string) => {
|
|
144
|
+
const date = new Date(iso);
|
|
145
|
+
if (Number.isNaN(date.getTime())) return { day: iso, time: "" };
|
|
146
|
+
return {
|
|
147
|
+
day: date.toLocaleDateString(undefined, { month: "short", day: "numeric", year: "numeric" }),
|
|
148
|
+
time: date.toLocaleTimeString(undefined, {
|
|
149
|
+
hour: "numeric",
|
|
150
|
+
minute: "2-digit",
|
|
151
|
+
second: "2-digit",
|
|
152
|
+
}),
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
|
|
104
156
|
/** A small, script-free picture of one version with its changed sections outlined (W-315). */
|
|
105
157
|
function Snapshot({
|
|
106
158
|
layout,
|
|
@@ -159,7 +211,12 @@ export function TimelineDialog({
|
|
|
159
211
|
const revisions = useRevisions(fetcher, collection, entryId, open);
|
|
160
212
|
const [pickedId, setPickedId] = React.useState<string | null>(null);
|
|
161
213
|
const [error, setError] = React.useState<string | null>(null);
|
|
162
|
-
const
|
|
214
|
+
const [who, setWho] = React.useState<Who>("all");
|
|
215
|
+
const all = revisions.kind === "ready" ? revisions.versions : [];
|
|
216
|
+
const hasAgents = all.some((v) => v.agent);
|
|
217
|
+
const versions = all.filter((v) =>
|
|
218
|
+
who === "all" ? true : who === "agents" ? Boolean(v.agent) : !v.agent,
|
|
219
|
+
);
|
|
163
220
|
const picked = versions.find((v) => v.id === pickedId) ?? versions[0];
|
|
164
221
|
const changes = React.useMemo(
|
|
165
222
|
() => (picked?.layout && current ? diffSections(picked.layout, current) : []),
|
|
@@ -181,6 +238,36 @@ export function TimelineDialog({
|
|
|
181
238
|
No saved versions yet. Each save adds one.
|
|
182
239
|
</p>
|
|
183
240
|
)}
|
|
241
|
+
{hasAgents && (
|
|
242
|
+
<div className="emvb-timeline-who" role="group" aria-label="Show versions by">
|
|
243
|
+
{(Object.keys(WHO_LABELS) as Who[]).map((key) => {
|
|
244
|
+
const WhoIcon = WHO_ICONS[key];
|
|
245
|
+
const count =
|
|
246
|
+
key === "all"
|
|
247
|
+
? all.length
|
|
248
|
+
: all.filter((v) => (key === "agents" ? v.agent : !v.agent)).length;
|
|
249
|
+
return (
|
|
250
|
+
<button
|
|
251
|
+
key={key}
|
|
252
|
+
type="button"
|
|
253
|
+
className="emvb-timeline-who-option"
|
|
254
|
+
aria-pressed={who === key}
|
|
255
|
+
data-emvb-timeline-who={key}
|
|
256
|
+
onClick={() => {
|
|
257
|
+
setWho(key);
|
|
258
|
+
setPickedId(null);
|
|
259
|
+
}}
|
|
260
|
+
>
|
|
261
|
+
<WhoIcon aria-hidden="true" size={14} />
|
|
262
|
+
{WHO_LABELS[key]}
|
|
263
|
+
<span className="emvb-timeline-count" aria-label={`, ${count}`}>
|
|
264
|
+
{count}
|
|
265
|
+
</span>
|
|
266
|
+
</button>
|
|
267
|
+
);
|
|
268
|
+
})}
|
|
269
|
+
</div>
|
|
270
|
+
)}
|
|
184
271
|
{picked && current && (
|
|
185
272
|
<div className="emvb-timeline-body">
|
|
186
273
|
<ol className="emvb-timeline-list" aria-label="Saved versions">
|
|
@@ -193,8 +280,23 @@ export function TimelineDialog({
|
|
|
193
280
|
data-emvb-version={v.id}
|
|
194
281
|
onClick={() => setPickedId(v.id)}
|
|
195
282
|
>
|
|
196
|
-
|
|
197
|
-
|
|
283
|
+
<span className="emvb-timeline-when">
|
|
284
|
+
<span>{whenParts(v.at).day}</span>
|
|
285
|
+
<span className="emvb-timeline-time">
|
|
286
|
+
{whenParts(v.at).time}
|
|
287
|
+
{!v.layout && " (no layout)"}
|
|
288
|
+
</span>
|
|
289
|
+
</span>
|
|
290
|
+
{v.agent && (
|
|
291
|
+
<span
|
|
292
|
+
className="emvb-timeline-agent"
|
|
293
|
+
data-emvb-agent-version=""
|
|
294
|
+
title={v.agent.summary}
|
|
295
|
+
>
|
|
296
|
+
<RobotIcon aria-hidden="true" size={12} />
|
|
297
|
+
Agent
|
|
298
|
+
</span>
|
|
299
|
+
)}
|
|
198
300
|
</button>
|
|
199
301
|
</li>
|
|
200
302
|
))}
|
|
@@ -44,7 +44,8 @@ function previewPost(item: ContentItem, loop: CollectionLoop): ThemePostFields {
|
|
|
44
44
|
/**
|
|
45
45
|
* W-330: the canvas applies a Loop's `field = value` filters to the entries it read. A field the
|
|
46
46
|
* entries don't have (a taxonomy, say) can't be checked here, so it doesn't filter the preview;
|
|
47
|
-
* the published page asks EmDash, which checks taxonomies too.
|
|
47
|
+
* the published page asks EmDash, which checks taxonomies too. A list or object field never
|
|
48
|
+
* matches, as on the published page (W-505).
|
|
48
49
|
*/
|
|
49
50
|
export function matchesPreviewFilter(
|
|
50
51
|
data: Record<string, unknown>,
|
|
@@ -54,6 +55,10 @@ export function matchesPreviewFilter(
|
|
|
54
55
|
return Object.entries(where).every(([field, wanted]) => {
|
|
55
56
|
if (!(field in data)) return true;
|
|
56
57
|
const value = data[field];
|
|
58
|
+
// W-505: EmDash 1.2 filters a non-taxonomy field with SQL `column = value` (or IN), so a
|
|
59
|
+
// list field (stored as JSON text) never matches there. String(["news"]) is "news", which
|
|
60
|
+
// showed entries in the preview that the published Loop leaves out.
|
|
61
|
+
if (Array.isArray(value) || (typeof value === "object" && value !== null)) return false;
|
|
57
62
|
const values = Array.isArray(wanted) ? wanted : [wanted];
|
|
58
63
|
return values.some((option) => String(value) === option);
|
|
59
64
|
});
|