@perkyzz/emvb 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/package.json +3 -1
- package/src/admin/access/role.ts +9 -3
- package/src/admin/api.ts +17 -7
- package/src/admin/content-api.ts +7 -51
- package/src/admin/content-item.ts +22 -0
- package/src/admin/design-api.ts +30 -0
- package/src/admin/editor/A11yCopilot.tsx +126 -0
- package/src/admin/editor/CommandPalette.tsx +118 -0
- package/src/admin/editor/Editor.tsx +188 -152
- package/src/admin/editor/EditorOverlay.tsx +9 -1
- package/src/admin/editor/PerfMeter.tsx +121 -0
- package/src/admin/editor/ShareLink.tsx +164 -0
- package/src/admin/editor/ShortcutsDialog.tsx +4 -1
- package/src/admin/editor/Timeline.tsx +287 -0
- package/src/admin/editor/TopBar.tsx +4 -0
- package/src/admin/editor/canvas/CanvasFrame.tsx +62 -370
- package/src/admin/editor/canvas/DeviceBar.tsx +4 -1
- package/src/admin/editor/canvas/SelectionOverlay.tsx +87 -47
- package/src/admin/editor/canvas/canvas-scale.ts +20 -0
- package/src/admin/editor/canvas/drop-line.ts +24 -0
- package/src/admin/editor/canvas/use-canvas-dnd.ts +207 -0
- package/src/admin/editor/canvas/use-canvas-session.ts +216 -0
- package/src/admin/editor/collection-previews.ts +114 -0
- package/src/admin/editor/editor-chrome.tsx +346 -0
- package/src/admin/editor/editor-commands.ts +360 -0
- package/src/admin/editor/editor-css.ts +5 -3
- package/src/admin/editor/element-chrome.ts +89 -0
- package/src/admin/editor/feature-css.ts +105 -0
- package/src/admin/editor/host.ts +35 -0
- package/src/admin/editor/icons/IconLibraryDialog.tsx +64 -218
- package/src/admin/editor/icons/library.ts +29 -19
- package/src/admin/editor/icons/use-icon-library.ts +315 -0
- package/src/admin/editor/live-data.tsx +71 -0
- package/src/admin/editor/palette-items.ts +136 -0
- package/src/admin/editor/palette.ts +68 -0
- package/src/admin/editor/panels/AddPanel.tsx +48 -68
- package/src/admin/editor/panels/ClassesSection.tsx +5 -1
- package/src/admin/editor/panels/ColorControl.tsx +2 -10
- package/src/admin/editor/panels/ElementPanel.tsx +74 -102
- package/src/admin/editor/panels/LayersPanel.tsx +72 -63
- package/src/admin/editor/panels/LeftPanel.tsx +4 -1
- package/src/admin/editor/panels/SettingsPanel.tsx +13 -0
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +18 -10
- package/src/admin/editor/panels/TokenScales.tsx +168 -0
- package/src/admin/editor/panels/VariableSection.tsx +10 -14
- package/src/admin/editor/panels/inline-error.tsx +11 -0
- package/src/admin/editor/panels/settings/AdvancedFields.tsx +87 -1
- package/src/admin/editor/panels/settings/AudienceEditor.tsx +285 -0
- package/src/admin/editor/panels/settings/BindingsEditor.tsx +221 -0
- package/src/admin/editor/panels/settings/ClassChipInput.tsx +1 -1
- package/src/admin/editor/panels/settings/DraftTextField.tsx +4 -0
- package/src/admin/editor/panels/settings/EffectsControls.tsx +2 -2
- package/src/admin/editor/panels/settings/FormBindControl.tsx +8 -4
- package/src/admin/editor/panels/settings/ItemList.tsx +34 -1
- package/src/admin/editor/panels/settings/MotionControl.tsx +252 -0
- package/src/admin/editor/panels/settings/StateSwitcher.tsx +1 -1
- package/src/admin/editor/panels/settings/StyleRow.tsx +26 -2
- package/src/admin/editor/panels/settings/StyleSources.tsx +94 -0
- package/src/admin/editor/panels/settings/VariableBinding.tsx +1 -1
- package/src/admin/editor/panels/settings/VariantEditor.tsx +83 -0
- package/src/admin/editor/panels/settings/form-names.ts +7 -11
- package/src/admin/editor/panels/settings/length-units.ts +16 -5
- package/src/admin/editor/panels/settings/style-sections.ts +7 -2
- package/src/admin/editor/panels/style-target.ts +105 -0
- package/src/admin/editor/section-templates.ts +43 -21
- package/src/admin/editor/shortcuts.ts +6 -1
- package/src/admin/editor/store.ts +10 -1
- package/src/admin/editor/useClipboardActions.ts +1 -1
- package/src/admin/editor/useEditorCommands.ts +61 -13
- package/src/admin/editor/useEditorData.ts +7 -1
- package/src/admin/editor/useEditorShortcuts.ts +30 -14
- package/src/admin/editor/useNodeActions.ts +44 -16
- package/src/admin/forms-api.ts +17 -6
- package/src/admin/icon-uploads-api.ts +18 -0
- package/src/admin/theme-api.ts +5 -18
- package/src/admin/ui.ts +4 -4
- package/src/astro/content-port.ts +24 -0
- package/src/astro/forms/EmVBFormsClient.astro +11 -0
- package/src/astro/forms/EmVBFormsRuntime.astro +6 -7
- package/src/astro/forms/client.ts +1 -0
- package/src/astro/forms-definitions.ts +24 -11
- package/src/astro/index.ts +1 -0
- package/src/astro/render-session.ts +85 -0
- package/src/astro/request-data.ts +109 -0
- package/src/astro/resolve-theme.ts +184 -64
- package/src/astro/resolve.ts +63 -16
- package/src/astro/theme-posts.ts +48 -5
- package/src/astro/visitor.ts +204 -0
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +282 -0
- package/src/core/arrange.ts +150 -34
- package/src/core/audience/rules.ts +124 -0
- package/src/core/audience/variants.ts +51 -0
- package/src/core/canvas-styles.ts +24 -0
- package/src/core/clipboard.ts +11 -32
- package/src/core/css/generate.ts +29 -2
- package/src/core/css/print.ts +12 -0
- package/src/core/css/scope.ts +3 -3
- package/src/core/css/trace.ts +169 -0
- package/src/core/css-keywords.ts +83 -0
- package/src/core/data/bindings.ts +255 -0
- package/src/core/design/classes.ts +13 -15
- package/src/core/design/diff.ts +55 -0
- package/src/core/design/merge.ts +127 -0
- package/src/core/design/tokens.ts +127 -0
- package/src/core/design/variables.ts +25 -21
- package/src/core/elements/dynamic-elements.ts +117 -2
- package/src/core/elements/form-elements.ts +1 -0
- package/src/core/elements/index.ts +185 -7
- package/src/core/forms/binding.ts +4 -13
- package/src/core/history/diff.ts +152 -0
- package/src/core/index.ts +121 -0
- package/src/core/local-style.ts +27 -0
- package/src/core/migrate/index.ts +12 -4
- package/src/core/nesting.ts +4 -22
- package/src/core/perf/meter.ts +160 -0
- package/src/core/perf/scripts.ts +61 -0
- package/src/core/recipes/index.ts +433 -0
- package/src/core/record.ts +3 -0
- package/src/core/render/context.ts +2 -0
- package/src/core/render/dynamic-post.ts +1 -2
- package/src/core/render/form.ts +133 -10
- package/src/core/render/index.ts +206 -17
- package/src/core/render/loop.ts +54 -7
- package/src/core/render/pagination.ts +9 -1
- package/src/core/render/vnode.ts +12 -2
- package/src/core/sanitize/css.ts +129 -80
- package/src/core/sanitize/motion.ts +129 -0
- package/src/core/sanitize/svg.ts +8 -3
- package/src/core/sanitize/url.ts +10 -1
- package/src/core/schema/design.ts +29 -8
- package/src/core/schema/layout.ts +291 -169
- package/src/core/schema/motion.ts +14 -0
- package/src/core/schema/style.ts +101 -66
- package/src/core/share/link.ts +187 -0
- package/src/core/tabs/presence.ts +7 -17
- package/src/core/theme/dynamic.ts +242 -32
- package/src/core/theme/float.ts +1 -1
- package/src/core/theme/pagination.ts +56 -0
- package/src/core/tree-ops.ts +57 -0
- package/src/index.ts +14 -2
- package/src/server/design-routes.ts +4 -1
- package/src/server/icon-routes.ts +68 -16
- package/src/server/plugin.ts +8 -2
- package/src/admin/editor/icons/sets/fontawesome.json +0 -1
- package/src/admin/editor/icons/sets/lucide.json +0 -1
- package/src/admin/editor/icons/sets/remix.json +0 -1
- package/src/admin/editor/icons/sets/tabler.json +0 -1
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import type { PasteMode, PopupDevice, WrapType } from "../../core/index.ts";
|
|
2
|
+
|
|
3
|
+
/** Where an editor command is offered. Shortcuts call `runCommand` for the same ids. */
|
|
4
|
+
export type CommandSurface = "palette" | "layers" | "overlay" | "device";
|
|
5
|
+
|
|
6
|
+
export type EditorCommand = {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
hint?: string;
|
|
10
|
+
keywords?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
danger?: boolean;
|
|
13
|
+
surfaces: readonly CommandSurface[];
|
|
14
|
+
run: () => void;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** The actions a surface can invoke. Each surface fills the ones it shows. */
|
|
18
|
+
export type CommandRunners = {
|
|
19
|
+
duplicate?: (id: string) => void;
|
|
20
|
+
remove?: (id: string) => void;
|
|
21
|
+
wrap?: (id: string, type: WrapType) => void;
|
|
22
|
+
moveUp?: (id: string) => void;
|
|
23
|
+
moveDown?: (id: string) => void;
|
|
24
|
+
copy?: (id: string) => void;
|
|
25
|
+
paste?: (id: string | null, mode?: PasteMode) => void;
|
|
26
|
+
copyStyle?: (id: string) => void;
|
|
27
|
+
pasteStyle?: (id: string | null) => void;
|
|
28
|
+
pasteBlocked?: string | null;
|
|
29
|
+
pasteStyleBlocked?: string | null;
|
|
30
|
+
toggleHidden?: () => void;
|
|
31
|
+
save?: () => void;
|
|
32
|
+
publish?: () => void;
|
|
33
|
+
preview?: () => void;
|
|
34
|
+
undo?: () => void;
|
|
35
|
+
redo?: () => void;
|
|
36
|
+
deselect?: () => void;
|
|
37
|
+
openSiteStyles?: () => void;
|
|
38
|
+
openA11y?: () => void;
|
|
39
|
+
openTimeline?: () => void;
|
|
40
|
+
openShare?: () => void;
|
|
41
|
+
openWeight?: () => void;
|
|
42
|
+
setDevice?: (device: PopupDevice) => void;
|
|
43
|
+
openShortcuts?: () => void;
|
|
44
|
+
rename?: () => void;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type CommandInput = {
|
|
48
|
+
surface: CommandSurface;
|
|
49
|
+
targetId: string | null;
|
|
50
|
+
isRoot: boolean;
|
|
51
|
+
isParent: boolean;
|
|
52
|
+
device: PopupDevice;
|
|
53
|
+
/** Duplicate and wrap. False on the root and when nothing is selected. */
|
|
54
|
+
canDuplicate: boolean;
|
|
55
|
+
/** Delete and the sibling moves. False on the root. */
|
|
56
|
+
canDelete: boolean;
|
|
57
|
+
runners: CommandRunners;
|
|
58
|
+
a11yHint?: string;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
type Spec = {
|
|
62
|
+
id: string;
|
|
63
|
+
labels: Partial<Record<CommandSurface, string>>;
|
|
64
|
+
hint?: string;
|
|
65
|
+
keywords?: string;
|
|
66
|
+
surfaces: readonly CommandSurface[];
|
|
67
|
+
danger?: boolean;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// One row per command. A surface shows a row when its name is in `surfaces` and `shown` agrees.
|
|
71
|
+
// Labels stay per surface: the palette, Layers and the overlay do not share wording.
|
|
72
|
+
const SPECS: readonly Spec[] = [
|
|
73
|
+
{ id: "rename", labels: { layers: "Rename" }, surfaces: ["layers"] },
|
|
74
|
+
{
|
|
75
|
+
id: "copy",
|
|
76
|
+
labels: { layers: "Copy", overlay: "Copy" },
|
|
77
|
+
surfaces: ["layers", "overlay"],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: "paste",
|
|
81
|
+
labels: { layers: "Paste", overlay: "Paste" },
|
|
82
|
+
surfaces: ["layers", "overlay"],
|
|
83
|
+
},
|
|
84
|
+
{ id: "paste-inside", labels: { layers: "Paste inside" }, surfaces: ["layers"] },
|
|
85
|
+
{
|
|
86
|
+
id: "copy-style",
|
|
87
|
+
labels: { layers: "Copy style", overlay: "Copy style" },
|
|
88
|
+
surfaces: ["layers", "overlay"],
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: "paste-style",
|
|
92
|
+
labels: { layers: "Paste style", overlay: "Paste style" },
|
|
93
|
+
surfaces: ["layers", "overlay"],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: "duplicate",
|
|
97
|
+
labels: {
|
|
98
|
+
layers: "Duplicate",
|
|
99
|
+
overlay: "Duplicate element",
|
|
100
|
+
palette: "Duplicate selected element",
|
|
101
|
+
},
|
|
102
|
+
hint: "Ctrl/Cmd+D",
|
|
103
|
+
surfaces: ["layers", "overlay", "palette"],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
id: "delete",
|
|
107
|
+
labels: {
|
|
108
|
+
layers: "Delete",
|
|
109
|
+
overlay: "Delete element",
|
|
110
|
+
palette: "Delete selected element",
|
|
111
|
+
},
|
|
112
|
+
hint: "Delete",
|
|
113
|
+
surfaces: ["layers", "overlay", "palette"],
|
|
114
|
+
danger: true,
|
|
115
|
+
},
|
|
116
|
+
{ id: "move-up", labels: { layers: "Move up" }, surfaces: ["layers"] },
|
|
117
|
+
{ id: "move-down", labels: { layers: "Move down" }, surfaces: ["layers"] },
|
|
118
|
+
{
|
|
119
|
+
id: "wrap-flexbox",
|
|
120
|
+
labels: { palette: "Wrap in Flexbox" },
|
|
121
|
+
keywords: "wrap box container",
|
|
122
|
+
surfaces: ["palette"],
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: "wrap-grid",
|
|
126
|
+
labels: { palette: "Wrap in Grid" },
|
|
127
|
+
keywords: "wrap box columns",
|
|
128
|
+
surfaces: ["palette"],
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: "wrap-div",
|
|
132
|
+
labels: { palette: "Wrap in Div Block" },
|
|
133
|
+
keywords: "wrap box",
|
|
134
|
+
surfaces: ["palette"],
|
|
135
|
+
},
|
|
136
|
+
{ id: "save", labels: { palette: "Save draft" }, hint: "Ctrl/Cmd+S", surfaces: ["palette"] },
|
|
137
|
+
{ id: "publish", labels: { palette: "Publish" }, surfaces: ["palette"] },
|
|
138
|
+
{ id: "preview", labels: { palette: "Preview" }, keywords: "open view", surfaces: ["palette"] },
|
|
139
|
+
{ id: "undo", labels: { palette: "Undo" }, hint: "Ctrl/Cmd+Z", surfaces: ["palette"] },
|
|
140
|
+
{ id: "redo", labels: { palette: "Redo" }, hint: "Ctrl/Cmd+Shift+Z", surfaces: ["palette"] },
|
|
141
|
+
{
|
|
142
|
+
id: "deselect",
|
|
143
|
+
labels: { palette: "Clear selection" },
|
|
144
|
+
hint: "Esc",
|
|
145
|
+
surfaces: ["palette"],
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
id: "site-styles",
|
|
149
|
+
labels: { palette: "Open Site styles" },
|
|
150
|
+
keywords: "design variables classes colors fonts",
|
|
151
|
+
surfaces: ["palette"],
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
id: "a11y",
|
|
155
|
+
labels: { palette: "Check accessibility" },
|
|
156
|
+
keywords: "a11y contrast alt headings audit",
|
|
157
|
+
surfaces: ["palette"],
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
id: "timeline",
|
|
161
|
+
labels: { palette: "Version timeline" },
|
|
162
|
+
keywords: "history revisions restore diff",
|
|
163
|
+
surfaces: ["palette"],
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
id: "share",
|
|
167
|
+
labels: { palette: "Share as a playground link" },
|
|
168
|
+
keywords: "copy link url playground share send",
|
|
169
|
+
surfaces: ["palette"],
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
id: "weight",
|
|
173
|
+
labels: { palette: "Show page weight" },
|
|
174
|
+
keywords: "performance budget size speed",
|
|
175
|
+
surfaces: ["palette"],
|
|
176
|
+
},
|
|
177
|
+
{ id: "device-desktop", labels: { palette: "View on desktop" }, surfaces: ["palette"] },
|
|
178
|
+
{ id: "device-tablet", labels: { palette: "View on tablet" }, surfaces: ["palette"] },
|
|
179
|
+
{ id: "device-mobile", labels: { palette: "View on mobile" }, surfaces: ["palette"] },
|
|
180
|
+
{ id: "shortcuts", labels: { palette: "Keyboard shortcuts" }, surfaces: ["palette"] },
|
|
181
|
+
{ id: "hide-on-device", labels: {}, surfaces: ["device"] },
|
|
182
|
+
];
|
|
183
|
+
|
|
184
|
+
const ORDER: Record<CommandSurface, readonly string[]> = {
|
|
185
|
+
layers: [
|
|
186
|
+
"rename",
|
|
187
|
+
"copy",
|
|
188
|
+
"paste",
|
|
189
|
+
"paste-inside",
|
|
190
|
+
"duplicate",
|
|
191
|
+
"copy-style",
|
|
192
|
+
"paste-style",
|
|
193
|
+
"move-up",
|
|
194
|
+
"move-down",
|
|
195
|
+
"delete",
|
|
196
|
+
],
|
|
197
|
+
overlay: ["duplicate", "copy", "paste", "copy-style", "paste-style", "delete"],
|
|
198
|
+
palette: [
|
|
199
|
+
"wrap-flexbox",
|
|
200
|
+
"wrap-grid",
|
|
201
|
+
"wrap-div",
|
|
202
|
+
"save",
|
|
203
|
+
"publish",
|
|
204
|
+
"preview",
|
|
205
|
+
"undo",
|
|
206
|
+
"redo",
|
|
207
|
+
"duplicate",
|
|
208
|
+
"delete",
|
|
209
|
+
"deselect",
|
|
210
|
+
"site-styles",
|
|
211
|
+
"a11y",
|
|
212
|
+
"timeline",
|
|
213
|
+
"share",
|
|
214
|
+
"weight",
|
|
215
|
+
"device-desktop",
|
|
216
|
+
"device-tablet",
|
|
217
|
+
"device-mobile",
|
|
218
|
+
"shortcuts",
|
|
219
|
+
],
|
|
220
|
+
device: ["hide-on-device"],
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const CLIP_IDS = new Set(["copy", "paste", "paste-inside", "copy-style", "paste-style"]);
|
|
224
|
+
const WRAP_IDS = new Set(["wrap-flexbox", "wrap-grid", "wrap-div"]);
|
|
225
|
+
const MOVE_IDS = new Set(["move-up", "move-down", "delete"]);
|
|
226
|
+
|
|
227
|
+
function shown(id: string, input: CommandInput): boolean {
|
|
228
|
+
const clip = !!input.runners.copy;
|
|
229
|
+
if (id === "rename") return !!input.runners.rename;
|
|
230
|
+
if (id === "paste-inside") return clip && input.isParent;
|
|
231
|
+
if (id === "paste") return clip && (input.surface !== "layers" || !input.isRoot);
|
|
232
|
+
if (CLIP_IDS.has(id)) return clip;
|
|
233
|
+
if (id === "duplicate" || WRAP_IDS.has(id)) return input.canDuplicate;
|
|
234
|
+
if (MOVE_IDS.has(id)) return input.canDelete;
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function blocked(id: string, input: CommandInput): boolean {
|
|
239
|
+
if (id === "paste" || id === "paste-inside") return !!input.runners.pasteBlocked;
|
|
240
|
+
if (id === "paste-style") return !!input.runners.pasteStyleBlocked;
|
|
241
|
+
if (id === "hide-on-device") return !input.targetId;
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function labelFor(spec: Spec, input: CommandInput): string {
|
|
246
|
+
if (spec.id === "hide-on-device") return `Hide on ${input.device}`;
|
|
247
|
+
return spec.labels[input.surface] ?? spec.id;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Commands one surface shows for this target, in that surface's order. */
|
|
251
|
+
export function editorCommands(input: CommandInput): EditorCommand[] {
|
|
252
|
+
const rank = new Map(ORDER[input.surface].map((id, index) => [id, index]));
|
|
253
|
+
return SPECS.filter((spec) => spec.surfaces.includes(input.surface) && shown(spec.id, input))
|
|
254
|
+
.toSorted((a, b) => (rank.get(a.id) ?? 999) - (rank.get(b.id) ?? 999))
|
|
255
|
+
.map((spec) => ({
|
|
256
|
+
id: spec.id,
|
|
257
|
+
label: labelFor(spec, input),
|
|
258
|
+
hint: spec.id === "a11y" ? input.a11yHint : spec.hint,
|
|
259
|
+
keywords: spec.keywords,
|
|
260
|
+
disabled: blocked(spec.id, input),
|
|
261
|
+
danger: spec.danger,
|
|
262
|
+
surfaces: spec.surfaces,
|
|
263
|
+
run: () => runCommand(input.runners, spec.id, input.targetId),
|
|
264
|
+
}));
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** One implementation for the palette, Layers, the overlay, the device bar and shortcuts. */
|
|
268
|
+
export function runCommand(runners: CommandRunners, id: string, targetId: string | null): void {
|
|
269
|
+
switch (id) {
|
|
270
|
+
case "rename":
|
|
271
|
+
runners.rename?.();
|
|
272
|
+
return;
|
|
273
|
+
case "copy":
|
|
274
|
+
if (targetId) runners.copy?.(targetId);
|
|
275
|
+
return;
|
|
276
|
+
case "paste":
|
|
277
|
+
runners.paste?.(targetId);
|
|
278
|
+
return;
|
|
279
|
+
case "paste-inside":
|
|
280
|
+
runners.paste?.(targetId, "inside");
|
|
281
|
+
return;
|
|
282
|
+
case "copy-style":
|
|
283
|
+
if (targetId) runners.copyStyle?.(targetId);
|
|
284
|
+
return;
|
|
285
|
+
case "paste-style":
|
|
286
|
+
runners.pasteStyle?.(targetId);
|
|
287
|
+
return;
|
|
288
|
+
case "duplicate":
|
|
289
|
+
if (targetId) runners.duplicate?.(targetId);
|
|
290
|
+
return;
|
|
291
|
+
case "delete":
|
|
292
|
+
if (targetId) runners.remove?.(targetId);
|
|
293
|
+
return;
|
|
294
|
+
case "move-up":
|
|
295
|
+
if (targetId) runners.moveUp?.(targetId);
|
|
296
|
+
return;
|
|
297
|
+
case "move-down":
|
|
298
|
+
if (targetId) runners.moveDown?.(targetId);
|
|
299
|
+
return;
|
|
300
|
+
case "wrap-flexbox":
|
|
301
|
+
if (targetId) runners.wrap?.(targetId, "flexbox");
|
|
302
|
+
return;
|
|
303
|
+
case "wrap-grid":
|
|
304
|
+
if (targetId) runners.wrap?.(targetId, "grid");
|
|
305
|
+
return;
|
|
306
|
+
case "wrap-div":
|
|
307
|
+
if (targetId) runners.wrap?.(targetId, "div-block");
|
|
308
|
+
return;
|
|
309
|
+
case "save":
|
|
310
|
+
runners.save?.();
|
|
311
|
+
return;
|
|
312
|
+
case "publish":
|
|
313
|
+
runners.publish?.();
|
|
314
|
+
return;
|
|
315
|
+
case "preview":
|
|
316
|
+
runners.preview?.();
|
|
317
|
+
return;
|
|
318
|
+
case "undo":
|
|
319
|
+
runners.undo?.();
|
|
320
|
+
return;
|
|
321
|
+
case "redo":
|
|
322
|
+
runners.redo?.();
|
|
323
|
+
return;
|
|
324
|
+
case "deselect":
|
|
325
|
+
runners.deselect?.();
|
|
326
|
+
return;
|
|
327
|
+
case "site-styles":
|
|
328
|
+
runners.openSiteStyles?.();
|
|
329
|
+
return;
|
|
330
|
+
case "a11y":
|
|
331
|
+
runners.openA11y?.();
|
|
332
|
+
return;
|
|
333
|
+
case "timeline":
|
|
334
|
+
runners.openTimeline?.();
|
|
335
|
+
return;
|
|
336
|
+
case "share":
|
|
337
|
+
runners.openShare?.();
|
|
338
|
+
return;
|
|
339
|
+
case "weight":
|
|
340
|
+
runners.openWeight?.();
|
|
341
|
+
return;
|
|
342
|
+
case "device-desktop":
|
|
343
|
+
runners.setDevice?.("desktop");
|
|
344
|
+
return;
|
|
345
|
+
case "device-tablet":
|
|
346
|
+
runners.setDevice?.("tablet");
|
|
347
|
+
return;
|
|
348
|
+
case "device-mobile":
|
|
349
|
+
runners.setDevice?.("mobile");
|
|
350
|
+
return;
|
|
351
|
+
case "shortcuts":
|
|
352
|
+
runners.openShortcuts?.();
|
|
353
|
+
return;
|
|
354
|
+
case "hide-on-device":
|
|
355
|
+
runners.toggleHidden?.();
|
|
356
|
+
return;
|
|
357
|
+
default:
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Editor chrome styles. The admin's Tailwind build is precompiled, so EmVB ships its
|
|
2
|
+
* Editor chrome styles (DESIGN.md). The admin's Tailwind build is precompiled, so EmVB ships its
|
|
3
3
|
* own rules, scoped to the editor root and built only from Kumo variables. Panels keep their
|
|
4
4
|
* 1 px borders inside their width, so the canvas gets exactly the space between them (D-025).
|
|
5
5
|
* Density is compact (28 px controls, 44 px top bar, 256/288 panels) with near-opaque
|
|
6
6
|
* elevated cards (hairline rings, soft lift shadows, light blur); the canvas stage stays clear.
|
|
7
7
|
*/
|
|
8
8
|
import { UI_CSS } from "../ui.ts";
|
|
9
|
+
import { FEATURE_CSS } from "./feature-css.ts";
|
|
9
10
|
|
|
10
11
|
export const EDITOR_CSS = `${UI_CSS}
|
|
11
12
|
[data-emvb-editor] {
|
|
@@ -339,7 +340,7 @@ export const EDITOR_CSS = `${UI_CSS}
|
|
|
339
340
|
}
|
|
340
341
|
.emvb-unit-btn:hover, .emvb-unit-btn[data-popup-open] { background: var(--color-kumo-tint); color: var(--text-color-kumo-default); }
|
|
341
342
|
.emvb-unit-btn:focus-visible { outline: 2px solid var(--color-kumo-brand); outline-offset: -2px; }
|
|
342
|
-
/* Variable button and bound-variable chip (W-087) */
|
|
343
|
+
/* Variable button and bound-variable chip (W-087, DESIGN.md "variable chip") */
|
|
343
344
|
.emvb-var-btn {
|
|
344
345
|
display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
|
|
345
346
|
width: 28px; height: 28px; margin-top: 28px; padding: 0; border: 0; border-radius: 6px;
|
|
@@ -431,7 +432,7 @@ export const EDITOR_CSS = `${UI_CSS}
|
|
|
431
432
|
.emvb-icon-current-text strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
432
433
|
.emvb-icon-current-text span { color: var(--text-color-kumo-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
433
434
|
|
|
434
|
-
/* Class chip input (W-087): one 28 px box holding the chips and the text input */
|
|
435
|
+
/* Class chip input (W-087, DESIGN.md): one 28 px box holding the chips and the text input */
|
|
435
436
|
.emvb-class-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
|
|
436
437
|
.emvb-chip-anchor { position: relative; }
|
|
437
438
|
.emvb-chip-box {
|
|
@@ -622,4 +623,5 @@ export const EDITOR_CSS = `${UI_CSS}
|
|
|
622
623
|
background: var(--color-kumo-elevated);
|
|
623
624
|
}
|
|
624
625
|
}
|
|
626
|
+
${FEATURE_CSS}
|
|
625
627
|
`;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ArrowsLeftRightIcon,
|
|
3
|
+
ArrowsVerticalIcon,
|
|
4
|
+
ArticleIcon,
|
|
5
|
+
BrowserIcon,
|
|
6
|
+
CaretCircleDownIcon,
|
|
7
|
+
CaretDownIcon,
|
|
8
|
+
CheckSquareIcon,
|
|
9
|
+
CursorClickIcon,
|
|
10
|
+
GraphIcon,
|
|
11
|
+
GridFourIcon,
|
|
12
|
+
ImageIcon,
|
|
13
|
+
LinkIcon,
|
|
14
|
+
ListBulletsIcon,
|
|
15
|
+
MinusIcon,
|
|
16
|
+
NotePencilIcon,
|
|
17
|
+
PaperPlaneRightIcon,
|
|
18
|
+
RadioButtonIcon,
|
|
19
|
+
RowsIcon,
|
|
20
|
+
SmileyIcon,
|
|
21
|
+
SquareIcon,
|
|
22
|
+
SquaresFourIcon,
|
|
23
|
+
TextAaIcon,
|
|
24
|
+
TextAlignLeftIcon,
|
|
25
|
+
TextboxIcon,
|
|
26
|
+
TextHIcon,
|
|
27
|
+
TextTIcon,
|
|
28
|
+
VideoCameraIcon,
|
|
29
|
+
type Icon,
|
|
30
|
+
} from "@phosphor-icons/react";
|
|
31
|
+
import { ELEMENT_DESCRIPTORS } from "../../core/index.ts";
|
|
32
|
+
|
|
33
|
+
/** Labels for element types. One list, from the descriptors (W-361). */
|
|
34
|
+
export const ELEMENT_NAMES: Record<string, string> = Object.fromEntries(
|
|
35
|
+
ELEMENT_DESCRIPTORS.map((descriptor) => [descriptor.type, descriptor.name]),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Phosphor icon for each element. The names in `docs/DESIGN.md` win. Types that table
|
|
40
|
+
* does not list keep the icon the add panel already showed.
|
|
41
|
+
*/
|
|
42
|
+
export const ELEMENT_ICONS: Record<string, Icon> = {
|
|
43
|
+
container: SquaresFourIcon,
|
|
44
|
+
"div-block": SquareIcon,
|
|
45
|
+
"layout-section": RowsIcon,
|
|
46
|
+
section: RowsIcon,
|
|
47
|
+
flexbox: SquaresFourIcon,
|
|
48
|
+
grid: GridFourIcon,
|
|
49
|
+
spacer: ArrowsVerticalIcon,
|
|
50
|
+
divider: MinusIcon,
|
|
51
|
+
heading: TextHIcon,
|
|
52
|
+
text: TextAlignLeftIcon,
|
|
53
|
+
label: TextTIcon,
|
|
54
|
+
link: LinkIcon,
|
|
55
|
+
button: CursorClickIcon,
|
|
56
|
+
list: ListBulletsIcon,
|
|
57
|
+
image: ImageIcon,
|
|
58
|
+
icon: SmileyIcon,
|
|
59
|
+
svg: GraphIcon,
|
|
60
|
+
tabs: BrowserIcon,
|
|
61
|
+
"tab-panel": BrowserIcon,
|
|
62
|
+
accordion: ListBulletsIcon,
|
|
63
|
+
"accordion-item": ListBulletsIcon,
|
|
64
|
+
menu: CaretDownIcon,
|
|
65
|
+
"menu-item": CaretDownIcon,
|
|
66
|
+
toc: ListBulletsIcon,
|
|
67
|
+
video: VideoCameraIcon,
|
|
68
|
+
form: ArticleIcon,
|
|
69
|
+
"text-input": TextboxIcon,
|
|
70
|
+
textarea: TextAaIcon,
|
|
71
|
+
select: CaretCircleDownIcon,
|
|
72
|
+
checkbox: CheckSquareIcon,
|
|
73
|
+
radio: RadioButtonIcon,
|
|
74
|
+
submit: PaperPlaneRightIcon,
|
|
75
|
+
"post-title": TextHIcon,
|
|
76
|
+
"post-excerpt": TextAlignLeftIcon,
|
|
77
|
+
"post-content": NotePencilIcon,
|
|
78
|
+
"post-image": ImageIcon,
|
|
79
|
+
"post-link": LinkIcon,
|
|
80
|
+
"post-date": TextTIcon,
|
|
81
|
+
"post-author": TextTIcon,
|
|
82
|
+
loop: ListBulletsIcon,
|
|
83
|
+
"loop-empty": SquareIcon,
|
|
84
|
+
pagination: ArrowsLeftRightIcon,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export function elementIcon(type: string): Icon {
|
|
88
|
+
return ELEMENT_ICONS[type] ?? SquaresFourIcon;
|
|
89
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor styles for the W-307 feature batch (bindings, palette, meters, timeline…), kept apart
|
|
3
|
+
* from the core chrome in editor-css.ts. Kumo variables only.
|
|
4
|
+
*/
|
|
5
|
+
export const FEATURE_CSS = `
|
|
6
|
+
.emvb-native-select, .emvb-native-input {
|
|
7
|
+
height: var(--emvb-control, 28px);
|
|
8
|
+
min-width: 0;
|
|
9
|
+
padding: 0 8px;
|
|
10
|
+
border: 1px solid var(--color-kumo-line);
|
|
11
|
+
border-radius: 6px;
|
|
12
|
+
background: var(--color-kumo-base);
|
|
13
|
+
color: var(--text-color-kumo-default);
|
|
14
|
+
font: inherit;
|
|
15
|
+
}
|
|
16
|
+
.emvb-native-select:focus-visible, .emvb-native-input:focus-visible {
|
|
17
|
+
outline: 2px solid var(--color-kumo-brand);
|
|
18
|
+
outline-offset: 1px;
|
|
19
|
+
}
|
|
20
|
+
.emvb-bind { display: grid; gap: 8px; padding-top: 8px; border-top: 1px solid var(--color-kumo-hairline); }
|
|
21
|
+
.emvb-bind-title { margin: 0; font-size: 12px; font-weight: 600; }
|
|
22
|
+
.emvb-bind-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; align-items: center; }
|
|
23
|
+
.emvb-bind-row > .emvb-bind-label { grid-column: 1 / -1; font-size: 12px; color: var(--text-color-kumo-subtle); }
|
|
24
|
+
.emvb-bind-live { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--text-color-kumo-default); overflow-wrap: anywhere; }
|
|
25
|
+
.emvb-bind-live > b { font-weight: 600; }
|
|
26
|
+
.emvb-bind-outside { grid-column: 1 / -1; display: grid; gap: 4px; }
|
|
27
|
+
.emvb-bind-outside > label { display: flex; gap: 6px; align-items: center; font-size: 12px; }
|
|
28
|
+
.emvb-bind-warning { margin: 0; padding: 6px 8px; border-radius: 6px; font-size: 12px; background: var(--color-kumo-warning-tint); color: var(--text-color-kumo-default); }
|
|
29
|
+
.emvb-js-badge { margin-left: auto; padding: 0 4px; border-radius: 4px; font-size: 10px; font-weight: 700; line-height: 16px; background: var(--color-kumo-warning-tint); color: var(--text-color-kumo-default); }
|
|
30
|
+
.emvb-element-tile { position: relative; }
|
|
31
|
+
.emvb-element-tile > .emvb-js-badge { position: absolute; top: 4px; right: 4px; }
|
|
32
|
+
.emvb-perf-bars { display: grid; gap: 8px; margin: 12px 0; padding: 0; list-style: none; }
|
|
33
|
+
.emvb-perf-bars > li { display: grid; grid-template-columns: 90px 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
|
|
34
|
+
.emvb-perf-bar { display: block; height: 8px; border-radius: 4px; background: var(--color-kumo-tint); overflow: hidden; }
|
|
35
|
+
.emvb-perf-bar > span { display: block; height: 100%; background: var(--color-kumo-brand); }
|
|
36
|
+
.emvb-perf-bars > li[data-over] .emvb-perf-bar > span { background: var(--color-kumo-danger); }
|
|
37
|
+
.emvb-perf-value { font-variant-numeric: tabular-nums; color: var(--text-color-kumo-subtle); }
|
|
38
|
+
.emvb-perf-warnings { margin: 8px 0; padding-left: 18px; font-size: 13px; }
|
|
39
|
+
.emvb-perf-heading { margin: 12px 0 4px; font-size: 13px; font-weight: 600; }
|
|
40
|
+
.emvb-perf-sections { margin: 0 0 8px; padding-left: 18px; font-size: 13px; }
|
|
41
|
+
.emvb-topbar-meter { font-variant-numeric: tabular-nums; font-size: 12px; }
|
|
42
|
+
.emvb-js-badge + .emvb-ab-badge { margin-left: 2px; }
|
|
43
|
+
.emvb-ab-badge { background: var(--color-kumo-info-tint); }
|
|
44
|
+
.emvb-aud-checks { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 0; padding: 0; border: 0; font-size: 12px; }
|
|
45
|
+
.emvb-aud-checks > legend { width: 100%; padding: 0; margin-bottom: 2px; }
|
|
46
|
+
.emvb-palette { padding: 0; overflow: hidden; }
|
|
47
|
+
.emvb-palette-input { width: 100%; height: 44px; padding: 0 16px; border: 0; border-bottom: 1px solid var(--color-kumo-line); background: transparent; color: var(--text-color-kumo-default); font: inherit; font-size: 15px; outline: none; }
|
|
48
|
+
.emvb-palette-list { max-height: min(60vh, 420px); overflow-y: auto; margin: 0; padding: 4px; list-style: none; }
|
|
49
|
+
.emvb-palette-group { padding: 8px 10px 2px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-color-kumo-subtle); }
|
|
50
|
+
.emvb-palette-item { display: flex; justify-content: space-between; gap: 12px; padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
|
|
51
|
+
.emvb-palette-item[aria-selected="true"] { background: var(--color-kumo-tint); }
|
|
52
|
+
.emvb-palette-hint { color: var(--text-color-kumo-subtle); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50%; }
|
|
53
|
+
.emvb-palette-empty { padding: 12px; color: var(--text-color-kumo-subtle); font-size: 13px; }
|
|
54
|
+
.emvb-palette-tips { margin: 0; padding: 6px 12px; border-top: 1px solid var(--color-kumo-line); font-size: 11px; color: var(--text-color-kumo-subtle); }
|
|
55
|
+
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
56
|
+
.emvb-timeline-body { display: grid; grid-template-columns: 200px 1fr; gap: 16px; margin: 12px 0; min-height: 0; }
|
|
57
|
+
.emvb-timeline-list { margin: 0; padding: 0; list-style: none; max-height: 60vh; overflow-y: auto; }
|
|
58
|
+
.emvb-timeline-version { width: 100%; padding: 6px 8px; border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit; font-size: 12px; text-align: start; cursor: pointer; }
|
|
59
|
+
.emvb-timeline-version[aria-current="true"] { background: var(--color-kumo-tint); font-weight: 600; }
|
|
60
|
+
.emvb-timeline-frames { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
|
|
61
|
+
.emvb-timeline-frames figure { margin: 0; }
|
|
62
|
+
.emvb-timeline-frames figcaption { font-size: 12px; color: var(--text-color-kumo-subtle); margin-bottom: 4px; }
|
|
63
|
+
.emvb-timeline-frame { width: 100%; height: 260px; border: 1px solid var(--color-kumo-line); border-radius: 6px; background: var(--color-kumo-base); }
|
|
64
|
+
.emvb-timeline-changes { margin: 8px 0; padding: 0; list-style: none; font-size: 13px; display: grid; gap: 4px; }
|
|
65
|
+
.emvb-timeline-changes > li { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
|
|
66
|
+
.emvb-timeline-kind { font-weight: 600; }
|
|
67
|
+
.emvb-timeline-changes > li[data-kind="added"] .emvb-timeline-kind { color: var(--text-color-kumo-success); }
|
|
68
|
+
.emvb-timeline-changes > li[data-kind="removed"] .emvb-timeline-kind { color: var(--text-color-kumo-danger); }
|
|
69
|
+
.emvb-timeline-changes > li[data-kind="changed"] .emvb-timeline-kind { color: var(--text-color-kumo-warning); }
|
|
70
|
+
.emvb-tokens-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; }
|
|
71
|
+
.emvb-tokens-grid > label { display: grid; gap: 4px; min-width: 0; }
|
|
72
|
+
.emvb-tokens-fluid { display: flex !important; align-items: center; gap: 4px; font-size: 12px; }
|
|
73
|
+
.emvb-tokens-preview { margin: 8px 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 12px; }
|
|
74
|
+
.emvb-tokens-preview > li { display: grid; grid-template-columns: 48px 1fr auto; gap: 8px; align-items: center; }
|
|
75
|
+
.emvb-tokens-sample { display: inline-block; height: 1em; line-height: 1; }
|
|
76
|
+
.emvb-tokens-preview .emvb-tokens-sample:empty { height: 8px; border-radius: 2px; background: var(--color-kumo-brand); }
|
|
77
|
+
.emvb-tokens-preview code { font-size: 11px; color: var(--text-color-kumo-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
|
|
78
|
+
.emvb-a11y-score { height: 28px; padding: 0 8px; border: 1px solid var(--color-kumo-line); border-radius: 999px; background: transparent; color: var(--text-color-kumo-default); font: inherit; font-size: 12px; cursor: pointer; white-space: nowrap; }
|
|
79
|
+
.emvb-a11y-score[data-band="good"] b, .emvb-a11y [data-band="good"] { color: var(--text-color-kumo-success); }
|
|
80
|
+
.emvb-a11y-score[data-band="fair"] b, .emvb-a11y [data-band="fair"] { color: var(--text-color-kumo-warning); }
|
|
81
|
+
.emvb-a11y-score[data-band="poor"] b, .emvb-a11y [data-band="poor"] { color: var(--text-color-kumo-danger); }
|
|
82
|
+
.emvb-a11y-score:focus-visible { outline: 2px solid var(--color-kumo-brand); outline-offset: 1px; }
|
|
83
|
+
.emvb-a11y-issues { margin: 12px 0; padding: 0; list-style: none; display: grid; gap: 8px; max-height: 50vh; overflow-y: auto; }
|
|
84
|
+
.emvb-a11y-issues > li { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; font-size: 13px; padding-left: 8px; border-left: 3px solid var(--color-kumo-warning); }
|
|
85
|
+
.emvb-a11y-issues > li[data-severity="error"] { border-left-color: var(--color-kumo-danger); }
|
|
86
|
+
.emvb-a11y-actions { display: flex; gap: 8px; justify-content: flex-end; }
|
|
87
|
+
.emvb-sources { margin: 4px 0 8px; font-size: 12px; }
|
|
88
|
+
.emvb-sources > summary { cursor: pointer; display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
|
|
89
|
+
.emvb-sources-count { font-weight: 400; color: var(--text-color-kumo-subtle); }
|
|
90
|
+
.emvb-sources ul { margin: 6px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
|
|
91
|
+
.emvb-sources li { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; padding-left: 6px; border-left: 2px solid var(--color-kumo-line); }
|
|
92
|
+
.emvb-sources li[data-kind="class"] { border-left-color: var(--color-kumo-info); }
|
|
93
|
+
.emvb-sources li[data-kind="default"] { border-left-color: var(--color-kumo-success); }
|
|
94
|
+
.emvb-sources li[data-kind="local"] { border-left-color: var(--color-kumo-brand); }
|
|
95
|
+
.emvb-sources-value { font-family: ui-monospace, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
|
|
96
|
+
.emvb-sources-from, .emvb-sources-over { grid-column: 1 / -1; color: var(--text-color-kumo-subtle); }
|
|
97
|
+
.emvb-sources-over { text-decoration: line-through; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); }
|
|
98
|
+
.emvb-recipe-list { display: grid; gap: 6px; }
|
|
99
|
+
.emvb-recipe-tile { display: grid; gap: 2px; text-align: start; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--color-kumo-line); background: var(--color-kumo-base, transparent); cursor: pointer; font: inherit; color: inherit; }
|
|
100
|
+
.emvb-recipe-tile:hover, .emvb-recipe-tile:focus-visible { border-color: var(--color-kumo-brand); }
|
|
101
|
+
.emvb-recipe-name { font-weight: 600; font-size: 13px; }
|
|
102
|
+
.emvb-recipe-desc { font-size: 12px; color: var(--text-color-kumo-subtle); }
|
|
103
|
+
.emvb-motion-effect { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; align-items: end; }
|
|
104
|
+
.emvb-motion-name { grid-column: 1 / -1; font-size: 12px; font-weight: 600; }
|
|
105
|
+
`;
|
package/src/admin/editor/host.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { PLUGIN_ID } from "../../constants.ts";
|
|
3
|
+
import { canvasStyleUrls } from "../../core/canvas-styles.ts";
|
|
4
|
+
import { requestJson, type Fetcher } from "../api.ts";
|
|
2
5
|
import { exitTarget, PAGES_URL } from "./exit.ts";
|
|
3
6
|
|
|
4
7
|
/**
|
|
@@ -15,6 +18,13 @@ export type EditorHost = {
|
|
|
15
18
|
* admin (the playground) sets false, so those links don't lead nowhere (W-289). Default true.
|
|
16
19
|
*/
|
|
17
20
|
adminLinks?: boolean;
|
|
21
|
+
/** Where shared page links open (W-321). Default emvb.dev/playground. */
|
|
22
|
+
playgroundUrl?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Stylesheets the canvas loads before EmVB's CSS (W-327). Unset: the editor asks the plugin
|
|
25
|
+
* for the host's `emvb({ canvasStyles })`.
|
|
26
|
+
*/
|
|
27
|
+
canvasStyles?: readonly string[];
|
|
18
28
|
};
|
|
19
29
|
|
|
20
30
|
const defaultEditorHost: EditorHost = {
|
|
@@ -28,3 +38,28 @@ export const useEditorHost = (): EditorHost => React.useContext(EditorHostContex
|
|
|
28
38
|
|
|
29
39
|
/** False when the editor runs outside the EmDash admin, where admin links would lead nowhere. */
|
|
30
40
|
export const useAdminLinks = (): boolean => useEditorHost().adminLinks !== false;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* W-327: the host's canvas stylesheets, from the EditorHost or else the plugin's
|
|
44
|
+
* `editor/config` route. Empty while loading and when the route fails.
|
|
45
|
+
*/
|
|
46
|
+
export function useCanvasStyles(fetcher: Fetcher): readonly string[] {
|
|
47
|
+
const provided = useEditorHost().canvasStyles;
|
|
48
|
+
const [loaded, setLoaded] = React.useState<readonly string[]>([]);
|
|
49
|
+
React.useEffect(() => {
|
|
50
|
+
if (provided) return;
|
|
51
|
+
let cancelled = false;
|
|
52
|
+
void requestJson<{ canvasStyles?: unknown }>(
|
|
53
|
+
fetcher,
|
|
54
|
+
`/_emdash/api/plugins/${PLUGIN_ID}/editor/config`,
|
|
55
|
+
)
|
|
56
|
+
.then((body) => {
|
|
57
|
+
if (!cancelled) setLoaded(canvasStyleUrls(body?.canvasStyles));
|
|
58
|
+
})
|
|
59
|
+
.catch(() => undefined);
|
|
60
|
+
return () => {
|
|
61
|
+
cancelled = true;
|
|
62
|
+
};
|
|
63
|
+
}, [fetcher, provided]);
|
|
64
|
+
return provided ? canvasStyleUrls(provided) : loaded;
|
|
65
|
+
}
|