@kurumera/editable 0.3.1 → 0.5.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 +17 -0
- package/dist/ChromeStyles.d.ts +13 -0
- package/dist/ChromeStyles.js +18 -0
- package/dist/chrome-css.d.ts +15 -0
- package/dist/chrome-css.js +183 -0
- package/dist/context.js +16 -3
- package/dist/primitives/EditableBackgroundImageClient.js +1 -1
- package/dist/server/resolve.js +8 -0
- package/package.json +21 -7
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @kurumera/editable — changelog
|
|
2
|
+
|
|
3
|
+
## 0.5.0 — 2026-10-16
|
|
4
|
+
|
|
5
|
+
`resolveEditableContent()` now forwards the visitor's `x-forwarded-for` and
|
|
6
|
+
`cf-connecting-ip`, as received, on its platform call — the same change as
|
|
7
|
+
`@kurumera/storefront` 0.9.0's `forwardHeaders`.
|
|
8
|
+
|
|
9
|
+
It runs from the root layout on every page, and it never throws by design, so a
|
|
10
|
+
call the platform throttled did not fail the page: it quietly rendered without
|
|
11
|
+
the merchant's edited content. Without the visitor's address every page view on
|
|
12
|
+
a server looked like one visitor, and a single crawler was enough to cause that.
|
|
13
|
+
|
|
14
|
+
**Dependency change:** `@kurumera/storefront` is now `^0.9.0`, was `^0.3.0`. The
|
|
15
|
+
old range made every theme install a separate nested 0.3.x copy of the SDK just
|
|
16
|
+
for this package; with it, the forwarding above would have been silently
|
|
17
|
+
ignored. Update both packages together.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The editor chrome stylesheet, isolated in its own module with a DEFAULT
|
|
3
|
+
* export so <EditableProvider> can pull it in via `next/dynamic`.
|
|
4
|
+
*
|
|
5
|
+
* That indirection is load-bearing, not ceremony: importing CHROME_CSS
|
|
6
|
+
* directly into the provider put the whole stylesheet string in the shared
|
|
7
|
+
* client bundle, so every shopper downloaded ~3 kB of editor CSS they can
|
|
8
|
+
* never use. `next/dynamic` inside a Client Component IS code-split (unlike
|
|
9
|
+
* a Server Component dynamically importing a Client Component, which Next
|
|
10
|
+
* explicitly does not split) — so this chunk is fetched only when a merchant
|
|
11
|
+
* actually opens edit mode.
|
|
12
|
+
*/
|
|
13
|
+
export default function ChromeStyles(): import("react").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { CHROME_CSS } from "./chrome-css.js";
|
|
4
|
+
/**
|
|
5
|
+
* The editor chrome stylesheet, isolated in its own module with a DEFAULT
|
|
6
|
+
* export so <EditableProvider> can pull it in via `next/dynamic`.
|
|
7
|
+
*
|
|
8
|
+
* That indirection is load-bearing, not ceremony: importing CHROME_CSS
|
|
9
|
+
* directly into the provider put the whole stylesheet string in the shared
|
|
10
|
+
* client bundle, so every shopper downloaded ~3 kB of editor CSS they can
|
|
11
|
+
* never use. `next/dynamic` inside a Client Component IS code-split (unlike
|
|
12
|
+
* a Server Component dynamically importing a Client Component, which Next
|
|
13
|
+
* explicitly does not split) — so this chunk is fetched only when a merchant
|
|
14
|
+
* actually opens edit mode.
|
|
15
|
+
*/
|
|
16
|
+
export default function ChromeStyles() {
|
|
17
|
+
return _jsx("style", { dangerouslySetInnerHTML: { __html: CHROME_CSS } });
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor chrome styles, injected by <EditableProvider> ONLY in edit mode.
|
|
3
|
+
*
|
|
4
|
+
* Shipping this as a real .css file would force every theme to remember an
|
|
5
|
+
* import (and silently render raw browser buttons if they forgot). Injecting
|
|
6
|
+
* it from the provider means it costs a shopper nothing — the provider bails
|
|
7
|
+
* out of rendering it entirely when mode !== "edit" — and a theme dev has
|
|
8
|
+
* zero setup.
|
|
9
|
+
*
|
|
10
|
+
* Every rule is namespaced under `.kurumera-editable*` and every control
|
|
11
|
+
* resets the properties a host theme's own `button {}` / `input {}` rules
|
|
12
|
+
* would otherwise leak in. The theme's own design must look untouched;
|
|
13
|
+
* only the controls we add are ours to style.
|
|
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";
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor chrome styles, injected by <EditableProvider> ONLY in edit mode.
|
|
3
|
+
*
|
|
4
|
+
* Shipping this as a real .css file would force every theme to remember an
|
|
5
|
+
* import (and silently render raw browser buttons if they forgot). Injecting
|
|
6
|
+
* it from the provider means it costs a shopper nothing — the provider bails
|
|
7
|
+
* out of rendering it entirely when mode !== "edit" — and a theme dev has
|
|
8
|
+
* zero setup.
|
|
9
|
+
*
|
|
10
|
+
* Every rule is namespaced under `.kurumera-editable*` and every control
|
|
11
|
+
* resets the properties a host theme's own `button {}` / `input {}` rules
|
|
12
|
+
* would otherwise leak in. The theme's own design must look untouched;
|
|
13
|
+
* only the controls we add are ours to style.
|
|
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
|
+
.kurumera-editable-video__popover button {
|
|
48
|
+
-webkit-appearance: none; appearance: none;
|
|
49
|
+
font: 600 11px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
50
|
+
letter-spacing: .01em;
|
|
51
|
+
padding: 5px 9px;
|
|
52
|
+
margin: 0;
|
|
53
|
+
border: 0;
|
|
54
|
+
border-radius: 6px;
|
|
55
|
+
background: #111827;
|
|
56
|
+
color: #fff;
|
|
57
|
+
cursor: pointer;
|
|
58
|
+
box-shadow: 0 1px 3px rgba(0,0,0,.28);
|
|
59
|
+
text-transform: none;
|
|
60
|
+
white-space: nowrap;
|
|
61
|
+
min-width: 0; min-height: 0; width: auto; height: auto;
|
|
62
|
+
transition: background-color .12s ease, opacity .12s ease;
|
|
63
|
+
}
|
|
64
|
+
.kurumera-editable-image__change:hover,
|
|
65
|
+
.kurumera-editable-bg__change:hover,
|
|
66
|
+
.kurumera-editable-video__change:hover,
|
|
67
|
+
.kurumera-editable-linkfield__edit-link:hover,
|
|
68
|
+
.kurumera-editable-section__chip button:hover,
|
|
69
|
+
.kurumera-editable-repeater__chrome button:hover,
|
|
70
|
+
.kurumera-editable-repeater__add:hover,
|
|
71
|
+
.kurumera-editable-richtext__toolbar button:hover,
|
|
72
|
+
.kurumera-editable-linkfield__popover button:hover,
|
|
73
|
+
.kurumera-editable-video__popover button:hover { background: #2563eb; }
|
|
74
|
+
.kurumera-editable-repeater__chrome button:disabled { opacity: .35; cursor: default; background: #111827; }
|
|
75
|
+
|
|
76
|
+
/* ── Media: float the control over the media, never in the layout ───── */
|
|
77
|
+
.kurumera-editable-image,
|
|
78
|
+
.kurumera-editable-video { position: relative; display: inline-block; line-height: 0; }
|
|
79
|
+
.kurumera-editable-image__change,
|
|
80
|
+
.kurumera-editable-video__change,
|
|
81
|
+
.kurumera-editable-bg__change {
|
|
82
|
+
position: absolute; top: 8px; right: 8px; z-index: 20;
|
|
83
|
+
opacity: 0; pointer-events: none;
|
|
84
|
+
}
|
|
85
|
+
.kurumera-editable-image:hover .kurumera-editable-image__change,
|
|
86
|
+
.kurumera-editable-image:focus-within .kurumera-editable-image__change,
|
|
87
|
+
.kurumera-editable-video:hover .kurumera-editable-video__change,
|
|
88
|
+
.kurumera-editable-video:focus-within .kurumera-editable-video__change,
|
|
89
|
+
.kurumera-editable-bg:hover .kurumera-editable-bg__change,
|
|
90
|
+
.kurumera-editable-bg:focus-within .kurumera-editable-bg__change { opacity: 1; pointer-events: auto; }
|
|
91
|
+
/* Background image: the primitive IS the theme's container, so only add
|
|
92
|
+
positioning context — never change its display/layout. */
|
|
93
|
+
.kurumera-edit-mode .kurumera-editable-bg { position: relative; }
|
|
94
|
+
|
|
95
|
+
/* ── Section chip: floats at the top-left corner, out of flow ───────── */
|
|
96
|
+
.kurumera-editable-section { position: relative; }
|
|
97
|
+
.kurumera-editable-section__chip {
|
|
98
|
+
position: absolute; top: 6px; left: 6px; z-index: 25;
|
|
99
|
+
display: inline-flex; align-items: center; gap: 6px;
|
|
100
|
+
padding: 3px 4px 3px 9px;
|
|
101
|
+
border-radius: 999px;
|
|
102
|
+
background: rgba(17,24,39,.92);
|
|
103
|
+
color: #fff;
|
|
104
|
+
font: 600 11px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
105
|
+
box-shadow: 0 1px 4px rgba(0,0,0,.3);
|
|
106
|
+
opacity: 0; pointer-events: none; transition: opacity .12s ease;
|
|
107
|
+
}
|
|
108
|
+
.kurumera-editable-section:hover .kurumera-editable-section__chip,
|
|
109
|
+
.kurumera-editable-section:focus-within .kurumera-editable-section__chip { opacity: 1; pointer-events: auto; }
|
|
110
|
+
.kurumera-editable-section__chip button { padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.16); }
|
|
111
|
+
|
|
112
|
+
/* ── Repeater: per-item controls float top-right of each item ───────── */
|
|
113
|
+
.kurumera-edit-mode [data-kurumera-repeater-item] { position: relative; }
|
|
114
|
+
.kurumera-editable-repeater__chrome {
|
|
115
|
+
position: absolute; top: 6px; right: 6px; z-index: 25;
|
|
116
|
+
display: inline-flex; gap: 4px;
|
|
117
|
+
opacity: 0; pointer-events: none; transition: opacity .12s ease;
|
|
118
|
+
}
|
|
119
|
+
[data-kurumera-repeater-item]:hover .kurumera-editable-repeater__chrome,
|
|
120
|
+
[data-kurumera-repeater-item]:focus-within .kurumera-editable-repeater__chrome { opacity: 1; pointer-events: auto; }
|
|
121
|
+
.kurumera-editable-repeater__chrome button { padding: 4px 7px; }
|
|
122
|
+
.kurumera-editable-repeater__add {
|
|
123
|
+
display: inline-flex; align-items: center; margin-top: 10px;
|
|
124
|
+
background: #2563eb;
|
|
125
|
+
}
|
|
126
|
+
.kurumera-editable-repeater__add:hover { background: #1d4ed8; }
|
|
127
|
+
.kurumera-editable-repeater__pending { padding: 12px; font: 12px system-ui; color: #6b7280; }
|
|
128
|
+
|
|
129
|
+
/* ── Rich text toolbar ──────────────────────────────────────────────── */
|
|
130
|
+
.kurumera-editable-richtext { position: relative; }
|
|
131
|
+
.kurumera-editable-richtext__toolbar {
|
|
132
|
+
position: absolute; top: 0; right: 0; z-index: 25;
|
|
133
|
+
transform: translateY(-115%);
|
|
134
|
+
display: inline-flex; gap: 4px; padding: 4px;
|
|
135
|
+
border-radius: 8px; background: rgba(17,24,39,.92);
|
|
136
|
+
box-shadow: 0 2px 6px rgba(0,0,0,.3);
|
|
137
|
+
opacity: 0; pointer-events: none; transition: opacity .12s ease;
|
|
138
|
+
}
|
|
139
|
+
.kurumera-editable-richtext:hover .kurumera-editable-richtext__toolbar,
|
|
140
|
+
.kurumera-editable-richtext:focus-within .kurumera-editable-richtext__toolbar { opacity: 1; pointer-events: auto; }
|
|
141
|
+
.kurumera-editable-richtext__toolbar button { background: rgba(255,255,255,.16); min-width: 26px; text-align: center; }
|
|
142
|
+
|
|
143
|
+
/* ── Link / button field ────────────────────────────────────────────── */
|
|
144
|
+
.kurumera-editable-linkfield { position: relative; display: inline-block; }
|
|
145
|
+
.kurumera-editable-linkfield__edit-link {
|
|
146
|
+
position: absolute; top: -8px; right: -8px; z-index: 25;
|
|
147
|
+
padding: 3px 7px;
|
|
148
|
+
opacity: 0; pointer-events: none; transition: opacity .12s ease;
|
|
149
|
+
}
|
|
150
|
+
.kurumera-editable-linkfield:hover .kurumera-editable-linkfield__edit-link,
|
|
151
|
+
.kurumera-editable-linkfield:focus-within .kurumera-editable-linkfield__edit-link { opacity: 1; pointer-events: auto; }
|
|
152
|
+
|
|
153
|
+
/* ── Popovers (link href, video source) ─────────────────────────────── */
|
|
154
|
+
.kurumera-editable-linkfield__popover,
|
|
155
|
+
.kurumera-editable-video__popover {
|
|
156
|
+
position: absolute; top: calc(100% + 8px); left: 0; z-index: 30;
|
|
157
|
+
display: inline-flex; align-items: center; gap: 6px;
|
|
158
|
+
padding: 8px; border-radius: 8px;
|
|
159
|
+
background: #fff; border: 1px solid #e5e7eb;
|
|
160
|
+
box-shadow: 0 6px 20px rgba(0,0,0,.16);
|
|
161
|
+
white-space: nowrap;
|
|
162
|
+
}
|
|
163
|
+
.kurumera-editable-linkfield__popover input,
|
|
164
|
+
.kurumera-editable-video__popover input {
|
|
165
|
+
-webkit-appearance: none; appearance: none;
|
|
166
|
+
font: 12px/1.3 system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
167
|
+
color: #111827; background: #fff;
|
|
168
|
+
padding: 6px 8px; margin: 0;
|
|
169
|
+
border: 1px solid #d1d5db; border-radius: 6px;
|
|
170
|
+
min-width: 230px; width: auto; height: auto;
|
|
171
|
+
}
|
|
172
|
+
.kurumera-editable-linkfield__popover input:focus,
|
|
173
|
+
.kurumera-editable-video__popover input:focus { outline: 2px solid #2563eb; outline-offset: -1px; border-color: #2563eb; }
|
|
174
|
+
.kurumera-editable-video__popover-or { font: 11px system-ui; color: #6b7280; }
|
|
175
|
+
|
|
176
|
+
@media (prefers-reduced-motion: reduce) {
|
|
177
|
+
.kurumera-editable, .kurumera-editable-section__chip, .kurumera-editable-repeater__chrome,
|
|
178
|
+
.kurumera-editable-richtext__toolbar, .kurumera-editable-linkfield__edit-link,
|
|
179
|
+
.kurumera-editable-image__change, .kurumera-editable-video__change, .kurumera-editable-bg__change {
|
|
180
|
+
transition: none;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
`;
|
package/dist/context.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useContext, useMemo, useRef } from "react";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useEffect, useMemo, useRef } from "react";
|
|
4
|
+
import dynamic from "next/dynamic";
|
|
4
5
|
import { createKurumeraClient } from "@kurumera/storefront";
|
|
5
6
|
import { EditableStore } from "./store.js";
|
|
6
7
|
import { createSaveQueue } from "./save-queue.js";
|
|
8
|
+
/** Lazily loaded so the stylesheet never reaches a shopper's bundle — see
|
|
9
|
+
* ChromeStyles.tsx for why this indirection is required, not cosmetic. */
|
|
10
|
+
const ChromeStyles = dynamic(() => import("./ChromeStyles.js"));
|
|
7
11
|
const EditableContext = createContext(null);
|
|
8
12
|
/**
|
|
9
13
|
* Mounted ONCE, at the theme's root layout, seeded from the same
|
|
@@ -44,7 +48,16 @@ export function EditableProvider({ mode, editToken, tenant, apiUrl, fields, chil
|
|
|
44
48
|
// storeRef.current is stable for the component's lifetime — intentionally omitted.
|
|
45
49
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
50
|
}, [mode, editToken, tenant, apiUrl]);
|
|
47
|
-
|
|
51
|
+
// `.kurumera-edit-mode` on <html> is what scopes every chrome rule, so a
|
|
52
|
+
// shopper's DOM carries no editor styling even if a stale style tag existed.
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (mode !== "edit")
|
|
55
|
+
return;
|
|
56
|
+
const root = document.documentElement;
|
|
57
|
+
root.classList.add("kurumera-edit-mode");
|
|
58
|
+
return () => root.classList.remove("kurumera-edit-mode");
|
|
59
|
+
}, [mode]);
|
|
60
|
+
return (_jsxs(EditableContext.Provider, { value: value, children: [mode === "edit" ? _jsx(ChromeStyles, {}) : null, children] }));
|
|
48
61
|
}
|
|
49
62
|
const FALLBACK_STORE = new EditableStore({});
|
|
50
63
|
/** Used outside an `<EditableProvider>` (e.g. the package isn't wired into
|
|
@@ -28,5 +28,5 @@ export function EditableBackgroundImageClient({ field, defaultSrc, as, className
|
|
|
28
28
|
setUploading(false);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
return (_jsxs(As, { className: editableClassName(className, status)
|
|
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 })] }));
|
|
32
32
|
}
|
package/dist/server/resolve.js
CHANGED
|
@@ -36,6 +36,14 @@ export const resolveEditableContent = cache(async () => {
|
|
|
36
36
|
domain: domain || undefined,
|
|
37
37
|
apiUrl,
|
|
38
38
|
editSessionToken: editToken || undefined,
|
|
39
|
+
// The visitor, as received — same reason as getStore() in the theme.
|
|
40
|
+
// This runs from the root layout on EVERY page, and the never-throws
|
|
41
|
+
// rule above means a throttled call here does not fail the page: it
|
|
42
|
+
// silently renders without the merchant's edited content instead.
|
|
43
|
+
forwardHeaders: {
|
|
44
|
+
"x-forwarded-for": h.get("x-forwarded-for"),
|
|
45
|
+
"cf-connecting-ip": h.get("cf-connecting-ip"),
|
|
46
|
+
},
|
|
39
47
|
});
|
|
40
48
|
const res = await client.content.getAll();
|
|
41
49
|
const mode = !res.editable ? "off" : modeParam === "preview" ? "preview" : "edit";
|
package/package.json
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kurumera/editable",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./client": {
|
|
14
|
+
"types": "./dist/client.d.ts",
|
|
15
|
+
"import": "./dist/client.js"
|
|
16
|
+
},
|
|
17
|
+
"./server": {
|
|
18
|
+
"types": "./dist/server.d.ts",
|
|
19
|
+
"import": "./dist/server.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"CHANGELOG.md"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
12
28
|
},
|
|
13
|
-
"files": ["dist"],
|
|
14
|
-
"publishConfig": { "access": "public" },
|
|
15
29
|
"scripts": {
|
|
16
30
|
"build": "tsc -p tsconfig.json",
|
|
17
31
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
@@ -23,7 +37,7 @@
|
|
|
23
37
|
"react-dom": "^19.0.0"
|
|
24
38
|
},
|
|
25
39
|
"dependencies": {
|
|
26
|
-
"@kurumera/storefront": "^0.
|
|
40
|
+
"@kurumera/storefront": "^0.9.0"
|
|
27
41
|
},
|
|
28
42
|
"devDependencies": {
|
|
29
43
|
"@types/react": "^19.0.0",
|