@kurumera/editable 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/CHANGELOG.md +57 -17
- package/dist/chrome-css.d.ts +1 -1
- package/dist/chrome-css.js +283 -168
- package/dist/context.js +4 -0
- package/dist/media-host.d.ts +34 -0
- package/dist/media-host.js +66 -0
- package/dist/primitives/EditableBackgroundImageClient.d.ts +1 -1
- package/dist/primitives/EditableBackgroundImageClient.js +2 -24
- package/dist/primitives/EditableImageClient.js +5 -26
- package/dist/primitives/EditableVideo.js +8 -4
- package/dist/primitives/EditableVideoClient.js +11 -34
- package/dist/primitives/MediaChange.d.ts +27 -0
- package/dist/primitives/MediaChange.js +93 -0
- package/dist/primitives/MediaMenu.d.ts +24 -0
- package/dist/primitives/MediaMenu.js +87 -0
- package/dist/primitives/videoField.d.ts +12 -0
- package/dist/primitives/videoField.js +18 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,57 @@
|
|
|
1
|
-
# @kurumera/editable — changelog
|
|
2
|
-
|
|
3
|
-
## 0.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
the
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
# @kurumera/editable — changelog
|
|
2
|
+
|
|
3
|
+
## 0.6.0 — 2026-12-01
|
|
4
|
+
|
|
5
|
+
**One media control for pictures, backgrounds and videos.** "Change image",
|
|
6
|
+
"Change background" and "Change video" open a small menu:
|
|
7
|
+
|
|
8
|
+
- **Choose from Media**: the store's Media library, opened by the Kurumera
|
|
9
|
+
dashboard that frames the editor. The dashboard says it can do this with a
|
|
10
|
+
`postMessage` hello (protocol in `src/media-host.ts`); messages are read only
|
|
11
|
+
from the window's own parent, and answers are only accepted from the origin
|
|
12
|
+
that said hello. Unframed (`kurumera theme dev`) the option is not shown.
|
|
13
|
+
- **Upload from computer**, as before, now saying why when an upload fails
|
|
14
|
+
(it used to fail silently).
|
|
15
|
+
- Videos keep the YouTube / Vimeo link, now checked before it is used.
|
|
16
|
+
|
|
17
|
+
The menu renders into `<body>` with fixed coordinates, so a theme frame with
|
|
18
|
+
`overflow: hidden` can no longer clip it (0.5.1 placed the video popover below
|
|
19
|
+
the video, where Amber Zia's frame cut it off entirely). Its code is loaded on
|
|
20
|
+
first open, not in a shopper's bundle.
|
|
21
|
+
|
|
22
|
+
**A new video drops the old poster.** 0.5.1 kept the theme's placeholder poster
|
|
23
|
+
on the merchant's own film. A browser sizes a video by its poster until it
|
|
24
|
+
plays, so a wide sample card framed a portrait film, and the frame jumped to
|
|
25
|
+
the film's own shape on play. Now:
|
|
26
|
+
|
|
27
|
+
- A video set after this release saves `poster: ""`.
|
|
28
|
+
- Films saved before it are repaired as they render, with no migration: the
|
|
29
|
+
theme's own poster on a film that is not the theme's own film is ignored.
|
|
30
|
+
The film's first frame shows instead (`preload="metadata"`), and the frame
|
|
31
|
+
has the film's shape before play.
|
|
32
|
+
|
|
33
|
+
Needs a dashboard that answers the hello (admin `themes/content`, 30 Nov 2026)
|
|
34
|
+
for "Choose from Media"; everything else works without it.
|
|
35
|
+
|
|
36
|
+
## 0.5.1 — 2026-11-12
|
|
37
|
+
|
|
38
|
+
`@kurumera/storefront` is now accepted from 0.9.0 up to (not including) 1.0.0,
|
|
39
|
+
was `^0.9.0`. For a 0.x package `^0.9.0` stops at 0.9.x, so a theme on
|
|
40
|
+
storefront 0.10 or 0.11 got a second, older copy of the SDK nested under this
|
|
41
|
+
package. Nothing here needs more than 0.9 (forwardHeaders).
|
|
42
|
+
|
|
43
|
+
## 0.5.0 — 2026-10-16
|
|
44
|
+
|
|
45
|
+
`resolveEditableContent()` now forwards the visitor's `x-forwarded-for` and
|
|
46
|
+
`cf-connecting-ip`, as received, on its platform call — the same change as
|
|
47
|
+
`@kurumera/storefront` 0.9.0's `forwardHeaders`.
|
|
48
|
+
|
|
49
|
+
It runs from the root layout on every page, and it never throws by design, so a
|
|
50
|
+
call the platform throttled did not fail the page: it quietly rendered without
|
|
51
|
+
the merchant's edited content. Without the visitor's address every page view on
|
|
52
|
+
a server looked like one visitor, and a single crawler was enough to cause that.
|
|
53
|
+
|
|
54
|
+
**Dependency change:** `@kurumera/storefront` is now `^0.9.0`, was `^0.3.0`. The
|
|
55
|
+
old range made every theme install a separate nested 0.3.x copy of the SDK just
|
|
56
|
+
for this package; with it, the forwarding above would have been silently
|
|
57
|
+
ignored. Update both packages together.
|
package/dist/chrome-css.d.ts
CHANGED
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
* would otherwise leak in. The theme's own design must look untouched;
|
|
13
13
|
* only the controls we add are ours to style.
|
|
14
14
|
*/
|
|
15
|
-
export declare const CHROME_CSS = "\n.kurumera-edit-mode [data-kurumera-field],\n.kurumera-edit-mode .kurumera-editable {\n outline: 1px dashed rgba(37,99,235,.45);\n outline-offset: 3px;\n border-radius: 2px;\n transition: outline-color .12s ease, background-color .12s ease;\n}\n.kurumera-edit-mode .kurumera-editable:hover {\n outline: 1px dashed rgba(37,99,235,.9);\n background-color: rgba(37,99,235,.05);\n}\n.kurumera-edit-mode .kurumera-editable:focus,\n.kurumera-edit-mode .kurumera-editable:focus-visible {\n outline: 2px solid #2563eb;\n outline-offset: 3px;\n background-color: rgba(37,99,235,.06);\n}\n.kurumera-editable--saving { outline-color: #f59e0b !important; }\n.kurumera-editable--saved { outline-color: #10b981 !important; }\n.kurumera-editable--error { outline: 2px solid #ef4444 !important; cursor: pointer; }\n\n/* \u2500\u2500 Shared control chrome \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.kurumera-editable-image__change,\n.kurumera-editable-bg__change,\n.kurumera-editable-video__change,\n.kurumera-editable-linkfield__edit-link,\n.kurumera-editable-section__chip button,\n.kurumera-editable-repeater__chrome button,\n.kurumera-editable-repeater__add,\n.kurumera-editable-richtext__toolbar button,\n.kurumera-editable-linkfield__popover button,\n.kurumera-editable-video__popover button {\n -webkit-appearance: none; appearance: none;\n font: 600 11px/1 system-ui, -apple-system, \"Segoe UI\", sans-serif;\n letter-spacing: .01em;\n padding: 5px 9px;\n margin: 0;\n border: 0;\n border-radius: 6px;\n background: #111827;\n color: #fff;\n cursor: pointer;\n box-shadow: 0 1px 3px rgba(0,0,0,.28);\n text-transform: none;\n white-space: nowrap;\n min-width: 0; min-height: 0; width: auto; height: auto;\n transition: background-color .12s ease, opacity .12s ease;\n}\n.kurumera-editable-image__change:hover,\n.kurumera-editable-bg__change:hover,\n.kurumera-editable-video__change:hover,\n.kurumera-editable-linkfield__edit-link:hover,\n.kurumera-editable-section__chip button:hover,\n.kurumera-editable-repeater__chrome button:hover,\n.kurumera-editable-repeater__add:hover,\n.kurumera-editable-richtext__toolbar button:hover,\n.kurumera-editable-linkfield__popover button:hover,\n.kurumera-editable-video__popover button:hover { background: #2563eb; }\n.kurumera-editable-repeater__chrome button:disabled { opacity: .35; cursor: default; background: #111827; }\n\n/* \u2500\u2500 Media: float the control over the media, never in the layout \u2500\u2500\u2500\u2500\u2500 */\n.kurumera-editable-image,\n.kurumera-editable-video { position: relative; display: inline-block; line-height: 0; }\n.kurumera-editable-image__change,\n.kurumera-editable-video__change,\n.kurumera-editable-bg__change {\n position: absolute; top: 8px; right: 8px; z-index: 20;\n opacity: 0; pointer-events: none;\n}\n.kurumera-editable-image:hover .kurumera-editable-image__change,\n.kurumera-editable-image:focus-within .kurumera-editable-image__change,\n.kurumera-editable-video:hover .kurumera-editable-video__change,\n.kurumera-editable-video:focus-within .kurumera-editable-video__change,\n.kurumera-editable-bg:hover .kurumera-editable-bg__change,\n.kurumera-editable-bg:focus-within .kurumera-editable-bg__change { opacity: 1; pointer-events: auto; }\n/* Background image: the primitive IS the theme's container, so only add\n positioning context \u2014 never change its display/layout. */\n.kurumera-edit-mode .kurumera-editable-bg { position: relative; }\n\n/* \u2500\u2500 Section chip: floats at the top-left corner, out of flow \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.kurumera-editable-section { position: relative; }\n.kurumera-editable-section__chip {\n position: absolute; top: 6px; left: 6px; z-index: 25;\n display: inline-flex; align-items: center; gap: 6px;\n padding: 3px 4px 3px 9px;\n border-radius: 999px;\n background: rgba(17,24,39,.92);\n color: #fff;\n font: 600 11px/1 system-ui, -apple-system, \"Segoe UI\", sans-serif;\n box-shadow: 0 1px 4px rgba(0,0,0,.3);\n opacity: 0; pointer-events: none; transition: opacity .12s ease;\n}\n.kurumera-editable-section:hover .kurumera-editable-section__chip,\n.kurumera-editable-section:focus-within .kurumera-editable-section__chip { opacity: 1; pointer-events: auto; }\n.kurumera-editable-section__chip button { padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.16); }\n\n/* \u2500\u2500 Repeater: per-item controls float top-right of each item \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.kurumera-edit-mode [data-kurumera-repeater-item] { position: relative; }\n.kurumera-editable-repeater__chrome {\n position: absolute; top: 6px; right: 6px; z-index: 25;\n display: inline-flex; gap: 4px;\n opacity: 0; pointer-events: none; transition: opacity .12s ease;\n}\n[data-kurumera-repeater-item]:hover .kurumera-editable-repeater__chrome,\n[data-kurumera-repeater-item]:focus-within .kurumera-editable-repeater__chrome { opacity: 1; pointer-events: auto; }\n.kurumera-editable-repeater__chrome button { padding: 4px 7px; }\n.kurumera-editable-repeater__add {\n display: inline-flex; align-items: center; margin-top: 10px;\n background: #2563eb;\n}\n.kurumera-editable-repeater__add:hover { background: #1d4ed8; }\n.kurumera-editable-repeater__pending { padding: 12px; font: 12px system-ui; color: #6b7280; }\n\n/* \u2500\u2500 Rich text toolbar \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.kurumera-editable-richtext { position: relative; }\n.kurumera-editable-richtext__toolbar {\n position: absolute; top: 0; right: 0; z-index: 25;\n transform: translateY(-115%);\n display: inline-flex; gap: 4px; padding: 4px;\n border-radius: 8px; background: rgba(17,24,39,.92);\n box-shadow: 0 2px 6px rgba(0,0,0,.3);\n opacity: 0; pointer-events: none; transition: opacity .12s ease;\n}\n.kurumera-editable-richtext:hover .kurumera-editable-richtext__toolbar,\n.kurumera-editable-richtext:focus-within .kurumera-editable-richtext__toolbar { opacity: 1; pointer-events: auto; }\n.kurumera-editable-richtext__toolbar button { background: rgba(255,255,255,.16); min-width: 26px; text-align: center; }\n\n/* \u2500\u2500 Link / button field \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.kurumera-editable-linkfield { position: relative; display: inline-block; }\n.kurumera-editable-linkfield__edit-link {\n position: absolute; top: -8px; right: -8px; z-index: 25;\n padding: 3px 7px;\n opacity: 0; pointer-events: none; transition: opacity .12s ease;\n}\n.kurumera-editable-linkfield:hover .kurumera-editable-linkfield__edit-link,\n.kurumera-editable-linkfield:focus-within .kurumera-editable-linkfield__edit-link { opacity: 1; pointer-events: auto; }\n\n/* \u2500\u2500 Popovers (link href, video source) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.kurumera-editable-linkfield__popover,\n.kurumera-editable-video__popover {\n position: absolute; top: calc(100% + 8px); left: 0; z-index: 30;\n display: inline-flex; align-items: center; gap: 6px;\n padding: 8px; border-radius: 8px;\n background: #fff; border: 1px solid #e5e7eb;\n box-shadow: 0 6px 20px rgba(0,0,0,.16);\n white-space: nowrap;\n}\n.kurumera-editable-linkfield__popover input,\n.kurumera-editable-video__popover input {\n -webkit-appearance: none; appearance: none;\n font: 12px/1.3 system-ui, -apple-system, \"Segoe UI\", sans-serif;\n color: #111827; background: #fff;\n padding: 6px 8px; margin: 0;\n border: 1px solid #d1d5db; border-radius: 6px;\n min-width: 230px; width: auto; height: auto;\n}\n.kurumera-editable-linkfield__popover input:focus,\n.kurumera-editable-video__popover input:focus { outline: 2px solid #2563eb; outline-offset: -1px; border-color: #2563eb; }\n.kurumera-editable-video__popover-or { font: 11px system-ui; color: #6b7280; }\n\n@media (prefers-reduced-motion: reduce) {\n .kurumera-editable, .kurumera-editable-section__chip, .kurumera-editable-repeater__chrome,\n .kurumera-editable-richtext__toolbar, .kurumera-editable-linkfield__edit-link,\n .kurumera-editable-image__change, .kurumera-editable-video__change, .kurumera-editable-bg__change {\n transition: none;\n }\n}\n";
|
|
15
|
+
export declare const CHROME_CSS = "\n.kurumera-edit-mode [data-kurumera-field],\n.kurumera-edit-mode .kurumera-editable {\n outline: 1px dashed rgba(37,99,235,.45);\n outline-offset: 3px;\n border-radius: 2px;\n transition: outline-color .12s ease, background-color .12s ease;\n}\n.kurumera-edit-mode .kurumera-editable:hover {\n outline: 1px dashed rgba(37,99,235,.9);\n background-color: rgba(37,99,235,.05);\n}\n.kurumera-edit-mode .kurumera-editable:focus,\n.kurumera-edit-mode .kurumera-editable:focus-visible {\n outline: 2px solid #2563eb;\n outline-offset: 3px;\n background-color: rgba(37,99,235,.06);\n}\n.kurumera-editable--saving { outline-color: #f59e0b !important; }\n.kurumera-editable--saved { outline-color: #10b981 !important; }\n.kurumera-editable--error { outline: 2px solid #ef4444 !important; cursor: pointer; }\n\n/* \u2500\u2500 Shared control chrome \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.kurumera-editable-image__change,\n.kurumera-editable-bg__change,\n.kurumera-editable-video__change,\n.kurumera-editable-linkfield__edit-link,\n.kurumera-editable-section__chip button,\n.kurumera-editable-repeater__chrome button,\n.kurumera-editable-repeater__add,\n.kurumera-editable-richtext__toolbar button,\n.kurumera-editable-linkfield__popover button {\n -webkit-appearance: none; appearance: none;\n font: 600 11px/1 system-ui, -apple-system, \"Segoe UI\", sans-serif;\n letter-spacing: .01em;\n padding: 5px 9px;\n margin: 0;\n border: 0;\n border-radius: 6px;\n background: #111827;\n color: #fff;\n cursor: pointer;\n box-shadow: 0 1px 3px rgba(0,0,0,.28);\n text-transform: none;\n white-space: nowrap;\n min-width: 0; min-height: 0; width: auto; height: auto;\n transition: background-color .12s ease, opacity .12s ease;\n}\n.kurumera-editable-image__change:hover,\n.kurumera-editable-bg__change:hover,\n.kurumera-editable-video__change:hover,\n.kurumera-editable-linkfield__edit-link:hover,\n.kurumera-editable-section__chip button:hover,\n.kurumera-editable-repeater__chrome button:hover,\n.kurumera-editable-repeater__add:hover,\n.kurumera-editable-richtext__toolbar button:hover,\n.kurumera-editable-linkfield__popover button:hover { background: #2563eb; }\n.kurumera-editable-repeater__chrome button:disabled { opacity: .35; cursor: default; background: #111827; }\n\n/* \u2500\u2500 Media: float the control over the media, never in the layout \u2500\u2500\u2500\u2500\u2500 */\n.kurumera-editable-image,\n.kurumera-editable-video { position: relative; display: inline-block; line-height: 0; }\n.kurumera-editable-image__change,\n.kurumera-editable-video__change,\n.kurumera-editable-bg__change {\n position: absolute; top: 8px; right: 8px; z-index: 20;\n opacity: 0; pointer-events: none;\n}\n/* The trigger is a soft dark pill over the media. It reads on a light or a\n dark picture (the blur carries it), and presses in when clicked. */\n.kurumera-editable-media__change {\n display: inline-flex; align-items: center; gap: 6px;\n padding: 7px 12px 7px 10px;\n border-radius: 999px;\n font-size: 12px;\n background: rgba(17,24,39,.8);\n -webkit-backdrop-filter: blur(10px) saturate(1.4); backdrop-filter: blur(10px) saturate(1.4);\n box-shadow: 0 0 0 1px rgba(255,255,255,.14) inset, 0 4px 14px rgba(0,0,0,.22);\n transition: opacity .12s ease, background-color .12s ease, transform .12s cubic-bezier(.23,1,.32,1);\n}\n.kurumera-editable-media__change svg { flex: none; opacity: .9; }\n.kurumera-editable-media__change:active { transform: scale(.97); }\n.kurumera-editable-media__change:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }\n.kurumera-editable-media__change:disabled { cursor: progress; }\n.kurumera-editable-media__change.is-open { opacity: 1; pointer-events: auto; background: #111827; }\n.kurumera-editable-media__change.is-error { opacity: 1; pointer-events: auto; background: #b42318; }\n.kurumera-editable-image:hover .kurumera-editable-image__change,\n.kurumera-editable-image:focus-within .kurumera-editable-image__change,\n.kurumera-editable-video:hover .kurumera-editable-video__change,\n.kurumera-editable-video:focus-within .kurumera-editable-video__change,\n.kurumera-editable-bg:hover .kurumera-editable-bg__change,\n.kurumera-editable-bg:focus-within .kurumera-editable-bg__change { opacity: 1; pointer-events: auto; }\n/* Background image: the primitive IS the theme's container, so only add\n positioning context \u2014 never change its display/layout. */\n.kurumera-edit-mode .kurumera-editable-bg { position: relative; }\n\n/* \u2500\u2500 Section chip: floats at the top-left corner, out of flow \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.kurumera-editable-section { position: relative; }\n.kurumera-editable-section__chip {\n position: absolute; top: 6px; left: 6px; z-index: 25;\n display: inline-flex; align-items: center; gap: 6px;\n padding: 3px 4px 3px 9px;\n border-radius: 999px;\n background: rgba(17,24,39,.92);\n color: #fff;\n font: 600 11px/1 system-ui, -apple-system, \"Segoe UI\", sans-serif;\n box-shadow: 0 1px 4px rgba(0,0,0,.3);\n opacity: 0; pointer-events: none; transition: opacity .12s ease;\n}\n.kurumera-editable-section:hover .kurumera-editable-section__chip,\n.kurumera-editable-section:focus-within .kurumera-editable-section__chip { opacity: 1; pointer-events: auto; }\n.kurumera-editable-section__chip button { padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.16); }\n\n/* \u2500\u2500 Repeater: per-item controls float top-right of each item \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.kurumera-edit-mode [data-kurumera-repeater-item] { position: relative; }\n.kurumera-editable-repeater__chrome {\n position: absolute; top: 6px; right: 6px; z-index: 25;\n display: inline-flex; gap: 4px;\n opacity: 0; pointer-events: none; transition: opacity .12s ease;\n}\n[data-kurumera-repeater-item]:hover .kurumera-editable-repeater__chrome,\n[data-kurumera-repeater-item]:focus-within .kurumera-editable-repeater__chrome { opacity: 1; pointer-events: auto; }\n.kurumera-editable-repeater__chrome button { padding: 4px 7px; }\n.kurumera-editable-repeater__add {\n display: inline-flex; align-items: center; margin-top: 10px;\n background: #2563eb;\n}\n.kurumera-editable-repeater__add:hover { background: #1d4ed8; }\n.kurumera-editable-repeater__pending { padding: 12px; font: 12px system-ui; color: #6b7280; }\n\n/* \u2500\u2500 Rich text toolbar \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.kurumera-editable-richtext { position: relative; }\n.kurumera-editable-richtext__toolbar {\n position: absolute; top: 0; right: 0; z-index: 25;\n transform: translateY(-115%);\n display: inline-flex; gap: 4px; padding: 4px;\n border-radius: 8px; background: rgba(17,24,39,.92);\n box-shadow: 0 2px 6px rgba(0,0,0,.3);\n opacity: 0; pointer-events: none; transition: opacity .12s ease;\n}\n.kurumera-editable-richtext:hover .kurumera-editable-richtext__toolbar,\n.kurumera-editable-richtext:focus-within .kurumera-editable-richtext__toolbar { opacity: 1; pointer-events: auto; }\n.kurumera-editable-richtext__toolbar button { background: rgba(255,255,255,.16); min-width: 26px; text-align: center; }\n\n/* \u2500\u2500 Link / button field \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.kurumera-editable-linkfield { position: relative; display: inline-block; }\n.kurumera-editable-linkfield__edit-link {\n position: absolute; top: -8px; right: -8px; z-index: 25;\n padding: 3px 7px;\n opacity: 0; pointer-events: none; transition: opacity .12s ease;\n}\n.kurumera-editable-linkfield:hover .kurumera-editable-linkfield__edit-link,\n.kurumera-editable-linkfield:focus-within .kurumera-editable-linkfield__edit-link { opacity: 1; pointer-events: auto; }\n\n/* \u2500\u2500 Popover (link href) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.kurumera-editable-linkfield__popover {\n position: absolute; top: calc(100% + 8px); left: 0; z-index: 30;\n display: inline-flex; align-items: center; gap: 6px;\n padding: 8px; border-radius: 8px;\n background: #fff; border: 1px solid #e5e7eb;\n box-shadow: 0 6px 20px rgba(0,0,0,.16);\n white-space: nowrap;\n}\n.kurumera-editable-linkfield__popover input {\n -webkit-appearance: none; appearance: none;\n font: 12px/1.3 system-ui, -apple-system, \"Segoe UI\", sans-serif;\n color: #111827; background: #fff;\n padding: 6px 8px; margin: 0;\n border: 1px solid #d1d5db; border-radius: 6px;\n min-width: 230px; width: auto; height: auto;\n}\n.kurumera-editable-linkfield__popover input:focus { outline: 2px solid #2563eb; outline-offset: -1px; border-color: #2563eb; }\n\n/* \u2500\u2500 Media menu (change a picture or a video) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n Lives in <body> with fixed coordinates (MediaMenu.tsx), so no theme\n frame can clip it. Every control starts from \"all: unset\": the rules a\n theme writes for button {} / input {} / p {} must not reach in. */\n.kurumera-media-menu {\n all: unset; box-sizing: border-box;\n position: fixed; z-index: 2147483000;\n display: flex; flex-direction: column; gap: 2px;\n width: 284px; max-width: calc(100vw - 16px);\n padding: 6px;\n border-radius: 14px;\n background: #fff; color: #111827;\n box-shadow: 0 0 0 1px rgba(17,24,39,.08), 0 2px 6px rgba(17,24,39,.08), 0 16px 40px rgba(17,24,39,.2);\n font: 13px/1.35 system-ui, -apple-system, \"Segoe UI\", sans-serif;\n letter-spacing: 0; text-transform: none; text-align: left;\n transform-origin: top right;\n transition: opacity .14s cubic-bezier(.23,1,.32,1), transform .14s cubic-bezier(.23,1,.32,1);\n}\n.kurumera-media-menu[data-side=\"above\"] { transform-origin: bottom right; }\n@starting-style {\n .kurumera-media-menu { opacity: 0; transform: scale(.96) translateY(-4px); }\n .kurumera-media-menu[data-side=\"above\"] { transform: scale(.96) translateY(4px); }\n}\n.kurumera-media-menu * { box-sizing: border-box; }\n.kurumera-media-menu__title {\n all: unset; display: block;\n padding: 7px 8px 5px;\n font: 600 12px/1.3 system-ui, -apple-system, \"Segoe UI\", sans-serif;\n color: #6b7280;\n}\n.kurumera-media-menu__item {\n all: unset; box-sizing: border-box;\n display: flex; align-items: center; gap: 10px;\n width: 100%; padding: 8px;\n border-radius: 10px;\n cursor: pointer;\n transition: background-color .12s ease, transform .12s cubic-bezier(.23,1,.32,1);\n}\n@media (hover: hover) and (pointer: fine) {\n .kurumera-media-menu__item:hover:not(:disabled) { background: #f3f4f6; }\n .kurumera-media-menu__item:hover:not(:disabled) .kurumera-media-menu__icon { background: #fff; box-shadow: 0 0 0 1px rgba(17,24,39,.08); }\n .kurumera-media-menu__link button:hover:not(:disabled) { background: #2563eb; }\n}\n.kurumera-media-menu__item:active:not(:disabled) { transform: scale(.985); background: #eceef1; }\n.kurumera-media-menu__item:focus-visible { outline: 2px solid #2563eb; outline-offset: -2px; }\n.kurumera-media-menu__item:disabled { cursor: default; opacity: .55; }\n.kurumera-media-menu__icon {\n flex: none; display: grid; place-items: center;\n width: 36px; height: 36px; border-radius: 9px;\n background: #f3f4f6; color: #111827;\n transition: background-color .12s ease;\n}\n.kurumera-media-menu__text { display: flex; flex-direction: column; min-width: 0; }\n.kurumera-media-menu__name { font: 600 13px/1.3 system-ui, -apple-system, \"Segoe UI\", sans-serif; color: #111827; }\n.kurumera-media-menu__hint { font: 12px/1.35 system-ui, -apple-system, \"Segoe UI\", sans-serif; color: #6b7280; }\n.kurumera-media-menu__spinner {\n width: 16px; height: 16px; border-radius: 50%;\n border: 2px solid #d1d5db; border-top-color: #111827;\n animation: kurumera-media-spin .6s linear infinite;\n}\n@keyframes kurumera-media-spin { to { transform: rotate(360deg); } }\n.kurumera-media-menu__link {\n all: unset; display: block;\n margin-top: 4px; padding: 10px 8px 8px;\n border-top: 1px solid #eef0f2;\n}\n.kurumera-media-menu__link label {\n all: unset; display: block; margin-bottom: 6px;\n font: 600 12px/1.3 system-ui, -apple-system, \"Segoe UI\", sans-serif; color: #6b7280;\n}\n.kurumera-media-menu__linkrow { display: flex; gap: 6px; }\n.kurumera-media-menu__link input {\n all: unset; box-sizing: border-box;\n flex: 1 1 auto; min-width: 0; height: 34px; padding: 0 10px;\n border-radius: 8px; box-shadow: 0 0 0 1px #d1d5db inset;\n background: #fff; color: #111827;\n font: 13px/1 system-ui, -apple-system, \"Segoe UI\", sans-serif;\n cursor: text;\n}\n.kurumera-media-menu__link input::placeholder { color: #9ca3af; }\n.kurumera-media-menu__link input:focus { box-shadow: 0 0 0 2px #2563eb inset; }\n.kurumera-media-menu__link button {\n all: unset; box-sizing: border-box;\n flex: none; height: 34px; padding: 0 12px;\n border-radius: 8px; background: #111827; color: #fff;\n font: 600 12px/34px system-ui, -apple-system, \"Segoe UI\", sans-serif;\n cursor: pointer; white-space: nowrap;\n transition: background-color .12s ease, transform .12s cubic-bezier(.23,1,.32,1);\n}\n.kurumera-media-menu__link button:active:not(:disabled) { transform: scale(.97); }\n.kurumera-media-menu__link button:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }\n.kurumera-media-menu__link button:disabled, .kurumera-media-menu__link input:disabled { opacity: .5; cursor: default; }\n.kurumera-media-menu__error {\n all: unset; display: block;\n margin: 2px; padding: 8px 10px;\n border-radius: 8px; background: #fef3f2; color: #b42318;\n font: 12px/1.4 system-ui, -apple-system, \"Segoe UI\", sans-serif;\n overflow-wrap: anywhere;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .kurumera-editable, .kurumera-editable-section__chip, .kurumera-editable-repeater__chrome,\n .kurumera-editable-richtext__toolbar, .kurumera-editable-linkfield__edit-link,\n .kurumera-editable-image__change, .kurumera-editable-video__change, .kurumera-editable-bg__change {\n transition: none;\n }\n /* The menu still fades, but does not move. */\n .kurumera-media-menu { transition: opacity .14s ease; }\n .kurumera-media-menu__item, .kurumera-media-menu__link button { transition: none; }\n}\n";
|
package/dist/chrome-css.js
CHANGED
|
@@ -12,172 +12,287 @@
|
|
|
12
12
|
* would otherwise leak in. The theme's own design must look untouched;
|
|
13
13
|
* only the controls we add are ours to style.
|
|
14
14
|
*/
|
|
15
|
-
export const CHROME_CSS = `
|
|
16
|
-
.kurumera-edit-mode [data-kurumera-field],
|
|
17
|
-
.kurumera-edit-mode .kurumera-editable {
|
|
18
|
-
outline: 1px dashed rgba(37,99,235,.45);
|
|
19
|
-
outline-offset: 3px;
|
|
20
|
-
border-radius: 2px;
|
|
21
|
-
transition: outline-color .12s ease, background-color .12s ease;
|
|
22
|
-
}
|
|
23
|
-
.kurumera-edit-mode .kurumera-editable:hover {
|
|
24
|
-
outline: 1px dashed rgba(37,99,235,.9);
|
|
25
|
-
background-color: rgba(37,99,235,.05);
|
|
26
|
-
}
|
|
27
|
-
.kurumera-edit-mode .kurumera-editable:focus,
|
|
28
|
-
.kurumera-edit-mode .kurumera-editable:focus-visible {
|
|
29
|
-
outline: 2px solid #2563eb;
|
|
30
|
-
outline-offset: 3px;
|
|
31
|
-
background-color: rgba(37,99,235,.06);
|
|
32
|
-
}
|
|
33
|
-
.kurumera-editable--saving { outline-color: #f59e0b !important; }
|
|
34
|
-
.kurumera-editable--saved { outline-color: #10b981 !important; }
|
|
35
|
-
.kurumera-editable--error { outline: 2px solid #ef4444 !important; cursor: pointer; }
|
|
36
|
-
|
|
37
|
-
/* ── Shared control chrome ──────────────────────────────────────────── */
|
|
38
|
-
.kurumera-editable-image__change,
|
|
39
|
-
.kurumera-editable-bg__change,
|
|
40
|
-
.kurumera-editable-video__change,
|
|
41
|
-
.kurumera-editable-linkfield__edit-link,
|
|
42
|
-
.kurumera-editable-section__chip button,
|
|
43
|
-
.kurumera-editable-repeater__chrome button,
|
|
44
|
-
.kurumera-editable-repeater__add,
|
|
45
|
-
.kurumera-editable-richtext__toolbar button,
|
|
46
|
-
.kurumera-editable-linkfield__popover button
|
|
47
|
-
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
border:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
.kurumera-editable-
|
|
65
|
-
.kurumera-editable-
|
|
66
|
-
.kurumera-editable-
|
|
67
|
-
.kurumera-editable-
|
|
68
|
-
.kurumera-editable-
|
|
69
|
-
.kurumera-editable-
|
|
70
|
-
.kurumera-editable-
|
|
71
|
-
.kurumera-editable-
|
|
72
|
-
.kurumera-editable-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
.kurumera-editable-
|
|
78
|
-
.kurumera-editable-
|
|
79
|
-
.kurumera-editable-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
.kurumera-editable-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
.kurumera-editable-
|
|
97
|
-
.kurumera-editable-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
.
|
|
109
|
-
.kurumera-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
.kurumera-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
.kurumera-editable-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
.kurumera-editable-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
.kurumera-editable-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
15
|
+
export const CHROME_CSS = `
|
|
16
|
+
.kurumera-edit-mode [data-kurumera-field],
|
|
17
|
+
.kurumera-edit-mode .kurumera-editable {
|
|
18
|
+
outline: 1px dashed rgba(37,99,235,.45);
|
|
19
|
+
outline-offset: 3px;
|
|
20
|
+
border-radius: 2px;
|
|
21
|
+
transition: outline-color .12s ease, background-color .12s ease;
|
|
22
|
+
}
|
|
23
|
+
.kurumera-edit-mode .kurumera-editable:hover {
|
|
24
|
+
outline: 1px dashed rgba(37,99,235,.9);
|
|
25
|
+
background-color: rgba(37,99,235,.05);
|
|
26
|
+
}
|
|
27
|
+
.kurumera-edit-mode .kurumera-editable:focus,
|
|
28
|
+
.kurumera-edit-mode .kurumera-editable:focus-visible {
|
|
29
|
+
outline: 2px solid #2563eb;
|
|
30
|
+
outline-offset: 3px;
|
|
31
|
+
background-color: rgba(37,99,235,.06);
|
|
32
|
+
}
|
|
33
|
+
.kurumera-editable--saving { outline-color: #f59e0b !important; }
|
|
34
|
+
.kurumera-editable--saved { outline-color: #10b981 !important; }
|
|
35
|
+
.kurumera-editable--error { outline: 2px solid #ef4444 !important; cursor: pointer; }
|
|
36
|
+
|
|
37
|
+
/* ── Shared control chrome ──────────────────────────────────────────── */
|
|
38
|
+
.kurumera-editable-image__change,
|
|
39
|
+
.kurumera-editable-bg__change,
|
|
40
|
+
.kurumera-editable-video__change,
|
|
41
|
+
.kurumera-editable-linkfield__edit-link,
|
|
42
|
+
.kurumera-editable-section__chip button,
|
|
43
|
+
.kurumera-editable-repeater__chrome button,
|
|
44
|
+
.kurumera-editable-repeater__add,
|
|
45
|
+
.kurumera-editable-richtext__toolbar button,
|
|
46
|
+
.kurumera-editable-linkfield__popover button {
|
|
47
|
+
-webkit-appearance: none; appearance: none;
|
|
48
|
+
font: 600 11px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
49
|
+
letter-spacing: .01em;
|
|
50
|
+
padding: 5px 9px;
|
|
51
|
+
margin: 0;
|
|
52
|
+
border: 0;
|
|
53
|
+
border-radius: 6px;
|
|
54
|
+
background: #111827;
|
|
55
|
+
color: #fff;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
box-shadow: 0 1px 3px rgba(0,0,0,.28);
|
|
58
|
+
text-transform: none;
|
|
59
|
+
white-space: nowrap;
|
|
60
|
+
min-width: 0; min-height: 0; width: auto; height: auto;
|
|
61
|
+
transition: background-color .12s ease, opacity .12s ease;
|
|
62
|
+
}
|
|
63
|
+
.kurumera-editable-image__change:hover,
|
|
64
|
+
.kurumera-editable-bg__change:hover,
|
|
65
|
+
.kurumera-editable-video__change:hover,
|
|
66
|
+
.kurumera-editable-linkfield__edit-link:hover,
|
|
67
|
+
.kurumera-editable-section__chip button:hover,
|
|
68
|
+
.kurumera-editable-repeater__chrome button:hover,
|
|
69
|
+
.kurumera-editable-repeater__add:hover,
|
|
70
|
+
.kurumera-editable-richtext__toolbar button:hover,
|
|
71
|
+
.kurumera-editable-linkfield__popover button:hover { background: #2563eb; }
|
|
72
|
+
.kurumera-editable-repeater__chrome button:disabled { opacity: .35; cursor: default; background: #111827; }
|
|
73
|
+
|
|
74
|
+
/* ── Media: float the control over the media, never in the layout ───── */
|
|
75
|
+
.kurumera-editable-image,
|
|
76
|
+
.kurumera-editable-video { position: relative; display: inline-block; line-height: 0; }
|
|
77
|
+
.kurumera-editable-image__change,
|
|
78
|
+
.kurumera-editable-video__change,
|
|
79
|
+
.kurumera-editable-bg__change {
|
|
80
|
+
position: absolute; top: 8px; right: 8px; z-index: 20;
|
|
81
|
+
opacity: 0; pointer-events: none;
|
|
82
|
+
}
|
|
83
|
+
/* The trigger is a soft dark pill over the media. It reads on a light or a
|
|
84
|
+
dark picture (the blur carries it), and presses in when clicked. */
|
|
85
|
+
.kurumera-editable-media__change {
|
|
86
|
+
display: inline-flex; align-items: center; gap: 6px;
|
|
87
|
+
padding: 7px 12px 7px 10px;
|
|
88
|
+
border-radius: 999px;
|
|
89
|
+
font-size: 12px;
|
|
90
|
+
background: rgba(17,24,39,.8);
|
|
91
|
+
-webkit-backdrop-filter: blur(10px) saturate(1.4); backdrop-filter: blur(10px) saturate(1.4);
|
|
92
|
+
box-shadow: 0 0 0 1px rgba(255,255,255,.14) inset, 0 4px 14px rgba(0,0,0,.22);
|
|
93
|
+
transition: opacity .12s ease, background-color .12s ease, transform .12s cubic-bezier(.23,1,.32,1);
|
|
94
|
+
}
|
|
95
|
+
.kurumera-editable-media__change svg { flex: none; opacity: .9; }
|
|
96
|
+
.kurumera-editable-media__change:active { transform: scale(.97); }
|
|
97
|
+
.kurumera-editable-media__change:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
|
|
98
|
+
.kurumera-editable-media__change:disabled { cursor: progress; }
|
|
99
|
+
.kurumera-editable-media__change.is-open { opacity: 1; pointer-events: auto; background: #111827; }
|
|
100
|
+
.kurumera-editable-media__change.is-error { opacity: 1; pointer-events: auto; background: #b42318; }
|
|
101
|
+
.kurumera-editable-image:hover .kurumera-editable-image__change,
|
|
102
|
+
.kurumera-editable-image:focus-within .kurumera-editable-image__change,
|
|
103
|
+
.kurumera-editable-video:hover .kurumera-editable-video__change,
|
|
104
|
+
.kurumera-editable-video:focus-within .kurumera-editable-video__change,
|
|
105
|
+
.kurumera-editable-bg:hover .kurumera-editable-bg__change,
|
|
106
|
+
.kurumera-editable-bg:focus-within .kurumera-editable-bg__change { opacity: 1; pointer-events: auto; }
|
|
107
|
+
/* Background image: the primitive IS the theme's container, so only add
|
|
108
|
+
positioning context — never change its display/layout. */
|
|
109
|
+
.kurumera-edit-mode .kurumera-editable-bg { position: relative; }
|
|
110
|
+
|
|
111
|
+
/* ── Section chip: floats at the top-left corner, out of flow ───────── */
|
|
112
|
+
.kurumera-editable-section { position: relative; }
|
|
113
|
+
.kurumera-editable-section__chip {
|
|
114
|
+
position: absolute; top: 6px; left: 6px; z-index: 25;
|
|
115
|
+
display: inline-flex; align-items: center; gap: 6px;
|
|
116
|
+
padding: 3px 4px 3px 9px;
|
|
117
|
+
border-radius: 999px;
|
|
118
|
+
background: rgba(17,24,39,.92);
|
|
119
|
+
color: #fff;
|
|
120
|
+
font: 600 11px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
121
|
+
box-shadow: 0 1px 4px rgba(0,0,0,.3);
|
|
122
|
+
opacity: 0; pointer-events: none; transition: opacity .12s ease;
|
|
123
|
+
}
|
|
124
|
+
.kurumera-editable-section:hover .kurumera-editable-section__chip,
|
|
125
|
+
.kurumera-editable-section:focus-within .kurumera-editable-section__chip { opacity: 1; pointer-events: auto; }
|
|
126
|
+
.kurumera-editable-section__chip button { padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.16); }
|
|
127
|
+
|
|
128
|
+
/* ── Repeater: per-item controls float top-right of each item ───────── */
|
|
129
|
+
.kurumera-edit-mode [data-kurumera-repeater-item] { position: relative; }
|
|
130
|
+
.kurumera-editable-repeater__chrome {
|
|
131
|
+
position: absolute; top: 6px; right: 6px; z-index: 25;
|
|
132
|
+
display: inline-flex; gap: 4px;
|
|
133
|
+
opacity: 0; pointer-events: none; transition: opacity .12s ease;
|
|
134
|
+
}
|
|
135
|
+
[data-kurumera-repeater-item]:hover .kurumera-editable-repeater__chrome,
|
|
136
|
+
[data-kurumera-repeater-item]:focus-within .kurumera-editable-repeater__chrome { opacity: 1; pointer-events: auto; }
|
|
137
|
+
.kurumera-editable-repeater__chrome button { padding: 4px 7px; }
|
|
138
|
+
.kurumera-editable-repeater__add {
|
|
139
|
+
display: inline-flex; align-items: center; margin-top: 10px;
|
|
140
|
+
background: #2563eb;
|
|
141
|
+
}
|
|
142
|
+
.kurumera-editable-repeater__add:hover { background: #1d4ed8; }
|
|
143
|
+
.kurumera-editable-repeater__pending { padding: 12px; font: 12px system-ui; color: #6b7280; }
|
|
144
|
+
|
|
145
|
+
/* ── Rich text toolbar ──────────────────────────────────────────────── */
|
|
146
|
+
.kurumera-editable-richtext { position: relative; }
|
|
147
|
+
.kurumera-editable-richtext__toolbar {
|
|
148
|
+
position: absolute; top: 0; right: 0; z-index: 25;
|
|
149
|
+
transform: translateY(-115%);
|
|
150
|
+
display: inline-flex; gap: 4px; padding: 4px;
|
|
151
|
+
border-radius: 8px; background: rgba(17,24,39,.92);
|
|
152
|
+
box-shadow: 0 2px 6px rgba(0,0,0,.3);
|
|
153
|
+
opacity: 0; pointer-events: none; transition: opacity .12s ease;
|
|
154
|
+
}
|
|
155
|
+
.kurumera-editable-richtext:hover .kurumera-editable-richtext__toolbar,
|
|
156
|
+
.kurumera-editable-richtext:focus-within .kurumera-editable-richtext__toolbar { opacity: 1; pointer-events: auto; }
|
|
157
|
+
.kurumera-editable-richtext__toolbar button { background: rgba(255,255,255,.16); min-width: 26px; text-align: center; }
|
|
158
|
+
|
|
159
|
+
/* ── Link / button field ────────────────────────────────────────────── */
|
|
160
|
+
.kurumera-editable-linkfield { position: relative; display: inline-block; }
|
|
161
|
+
.kurumera-editable-linkfield__edit-link {
|
|
162
|
+
position: absolute; top: -8px; right: -8px; z-index: 25;
|
|
163
|
+
padding: 3px 7px;
|
|
164
|
+
opacity: 0; pointer-events: none; transition: opacity .12s ease;
|
|
165
|
+
}
|
|
166
|
+
.kurumera-editable-linkfield:hover .kurumera-editable-linkfield__edit-link,
|
|
167
|
+
.kurumera-editable-linkfield:focus-within .kurumera-editable-linkfield__edit-link { opacity: 1; pointer-events: auto; }
|
|
168
|
+
|
|
169
|
+
/* ── Popover (link href) ────────────────────────────────────────────── */
|
|
170
|
+
.kurumera-editable-linkfield__popover {
|
|
171
|
+
position: absolute; top: calc(100% + 8px); left: 0; z-index: 30;
|
|
172
|
+
display: inline-flex; align-items: center; gap: 6px;
|
|
173
|
+
padding: 8px; border-radius: 8px;
|
|
174
|
+
background: #fff; border: 1px solid #e5e7eb;
|
|
175
|
+
box-shadow: 0 6px 20px rgba(0,0,0,.16);
|
|
176
|
+
white-space: nowrap;
|
|
177
|
+
}
|
|
178
|
+
.kurumera-editable-linkfield__popover input {
|
|
179
|
+
-webkit-appearance: none; appearance: none;
|
|
180
|
+
font: 12px/1.3 system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
181
|
+
color: #111827; background: #fff;
|
|
182
|
+
padding: 6px 8px; margin: 0;
|
|
183
|
+
border: 1px solid #d1d5db; border-radius: 6px;
|
|
184
|
+
min-width: 230px; width: auto; height: auto;
|
|
185
|
+
}
|
|
186
|
+
.kurumera-editable-linkfield__popover input:focus { outline: 2px solid #2563eb; outline-offset: -1px; border-color: #2563eb; }
|
|
187
|
+
|
|
188
|
+
/* ── Media menu (change a picture or a video) ───────────────────────────
|
|
189
|
+
Lives in <body> with fixed coordinates (MediaMenu.tsx), so no theme
|
|
190
|
+
frame can clip it. Every control starts from "all: unset": the rules a
|
|
191
|
+
theme writes for button {} / input {} / p {} must not reach in. */
|
|
192
|
+
.kurumera-media-menu {
|
|
193
|
+
all: unset; box-sizing: border-box;
|
|
194
|
+
position: fixed; z-index: 2147483000;
|
|
195
|
+
display: flex; flex-direction: column; gap: 2px;
|
|
196
|
+
width: 284px; max-width: calc(100vw - 16px);
|
|
197
|
+
padding: 6px;
|
|
198
|
+
border-radius: 14px;
|
|
199
|
+
background: #fff; color: #111827;
|
|
200
|
+
box-shadow: 0 0 0 1px rgba(17,24,39,.08), 0 2px 6px rgba(17,24,39,.08), 0 16px 40px rgba(17,24,39,.2);
|
|
201
|
+
font: 13px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
202
|
+
letter-spacing: 0; text-transform: none; text-align: left;
|
|
203
|
+
transform-origin: top right;
|
|
204
|
+
transition: opacity .14s cubic-bezier(.23,1,.32,1), transform .14s cubic-bezier(.23,1,.32,1);
|
|
205
|
+
}
|
|
206
|
+
.kurumera-media-menu[data-side="above"] { transform-origin: bottom right; }
|
|
207
|
+
@starting-style {
|
|
208
|
+
.kurumera-media-menu { opacity: 0; transform: scale(.96) translateY(-4px); }
|
|
209
|
+
.kurumera-media-menu[data-side="above"] { transform: scale(.96) translateY(4px); }
|
|
210
|
+
}
|
|
211
|
+
.kurumera-media-menu * { box-sizing: border-box; }
|
|
212
|
+
.kurumera-media-menu__title {
|
|
213
|
+
all: unset; display: block;
|
|
214
|
+
padding: 7px 8px 5px;
|
|
215
|
+
font: 600 12px/1.3 system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
216
|
+
color: #6b7280;
|
|
217
|
+
}
|
|
218
|
+
.kurumera-media-menu__item {
|
|
219
|
+
all: unset; box-sizing: border-box;
|
|
220
|
+
display: flex; align-items: center; gap: 10px;
|
|
221
|
+
width: 100%; padding: 8px;
|
|
222
|
+
border-radius: 10px;
|
|
223
|
+
cursor: pointer;
|
|
224
|
+
transition: background-color .12s ease, transform .12s cubic-bezier(.23,1,.32,1);
|
|
225
|
+
}
|
|
226
|
+
@media (hover: hover) and (pointer: fine) {
|
|
227
|
+
.kurumera-media-menu__item:hover:not(:disabled) { background: #f3f4f6; }
|
|
228
|
+
.kurumera-media-menu__item:hover:not(:disabled) .kurumera-media-menu__icon { background: #fff; box-shadow: 0 0 0 1px rgba(17,24,39,.08); }
|
|
229
|
+
.kurumera-media-menu__link button:hover:not(:disabled) { background: #2563eb; }
|
|
230
|
+
}
|
|
231
|
+
.kurumera-media-menu__item:active:not(:disabled) { transform: scale(.985); background: #eceef1; }
|
|
232
|
+
.kurumera-media-menu__item:focus-visible { outline: 2px solid #2563eb; outline-offset: -2px; }
|
|
233
|
+
.kurumera-media-menu__item:disabled { cursor: default; opacity: .55; }
|
|
234
|
+
.kurumera-media-menu__icon {
|
|
235
|
+
flex: none; display: grid; place-items: center;
|
|
236
|
+
width: 36px; height: 36px; border-radius: 9px;
|
|
237
|
+
background: #f3f4f6; color: #111827;
|
|
238
|
+
transition: background-color .12s ease;
|
|
239
|
+
}
|
|
240
|
+
.kurumera-media-menu__text { display: flex; flex-direction: column; min-width: 0; }
|
|
241
|
+
.kurumera-media-menu__name { font: 600 13px/1.3 system-ui, -apple-system, "Segoe UI", sans-serif; color: #111827; }
|
|
242
|
+
.kurumera-media-menu__hint { font: 12px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif; color: #6b7280; }
|
|
243
|
+
.kurumera-media-menu__spinner {
|
|
244
|
+
width: 16px; height: 16px; border-radius: 50%;
|
|
245
|
+
border: 2px solid #d1d5db; border-top-color: #111827;
|
|
246
|
+
animation: kurumera-media-spin .6s linear infinite;
|
|
247
|
+
}
|
|
248
|
+
@keyframes kurumera-media-spin { to { transform: rotate(360deg); } }
|
|
249
|
+
.kurumera-media-menu__link {
|
|
250
|
+
all: unset; display: block;
|
|
251
|
+
margin-top: 4px; padding: 10px 8px 8px;
|
|
252
|
+
border-top: 1px solid #eef0f2;
|
|
253
|
+
}
|
|
254
|
+
.kurumera-media-menu__link label {
|
|
255
|
+
all: unset; display: block; margin-bottom: 6px;
|
|
256
|
+
font: 600 12px/1.3 system-ui, -apple-system, "Segoe UI", sans-serif; color: #6b7280;
|
|
257
|
+
}
|
|
258
|
+
.kurumera-media-menu__linkrow { display: flex; gap: 6px; }
|
|
259
|
+
.kurumera-media-menu__link input {
|
|
260
|
+
all: unset; box-sizing: border-box;
|
|
261
|
+
flex: 1 1 auto; min-width: 0; height: 34px; padding: 0 10px;
|
|
262
|
+
border-radius: 8px; box-shadow: 0 0 0 1px #d1d5db inset;
|
|
263
|
+
background: #fff; color: #111827;
|
|
264
|
+
font: 13px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
265
|
+
cursor: text;
|
|
266
|
+
}
|
|
267
|
+
.kurumera-media-menu__link input::placeholder { color: #9ca3af; }
|
|
268
|
+
.kurumera-media-menu__link input:focus { box-shadow: 0 0 0 2px #2563eb inset; }
|
|
269
|
+
.kurumera-media-menu__link button {
|
|
270
|
+
all: unset; box-sizing: border-box;
|
|
271
|
+
flex: none; height: 34px; padding: 0 12px;
|
|
272
|
+
border-radius: 8px; background: #111827; color: #fff;
|
|
273
|
+
font: 600 12px/34px system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
274
|
+
cursor: pointer; white-space: nowrap;
|
|
275
|
+
transition: background-color .12s ease, transform .12s cubic-bezier(.23,1,.32,1);
|
|
276
|
+
}
|
|
277
|
+
.kurumera-media-menu__link button:active:not(:disabled) { transform: scale(.97); }
|
|
278
|
+
.kurumera-media-menu__link button:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
|
|
279
|
+
.kurumera-media-menu__link button:disabled, .kurumera-media-menu__link input:disabled { opacity: .5; cursor: default; }
|
|
280
|
+
.kurumera-media-menu__error {
|
|
281
|
+
all: unset; display: block;
|
|
282
|
+
margin: 2px; padding: 8px 10px;
|
|
283
|
+
border-radius: 8px; background: #fef3f2; color: #b42318;
|
|
284
|
+
font: 12px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
285
|
+
overflow-wrap: anywhere;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
@media (prefers-reduced-motion: reduce) {
|
|
289
|
+
.kurumera-editable, .kurumera-editable-section__chip, .kurumera-editable-repeater__chrome,
|
|
290
|
+
.kurumera-editable-richtext__toolbar, .kurumera-editable-linkfield__edit-link,
|
|
291
|
+
.kurumera-editable-image__change, .kurumera-editable-video__change, .kurumera-editable-bg__change {
|
|
292
|
+
transition: none;
|
|
293
|
+
}
|
|
294
|
+
/* The menu still fades, but does not move. */
|
|
295
|
+
.kurumera-media-menu { transition: opacity .14s ease; }
|
|
296
|
+
.kurumera-media-menu__item, .kurumera-media-menu__link button { transition: none; }
|
|
297
|
+
}
|
|
183
298
|
`;
|
package/dist/context.js
CHANGED
|
@@ -5,6 +5,7 @@ import dynamic from "next/dynamic";
|
|
|
5
5
|
import { createKurumeraClient } from "@kurumera/storefront";
|
|
6
6
|
import { EditableStore } from "./store.js";
|
|
7
7
|
import { createSaveQueue } from "./save-queue.js";
|
|
8
|
+
import { startMediaHostBridge } from "./media-host.js";
|
|
8
9
|
/** Lazily loaded so the stylesheet never reaches a shopper's bundle — see
|
|
9
10
|
* ChromeStyles.tsx for why this indirection is required, not cosmetic. */
|
|
10
11
|
const ChromeStyles = dynamic(() => import("./ChromeStyles.js"));
|
|
@@ -53,6 +54,9 @@ export function EditableProvider({ mode, editToken, tenant, apiUrl, fields, chil
|
|
|
53
54
|
useEffect(() => {
|
|
54
55
|
if (mode !== "edit")
|
|
55
56
|
return;
|
|
57
|
+
// Says hello to the dashboard that frames this page, so media controls
|
|
58
|
+
// can offer its Media library (see media-host.ts). A no-op unframed.
|
|
59
|
+
startMediaHostBridge();
|
|
56
60
|
const root = document.documentElement;
|
|
57
61
|
root.classList.add("kurumera-edit-mode");
|
|
58
62
|
return () => root.classList.remove("kurumera-edit-mode");
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The editor host bridge: lets a media control inside the edit-mode iframe
|
|
3
|
+
* ask the Kurumera dashboard that frames it to open the store's Media
|
|
4
|
+
* library, and hands back the file the merchant picked.
|
|
5
|
+
*
|
|
6
|
+
* Protocol (all messages carry `v: 1`):
|
|
7
|
+
* iframe → parent kurumera:editor-ready (on start; carries nothing)
|
|
8
|
+
* parent → iframe kurumera:editor-host { media } (the host can pick media)
|
|
9
|
+
* iframe → parent kurumera:media-pick { id, kind } kind: "IMAGE" | "VIDEO"
|
|
10
|
+
* parent → iframe kurumera:media-picked { id, url, alt? } | kurumera:media-cancel { id }
|
|
11
|
+
*
|
|
12
|
+
* Trust: only messages whose `source` is this window's own parent are read,
|
|
13
|
+
* and after the host has introduced itself, only from the origin it spoke
|
|
14
|
+
* from. Requests go to that origin, never "*". A returned URL must be
|
|
15
|
+
* http(s). Nothing secret crosses: the edit token never leaves the URL the
|
|
16
|
+
* dashboard itself put in the iframe.
|
|
17
|
+
*
|
|
18
|
+
* Outside an iframe, or framed by something that never says hello (a theme
|
|
19
|
+
* running under `kurumera theme dev`), `useMediaHost()` stays false and the
|
|
20
|
+
* controls offer only upload and link, as before.
|
|
21
|
+
*/
|
|
22
|
+
export interface PickedMedia {
|
|
23
|
+
url: string;
|
|
24
|
+
alt?: string;
|
|
25
|
+
}
|
|
26
|
+
type Kind = "IMAGE" | "VIDEO";
|
|
27
|
+
/** Called once by <EditableProvider> in edit mode. Safe to call again. */
|
|
28
|
+
export declare function startMediaHostBridge(): void;
|
|
29
|
+
/** true once the framing dashboard has said it can open its Media library. */
|
|
30
|
+
export declare function useMediaHost(): boolean;
|
|
31
|
+
/** Opens the dashboard's Media library; resolves with the pick, or null when
|
|
32
|
+
* the merchant closed it without choosing. */
|
|
33
|
+
export declare function pickFromMediaLibrary(kind: Kind): Promise<PickedMedia | null>;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useSyncExternalStore } from "react";
|
|
3
|
+
let hostOrigin = null;
|
|
4
|
+
let started = false;
|
|
5
|
+
const listeners = new Set();
|
|
6
|
+
const pending = new Map();
|
|
7
|
+
function onMessage(e) {
|
|
8
|
+
if (typeof window === "undefined" || e.source !== window.parent)
|
|
9
|
+
return;
|
|
10
|
+
const d = e.data;
|
|
11
|
+
if (!d || typeof d !== "object" || d.v !== 1 || typeof d.type !== "string")
|
|
12
|
+
return;
|
|
13
|
+
if (d.type === "kurumera:editor-host") {
|
|
14
|
+
const next = d.media === true ? e.origin : null;
|
|
15
|
+
if (next !== hostOrigin) {
|
|
16
|
+
hostOrigin = next;
|
|
17
|
+
listeners.forEach((fn) => fn());
|
|
18
|
+
}
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (!hostOrigin || e.origin !== hostOrigin || typeof d.id !== "string")
|
|
22
|
+
return;
|
|
23
|
+
const done = pending.get(d.id);
|
|
24
|
+
if (!done)
|
|
25
|
+
return;
|
|
26
|
+
if (d.type === "kurumera:media-picked") {
|
|
27
|
+
pending.delete(d.id);
|
|
28
|
+
const url = typeof d.url === "string" && /^https?:\/\//i.test(d.url) ? d.url : "";
|
|
29
|
+
done(url ? { url, alt: typeof d.alt === "string" ? d.alt : undefined } : null);
|
|
30
|
+
}
|
|
31
|
+
else if (d.type === "kurumera:media-cancel") {
|
|
32
|
+
pending.delete(d.id);
|
|
33
|
+
done(null);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Called once by <EditableProvider> in edit mode. Safe to call again. */
|
|
37
|
+
export function startMediaHostBridge() {
|
|
38
|
+
if (started || typeof window === "undefined" || window.parent === window)
|
|
39
|
+
return;
|
|
40
|
+
started = true;
|
|
41
|
+
window.addEventListener("message", onMessage);
|
|
42
|
+
// Says only "I'm here": the host answers with editor-host if it can pick.
|
|
43
|
+
window.parent.postMessage({ type: "kurumera:editor-ready", v: 1 }, "*");
|
|
44
|
+
}
|
|
45
|
+
function subscribe(fn) {
|
|
46
|
+
listeners.add(fn);
|
|
47
|
+
return () => {
|
|
48
|
+
listeners.delete(fn);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** true once the framing dashboard has said it can open its Media library. */
|
|
52
|
+
export function useMediaHost() {
|
|
53
|
+
return useSyncExternalStore(subscribe, () => hostOrigin !== null, () => false);
|
|
54
|
+
}
|
|
55
|
+
/** Opens the dashboard's Media library; resolves with the pick, or null when
|
|
56
|
+
* the merchant closed it without choosing. */
|
|
57
|
+
export function pickFromMediaLibrary(kind) {
|
|
58
|
+
const origin = hostOrigin;
|
|
59
|
+
if (!origin || typeof window === "undefined")
|
|
60
|
+
return Promise.resolve(null);
|
|
61
|
+
const id = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
62
|
+
return new Promise((resolve) => {
|
|
63
|
+
pending.set(id, resolve);
|
|
64
|
+
window.parent.postMessage({ type: "kurumera:media-pick", v: 1, id, kind }, origin);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
@@ -1,32 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useRef, useState } from "react";
|
|
4
3
|
import { useEditableField } from "../useEditableField.js";
|
|
5
|
-
import { useEditableContext } from "../context.js";
|
|
6
4
|
import { editableClassName } from "../chrome.js";
|
|
5
|
+
import { MediaChange } from "./MediaChange.js";
|
|
7
6
|
export function EditableBackgroundImageClient({ field, defaultSrc, as, className, children }) {
|
|
8
7
|
const { value, setValue, status, retry } = useEditableField(field, defaultSrc, { type: "image" });
|
|
9
|
-
const { uploadMedia } = useEditableContext();
|
|
10
|
-
const inputRef = useRef(null);
|
|
11
|
-
const [uploading, setUploading] = useState(false);
|
|
12
8
|
const As = as;
|
|
13
|
-
|
|
14
|
-
const file = e.target.files?.[0];
|
|
15
|
-
e.target.value = "";
|
|
16
|
-
if (!file)
|
|
17
|
-
return;
|
|
18
|
-
setUploading(true);
|
|
19
|
-
try {
|
|
20
|
-
const uploaded = await uploadMedia(file, file.name);
|
|
21
|
-
if (uploaded.url)
|
|
22
|
-
setValue(uploaded.url);
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
// nothing was set — the merchant can just try again
|
|
26
|
-
}
|
|
27
|
-
finally {
|
|
28
|
-
setUploading(false);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return (_jsxs(As, { className: `kurumera-editable-bg ${editableClassName(className, status)}`, style: { backgroundImage: `url(${value})`, position: "relative" }, "data-kurumera-field": field, title: status === "error" ? "Couldn't save — click to retry" : undefined, children: [children, _jsx("button", { type: "button", className: "kurumera-editable-bg__change", contentEditable: false, onClick: () => (status === "error" ? retry() : inputRef.current?.click()), disabled: uploading, children: uploading ? "Uploading…" : status === "error" ? "Retry save" : "Change background" }), _jsx("input", { ref: inputRef, type: "file", accept: "image/*", hidden: true, onChange: handleFile })] }));
|
|
9
|
+
return (_jsxs(As, { className: `kurumera-editable-bg ${editableClassName(className, status)}`, style: { backgroundImage: `url(${value})`, position: "relative" }, "data-kurumera-field": field, title: status === "error" ? "Couldn't save — click to retry" : undefined, children: [children, _jsx(MediaChange, { kind: "IMAGE", label: "Change background", className: "kurumera-editable-bg__change", onPicked: (src) => setValue(src), saveFailed: status === "error", onRetrySave: retry })] }));
|
|
32
10
|
}
|
|
@@ -1,34 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useRef, useState } from "react";
|
|
4
3
|
import { useEditableField } from "../useEditableField.js";
|
|
5
|
-
import { useEditableContext } from "../context.js";
|
|
6
4
|
import { editableClassName } from "../chrome.js";
|
|
5
|
+
import { MediaChange } from "./MediaChange.js";
|
|
7
6
|
export function EditableImageClient({ field, defaultSrc, defaultAlt, className, width, height, sizes }) {
|
|
8
7
|
const defaultValue = { src: defaultSrc, alt: defaultAlt ?? "" };
|
|
9
8
|
const { value, setValue, status, retry } = useEditableField(field, defaultValue, { type: "image" });
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const file = e.target.files?.[0];
|
|
15
|
-
e.target.value = "";
|
|
16
|
-
if (!file)
|
|
17
|
-
return;
|
|
18
|
-
setUploading(true);
|
|
19
|
-
try {
|
|
20
|
-
const uploaded = await uploadMedia(file, file.name);
|
|
21
|
-
if (uploaded.url)
|
|
22
|
-
setValue({ src: uploaded.url, alt: value.alt });
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
// uploadMedia's own errors surface via a rejected promise only — the
|
|
26
|
-
// field's save status is untouched (nothing was set), so just let the
|
|
27
|
-
// merchant try again; no partial/broken state is left behind.
|
|
28
|
-
}
|
|
29
|
-
finally {
|
|
30
|
-
setUploading(false);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return (_jsxs("span", { className: "kurumera-editable-image", style: { position: "relative", display: "inline-block" }, children: [_jsx("img", { src: value.src, alt: value.alt, className: editableClassName(className, status), width: width, height: height, sizes: sizes, "data-kurumera-field": field, title: status === "error" ? "Couldn't save — click to retry" : undefined, onClick: status === "error" ? () => retry() : undefined }), _jsx("button", { type: "button", className: "kurumera-editable-image__change", onClick: () => inputRef.current?.click(), disabled: uploading, children: uploading ? "Uploading…" : "Change image" }), _jsx("input", { ref: inputRef, type: "file", accept: "image/*", hidden: true, onChange: handleFile })] }));
|
|
9
|
+
return (_jsxs("span", { className: "kurumera-editable-image", style: { position: "relative", display: "inline-block" }, children: [_jsx("img", { src: value.src, alt: value.alt, className: editableClassName(className, status), width: width, height: height, sizes: sizes, "data-kurumera-field": field, title: status === "error" ? "Couldn't save — click to retry" : undefined, onClick: status === "error" ? () => retry() : undefined }), _jsx(MediaChange, { kind: "IMAGE", label: "Change image", className: "kurumera-editable-image__change",
|
|
10
|
+
// A picture from Media brings its own alt text; an upload keeps the
|
|
11
|
+
// one already written for this spot.
|
|
12
|
+
onPicked: (src, alt) => setValue({ src, alt: alt || value.alt }) })] }));
|
|
34
13
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { resolveEditableContent } from "../server/resolve.js";
|
|
3
3
|
import { EditableVideoClient } from "./EditableVideoClient.js";
|
|
4
|
-
import { toEmbedSrc } from "./videoField.js";
|
|
4
|
+
import { posterFor, toEmbedSrc } from "./videoField.js";
|
|
5
5
|
function resolveValue(raw, defaults) {
|
|
6
6
|
if (raw && typeof raw === "object" && "src" in raw) {
|
|
7
7
|
const v = raw;
|
|
@@ -21,12 +21,16 @@ function resolveValue(raw, defaults) {
|
|
|
21
21
|
*/
|
|
22
22
|
export async function EditableVideo({ field, defaultSrc, defaultPoster, defaultProvider = "file", className, autoPlay, loop, muted, controls = true, }) {
|
|
23
23
|
const { mode, fields } = await resolveEditableContent();
|
|
24
|
-
const
|
|
24
|
+
const defaults = { src: defaultSrc, poster: defaultPoster, provider: defaultProvider };
|
|
25
|
+
const value = resolveValue(fields[field]?.value, defaults);
|
|
25
26
|
if (mode !== "edit") {
|
|
26
27
|
if (value.provider === "file") {
|
|
27
|
-
return (_jsx("video", { src: value.src, poster: value
|
|
28
|
+
return (_jsx("video", { src: value.src, poster: posterFor(value, defaults),
|
|
29
|
+
// Without a poster the first frame is what shows, and the frame
|
|
30
|
+
// takes the film's shape from its metadata before anyone presses play.
|
|
31
|
+
preload: "metadata", className: className, autoPlay: autoPlay, loop: loop, muted: muted, controls: controls, playsInline: true }));
|
|
28
32
|
}
|
|
29
33
|
return (_jsx("iframe", { src: toEmbedSrc(value.provider, value.src), className: className, title: "Video", allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture", allowFullScreen: true }));
|
|
30
34
|
}
|
|
31
|
-
return (_jsx(EditableVideoClient, { field: field, defaultValue:
|
|
35
|
+
return (_jsx(EditableVideoClient, { field: field, defaultValue: defaults, className: className, autoPlay: autoPlay, loop: loop, muted: muted, controls: controls }));
|
|
32
36
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useRef, useState } from "react";
|
|
4
3
|
import { useEditableField } from "../useEditableField.js";
|
|
5
|
-
import { useEditableContext } from "../context.js";
|
|
6
4
|
import { editableClassName } from "../chrome.js";
|
|
7
|
-
import {
|
|
5
|
+
import { MediaChange } from "./MediaChange.js";
|
|
6
|
+
import { posterFor, toEmbedSrc } from "./videoField.js";
|
|
8
7
|
function detectProvider(src) {
|
|
9
8
|
if (/youtu\.?be/.test(src))
|
|
10
9
|
return "youtube";
|
|
@@ -14,35 +13,13 @@ function detectProvider(src) {
|
|
|
14
13
|
}
|
|
15
14
|
export function EditableVideoClient({ field, defaultValue, className, autoPlay, loop, muted, controls = true }) {
|
|
16
15
|
const { value, setValue, status, retry } = useEditableField(field, defaultValue, { type: "video" });
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return;
|
|
27
|
-
setUploading(true);
|
|
28
|
-
try {
|
|
29
|
-
const uploaded = await uploadMedia(file, file.name, { contentType: "VIDEO" });
|
|
30
|
-
if (uploaded.url)
|
|
31
|
-
setValue({ src: uploaded.url, poster: value.poster, provider: "file" });
|
|
32
|
-
setEditing(false);
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
// merchant can retry from the still-open popover; nothing was set
|
|
36
|
-
}
|
|
37
|
-
finally {
|
|
38
|
-
setUploading(false);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function commitUrl() {
|
|
42
|
-
const next = urlInputRef.current?.value?.trim();
|
|
43
|
-
if (next)
|
|
44
|
-
setValue({ src: next, poster: value.poster, provider: detectProvider(next) });
|
|
45
|
-
setEditing(false);
|
|
46
|
-
}
|
|
47
|
-
return (_jsxs("span", { className: "kurumera-editable-video", style: { position: "relative", display: "inline-block" }, children: [value.provider === "file" ? (_jsx("video", { src: value.src, poster: value.poster, className: editableClassName(className, status), autoPlay: autoPlay, loop: loop, muted: muted, controls: controls, playsInline: true, "data-kurumera-field": field, title: status === "error" ? "Couldn't save — click to retry" : undefined, onClick: status === "error" ? () => retry() : undefined })) : (_jsx("iframe", { src: toEmbedSrc(value.provider, value.src), className: editableClassName(className, status), title: "Video", allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture", allowFullScreen: true, "data-kurumera-field": field })), _jsx("button", { type: "button", className: "kurumera-editable-video__change", onClick: () => setEditing((v) => !v), children: "Change video" }), editing ? (_jsxs("span", { className: "kurumera-editable-video__popover", children: [_jsx("input", { ref: urlInputRef, type: "text", defaultValue: value.provider !== "file" ? value.src : "", placeholder: "YouTube / Vimeo URL\u2026" }), _jsx("button", { type: "button", onClick: commitUrl, children: "Use URL" }), _jsx("span", { className: "kurumera-editable-video__popover-or", children: "or" }), _jsx("button", { type: "button", onClick: () => fileInputRef.current?.click(), disabled: uploading, children: uploading ? "Uploading…" : "Upload file" }), _jsx("input", { ref: fileInputRef, type: "file", accept: "video/mp4,video/webm,video/quicktime", hidden: true, onChange: handleFile })] })) : null] }));
|
|
16
|
+
// A new video never keeps the old one's poster: the theme's placeholder
|
|
17
|
+
// poster sat over the merchant's own film until it was played. "" (not
|
|
18
|
+
// undefined) so the saved value says "no poster" and the theme's default
|
|
19
|
+
// is not put back.
|
|
20
|
+
const use = (src, provider) => setValue({ src, poster: "", provider });
|
|
21
|
+
return (_jsxs("span", { className: "kurumera-editable-video", style: { position: "relative", display: "inline-block" }, children: [value.provider === "file" ? (_jsx("video", { src: value.src, poster: posterFor(value, defaultValue), preload: "metadata", className: editableClassName(className, status), autoPlay: autoPlay, loop: loop, muted: muted, controls: controls, playsInline: true, "data-kurumera-field": field, title: status === "error" ? "Couldn't save — click to retry" : undefined, onClick: status === "error" ? () => retry() : undefined })) : (_jsx("iframe", { src: toEmbedSrc(value.provider, value.src), className: editableClassName(className, status), title: "Video", allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture", allowFullScreen: true, "data-kurumera-field": field })), _jsx(MediaChange, { kind: "VIDEO", label: "Change video", className: "kurumera-editable-video__change", onPicked: (src) => use(src, "file"), link: {
|
|
22
|
+
value: value.provider !== "file" ? value.src : "",
|
|
23
|
+
onCommit: (src) => use(src, detectProvider(src)),
|
|
24
|
+
} })] }));
|
|
48
25
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type MediaKind = "IMAGE" | "VIDEO";
|
|
2
|
+
export interface MediaChangeProps {
|
|
3
|
+
kind: MediaKind;
|
|
4
|
+
/** "Change image" / "Change video" / "Change background". */
|
|
5
|
+
label: string;
|
|
6
|
+
/** The primitive's own trigger class (positioning lives in chrome-css). */
|
|
7
|
+
className: string;
|
|
8
|
+
/** A file was chosen: uploaded from the computer, or picked in Media. */
|
|
9
|
+
onPicked: (url: string, alt?: string) => void;
|
|
10
|
+
/** Video only: the YouTube / Vimeo link path. */
|
|
11
|
+
link?: {
|
|
12
|
+
value: string;
|
|
13
|
+
onCommit: (url: string) => void;
|
|
14
|
+
};
|
|
15
|
+
/** The field's last save failed: the trigger becomes "Retry save". */
|
|
16
|
+
saveFailed?: boolean;
|
|
17
|
+
onRetrySave?: () => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The one "change this picture / video" control every media primitive uses.
|
|
21
|
+
*
|
|
22
|
+
* Inside the Kurumera dashboard it opens a small menu: choose from the
|
|
23
|
+
* store's Media library, or upload from the computer (and, for a video, use
|
|
24
|
+
* a YouTube / Vimeo link). Where no dashboard is listening (`kurumera theme
|
|
25
|
+
* dev`) a picture goes straight to the file dialog, as it always did.
|
|
26
|
+
*/
|
|
27
|
+
export declare function MediaChange({ kind, label, className, onPicked, link, saveFailed, onRetrySave }: MediaChangeProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
import dynamic from "next/dynamic";
|
|
5
|
+
import { useEditableContext } from "../context.js";
|
|
6
|
+
import { pickFromMediaLibrary, useMediaHost } from "../media-host.js";
|
|
7
|
+
/** The menu itself (markup, positioning, icons) is fetched on first open, so
|
|
8
|
+
* none of it sits in a shopper's bundle: only this small trigger does. */
|
|
9
|
+
const MediaMenu = dynamic(() => import("./MediaMenu.js"), { ssr: false });
|
|
10
|
+
const ACCEPT = {
|
|
11
|
+
IMAGE: "image/*",
|
|
12
|
+
VIDEO: "video/mp4,video/webm,video/quicktime",
|
|
13
|
+
};
|
|
14
|
+
/** What went wrong, in the server's own words when it gave any. */
|
|
15
|
+
function reason(e) {
|
|
16
|
+
const any = e;
|
|
17
|
+
const said = any?.body?.error ?? any?.body?.detail ?? any?.message;
|
|
18
|
+
// The browser's own words for a dropped connection ("Failed to fetch",
|
|
19
|
+
// "NetworkError when attempting…", "Load failed") mean nothing to a merchant.
|
|
20
|
+
if (typeof said === "string" && /failed to fetch|networkerror|load failed/i.test(said)) {
|
|
21
|
+
return "the connection dropped. Check it and try again.";
|
|
22
|
+
}
|
|
23
|
+
return typeof said === "string" && said.trim() ? said.trim().slice(0, 180) : "The upload did not go through.";
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The one "change this picture / video" control every media primitive uses.
|
|
27
|
+
*
|
|
28
|
+
* Inside the Kurumera dashboard it opens a small menu: choose from the
|
|
29
|
+
* store's Media library, or upload from the computer (and, for a video, use
|
|
30
|
+
* a YouTube / Vimeo link). Where no dashboard is listening (`kurumera theme
|
|
31
|
+
* dev`) a picture goes straight to the file dialog, as it always did.
|
|
32
|
+
*/
|
|
33
|
+
export function MediaChange({ kind, label, className, onPicked, link, saveFailed, onRetrySave }) {
|
|
34
|
+
const { uploadMedia } = useEditableContext();
|
|
35
|
+
const canLibrary = useMediaHost();
|
|
36
|
+
const buttonRef = useRef(null);
|
|
37
|
+
const inputRef = useRef(null);
|
|
38
|
+
const [open, setOpen] = useState(false);
|
|
39
|
+
const [busy, setBusy] = useState(null);
|
|
40
|
+
const [error, setError] = useState("");
|
|
41
|
+
const hasMenu = canLibrary || !!link;
|
|
42
|
+
async function handleFile(e) {
|
|
43
|
+
const file = e.target.files?.[0];
|
|
44
|
+
e.target.value = "";
|
|
45
|
+
if (!file)
|
|
46
|
+
return;
|
|
47
|
+
setBusy("upload");
|
|
48
|
+
setError("");
|
|
49
|
+
try {
|
|
50
|
+
const uploaded = await uploadMedia(file, file.name, kind === "VIDEO" ? { contentType: "VIDEO" } : undefined);
|
|
51
|
+
if (!uploaded.url)
|
|
52
|
+
throw new Error("The upload finished without a file address.");
|
|
53
|
+
onPicked(uploaded.url);
|
|
54
|
+
setOpen(false);
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
// Nothing was set, so no broken state is left behind: say why, and
|
|
58
|
+
// leave the menu open to try again.
|
|
59
|
+
setError(reason(err));
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
setBusy(null);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async function chooseFromLibrary() {
|
|
66
|
+
setBusy("library");
|
|
67
|
+
setError("");
|
|
68
|
+
const picked = await pickFromMediaLibrary(kind);
|
|
69
|
+
setBusy(null);
|
|
70
|
+
if (!picked)
|
|
71
|
+
return;
|
|
72
|
+
onPicked(picked.url, picked.alt);
|
|
73
|
+
setOpen(false);
|
|
74
|
+
}
|
|
75
|
+
function onTrigger() {
|
|
76
|
+
if (saveFailed && onRetrySave)
|
|
77
|
+
return onRetrySave();
|
|
78
|
+
if (!hasMenu)
|
|
79
|
+
return inputRef.current?.click();
|
|
80
|
+
setOpen((v) => !v);
|
|
81
|
+
}
|
|
82
|
+
const text = saveFailed
|
|
83
|
+
? "Retry save"
|
|
84
|
+
: busy === "upload"
|
|
85
|
+
? "Uploading…"
|
|
86
|
+
: error && !open
|
|
87
|
+
? "Couldn’t upload. Try again"
|
|
88
|
+
: label;
|
|
89
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { ref: buttonRef, type: "button", className: `kurumera-editable-media__change ${className}${open ? " is-open" : ""}${error && !open ? " is-error" : ""}`, contentEditable: false, "aria-haspopup": hasMenu ? "dialog" : undefined, "aria-expanded": hasMenu ? open : undefined, title: error && !open ? error : undefined, onClick: onTrigger, disabled: busy === "upload" && !open, children: [_jsx("svg", { viewBox: "0 0 16 16", width: "13", height: "13", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "M2.5 6.5a5.5 5.5 0 0 1 9.6-2.9L13.5 5M13.5 2v3h-3M13.5 9.5a5.5 5.5 0 0 1-9.6 2.9L2.5 11M2.5 14v-3h3" }) }), text] }), _jsx("input", { ref: inputRef, type: "file", accept: ACCEPT[kind], hidden: true, onChange: handleFile }), open && buttonRef.current ? (_jsx(MediaMenu, { anchor: buttonRef.current, kind: kind, title: label, canLibrary: canLibrary, busy: busy, error: error, link: link, onLibrary: chooseFromLibrary, onUpload: () => inputRef.current?.click(), onLink: (url) => {
|
|
90
|
+
link?.onCommit(url);
|
|
91
|
+
setOpen(false);
|
|
92
|
+
}, onClose: () => setOpen(false) })) : null] }));
|
|
93
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { MediaKind } from "./MediaChange.js";
|
|
2
|
+
export interface MediaMenuProps {
|
|
3
|
+
anchor: HTMLElement;
|
|
4
|
+
kind: MediaKind;
|
|
5
|
+
title: string;
|
|
6
|
+
canLibrary: boolean;
|
|
7
|
+
busy: null | "upload" | "library";
|
|
8
|
+
error: string;
|
|
9
|
+
link?: {
|
|
10
|
+
value: string;
|
|
11
|
+
onCommit: (url: string) => void;
|
|
12
|
+
};
|
|
13
|
+
onLibrary: () => void;
|
|
14
|
+
onUpload: () => void;
|
|
15
|
+
onLink: (url: string) => void;
|
|
16
|
+
onClose: () => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The "change this picture / video" menu. Rendered into <body> and placed
|
|
20
|
+
* with fixed coordinates from its trigger, never inside the media element:
|
|
21
|
+
* themes clip their media frames (overflow: hidden), and a popover placed in
|
|
22
|
+
* one was cut off entirely (Amber Zia's brand film, 30 Nov 2026).
|
|
23
|
+
*/
|
|
24
|
+
export default function MediaMenu({ anchor, kind, title, canLibrary, busy, error, link, onLibrary, onUpload, onLink, onClose }: MediaMenuProps): import("react").ReactPortal;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
const NOUN = {
|
|
6
|
+
IMAGE: { many: "Pictures", files: "JPG, PNG, WebP or GIF" },
|
|
7
|
+
VIDEO: { many: "Videos", files: "MP4, WebM or MOV" },
|
|
8
|
+
};
|
|
9
|
+
function Icon({ children }) {
|
|
10
|
+
return (_jsx("svg", { viewBox: "0 0 20 20", width: "18", height: "18", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: children }));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The "change this picture / video" menu. Rendered into <body> and placed
|
|
14
|
+
* with fixed coordinates from its trigger, never inside the media element:
|
|
15
|
+
* themes clip their media frames (overflow: hidden), and a popover placed in
|
|
16
|
+
* one was cut off entirely (Amber Zia's brand film, 30 Nov 2026).
|
|
17
|
+
*/
|
|
18
|
+
export default function MediaMenu({ anchor, kind, title, canLibrary, busy, error, link, onLibrary, onUpload, onLink, onClose }) {
|
|
19
|
+
const ref = useRef(null);
|
|
20
|
+
const linkId = useId();
|
|
21
|
+
const [pos, setPos] = useState(null);
|
|
22
|
+
const [linkError, setLinkError] = useState("");
|
|
23
|
+
const noun = NOUN[kind];
|
|
24
|
+
// Under the trigger, right edges aligned; above it when there is no room
|
|
25
|
+
// below; always inside the viewport. Re-placed when its own height changes
|
|
26
|
+
// (an error line, the uploading note) and while the page scrolls.
|
|
27
|
+
useLayoutEffect(() => {
|
|
28
|
+
function place() {
|
|
29
|
+
const el = ref.current;
|
|
30
|
+
if (!el)
|
|
31
|
+
return;
|
|
32
|
+
const a = anchor.getBoundingClientRect();
|
|
33
|
+
const w = el.offsetWidth;
|
|
34
|
+
const h = el.offsetHeight;
|
|
35
|
+
const edge = 8;
|
|
36
|
+
const left = Math.min(Math.max(a.right - w, edge), Math.max(edge, window.innerWidth - w - edge));
|
|
37
|
+
const below = a.bottom + 6;
|
|
38
|
+
const above = a.top - 6 - h;
|
|
39
|
+
const side = below + h <= window.innerHeight - edge || above < edge ? "below" : "above";
|
|
40
|
+
setPos({ top: side === "below" ? below : above, left, side });
|
|
41
|
+
}
|
|
42
|
+
place();
|
|
43
|
+
window.addEventListener("scroll", place, true);
|
|
44
|
+
window.addEventListener("resize", place);
|
|
45
|
+
return () => {
|
|
46
|
+
window.removeEventListener("scroll", place, true);
|
|
47
|
+
window.removeEventListener("resize", place);
|
|
48
|
+
};
|
|
49
|
+
}, [anchor, busy, error, linkError]);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
ref.current?.querySelector("button:not(:disabled)")?.focus({ preventScroll: true });
|
|
52
|
+
}, []);
|
|
53
|
+
// Outside press and Escape close it, but not mid-upload: the file is on
|
|
54
|
+
// its way and its result has to land somewhere the merchant can see.
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
function onDown(e) {
|
|
57
|
+
const t = e.target;
|
|
58
|
+
if (busy === "upload" || ref.current?.contains(t) || anchor.contains(t))
|
|
59
|
+
return;
|
|
60
|
+
onClose();
|
|
61
|
+
}
|
|
62
|
+
function onKey(e) {
|
|
63
|
+
if (e.key !== "Escape" || busy === "upload")
|
|
64
|
+
return;
|
|
65
|
+
e.stopPropagation();
|
|
66
|
+
onClose();
|
|
67
|
+
anchor.focus({ preventScroll: true });
|
|
68
|
+
}
|
|
69
|
+
document.addEventListener("pointerdown", onDown, true);
|
|
70
|
+
document.addEventListener("keydown", onKey, true);
|
|
71
|
+
return () => {
|
|
72
|
+
document.removeEventListener("pointerdown", onDown, true);
|
|
73
|
+
document.removeEventListener("keydown", onKey, true);
|
|
74
|
+
};
|
|
75
|
+
}, [anchor, busy, onClose]);
|
|
76
|
+
function submitLink(e) {
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
const url = String(new FormData(e.currentTarget).get("url") ?? "").trim();
|
|
79
|
+
if (!/^https?:\/\/\S+\.\S+/i.test(url)) {
|
|
80
|
+
setLinkError("Paste the full link, starting with https://");
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
onLink(url);
|
|
84
|
+
}
|
|
85
|
+
const shown = error || linkError;
|
|
86
|
+
return createPortal(_jsxs("div", { ref: ref, className: "kurumera-media-menu", role: "dialog", "aria-label": title, "data-side": pos?.side ?? "below", style: pos ? { top: pos.top, left: pos.left } : { top: 0, left: 0, visibility: "hidden" }, children: [_jsx("p", { className: "kurumera-media-menu__title", children: title }), canLibrary ? (_jsxs("button", { type: "button", className: "kurumera-media-menu__item", onClick: onLibrary, disabled: busy !== null, children: [_jsx("span", { className: "kurumera-media-menu__icon", children: _jsxs(Icon, { children: [_jsx("rect", { x: "2.5", y: "3.5", width: "15", height: "13", rx: "2" }), _jsx("path", { d: "m2.5 13 4-4 3.5 3.5 2.5-2.5 5 5" }), _jsx("circle", { cx: "13", cy: "7.5", r: "1.2" })] }) }), _jsxs("span", { className: "kurumera-media-menu__text", children: [_jsx("span", { className: "kurumera-media-menu__name", children: "Choose from Media" }), _jsx("span", { className: "kurumera-media-menu__hint", children: busy === "library" ? "Pick one in the window that opened" : `${noun.many} already in your store` })] })] })) : null, _jsxs("button", { type: "button", className: "kurumera-media-menu__item", onClick: onUpload, disabled: busy !== null, children: [_jsx("span", { className: "kurumera-media-menu__icon", children: busy === "upload" ? (_jsx("span", { className: "kurumera-media-menu__spinner", "aria-hidden": "true" })) : (_jsx(Icon, { children: _jsx("path", { d: "M10 13V3.5M6.5 7 10 3.5 13.5 7M3.5 12.5v2a2 2 0 0 0 2 2h9a2 2 0 0 0 2-2v-2" }) })) }), _jsxs("span", { className: "kurumera-media-menu__text", children: [_jsx("span", { className: "kurumera-media-menu__name", children: busy === "upload" ? "Uploading…" : "Upload from computer" }), _jsx("span", { className: "kurumera-media-menu__hint", children: busy === "upload" ? "Keep this page open until it finishes" : noun.files })] })] }), link ? (_jsxs("form", { className: "kurumera-media-menu__link", onSubmit: submitLink, noValidate: true, children: [_jsx("label", { htmlFor: linkId, children: "Or use a YouTube or Vimeo link" }), _jsxs("span", { className: "kurumera-media-menu__linkrow", children: [_jsx("input", { id: linkId, name: "url", type: "url", inputMode: "url", autoComplete: "off", spellCheck: false, placeholder: "https://youtu.be/\u2026", defaultValue: link.value, onInput: () => linkError && setLinkError(""), disabled: busy !== null }), _jsx("button", { type: "submit", disabled: busy !== null, children: "Use link" })] })] })) : null, shown ? (_jsx("p", { className: "kurumera-media-menu__error", role: "alert", children: error ? `Couldn’t upload: ${error}` : linkError })) : null] }), document.body);
|
|
87
|
+
}
|
|
@@ -15,5 +15,17 @@ export interface EditableVideoValue {
|
|
|
15
15
|
poster?: string;
|
|
16
16
|
provider: VideoProvider;
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* The poster to show, or undefined for none.
|
|
20
|
+
*
|
|
21
|
+
* Up to 0.5.1 a merchant's new video kept the poster already on the field,
|
|
22
|
+
* which was usually the theme's sample poster. Saved values still carry it.
|
|
23
|
+
* A browser sizes a <video> by its poster until it plays, so a wide sample
|
|
24
|
+
* card framed a portrait film, and the frame jumped to the film's real
|
|
25
|
+
* shape on play (Amber Zia's brand film, 1 Dec 2026). The theme's own
|
|
26
|
+
* poster on a film that is not the theme's own film is that leftover:
|
|
27
|
+
* show the film's first frame instead.
|
|
28
|
+
*/
|
|
29
|
+
export declare function posterFor(value: EditableVideoValue, defaults: EditableVideoValue): string | undefined;
|
|
18
30
|
/** Resolves a merchant-pasted URL (or bare id) to an embeddable iframe src. */
|
|
19
31
|
export declare function toEmbedSrc(provider: "youtube" | "vimeo", src: string): string;
|
|
@@ -6,6 +6,24 @@ function extractVimeoId(src) {
|
|
|
6
6
|
const m = /vimeo\.com\/(?:video\/)?(\d+)/.exec(src);
|
|
7
7
|
return m ? m[1] : null;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* The poster to show, or undefined for none.
|
|
11
|
+
*
|
|
12
|
+
* Up to 0.5.1 a merchant's new video kept the poster already on the field,
|
|
13
|
+
* which was usually the theme's sample poster. Saved values still carry it.
|
|
14
|
+
* A browser sizes a <video> by its poster until it plays, so a wide sample
|
|
15
|
+
* card framed a portrait film, and the frame jumped to the film's real
|
|
16
|
+
* shape on play (Amber Zia's brand film, 1 Dec 2026). The theme's own
|
|
17
|
+
* poster on a film that is not the theme's own film is that leftover:
|
|
18
|
+
* show the film's first frame instead.
|
|
19
|
+
*/
|
|
20
|
+
export function posterFor(value, defaults) {
|
|
21
|
+
if (!value.poster)
|
|
22
|
+
return undefined;
|
|
23
|
+
if (value.poster === defaults.poster && value.src !== defaults.src)
|
|
24
|
+
return undefined;
|
|
25
|
+
return value.poster;
|
|
26
|
+
}
|
|
9
27
|
/** Resolves a merchant-pasted URL (or bare id) to an embeddable iframe src. */
|
|
10
28
|
export function toEmbedSrc(provider, src) {
|
|
11
29
|
if (provider === "youtube") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kurumera/editable",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Kurumera Editable Components — inline, draft/publish, no-rebuild content editing for code themes.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"react-dom": "^19.0.0"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@kurumera/storefront": "
|
|
40
|
+
"@kurumera/storefront": ">=0.9.0 <1.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/react": "^19.0.0",
|