@perkyzz/emvb 0.9.0 → 1.0.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 +1 -1
- package/package.json +2 -2
- package/src/admin/agents-api.ts +45 -0
- package/src/admin/editor/A11yCopilot.tsx +1 -1
- package/src/admin/editor/Editor.tsx +297 -248
- package/src/admin/editor/Timeline.tsx +2 -1
- package/src/admin/editor/TopBar.tsx +4 -2
- package/src/admin/editor/canvas/CanvasFrame.tsx +2 -2
- package/src/admin/editor/canvas/DeviceBar.tsx +17 -9
- package/src/admin/editor/canvas/canvas-scale.ts +2 -2
- package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
- package/src/admin/editor/co-design.ts +190 -0
- package/src/admin/editor/dnd/new-element.ts +26 -4
- package/src/admin/editor/editor-chrome.tsx +3 -3
- package/src/admin/editor/editor-commands.ts +8 -3
- package/src/admin/editor/element-chrome.ts +3 -1
- package/src/admin/editor/extension-manifests.ts +20 -0
- package/src/admin/editor/extensions/ExtensionPanels.tsx +26 -0
- package/src/admin/editor/extensions-context.tsx +27 -0
- package/src/admin/editor/feature-css.ts +17 -0
- package/src/admin/editor/palette-items.ts +2 -2
- package/src/admin/editor/panels/AddPanel.tsx +31 -1
- package/src/admin/editor/panels/AgentRequestBox.tsx +116 -0
- package/src/admin/editor/panels/ClassesSection.tsx +9 -6
- package/src/admin/editor/panels/CoDesignPanel.tsx +170 -0
- package/src/admin/editor/panels/ColorControl.tsx +2 -2
- package/src/admin/editor/panels/ElementPanel.tsx +49 -14
- package/src/admin/editor/panels/LanguagesSection.tsx +152 -0
- package/src/admin/editor/panels/LayersPanel.tsx +10 -6
- package/src/admin/editor/panels/LeftPanel.tsx +33 -5
- package/src/admin/editor/panels/PageSettings.tsx +4 -0
- package/src/admin/editor/panels/SettingsPanel.tsx +21 -2
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +7 -7
- package/src/admin/editor/panels/settings/BackgroundControls.tsx +72 -15
- package/src/admin/editor/panels/settings/BackgroundFill.tsx +8 -6
- package/src/admin/editor/panels/settings/BoxControl.tsx +5 -5
- package/src/admin/editor/panels/settings/EffectsControls.tsx +104 -9
- package/src/admin/editor/panels/settings/FieldControl.tsx +9 -3
- package/src/admin/editor/panels/settings/IconControls.tsx +14 -11
- package/src/admin/editor/panels/settings/LengthRow.tsx +27 -16
- package/src/admin/editor/panels/settings/LoopControl.tsx +269 -0
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +1 -1
- package/src/admin/editor/panels/settings/MotionControl.tsx +12 -11
- package/src/admin/editor/panels/settings/QueryStyleRows.tsx +7 -4
- package/src/admin/editor/panels/settings/StyleRow.tsx +113 -13
- package/src/admin/editor/panels/settings/TextMarksControl.tsx +247 -0
- package/src/admin/editor/panels/settings/VariableBinding.tsx +2 -2
- package/src/admin/editor/panels/settings/background-mode.ts +14 -11
- package/src/admin/editor/panels/settings/box-link-name.ts +1 -1
- package/src/admin/editor/panels/settings/box-sides.ts +22 -14
- package/src/admin/editor/panels/settings/heading-warning.ts +5 -1
- package/src/admin/editor/panels/settings/length-units.ts +53 -1
- package/src/admin/editor/panels/settings/query-style.ts +3 -3
- package/src/admin/editor/panels/settings/style-sections.ts +51 -10
- package/src/admin/editor/panels/style-target.ts +9 -7
- package/src/admin/editor/presence.ts +60 -0
- package/src/admin/editor/store.ts +6 -2
- package/src/admin/editor/useCoDesign.ts +177 -0
- package/src/admin/editor/useEditorCommands.ts +4 -4
- package/src/admin/editor/useExtensions.ts +45 -0
- package/src/admin/editor/useNodeActions.ts +15 -6
- package/src/admin/editor/useProposals.ts +81 -0
- package/src/admin/languages-api.ts +61 -0
- package/src/admin/pages/AgentSetup.tsx +148 -0
- package/src/admin/pages/AgentsPage.tsx +9 -26
- package/src/admin/pages/CreateDialog.tsx +15 -0
- package/src/admin/pages/ImportButton.tsx +18 -0
- package/src/admin/pages/ImportElementorDialog.tsx +669 -0
- package/src/admin/pages/ImportPageLinks.tsx +86 -0
- package/src/admin/pages/PageList.tsx +15 -1
- package/src/admin/pages/ThemePartList.tsx +15 -1
- package/src/admin/pages/section-head.tsx +27 -0
- package/src/admin/proposals-api.ts +91 -0
- package/src/admin/ui.ts +39 -2
- package/src/astro/content-port.ts +14 -1
- package/src/astro/resolve-theme.ts +14 -1
- package/src/astro/resolve.ts +89 -2
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +44 -14
- package/src/core/arrange.ts +5 -1
- package/src/core/bounded-array.ts +31 -0
- package/src/core/clipboard.ts +9 -0
- package/src/core/contract.ts +285 -0
- package/src/core/css/generate.ts +89 -20
- package/src/core/css/trace.ts +18 -9
- package/src/core/css-keywords.ts +51 -1
- package/src/core/design/cascade.ts +12 -9
- package/src/core/design/classes.ts +4 -5
- package/src/core/design/devices.ts +13 -13
- package/src/core/design/states.ts +5 -3
- package/src/core/design/transfer.ts +5 -0
- package/src/core/design/variables.ts +17 -4
- package/src/core/elements/dynamic-elements.ts +3 -3
- package/src/core/elements/index.ts +73 -9
- package/src/core/extensions/define.ts +13 -0
- package/src/core/extensions/index.ts +41 -0
- package/src/core/extensions/namespace.ts +82 -0
- package/src/core/extensions/normalize.ts +141 -0
- package/src/core/extensions/placeholder.ts +41 -0
- package/src/core/extensions/registry.ts +94 -0
- package/src/core/extensions/render-ext.ts +118 -0
- package/src/core/extensions/safe-nodes.ts +93 -0
- package/src/core/extensions/schema.ts +112 -0
- package/src/core/extensions/types.ts +159 -0
- package/src/core/forms/binding.ts +1 -1
- package/src/core/history/diff.ts +1 -1
- package/src/core/import/elementor/atomic.ts +1595 -0
- package/src/core/import/elementor/classes.ts +127 -0
- package/src/core/import/elementor/context.ts +429 -0
- package/src/core/import/elementor/counter-steps.ts +72 -0
- package/src/core/import/elementor/css.ts +445 -0
- package/src/core/import/elementor/html.ts +500 -0
- package/src/core/import/elementor/index.ts +949 -0
- package/src/core/import/elementor/inline-marks.ts +81 -0
- package/src/core/import/elementor/snapshots.ts +48 -0
- package/src/core/import/elementor/style.ts +409 -0
- package/src/core/import/elementor/values.ts +241 -0
- package/src/core/import/elementor/widgets.ts +1897 -0
- package/src/core/index.ts +82 -0
- package/src/core/json-schema.ts +107 -0
- package/src/core/limits.ts +19 -0
- package/src/core/migrate/index.ts +6 -1
- package/src/core/migrate/v18.ts +222 -0
- package/src/core/perf/meter.ts +5 -5
- package/src/core/proposals-safety.ts +102 -0
- package/src/core/proposals.ts +357 -0
- package/src/core/recipes/index.ts +2 -2
- package/src/core/render/extras.ts +3 -3
- package/src/core/render/index.ts +140 -20
- package/src/core/render/loop.ts +1 -1
- package/src/core/render/section.ts +4 -4
- package/src/core/render/vnode.ts +1 -1
- package/src/core/sanitize/css.ts +125 -10
- package/src/core/sanitize/motion.ts +116 -0
- package/src/core/saved-sections.ts +6 -0
- package/src/core/schema/descriptors.ts +3 -1
- package/src/core/schema/design.ts +2 -1
- package/src/core/schema/layout.ts +82 -14
- package/src/core/schema/style.ts +251 -114
- package/src/core/text-marks.ts +227 -0
- package/src/core/theme/dynamic.ts +9 -4
- package/src/core/theme/float.ts +1 -0
- package/src/core/theme/popup-rules.ts +17 -1
- package/src/core/translatable.ts +34 -0
- package/src/core/validate.ts +13 -1
- package/src/index.ts +24 -0
- package/src/mcp/errors.ts +3 -1
- package/src/mcp/ports.ts +67 -0
- package/src/mcp/prompts.ts +1 -11
- package/src/mcp/proposals.ts +281 -0
- package/src/mcp/read.ts +10 -9
- package/src/mcp/tools.ts +71 -3
- package/src/mcp/write.ts +66 -11
- package/src/server/agent-settings.ts +5 -1
- package/src/server/mcp-routes.ts +15 -0
- package/src/server/plugin.ts +35 -2
- package/src/server/presence.ts +78 -0
- package/src/server/proposals.ts +261 -0
- package/src/server/requests.ts +196 -0
- package/src/server/tools-served.ts +45 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Badge, Button, Checkbox } from "@cloudflare/kumo";
|
|
2
|
+
import { TranslateIcon } from "@phosphor-icons/react";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import type { Layout } from "../../../core/schema/layout.ts";
|
|
5
|
+
import { translatableStrings } from "../../../core/translatable.ts";
|
|
6
|
+
import type { Fetcher } from "../../api.ts";
|
|
7
|
+
import { ApiError } from "../../api.ts";
|
|
8
|
+
import {
|
|
9
|
+
createTranslation,
|
|
10
|
+
listTranslations,
|
|
11
|
+
siteLocales,
|
|
12
|
+
type Translation,
|
|
13
|
+
} from "../../languages-api.ts";
|
|
14
|
+
import { createRequest } from "../../proposals-api.ts";
|
|
15
|
+
import { editorUrl } from "../exit.ts";
|
|
16
|
+
|
|
17
|
+
const nameOf = (locale: string) => {
|
|
18
|
+
try {
|
|
19
|
+
return new Intl.DisplayNames(undefined, { type: "language" }).of(locale) ?? locale;
|
|
20
|
+
} catch {
|
|
21
|
+
return locale;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* W-936 Translate this page (D-068): each language is its own entry. A missing one is created as
|
|
27
|
+
* a draft copy of this layout (EmDash's `translationOf`) and opened; optionally the person's agent
|
|
28
|
+
* is asked to translate it, and its proposal is reviewed in the new page's Agent tab.
|
|
29
|
+
*/
|
|
30
|
+
export function LanguagesSection({
|
|
31
|
+
fetcher,
|
|
32
|
+
collection,
|
|
33
|
+
entryId,
|
|
34
|
+
title,
|
|
35
|
+
slug,
|
|
36
|
+
layout,
|
|
37
|
+
navigate = (url) => window.location.assign(url),
|
|
38
|
+
}: {
|
|
39
|
+
fetcher: Fetcher;
|
|
40
|
+
collection: string;
|
|
41
|
+
entryId: string;
|
|
42
|
+
title: string;
|
|
43
|
+
slug: string;
|
|
44
|
+
layout: Layout | null;
|
|
45
|
+
navigate?: (url: string) => void;
|
|
46
|
+
}) {
|
|
47
|
+
const [site, setSite] = React.useState<{ defaultLocale: string; locales: string[] } | null>(null);
|
|
48
|
+
const [translations, setTranslations] = React.useState<Translation[]>([]);
|
|
49
|
+
const [askAgent, setAskAgent] = React.useState(true);
|
|
50
|
+
const [busy, setBusy] = React.useState<string | null>(null);
|
|
51
|
+
const [error, setError] = React.useState<string | null>(null);
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
let cancelled = false;
|
|
54
|
+
siteLocales(fetcher)
|
|
55
|
+
.then(async (locales) => {
|
|
56
|
+
if (cancelled || !locales) return;
|
|
57
|
+
setSite(locales);
|
|
58
|
+
const list = await listTranslations(fetcher, collection, entryId);
|
|
59
|
+
if (!cancelled) setTranslations(list);
|
|
60
|
+
})
|
|
61
|
+
.catch(() => undefined);
|
|
62
|
+
return () => {
|
|
63
|
+
cancelled = true;
|
|
64
|
+
};
|
|
65
|
+
}, [fetcher, collection, entryId]);
|
|
66
|
+
if (!site) return null;
|
|
67
|
+
const current = translations.find((t) => t.id === entryId)?.locale ?? site.defaultLocale;
|
|
68
|
+
const texts = layout ? translatableStrings(layout).length : 0;
|
|
69
|
+
|
|
70
|
+
const translate = async (locale: string) => {
|
|
71
|
+
if (!layout || busy) return;
|
|
72
|
+
setBusy(locale);
|
|
73
|
+
setError(null);
|
|
74
|
+
try {
|
|
75
|
+
const id = await createTranslation(fetcher, {
|
|
76
|
+
collection,
|
|
77
|
+
sourceId: entryId,
|
|
78
|
+
locale,
|
|
79
|
+
title,
|
|
80
|
+
slug,
|
|
81
|
+
layout,
|
|
82
|
+
});
|
|
83
|
+
if (askAgent) {
|
|
84
|
+
await createRequest(
|
|
85
|
+
fetcher,
|
|
86
|
+
collection,
|
|
87
|
+
id,
|
|
88
|
+
`Translate this page from ${nameOf(current)} (${current}) into ${nameOf(locale)} (${locale}). Change only the words (${texts} texts: headings, text, buttons, alt text, labels); keep the layout, links, images and styles.`,
|
|
89
|
+
).catch(() => undefined);
|
|
90
|
+
}
|
|
91
|
+
navigate(editorUrl(id, collection));
|
|
92
|
+
} catch (e) {
|
|
93
|
+
setError(e instanceof ApiError ? e.message : "Couldn't create the translation. Try again.");
|
|
94
|
+
setBusy(null);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<section className="emvb-field-group" aria-label="Languages" data-emvb-languages="">
|
|
100
|
+
<span className="emvb-field-label">Languages</span>
|
|
101
|
+
<ul className="emvb-codesign-ops">
|
|
102
|
+
{site.locales.map((locale) => {
|
|
103
|
+
const found = translations.find((t) => t.locale === locale);
|
|
104
|
+
return (
|
|
105
|
+
<li key={locale} className="emvb-codesign-op" data-emvb-language={locale}>
|
|
106
|
+
<span className="emvb-codesign-op-text">
|
|
107
|
+
{nameOf(locale)} <span className="emvb-helper">({locale})</span>
|
|
108
|
+
</span>
|
|
109
|
+
<span className="emvb-codesign-op-actions">
|
|
110
|
+
{locale === current ? (
|
|
111
|
+
<Badge variant="blue">This page</Badge>
|
|
112
|
+
) : found ? (
|
|
113
|
+
<Button
|
|
114
|
+
size="sm"
|
|
115
|
+
variant="ghost"
|
|
116
|
+
data-emvb-language-open=""
|
|
117
|
+
onClick={() => navigate(editorUrl(found.id, collection))}
|
|
118
|
+
>
|
|
119
|
+
Open
|
|
120
|
+
</Button>
|
|
121
|
+
) : (
|
|
122
|
+
<Button
|
|
123
|
+
size="sm"
|
|
124
|
+
variant="secondary"
|
|
125
|
+
icon={<TranslateIcon aria-hidden="true" />}
|
|
126
|
+
aria-busy={busy === locale || undefined}
|
|
127
|
+
disabled={!layout || (busy !== null && busy !== locale)}
|
|
128
|
+
data-emvb-language-translate=""
|
|
129
|
+
onClick={() => void translate(locale)}
|
|
130
|
+
>
|
|
131
|
+
Translate
|
|
132
|
+
</Button>
|
|
133
|
+
)}
|
|
134
|
+
</span>
|
|
135
|
+
</li>
|
|
136
|
+
);
|
|
137
|
+
})}
|
|
138
|
+
</ul>
|
|
139
|
+
{site.locales.some((l) => l !== current && !translations.some((t) => t.locale === l)) && (
|
|
140
|
+
<Checkbox
|
|
141
|
+
label="Ask my agent to translate the new page"
|
|
142
|
+
checked={askAgent}
|
|
143
|
+
onCheckedChange={(checked: boolean) => setAskAgent(checked)}
|
|
144
|
+
/>
|
|
145
|
+
)}
|
|
146
|
+
<p className="emvb-helper" role={error ? "alert" : undefined}>
|
|
147
|
+
{error ??
|
|
148
|
+
`Translate copies this page's layout into a draft in that language (${texts} texts to translate), then opens it.`}
|
|
149
|
+
</p>
|
|
150
|
+
</section>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
@@ -365,10 +365,10 @@ const LayerRow = React.memo(function LayerRow({
|
|
|
365
365
|
const preview = layerPreview(node);
|
|
366
366
|
const typeName = ELEMENT_NAMES[node.type] ?? node.type;
|
|
367
367
|
// A label names the row in place of the type (W-157); the type stays in the tooltip.
|
|
368
|
-
const name = node.
|
|
368
|
+
const name = node.editorLabel ?? typeName;
|
|
369
369
|
// Names and previews truncate, so the tooltip carries them in full (DESIGN.md, W-168).
|
|
370
|
-
const tooltip = node.
|
|
371
|
-
? `${node.
|
|
370
|
+
const tooltip = node.editorLabel
|
|
371
|
+
? `${node.editorLabel} (${typeName})`
|
|
372
372
|
: preview
|
|
373
373
|
? `${typeName}: ${preview}`
|
|
374
374
|
: typeName;
|
|
@@ -439,7 +439,7 @@ const LayerRow = React.memo(function LayerRow({
|
|
|
439
439
|
setRenaming(false);
|
|
440
440
|
if (text === null || !actions.onRename) return;
|
|
441
441
|
const next = clipText(text.trim(), 80).trim() || undefined;
|
|
442
|
-
if (next !== node.
|
|
442
|
+
if (next !== node.editorLabel) actions.onRename(node.id, next);
|
|
443
443
|
};
|
|
444
444
|
return (
|
|
445
445
|
<li role="treeitem" aria-expanded={hasChildren ? !collapsed : undefined}>
|
|
@@ -477,7 +477,11 @@ const LayerRow = React.memo(function LayerRow({
|
|
|
477
477
|
<span className="emvb-layer-caret" />
|
|
478
478
|
)}
|
|
479
479
|
{renaming ? (
|
|
480
|
-
<RenameInput
|
|
480
|
+
<RenameInput
|
|
481
|
+
initial={node.editorLabel ?? ""}
|
|
482
|
+
placeholder={typeName}
|
|
483
|
+
onDone={finishRename}
|
|
484
|
+
/>
|
|
481
485
|
) : (
|
|
482
486
|
<button
|
|
483
487
|
ref={selectButton}
|
|
@@ -485,7 +489,7 @@ const LayerRow = React.memo(function LayerRow({
|
|
|
485
489
|
className="emvb-layer-select"
|
|
486
490
|
aria-current={selected ? "true" : undefined}
|
|
487
491
|
title={tooltip}
|
|
488
|
-
data-emvb-layer-label={node.
|
|
492
|
+
data-emvb-layer-label={node.editorLabel ? "" : undefined}
|
|
489
493
|
onDoubleClick={startRename}
|
|
490
494
|
onKeyDown={(event) => {
|
|
491
495
|
if (event.key === "F2") {
|
|
@@ -3,12 +3,15 @@ import * as React from "react";
|
|
|
3
3
|
import type { ElementType, Layout } from "../../../core/index.ts";
|
|
4
4
|
import { AddPanel } from "./AddPanel.tsx";
|
|
5
5
|
import { LayersPanel } from "./LayersPanel.tsx";
|
|
6
|
+
import { CoDesignPanel } from "./CoDesignPanel.tsx";
|
|
7
|
+
import type { CoDesign } from "../useCoDesign.ts";
|
|
8
|
+
import { ExtensionPanels } from "../extensions/ExtensionPanels.tsx";
|
|
6
9
|
import type { ClipboardActions } from "../useClipboardActions.ts";
|
|
7
10
|
import type { SavedSectionActions } from "../useSavedSections.ts";
|
|
8
11
|
|
|
9
12
|
const SESSION_KEY = "emvb-left-tab";
|
|
10
13
|
|
|
11
|
-
/** Add | Layers left panel (W-018). Remembers the last tab for the session. */
|
|
14
|
+
/** Add | Layers | Agent left panel (W-018, W-930). Remembers the last tab for the session. */
|
|
12
15
|
export function LeftPanel({
|
|
13
16
|
layout,
|
|
14
17
|
selectedId,
|
|
@@ -24,11 +27,12 @@ export function LeftPanel({
|
|
|
24
27
|
onRename,
|
|
25
28
|
onSaveSection,
|
|
26
29
|
formsAvailable = true,
|
|
30
|
+
coDesign,
|
|
27
31
|
}: {
|
|
28
32
|
layout: Layout | null;
|
|
29
33
|
selectedId: string | null;
|
|
30
34
|
onSelect: (id: string) => void;
|
|
31
|
-
onAdd: (type: ElementType) => void;
|
|
35
|
+
onAdd: (type: ElementType | string) => void;
|
|
32
36
|
/** Adds a section recipe (W-320). */
|
|
33
37
|
onRecipe?: (id: string) => void;
|
|
34
38
|
/** My sections (W-876). */
|
|
@@ -43,10 +47,13 @@ export function LeftPanel({
|
|
|
43
47
|
/** Save as section in the row menu (W-876). */
|
|
44
48
|
onSaveSection?: (id: string) => void;
|
|
45
49
|
formsAvailable?: boolean;
|
|
50
|
+
/** W-930: agent proposals to review; the Agent tab shows only with it. */
|
|
51
|
+
coDesign?: CoDesign;
|
|
46
52
|
}) {
|
|
47
53
|
const [tab, setTab] = React.useState(() => {
|
|
48
54
|
try {
|
|
49
|
-
|
|
55
|
+
const last = sessionStorage.getItem(SESSION_KEY);
|
|
56
|
+
return last === "layers" || (last === "agent" && coDesign) ? last : "add";
|
|
50
57
|
} catch {
|
|
51
58
|
return "add";
|
|
52
59
|
}
|
|
@@ -67,12 +74,33 @@ export function LeftPanel({
|
|
|
67
74
|
tabs={[
|
|
68
75
|
{ value: "add", label: "Add" },
|
|
69
76
|
{ value: "layers", label: "Layers" },
|
|
77
|
+
...(coDesign
|
|
78
|
+
? [
|
|
79
|
+
{
|
|
80
|
+
value: "agent",
|
|
81
|
+
label:
|
|
82
|
+
coDesign.proposals.items.length > 0
|
|
83
|
+
? `Agent (${coDesign.proposals.items.length})`
|
|
84
|
+
: "Agent",
|
|
85
|
+
},
|
|
86
|
+
]
|
|
87
|
+
: []),
|
|
70
88
|
]}
|
|
71
89
|
value={tab}
|
|
72
90
|
onValueChange={changeTab}
|
|
73
91
|
/>
|
|
74
|
-
{tab === "
|
|
75
|
-
<
|
|
92
|
+
{tab === "agent" && coDesign ? (
|
|
93
|
+
<CoDesignPanel co={coDesign} layout={layout} />
|
|
94
|
+
) : tab === "add" ? (
|
|
95
|
+
<>
|
|
96
|
+
<AddPanel
|
|
97
|
+
onAdd={onAdd}
|
|
98
|
+
onRecipe={onRecipe}
|
|
99
|
+
saved={saved}
|
|
100
|
+
formsAvailable={formsAvailable}
|
|
101
|
+
/>
|
|
102
|
+
<ExtensionPanels />
|
|
103
|
+
</>
|
|
76
104
|
) : (
|
|
77
105
|
<LayersPanel
|
|
78
106
|
layout={layout}
|
|
@@ -40,6 +40,7 @@ export function PageSettings({
|
|
|
40
40
|
onChange,
|
|
41
41
|
kind = "page",
|
|
42
42
|
fetcher,
|
|
43
|
+
languages,
|
|
43
44
|
}: {
|
|
44
45
|
page: PageDraft;
|
|
45
46
|
slugError: string | null;
|
|
@@ -47,6 +48,8 @@ export function PageSettings({
|
|
|
47
48
|
kind?: "page" | "theme-part";
|
|
48
49
|
/** For the Social image picker (W-287); without it the field isn't offered. */
|
|
49
50
|
fetcher?: Fetcher;
|
|
51
|
+
/** W-936: the Languages section, when the site has more than one. */
|
|
52
|
+
languages?: React.ReactNode;
|
|
50
53
|
}) {
|
|
51
54
|
// Hooks run before the theme-part branch, so switching `kind` keeps the hook order (W-092).
|
|
52
55
|
const descriptionId = React.useId();
|
|
@@ -234,6 +237,7 @@ export function PageSettings({
|
|
|
234
237
|
/>
|
|
235
238
|
</Collapsible.Panel>
|
|
236
239
|
</Collapsible.Root>
|
|
240
|
+
{languages}
|
|
237
241
|
</div>
|
|
238
242
|
);
|
|
239
243
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type * as React from "react";
|
|
2
2
|
import type { Deletion } from "../restore-deleted.ts";
|
|
3
|
-
import type { DesignSystem, LayoutNode,
|
|
3
|
+
import type { DesignSystem, LayoutNode, Device } from "../../../core/index.ts";
|
|
4
4
|
import type { Fetcher } from "../../api.ts";
|
|
5
5
|
import type { EditorAction, EditorState } from "../store.ts";
|
|
6
6
|
import { ElementPanel } from "./ElementPanel.tsx";
|
|
7
7
|
import type { ItemActions } from "./settings/ItemList.tsx";
|
|
8
8
|
import type { StyleStateChoice } from "./settings/StateSwitcher.tsx";
|
|
9
9
|
import { PageSettings } from "./PageSettings.tsx";
|
|
10
|
+
import { LanguagesSection } from "./LanguagesSection.tsx";
|
|
11
|
+
import { PAGES_COLLECTION } from "../../../constants.ts";
|
|
10
12
|
import { SiteStylesDrawer } from "./SiteStylesDrawer.tsx";
|
|
11
13
|
|
|
12
14
|
/** The right panel: Site styles when open, else the selected element's settings, else page settings. */
|
|
@@ -26,6 +28,7 @@ export function SettingsPanel({
|
|
|
26
28
|
slugError,
|
|
27
29
|
onSlugEdit,
|
|
28
30
|
kind,
|
|
31
|
+
translatable = false,
|
|
29
32
|
onStyleState,
|
|
30
33
|
device = "desktop",
|
|
31
34
|
items,
|
|
@@ -46,10 +49,12 @@ export function SettingsPanel({
|
|
|
46
49
|
slugError: string | null;
|
|
47
50
|
onSlugEdit: () => void;
|
|
48
51
|
kind: "page" | "theme-part";
|
|
52
|
+
/** W-936: an EmVB page (not field mode) offers its other languages. */
|
|
53
|
+
translatable?: boolean;
|
|
49
54
|
/** The Style tab's chosen state, for the canvas preview (W-089). */
|
|
50
55
|
onStyleState?: (nodeId: string, state: StyleStateChoice) => void;
|
|
51
56
|
/** Which device's styles the Style tab edits (W-096). */
|
|
52
|
-
device?:
|
|
57
|
+
device?: Device;
|
|
53
58
|
/** Accordion and Tabs item actions (W-130). */
|
|
54
59
|
items?: ItemActions;
|
|
55
60
|
}) {
|
|
@@ -115,6 +120,20 @@ export function SettingsPanel({
|
|
|
115
120
|
slugError={slugError}
|
|
116
121
|
kind={kind}
|
|
117
122
|
fetcher={fetcher}
|
|
123
|
+
{...(translatable && kind === "page"
|
|
124
|
+
? {
|
|
125
|
+
languages: (
|
|
126
|
+
<LanguagesSection
|
|
127
|
+
fetcher={fetcher}
|
|
128
|
+
collection={PAGES_COLLECTION}
|
|
129
|
+
entryId={state.id}
|
|
130
|
+
title={state.page.title}
|
|
131
|
+
slug={state.page.slug}
|
|
132
|
+
layout={state.page.layout}
|
|
133
|
+
/>
|
|
134
|
+
),
|
|
135
|
+
}
|
|
136
|
+
: {})}
|
|
118
137
|
onChange={(patch) => {
|
|
119
138
|
if (patch.slug !== undefined) onSlugEdit();
|
|
120
139
|
dispatch({ type: "set-page", patch });
|
|
@@ -20,7 +20,9 @@ import {
|
|
|
20
20
|
type DefaultStyleTag,
|
|
21
21
|
type DesignSystem,
|
|
22
22
|
type Layout,
|
|
23
|
-
type
|
|
23
|
+
type FlatStyleProps,
|
|
24
|
+
flattenMotion,
|
|
25
|
+
patchNestedStyle,
|
|
24
26
|
type VariableKind,
|
|
25
27
|
} from "../../../core/index.ts";
|
|
26
28
|
import { BUTTON, SOLID_DESTRUCTIVE } from "../../ui.ts";
|
|
@@ -566,12 +568,10 @@ function DefaultsSection({
|
|
|
566
568
|
onSave: (design: DesignSystem) => Promise<boolean | void>;
|
|
567
569
|
}) {
|
|
568
570
|
const [tag, setTag] = React.useState<DefaultStyleTag>("p");
|
|
569
|
-
const
|
|
570
|
-
const
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
if (partial[key] === undefined) delete next[key];
|
|
574
|
-
}
|
|
571
|
+
const stored = design.defaults?.[tag];
|
|
572
|
+
const style = flattenMotion(stored);
|
|
573
|
+
const patch = (partial: Partial<FlatStyleProps>) => {
|
|
574
|
+
const next = patchNestedStyle(stored, partial);
|
|
575
575
|
const defaults = {
|
|
576
576
|
...design.defaults,
|
|
577
577
|
[tag]: Object.keys(next).length > 0 ? next : undefined,
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { Button, Input, Select } from "@cloudflare/kumo";
|
|
2
2
|
import { PlusIcon } from "@phosphor-icons/react";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
sanitizeMediaUrl,
|
|
6
|
+
type DesignSystem,
|
|
7
|
+
type FlatStyleProps,
|
|
8
|
+
} from "../../../../core/index.ts";
|
|
5
9
|
import type { Fetcher } from "../../../api.ts";
|
|
6
10
|
import { listImages, uploadImage, type MediaLibraryItem } from "../../../media-api.ts";
|
|
7
11
|
import { BUTTON, FIELD } from "../../../ui.ts";
|
|
@@ -9,8 +13,8 @@ import { ColorControl } from "../ColorControl.tsx";
|
|
|
9
13
|
import { NumberField, type NumberSpec } from "./NumberRow.tsx";
|
|
10
14
|
import { isCommitEnter } from "../../ime.ts";
|
|
11
15
|
|
|
12
|
-
type Gradient = NonNullable<
|
|
13
|
-
type Overlay = NonNullable<
|
|
16
|
+
type Gradient = NonNullable<FlatStyleProps["gradient"]>;
|
|
17
|
+
type Overlay = NonNullable<FlatStyleProps["overlay"]>;
|
|
14
18
|
|
|
15
19
|
const ANGLE: NumberSpec = { min: 0, max: 360, integer: true, example: "180", suffix: "°" };
|
|
16
20
|
const OVERLAY_OPACITY: NumberSpec = { min: 0, max: 100, scale: 100, example: "40", suffix: "%" };
|
|
@@ -404,6 +408,18 @@ export function GradientControl({
|
|
|
404
408
|
);
|
|
405
409
|
}
|
|
406
410
|
|
|
411
|
+
/** A gradient overlay starts as a scrim: dark behind the text on the left, clear on the right. */
|
|
412
|
+
const NEW_GRADIENT_OVERLAY: Overlay = {
|
|
413
|
+
gradient: {
|
|
414
|
+
type: "linear",
|
|
415
|
+
angle: 90,
|
|
416
|
+
stops: [
|
|
417
|
+
{ color: "#000000cc", at: 0 },
|
|
418
|
+
{ color: "#00000000", at: 100 },
|
|
419
|
+
],
|
|
420
|
+
},
|
|
421
|
+
};
|
|
422
|
+
|
|
407
423
|
export function OverlayControl({
|
|
408
424
|
value,
|
|
409
425
|
design,
|
|
@@ -417,9 +433,19 @@ export function OverlayControl({
|
|
|
417
433
|
onDesignChange: (design: DesignSystem) => Promise<void>;
|
|
418
434
|
reset: React.ReactNode;
|
|
419
435
|
}) {
|
|
420
|
-
const
|
|
421
|
-
|
|
422
|
-
|
|
436
|
+
const kind = value && "gradient" in value ? "gradient" : "color";
|
|
437
|
+
// W-949: switching kind keeps the opacity and swaps the paint.
|
|
438
|
+
const choose = (next: "color" | "gradient") => {
|
|
439
|
+
if (!value || next === kind) return;
|
|
440
|
+
const opacity = value.opacity;
|
|
441
|
+
if (next === "gradient") {
|
|
442
|
+
onChange({
|
|
443
|
+
...NEW_GRADIENT_OVERLAY,
|
|
444
|
+
...(opacity !== undefined && opacity !== 1 ? { opacity } : {}),
|
|
445
|
+
});
|
|
446
|
+
} else {
|
|
447
|
+
onChange({ ...NEW_OVERLAY, ...(opacity !== undefined ? { opacity } : {}) });
|
|
448
|
+
}
|
|
423
449
|
};
|
|
424
450
|
return (
|
|
425
451
|
<div className="emvb-style-row" data-emvb-style="overlay" data-set={value ? "true" : undefined}>
|
|
@@ -427,19 +453,50 @@ export function OverlayControl({
|
|
|
427
453
|
<span className="emvb-var-field-label">Overlay</span>
|
|
428
454
|
{value ? (
|
|
429
455
|
<>
|
|
430
|
-
<
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
456
|
+
<div className="emvb-fill-types" role="radiogroup" aria-label="Overlay type">
|
|
457
|
+
{(["color", "gradient"] as const).map((option) => (
|
|
458
|
+
<button
|
|
459
|
+
key={option}
|
|
460
|
+
type="button"
|
|
461
|
+
role="radio"
|
|
462
|
+
aria-checked={kind === option}
|
|
463
|
+
// The Fill type above has its own Color and Gradient: these name the overlay.
|
|
464
|
+
aria-label={option === "color" ? "Color overlay" : "Gradient overlay"}
|
|
465
|
+
data-emvb-overlay-type={option}
|
|
466
|
+
onClick={() => choose(option)}
|
|
467
|
+
>
|
|
468
|
+
{option === "color" ? "Color" : "Gradient"}
|
|
469
|
+
</button>
|
|
470
|
+
))}
|
|
471
|
+
</div>
|
|
472
|
+
{"color" in value ? (
|
|
473
|
+
<ColorControl
|
|
474
|
+
label="Overlay color"
|
|
475
|
+
value={value.color}
|
|
476
|
+
design={design}
|
|
477
|
+
onChange={(color) => color && onChange({ ...value, color })}
|
|
478
|
+
onDesignChange={onDesignChange}
|
|
479
|
+
/>
|
|
480
|
+
) : (
|
|
481
|
+
<GradientControl
|
|
482
|
+
value={value.gradient}
|
|
483
|
+
design={design}
|
|
484
|
+
onChange={(gradient) => onChange({ ...value, gradient })}
|
|
485
|
+
onDesignChange={onDesignChange}
|
|
486
|
+
/>
|
|
487
|
+
)}
|
|
437
488
|
<NumberField
|
|
438
489
|
fieldKey="overlay.opacity"
|
|
439
490
|
label="Overlay opacity"
|
|
440
|
-
value={value.opacity}
|
|
491
|
+
value={value.opacity ?? ("gradient" in value ? 1 : undefined)}
|
|
441
492
|
spec={OVERLAY_OPACITY}
|
|
442
|
-
onCommit={(n) =>
|
|
493
|
+
onCommit={(n) => {
|
|
494
|
+
if ("color" in value) onChange({ ...value, opacity: n ?? 0 });
|
|
495
|
+
else {
|
|
496
|
+
const { opacity: _old, ...rest } = value;
|
|
497
|
+
onChange(n === undefined || n === 1 ? rest : { ...rest, opacity: n });
|
|
498
|
+
}
|
|
499
|
+
}}
|
|
443
500
|
/>
|
|
444
501
|
</>
|
|
445
502
|
) : (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Input, Select } from "@cloudflare/kumo";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import type { DesignSystem,
|
|
3
|
+
import type { DesignSystem, FlatStyleProps } from "../../../../core/index.ts";
|
|
4
4
|
import type { Fetcher } from "../../../api.ts";
|
|
5
5
|
import { FIELD } from "../../../ui.ts";
|
|
6
6
|
import { ColorControl } from "../ColorControl.tsx";
|
|
@@ -39,14 +39,14 @@ export function BackgroundFill({
|
|
|
39
39
|
reset,
|
|
40
40
|
memoryScope = "",
|
|
41
41
|
}: {
|
|
42
|
-
style:
|
|
42
|
+
style: FlatStyleProps | undefined;
|
|
43
43
|
elementType?: string;
|
|
44
44
|
design: DesignSystem;
|
|
45
45
|
fetcher?: Fetcher;
|
|
46
46
|
sizeOptions: { value: string; label: string }[];
|
|
47
47
|
positionOptions: { value: string; label: string }[];
|
|
48
48
|
repeatOptions: { value: string; label: string }[];
|
|
49
|
-
onPatch: (patch: Partial<
|
|
49
|
+
onPatch: (patch: Partial<FlatStyleProps>) => void;
|
|
50
50
|
onDesignChange: (design: DesignSystem) => Promise<void>;
|
|
51
51
|
reset: React.ReactNode;
|
|
52
52
|
/** Keeps remembered fills apart per class, device and state on one element (W-184). */
|
|
@@ -140,7 +140,7 @@ export function BackgroundFill({
|
|
|
140
140
|
value={style?.backgroundSize}
|
|
141
141
|
options={sizeOptions}
|
|
142
142
|
onChange={(backgroundSize) =>
|
|
143
|
-
onPatch({ backgroundSize: backgroundSize as
|
|
143
|
+
onPatch({ backgroundSize: backgroundSize as FlatStyleProps["backgroundSize"] })
|
|
144
144
|
}
|
|
145
145
|
/>
|
|
146
146
|
<OptionSelect
|
|
@@ -149,7 +149,7 @@ export function BackgroundFill({
|
|
|
149
149
|
options={positionOptions}
|
|
150
150
|
onChange={(backgroundPosition) =>
|
|
151
151
|
onPatch({
|
|
152
|
-
backgroundPosition: backgroundPosition as
|
|
152
|
+
backgroundPosition: backgroundPosition as FlatStyleProps["backgroundPosition"],
|
|
153
153
|
})
|
|
154
154
|
}
|
|
155
155
|
/>
|
|
@@ -158,7 +158,9 @@ export function BackgroundFill({
|
|
|
158
158
|
value={style?.backgroundRepeat}
|
|
159
159
|
options={repeatOptions}
|
|
160
160
|
onChange={(backgroundRepeat) =>
|
|
161
|
-
onPatch({
|
|
161
|
+
onPatch({
|
|
162
|
+
backgroundRepeat: backgroundRepeat as FlatStyleProps["backgroundRepeat"],
|
|
163
|
+
})
|
|
162
164
|
}
|
|
163
165
|
/>
|
|
164
166
|
</>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DropdownMenu } from "@cloudflare/kumo";
|
|
2
2
|
import { CaretDownIcon, LinkSimpleBreakIcon, LinkSimpleIcon } from "@phosphor-icons/react";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import type { DesignSystem,
|
|
4
|
+
import type { DesignSystem, FlatStyleProps } from "../../../../core/index.ts";
|
|
5
5
|
import {
|
|
6
6
|
allSame,
|
|
7
7
|
groupSet,
|
|
@@ -23,7 +23,7 @@ import { bindKind, boundRef, VariableButton } from "./VariableBinding.tsx";
|
|
|
23
23
|
import { isCommitEnter } from "../../ime.ts";
|
|
24
24
|
|
|
25
25
|
/** Margin's "auto" menu item: auto left and right margins centre a box with a width (W-151). */
|
|
26
|
-
const autoSidesPatch = (group: BoxGroup): Partial<
|
|
26
|
+
const autoSidesPatch = (group: BoxGroup): Partial<FlatStyleProps> => ({
|
|
27
27
|
[group.sides[1]]: "auto",
|
|
28
28
|
[group.sides[3]]: "auto",
|
|
29
29
|
});
|
|
@@ -40,11 +40,11 @@ export function BoxControl({
|
|
|
40
40
|
onPatch,
|
|
41
41
|
}: {
|
|
42
42
|
group: BoxGroup;
|
|
43
|
-
style:
|
|
43
|
+
style: FlatStyleProps | undefined;
|
|
44
44
|
/** The Normal styles while a state is edited, shown as placeholders (W-089). */
|
|
45
|
-
inherited?:
|
|
45
|
+
inherited?: FlatStyleProps;
|
|
46
46
|
design: DesignSystem;
|
|
47
|
-
onPatch: (patch: Partial<
|
|
47
|
+
onPatch: (patch: Partial<FlatStyleProps>) => void;
|
|
48
48
|
}) {
|
|
49
49
|
const values = sideValues(group, style);
|
|
50
50
|
const normal = inherited ? sideValues(group, inherited) : [];
|