@perkyzz/emvb 0.5.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 +4 -0
- 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 +2 -1
- package/src/admin/editor/Editor.tsx +6 -0
- 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 +3 -0
- package/src/admin/editor/panels/ColorControl.tsx +5 -4
- package/src/admin/editor/panels/LayersPanel.tsx +13 -3
- package/src/admin/editor/panels/VariableSection.tsx +5 -3
- package/src/admin/editor/panels/settings/FieldControl.tsx +18 -7
- package/src/admin/editor/panels/settings/MediaPicker.tsx +154 -4
- package/src/admin/editor/panels/settings/RequiredFieldsNotice.tsx +76 -0
- package/src/admin/editor/panels/variable-values.ts +14 -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/media-api.ts +113 -3
- package/src/admin/ui.ts +5 -0
- package/src/astro/EmVBPage.astro +11 -2
- package/src/astro/render.ts +3 -0
- package/src/astro/resolve-theme.ts +15 -4
- package/src/astro/visitor.ts +4 -3
- package/src/constants.ts +1 -1
- package/src/core/arrange.ts +2 -0
- 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 +16 -17
- 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 +2 -1
- package/src/core/render/form.ts +24 -6
- package/src/core/render/index.ts +26 -5
- package/src/core/schema/layout.ts +11 -1
- package/src/core/share/link.ts +5 -2
- package/src/core/stable-json.ts +15 -0
- package/src/core/theme/dynamic.ts +21 -18
- package/src/core/theme/pagination.ts +30 -3
- package/src/core/theme/popup-rules.ts +10 -5
- package/src/mcp/ports.ts +8 -1
- package/src/mcp/read.ts +68 -1
- package/src/mcp/tools.ts +1 -1
- package/src/mcp/write.ts +100 -18
- package/src/server/agent-settings.ts +28 -3
- package/src/server/icon-routes.ts +8 -5
- package/src/server/mcp-routes.ts +68 -10
package/README.md
CHANGED
|
@@ -6,6 +6,10 @@ 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
|
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",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@perkyzz/emvb-icons": "0.1.1",
|
|
53
|
+
"photocn": "0.1.2",
|
|
53
54
|
"zod": "~4.5.4"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
@@ -56,6 +56,7 @@ import { useRemoteChange } from "./remote-change.ts";
|
|
|
56
56
|
import { A11yScoreButton } from "./A11yCopilot.tsx";
|
|
57
57
|
import { restoreOnUndo, type Deletion } from "./restore-deleted.ts";
|
|
58
58
|
import { useEditorCommands } from "./useEditorCommands.ts";
|
|
59
|
+
import { editableSource } from "../image-editor/load.ts";
|
|
59
60
|
import { useSave } from "./useSave.ts";
|
|
60
61
|
import { type ShortcutHandlers, useEditorShortcuts } from "./useEditorShortcuts.ts";
|
|
61
62
|
import { useNodeActions } from "./useNodeActions.ts";
|
|
@@ -303,6 +304,11 @@ function EditorApp({
|
|
|
303
304
|
setDevice,
|
|
304
305
|
openShortcuts: () => chrome.open("shortcuts"),
|
|
305
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
|
+
: {}),
|
|
306
312
|
};
|
|
307
313
|
const paletteActions = editorCommands({
|
|
308
314
|
surface: "palette",
|
|
@@ -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
|
});
|
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
} from "../../core/index.ts";
|
|
11
11
|
import type { Fetcher } from "../api.ts";
|
|
12
12
|
import { discardDraft } from "../content-api.ts";
|
|
13
|
+
import { ImageEditorLauncher } from "../image-editor/ImageEditButton.tsx";
|
|
14
|
+
import { saveEditedCopy } from "../media-api.ts";
|
|
13
15
|
import { A11yDialog } from "./A11yCopilot.tsx";
|
|
14
16
|
import { CommandPalette } from "./CommandPalette.tsx";
|
|
15
17
|
import { ConflictDialog, DeleteSubtreeDialog, LeaveDialog, RevertDialog } from "./dialogs.tsx";
|
|
@@ -64,6 +66,7 @@ const CLOSED = {
|
|
|
64
66
|
a11y: false,
|
|
65
67
|
leave: false,
|
|
66
68
|
revert: false,
|
|
69
|
+
imageEditor: false,
|
|
67
70
|
};
|
|
68
71
|
|
|
69
72
|
type ChromeKey = keyof typeof CLOSED;
|
|
@@ -222,6 +225,13 @@ export function EditorDialogs({
|
|
|
222
225
|
count={deleteAsk?.count ?? 0}
|
|
223
226
|
onConfirm={() => deleteAsk && finishDelete(deleteAsk.id)}
|
|
224
227
|
/>
|
|
228
|
+
<PaletteImageEditor
|
|
229
|
+
open={chrome.flags.imageEditor}
|
|
230
|
+
onOpenChange={chrome.setOpen("imageEditor")}
|
|
231
|
+
selectedNode={selectedNode}
|
|
232
|
+
fetcher={fetcher}
|
|
233
|
+
dispatch={dispatch}
|
|
234
|
+
/>
|
|
225
235
|
<ShortcutsDialog open={chrome.flags.shortcuts} onOpenChange={chrome.setOpen("shortcuts")} />
|
|
226
236
|
<CommandPalette
|
|
227
237
|
open={chrome.flags.palette}
|
|
@@ -344,3 +354,42 @@ export function EditorDialogs({
|
|
|
344
354
|
</>
|
|
345
355
|
);
|
|
346
356
|
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* The image editor opened from the command palette's "Edit image" (W-486). It edits the Image
|
|
360
|
+
* element that was selected when it opened, and saves the copy onto that element.
|
|
361
|
+
*/
|
|
362
|
+
function PaletteImageEditor({
|
|
363
|
+
open,
|
|
364
|
+
onOpenChange,
|
|
365
|
+
selectedNode,
|
|
366
|
+
fetcher,
|
|
367
|
+
dispatch,
|
|
368
|
+
}: {
|
|
369
|
+
open: boolean;
|
|
370
|
+
onOpenChange: (open: boolean) => void;
|
|
371
|
+
selectedNode: LayoutNode | null;
|
|
372
|
+
fetcher: Fetcher;
|
|
373
|
+
dispatch: React.Dispatch<EditorAction>;
|
|
374
|
+
}) {
|
|
375
|
+
const [target, setTarget] = React.useState<LayoutNode | null>(null);
|
|
376
|
+
if (open && !target && selectedNode?.type === "image") setTarget(selectedNode);
|
|
377
|
+
if (!target) return null;
|
|
378
|
+
const props = target.props as Record<string, unknown>;
|
|
379
|
+
return (
|
|
380
|
+
<ImageEditorLauncher
|
|
381
|
+
open={open}
|
|
382
|
+
onOpenChange={onOpenChange}
|
|
383
|
+
imageProps={props}
|
|
384
|
+
onSave={async (file, copy) => {
|
|
385
|
+
const next = await saveEditedCopy(fetcher, props, file, copy);
|
|
386
|
+
dispatch({
|
|
387
|
+
type: "update-node",
|
|
388
|
+
id: target.id,
|
|
389
|
+
update: (node) => ({ ...node, props: next }) as LayoutNode,
|
|
390
|
+
});
|
|
391
|
+
}}
|
|
392
|
+
onClosed={() => setTarget(null)}
|
|
393
|
+
/>
|
|
394
|
+
);
|
|
395
|
+
}
|
|
@@ -42,6 +42,8 @@ export type CommandRunners = {
|
|
|
42
42
|
setDevice?: (device: PopupDevice) => void;
|
|
43
43
|
openShortcuts?: () => void;
|
|
44
44
|
rename?: () => void;
|
|
45
|
+
/** Set when the selection is an Image element the image editor can open (W-486). */
|
|
46
|
+
editImage?: () => void;
|
|
45
47
|
};
|
|
46
48
|
|
|
47
49
|
export type CommandInput = {
|
|
@@ -177,6 +179,12 @@ const SPECS: readonly Spec[] = [
|
|
|
177
179
|
{ id: "device-desktop", labels: { palette: "View on desktop" }, surfaces: ["palette"] },
|
|
178
180
|
{ id: "device-tablet", labels: { palette: "View on tablet" }, surfaces: ["palette"] },
|
|
179
181
|
{ id: "device-mobile", labels: { palette: "View on mobile" }, surfaces: ["palette"] },
|
|
182
|
+
{
|
|
183
|
+
id: "edit-image",
|
|
184
|
+
labels: { palette: "Edit image" },
|
|
185
|
+
keywords: "photo picture crop rotate adjust filter curves blur",
|
|
186
|
+
surfaces: ["palette"],
|
|
187
|
+
},
|
|
180
188
|
{ id: "shortcuts", labels: { palette: "Keyboard shortcuts" }, surfaces: ["palette"] },
|
|
181
189
|
{ id: "hide-on-device", labels: {}, surfaces: ["device"] },
|
|
182
190
|
];
|
|
@@ -204,6 +212,7 @@ const ORDER: Record<CommandSurface, readonly string[]> = {
|
|
|
204
212
|
"preview",
|
|
205
213
|
"undo",
|
|
206
214
|
"redo",
|
|
215
|
+
"edit-image",
|
|
207
216
|
"duplicate",
|
|
208
217
|
"delete",
|
|
209
218
|
"deselect",
|
|
@@ -227,6 +236,7 @@ const MOVE_IDS = new Set(["move-up", "move-down", "delete"]);
|
|
|
227
236
|
function shown(id: string, input: CommandInput): boolean {
|
|
228
237
|
const clip = !!input.runners.copy;
|
|
229
238
|
if (id === "rename") return !!input.runners.rename;
|
|
239
|
+
if (id === "edit-image") return !!input.runners.editImage;
|
|
230
240
|
if (id === "paste-inside") return clip && input.isParent;
|
|
231
241
|
if (id === "paste") return clip && (input.surface !== "layers" || !input.isRoot);
|
|
232
242
|
if (CLIP_IDS.has(id)) return clip;
|
|
@@ -270,6 +280,9 @@ export function runCommand(runners: CommandRunners, id: string, targetId: string
|
|
|
270
280
|
case "rename":
|
|
271
281
|
runners.rename?.();
|
|
272
282
|
return;
|
|
283
|
+
case "edit-image":
|
|
284
|
+
runners.editImage?.();
|
|
285
|
+
return;
|
|
273
286
|
case "copy":
|
|
274
287
|
if (targetId) runners.copy?.(targetId);
|
|
275
288
|
return;
|
|
@@ -408,6 +408,9 @@ export const EDITOR_CSS = `${UI_CSS}
|
|
|
408
408
|
|
|
409
409
|
.emvb-media-actions { display: flex; flex-wrap: wrap; gap: 8px; }
|
|
410
410
|
.emvb-media-preview { display: flex; flex-direction: column; gap: 4px; }
|
|
411
|
+
.emvb-media-edited { align-self: flex-start; }
|
|
412
|
+
.emvb-media-cell { position: relative; }
|
|
413
|
+
.emvb-media-cell .emvb-media-card-menu { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; padding: 0; opacity: 0.92; }
|
|
411
414
|
.emvb-media-thumb { display: block; max-width: 100%; max-height: 96px; border-radius: 6px; object-fit: contain; background: var(--color-kumo-canvas); }
|
|
412
415
|
.emvb-media-dialog {
|
|
413
416
|
display: flex;
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
toHex,
|
|
23
23
|
} from "./color-space.ts";
|
|
24
24
|
import { InlineError } from "./inline-error.tsx";
|
|
25
|
-
import { pickerHex } from "./variable-values.ts";
|
|
25
|
+
import { pickerHex, withPreviousAlpha } from "./variable-values.ts";
|
|
26
26
|
|
|
27
27
|
const HEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
28
28
|
const NONE = "__none__";
|
|
@@ -250,8 +250,9 @@ function CustomColor({
|
|
|
250
250
|
const el = picker.current;
|
|
251
251
|
if (!el) return;
|
|
252
252
|
const onPicked = () => {
|
|
253
|
-
|
|
254
|
-
|
|
253
|
+
const picked = withPreviousAlpha(el.value, value);
|
|
254
|
+
setDraft(picked);
|
|
255
|
+
commit(picked);
|
|
255
256
|
};
|
|
256
257
|
el.addEventListener("change", onPicked);
|
|
257
258
|
return () => el.removeEventListener("change", onPicked);
|
|
@@ -278,7 +279,7 @@ function CustomColor({
|
|
|
278
279
|
aria-label={`Pick ${label.toLowerCase()}`}
|
|
279
280
|
ref={picker}
|
|
280
281
|
value={pickerHex(HEX.test(draft) ? draft : value || "#000000")}
|
|
281
|
-
onChange={(event) => setDraft(event.target.value)}
|
|
282
|
+
onChange={(event) => setDraft(withPreviousAlpha(event.target.value, value))}
|
|
282
283
|
/>
|
|
283
284
|
</div>
|
|
284
285
|
{error?.field === "hex" && <InlineError>{error.message}</InlineError>}
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
SCRIPT_LABELS,
|
|
15
15
|
type PageScript,
|
|
16
16
|
} from "../../../core/index.ts";
|
|
17
|
+
import { clipText } from "../../../core/limits.ts";
|
|
17
18
|
import { indexLayout } from "../../../core/tree-ops.ts";
|
|
18
19
|
import { EXISTING_ELEMENT_MIME } from "../dnd/drop-target.ts";
|
|
19
20
|
import { ELEMENT_NAMES, elementIcon } from "../element-chrome.ts";
|
|
@@ -106,6 +107,14 @@ function menuItems(
|
|
|
106
107
|
}));
|
|
107
108
|
}
|
|
108
109
|
|
|
110
|
+
/** The row above or below `id` among the rows Layers shows, or `id` at either end. */
|
|
111
|
+
function visibleStep(layout: Layout, id: string, collapsed: Set<string>, by: 1 | -1): string {
|
|
112
|
+
const ids = rows(layout.root, 0, collapsed).map((row) => row.node.id);
|
|
113
|
+
const at = ids.indexOf(id);
|
|
114
|
+
if (at === -1) return by === 1 ? nextInOrder(layout, id) : previousInOrder(layout, id);
|
|
115
|
+
return ids[at + by] ?? id;
|
|
116
|
+
}
|
|
117
|
+
|
|
109
118
|
/** What a key does in the tree: select another row, toggle the selected one, or nothing. */
|
|
110
119
|
export function treeKey(
|
|
111
120
|
event: { key: string; shiftKey: boolean; altKey?: boolean; ctrlKey?: boolean; metaKey?: boolean },
|
|
@@ -118,10 +127,11 @@ export function treeKey(
|
|
|
118
127
|
// them. Selecting here first made the move act on the newly selected row instead.
|
|
119
128
|
if (event.altKey || event.ctrlKey || event.metaKey) return null;
|
|
120
129
|
switch (event.key) {
|
|
130
|
+
// W-520: rows inside a collapsed element are skipped; selecting one re-opened the branch.
|
|
121
131
|
case "ArrowDown":
|
|
122
|
-
return { select:
|
|
132
|
+
return { select: visibleStep(layout, id, collapsed, 1) };
|
|
123
133
|
case "ArrowUp":
|
|
124
|
-
return { select:
|
|
134
|
+
return { select: visibleStep(layout, id, collapsed, -1) };
|
|
125
135
|
case "ArrowRight":
|
|
126
136
|
return collapsed.has(id) ? { toggle: true } : { select: firstChild(layout, id) };
|
|
127
137
|
case "ArrowLeft": {
|
|
@@ -394,7 +404,7 @@ const LayerRow = React.memo(function LayerRow({
|
|
|
394
404
|
refocus.current = byKey;
|
|
395
405
|
setRenaming(false);
|
|
396
406
|
if (text === null || !actions.onRename) return;
|
|
397
|
-
const next = text.trim()
|
|
407
|
+
const next = clipText(text.trim(), 80).trim() || undefined;
|
|
398
408
|
if (next !== node.label) actions.onRename(node.id, next);
|
|
399
409
|
};
|
|
400
410
|
return (
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
lengthPx,
|
|
42
42
|
parseValue,
|
|
43
43
|
pickerHex,
|
|
44
|
+
withPreviousAlpha,
|
|
44
45
|
valueText,
|
|
45
46
|
type Length,
|
|
46
47
|
} from "./variable-values.ts";
|
|
@@ -162,8 +163,9 @@ function ValueEditor({
|
|
|
162
163
|
const el = picker.current;
|
|
163
164
|
if (!el) return;
|
|
164
165
|
const onChange = () => {
|
|
165
|
-
|
|
166
|
-
|
|
166
|
+
const picked = withPreviousAlpha(el.value, committed.current);
|
|
167
|
+
setText(picked);
|
|
168
|
+
commit(picked);
|
|
167
169
|
};
|
|
168
170
|
el.addEventListener("change", onChange);
|
|
169
171
|
return () => el.removeEventListener("change", onChange);
|
|
@@ -179,7 +181,7 @@ function ValueEditor({
|
|
|
179
181
|
className="emvb-site-picker"
|
|
180
182
|
aria-label={`Pick ${item.name}`}
|
|
181
183
|
value={pickerHex(error ? current : text)}
|
|
182
|
-
onChange={(event) => setText(event.target.value)}
|
|
184
|
+
onChange={(event) => setText(withPreviousAlpha(event.target.value, committed.current))}
|
|
183
185
|
/>
|
|
184
186
|
)}
|
|
185
187
|
<Input
|
|
@@ -6,6 +6,7 @@ import { FIELD } from "../../../ui.ts";
|
|
|
6
6
|
import { DraftTextField } from "./DraftTextField.tsx";
|
|
7
7
|
import { FieldBindControl } from "./FieldBindControl.tsx";
|
|
8
8
|
import { FormBindControl } from "./FormBindControl.tsx";
|
|
9
|
+
import { RequiredFieldsNotice } from "./RequiredFieldsNotice.tsx";
|
|
9
10
|
import { LoopItemBindControl } from "./LoopItemBindControl.tsx";
|
|
10
11
|
import { IconPicker } from "./IconPicker.tsx";
|
|
11
12
|
import { ImageSourcesField } from "./ImageSourcesField.tsx";
|
|
@@ -39,12 +40,14 @@ export function FieldControl({
|
|
|
39
40
|
|
|
40
41
|
if (field.key === "formId" && fetcher) {
|
|
41
42
|
return (
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
<React.Fragment key={field.key}>
|
|
44
|
+
<FormBindControl
|
|
45
|
+
value={typeof raw === "string" ? raw : ""}
|
|
46
|
+
fetcher={fetcher}
|
|
47
|
+
onChange={(formId) => onChange(withProp(node, "formId", formId))}
|
|
48
|
+
/>
|
|
49
|
+
<RequiredFieldsNotice node={node} fetcher={fetcher} />
|
|
50
|
+
</React.Fragment>
|
|
48
51
|
);
|
|
49
52
|
}
|
|
50
53
|
|
|
@@ -113,7 +116,15 @@ export function FieldControl({
|
|
|
113
116
|
</p>
|
|
114
117
|
);
|
|
115
118
|
}
|
|
116
|
-
return
|
|
119
|
+
return (
|
|
120
|
+
<MediaPicker
|
|
121
|
+
key={field.key}
|
|
122
|
+
node={node}
|
|
123
|
+
fetcher={fetcher}
|
|
124
|
+
onChange={onChange}
|
|
125
|
+
editable={node.type === "image"}
|
|
126
|
+
/>
|
|
127
|
+
);
|
|
117
128
|
}
|
|
118
129
|
|
|
119
130
|
if (field.kind === "boolean") {
|