@perkyzz/emvb 0.9.0 → 1.1.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 +10 -1
- package/package.json +2 -2
- package/src/admin/agents-api.ts +45 -0
- package/src/admin/bulk-api.ts +67 -0
- package/src/admin/content-api.ts +10 -6
- package/src/admin/copy-rich-text.ts +119 -0
- package/src/admin/dialog-tab-wrap.ts +78 -0
- package/src/admin/editor/A11yCopilot.tsx +3 -1
- package/src/admin/editor/Editor.tsx +311 -250
- package/src/admin/editor/Timeline.tsx +8 -3
- package/src/admin/editor/TopBar.tsx +29 -7
- package/src/admin/editor/canvas/CanvasFrame.tsx +7 -2
- package/src/admin/editor/canvas/DeviceBar.tsx +31 -10
- package/src/admin/editor/canvas/canvas-scale.ts +3 -3
- 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 +48 -4
- package/src/admin/editor/editor-chrome.tsx +8 -6
- package/src/admin/editor/editor-commands.ts +15 -4
- package/src/admin/editor/editor-css.ts +2 -1
- 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 +68 -20
- 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 +183 -10
- package/src/admin/editor/panels/settings/FieldControl.tsx +9 -3
- package/src/admin/editor/panels/settings/IconControls.tsx +25 -11
- package/src/admin/editor/panels/settings/LengthRow.tsx +63 -19
- package/src/admin/editor/panels/settings/LoopControl.tsx +269 -0
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +19 -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 +120 -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 +68 -4
- package/src/admin/editor/panels/settings/query-style.ts +3 -3
- package/src/admin/editor/panels/settings/style-sections.ts +52 -10
- package/src/admin/editor/panels/style-target.ts +22 -7
- package/src/admin/editor/presence.ts +60 -0
- package/src/admin/editor/section-templates.ts +26 -4
- package/src/admin/editor/store.ts +14 -4
- package/src/admin/editor/useCoDesign.ts +177 -0
- package/src/admin/editor/useEditorCommands.ts +7 -5
- package/src/admin/editor/useExtensions.ts +45 -0
- package/src/admin/editor/useNodeActions.ts +18 -7
- package/src/admin/editor/useProposals.ts +81 -0
- package/src/admin/export-api.ts +221 -0
- package/src/admin/index.tsx +6 -1
- 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/ExportDialog.tsx +395 -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 +82 -3
- package/src/admin/pages/ThemePartList.tsx +52 -2
- package/src/admin/pages/bulk.tsx +303 -0
- package/src/admin/pages/section-head.tsx +27 -0
- package/src/admin/proposals-api.ts +91 -0
- package/src/admin/search.ts +20 -0
- package/src/admin/theme-api.ts +4 -0
- package/src/admin/ui.ts +50 -4
- package/src/admin/widgets/CanvasField.tsx +8 -0
- package/src/admin/widgets/ConvertToRichText.tsx +136 -0
- package/src/admin/widgets/ExportEntryHtml.tsx +92 -0
- package/src/admin/widgets/convert-body.ts +73 -2
- package/src/astro/content-port.ts +14 -1
- package/src/astro/render.ts +6 -6
- package/src/astro/resolve-theme.ts +25 -8
- package/src/astro/resolve.ts +89 -2
- package/src/astro/tabs/runtime.ts +16 -6
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +45 -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 +305 -0
- package/src/core/css/generate.ts +151 -20
- package/src/core/css/scope.ts +10 -2
- package/src/core/css/trace.ts +47 -13
- package/src/core/css-keywords.ts +51 -1
- package/src/core/design/cascade.ts +12 -9
- package/src/core/design/classes.ts +28 -9
- package/src/core/design/devices.ts +89 -13
- package/src/core/design/states.ts +5 -3
- package/src/core/design/transfer.ts +5 -0
- package/src/core/design/variables.ts +31 -5
- package/src/core/elements/dynamic-elements.ts +3 -3
- package/src/core/elements/index.ts +73 -9
- package/src/core/export/runtimes.generated.ts +9 -0
- package/src/core/export/site.ts +562 -0
- package/src/core/export/zip.ts +95 -0
- 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 +26 -1
- package/src/core/import/elementor/atomic.ts +1608 -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 +967 -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 +429 -0
- package/src/core/import/elementor/values.ts +241 -0
- package/src/core/import/elementor/widgets.ts +1897 -0
- package/src/core/index.ts +96 -0
- package/src/core/json-schema.ts +114 -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 +42 -24
- package/src/core/portable-text-export.ts +243 -0
- package/src/core/proposals-safety.ts +102 -0
- package/src/core/proposals.ts +357 -0
- package/src/core/public-attributes.ts +30 -0
- package/src/core/recipes/index.ts +2 -2
- package/src/core/render/extras.ts +3 -3
- package/src/core/render/index.ts +222 -23
- package/src/core/render/loop.ts +1 -1
- package/src/core/render/section.ts +4 -4
- package/src/core/render/tabs.ts +18 -11
- package/src/core/render/vnode.ts +1 -1
- package/src/core/sanitize/css.ts +151 -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 +4 -3
- package/src/core/schema/layout.ts +92 -16
- package/src/core/schema/style.ts +296 -112
- package/src/core/search-text.ts +70 -0
- package/src/core/text-marks.ts +227 -0
- package/src/core/theme/dynamic.ts +9 -4
- package/src/core/theme/float.ts +2 -0
- package/src/core/theme/popup-rules.ts +33 -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 -10
- 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/icon-routes.ts +52 -12
- 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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Input, Select } from "@cloudflare/kumo";
|
|
2
2
|
import { MotionControl } from "./MotionControl.tsx";
|
|
3
|
-
import {
|
|
3
|
+
import { LoopControl } from "./LoopControl.tsx";
|
|
4
|
+
import { isSafeFontStack, type DesignSystem, type FlatStyleProps } from "../../../../core/index.ts";
|
|
4
5
|
import type { Fetcher } from "../../../api.ts";
|
|
5
6
|
import { FIELD } from "../../../ui.ts";
|
|
6
7
|
import { ColorControl } from "../ColorControl.tsx";
|
|
@@ -12,6 +13,7 @@ import {
|
|
|
12
13
|
EntranceControl,
|
|
13
14
|
FiltersControl,
|
|
14
15
|
ShadowControl,
|
|
16
|
+
TransformControl,
|
|
15
17
|
TransitionControl,
|
|
16
18
|
} from "./EffectsControls.tsx";
|
|
17
19
|
import {
|
|
@@ -33,6 +35,8 @@ const LENGTH_KEYS = new Set<StyleKey>([
|
|
|
33
35
|
"height",
|
|
34
36
|
"minHeight",
|
|
35
37
|
"maxHeight",
|
|
38
|
+
"flexBasis",
|
|
39
|
+
"markerSize",
|
|
36
40
|
"paddingTop",
|
|
37
41
|
"paddingRight",
|
|
38
42
|
"paddingBottom",
|
|
@@ -61,11 +65,14 @@ const LENGTH_KEYS = new Set<StyleKey>([
|
|
|
61
65
|
]);
|
|
62
66
|
|
|
63
67
|
const Z_INDEX: NumberSpec = { min: -9999, max: 9999, integer: true, example: "10" };
|
|
68
|
+
/** W-954: a flex child's share of free space (grow) or of the shortfall (shrink). */
|
|
69
|
+
const FLEX_FACTOR: NumberSpec = { min: 0, max: 100, example: "1" };
|
|
70
|
+
const ORDER: NumberSpec = { min: -99, max: 99, integer: true, example: "-1" };
|
|
64
71
|
const GRID_SPAN: NumberSpec = { min: 1, max: 12, integer: true, example: "2" };
|
|
65
72
|
const GRID_LINE: NumberSpec = { min: 1, max: 13, integer: true, example: "1" };
|
|
66
73
|
const OPACITY: NumberSpec = { min: 0, max: 100, scale: 100, example: "50", suffix: "%" };
|
|
67
74
|
|
|
68
|
-
const COLOR_KEYS = new Set<StyleKey>(["color", "backgroundColor", "borderColor"]);
|
|
75
|
+
const COLOR_KEYS = new Set<StyleKey>(["color", "backgroundColor", "borderColor", "markerColor"]);
|
|
69
76
|
|
|
70
77
|
const SELECT_OPTIONS: Partial<Record<StyleKey, { value: string; label: string }[]>> = {
|
|
71
78
|
textAlign: [
|
|
@@ -100,6 +107,39 @@ const SELECT_OPTIONS: Partial<Record<StyleKey, { value: string; label: string }[
|
|
|
100
107
|
{ value: "scroll", label: "Scroll" },
|
|
101
108
|
{ value: "auto", label: "Auto" },
|
|
102
109
|
],
|
|
110
|
+
alignSelf: [
|
|
111
|
+
{ value: "auto", label: "Follow the parent" },
|
|
112
|
+
{ value: "stretch", label: "Stretch" },
|
|
113
|
+
{ value: "flex-start", label: "Start" },
|
|
114
|
+
{ value: "center", label: "Center" },
|
|
115
|
+
{ value: "flex-end", label: "End" },
|
|
116
|
+
{ value: "baseline", label: "Baseline" },
|
|
117
|
+
],
|
|
118
|
+
overflowX: [
|
|
119
|
+
{ value: "visible", label: "Visible" },
|
|
120
|
+
{ value: "hidden", label: "Hidden" },
|
|
121
|
+
{ value: "clip", label: "Clip" },
|
|
122
|
+
{ value: "scroll", label: "Scroll" },
|
|
123
|
+
{ value: "auto", label: "Auto" },
|
|
124
|
+
],
|
|
125
|
+
overflowY: [
|
|
126
|
+
{ value: "visible", label: "Visible" },
|
|
127
|
+
{ value: "hidden", label: "Hidden" },
|
|
128
|
+
{ value: "clip", label: "Clip" },
|
|
129
|
+
{ value: "scroll", label: "Scroll" },
|
|
130
|
+
{ value: "auto", label: "Auto" },
|
|
131
|
+
],
|
|
132
|
+
objectPosition: [
|
|
133
|
+
{ value: "center", label: "Center" },
|
|
134
|
+
{ value: "top", label: "Top" },
|
|
135
|
+
{ value: "bottom", label: "Bottom" },
|
|
136
|
+
{ value: "left", label: "Left" },
|
|
137
|
+
{ value: "right", label: "Right" },
|
|
138
|
+
{ value: "top left", label: "Top left" },
|
|
139
|
+
{ value: "top right", label: "Top right" },
|
|
140
|
+
{ value: "bottom left", label: "Bottom left" },
|
|
141
|
+
{ value: "bottom right", label: "Bottom right" },
|
|
142
|
+
],
|
|
103
143
|
aspectRatio: [
|
|
104
144
|
{ value: "auto", label: "Auto" },
|
|
105
145
|
...["1/1", "4/3", "3/2", "16/9", "21/9", "3/4", "2/3", "9/16"].map((ratio) => ({
|
|
@@ -107,6 +147,21 @@ const SELECT_OPTIONS: Partial<Record<StyleKey, { value: string; label: string }[
|
|
|
107
147
|
label: ratio.replace("/", ":"),
|
|
108
148
|
})),
|
|
109
149
|
],
|
|
150
|
+
fontStyle: [
|
|
151
|
+
{ value: "normal", label: "Normal" },
|
|
152
|
+
{ value: "italic", label: "Italic" },
|
|
153
|
+
],
|
|
154
|
+
whiteSpace: [
|
|
155
|
+
{ value: "normal", label: "Wrap" },
|
|
156
|
+
{ value: "nowrap", label: "Don't wrap" },
|
|
157
|
+
{ value: "pre-line", label: "Keep line breaks" },
|
|
158
|
+
{ value: "pre-wrap", label: "Keep spaces and line breaks" },
|
|
159
|
+
],
|
|
160
|
+
overflowWrap: [
|
|
161
|
+
{ value: "normal", label: "Keep whole" },
|
|
162
|
+
{ value: "break-word", label: "Break if needed" },
|
|
163
|
+
{ value: "anywhere", label: "Break anywhere" },
|
|
164
|
+
],
|
|
110
165
|
objectFit: [
|
|
111
166
|
{ value: "fill", label: "Fill" },
|
|
112
167
|
{ value: "contain", label: "Contain" },
|
|
@@ -210,9 +265,9 @@ export function StyleRow({
|
|
|
210
265
|
onDesignChange,
|
|
211
266
|
}: {
|
|
212
267
|
styleKey: StyleKey;
|
|
213
|
-
style:
|
|
268
|
+
style: FlatStyleProps | undefined;
|
|
214
269
|
/** The Normal styles while a state is edited (W-089): shown as placeholders, never saved. */
|
|
215
|
-
inherited?:
|
|
270
|
+
inherited?: FlatStyleProps;
|
|
216
271
|
design: DesignSystem;
|
|
217
272
|
/** Present on an element, so a background image can use the media library. */
|
|
218
273
|
fetcher?: Fetcher;
|
|
@@ -220,7 +275,7 @@ export function StyleRow({
|
|
|
220
275
|
elementType?: string;
|
|
221
276
|
/** Which class and device the background fill memory belongs to (W-184). */
|
|
222
277
|
fillScope?: string;
|
|
223
|
-
onPatch: (patch: Partial<
|
|
278
|
+
onPatch: (patch: Partial<FlatStyleProps>) => void;
|
|
224
279
|
onDesignChange: (design: DesignSystem) => Promise<void>;
|
|
225
280
|
}) {
|
|
226
281
|
const value = style?.[styleKey];
|
|
@@ -287,7 +342,7 @@ export function StyleRow({
|
|
|
287
342
|
>
|
|
288
343
|
<ColorControl
|
|
289
344
|
label={label}
|
|
290
|
-
value={value as
|
|
345
|
+
value={value as FlatStyleProps["color"]}
|
|
291
346
|
placeholder={placeholder}
|
|
292
347
|
design={design}
|
|
293
348
|
onChange={(color) => onPatch({ [styleKey]: color })}
|
|
@@ -343,7 +398,7 @@ export function StyleRow({
|
|
|
343
398
|
const n = Number(next);
|
|
344
399
|
onPatch({
|
|
345
400
|
fontWeight: Number.isFinite(n)
|
|
346
|
-
? (n as NonNullable<
|
|
401
|
+
? (n as NonNullable<FlatStyleProps["fontWeight"]>)
|
|
347
402
|
: undefined,
|
|
348
403
|
});
|
|
349
404
|
return;
|
|
@@ -407,7 +462,7 @@ export function StyleRow({
|
|
|
407
462
|
kind="font"
|
|
408
463
|
design={design}
|
|
409
464
|
current={ref?.var ?? null}
|
|
410
|
-
onBind={(next) => onPatch({ fontFamily: next as
|
|
465
|
+
onBind={(next) => onPatch({ fontFamily: next as FlatStyleProps["fontFamily"] })}
|
|
411
466
|
/>
|
|
412
467
|
{reset}
|
|
413
468
|
</div>
|
|
@@ -416,6 +471,9 @@ export function StyleRow({
|
|
|
416
471
|
|
|
417
472
|
if (
|
|
418
473
|
styleKey === "zIndex" ||
|
|
474
|
+
styleKey === "flexGrow" ||
|
|
475
|
+
styleKey === "flexShrink" ||
|
|
476
|
+
styleKey === "order" ||
|
|
419
477
|
styleKey === "opacity" ||
|
|
420
478
|
styleKey === "gridColumnSpan" ||
|
|
421
479
|
styleKey === "gridRowSpan" ||
|
|
@@ -425,11 +483,15 @@ export function StyleRow({
|
|
|
425
483
|
const spec =
|
|
426
484
|
styleKey === "zIndex"
|
|
427
485
|
? Z_INDEX
|
|
428
|
-
: styleKey === "
|
|
429
|
-
?
|
|
430
|
-
: styleKey === "
|
|
431
|
-
?
|
|
432
|
-
:
|
|
486
|
+
: styleKey === "flexGrow" || styleKey === "flexShrink"
|
|
487
|
+
? FLEX_FACTOR
|
|
488
|
+
: styleKey === "order"
|
|
489
|
+
? ORDER
|
|
490
|
+
: styleKey === "opacity"
|
|
491
|
+
? OPACITY
|
|
492
|
+
: styleKey === "gridColumnStart" || styleKey === "gridRowStart"
|
|
493
|
+
? GRID_LINE
|
|
494
|
+
: GRID_SPAN;
|
|
433
495
|
return (
|
|
434
496
|
<NumberRow
|
|
435
497
|
rowKey={styleKey}
|
|
@@ -477,6 +539,7 @@ export function StyleRow({
|
|
|
477
539
|
return (
|
|
478
540
|
<IconShadowControl
|
|
479
541
|
value={style?.iconShadow}
|
|
542
|
+
inherited={inherited?.iconShadow}
|
|
480
543
|
design={design}
|
|
481
544
|
onChange={(iconShadow) => onPatch({ iconShadow })}
|
|
482
545
|
onDesignChange={onDesignChange}
|
|
@@ -497,6 +560,7 @@ export function StyleRow({
|
|
|
497
560
|
return (
|
|
498
561
|
<ShadowControl
|
|
499
562
|
value={style?.boxShadow}
|
|
563
|
+
inherited={inherited?.boxShadow}
|
|
500
564
|
design={design}
|
|
501
565
|
onChange={(boxShadow) => onPatch({ boxShadow })}
|
|
502
566
|
onDesignChange={onDesignChange}
|
|
@@ -509,6 +573,7 @@ export function StyleRow({
|
|
|
509
573
|
return (
|
|
510
574
|
<EntranceControl
|
|
511
575
|
value={style?.entrance}
|
|
576
|
+
inherited={inherited?.entrance}
|
|
512
577
|
onChange={(entrance) => onPatch({ entrance })}
|
|
513
578
|
reset={reset}
|
|
514
579
|
/>
|
|
@@ -525,10 +590,21 @@ export function StyleRow({
|
|
|
525
590
|
);
|
|
526
591
|
}
|
|
527
592
|
|
|
593
|
+
if (styleKey === "loopMotion") {
|
|
594
|
+
return (
|
|
595
|
+
<LoopControl
|
|
596
|
+
value={style?.loopMotion}
|
|
597
|
+
onChange={(loopMotion) => onPatch({ loopMotion })}
|
|
598
|
+
reset={reset}
|
|
599
|
+
/>
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
|
|
528
603
|
if (styleKey === "transition") {
|
|
529
604
|
return (
|
|
530
605
|
<TransitionControl
|
|
531
606
|
value={style?.transition}
|
|
607
|
+
inherited={inherited?.transition}
|
|
532
608
|
onChange={(transition) => onPatch({ transition })}
|
|
533
609
|
reset={reset}
|
|
534
610
|
/>
|
|
@@ -545,6 +621,28 @@ export function StyleRow({
|
|
|
545
621
|
);
|
|
546
622
|
}
|
|
547
623
|
|
|
624
|
+
if (styleKey === "transform") {
|
|
625
|
+
return (
|
|
626
|
+
<TransformControl
|
|
627
|
+
value={style?.transform}
|
|
628
|
+
inherited={inherited?.transform}
|
|
629
|
+
onChange={(transform) => onPatch({ transform })}
|
|
630
|
+
/>
|
|
631
|
+
);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
if (styleKey === "backdropFilter") {
|
|
635
|
+
return (
|
|
636
|
+
<FiltersControl
|
|
637
|
+
styleKey="backdropFilter"
|
|
638
|
+
label="Backdrop filters"
|
|
639
|
+
value={style?.backdropFilter}
|
|
640
|
+
inherited={inherited?.backdropFilter}
|
|
641
|
+
onChange={(backdropFilter) => onPatch({ backdropFilter })}
|
|
642
|
+
/>
|
|
643
|
+
);
|
|
644
|
+
}
|
|
645
|
+
|
|
548
646
|
if (LENGTH_KEYS.has(styleKey)) {
|
|
549
647
|
return (
|
|
550
648
|
<LengthRow
|
|
@@ -557,6 +655,7 @@ export function StyleRow({
|
|
|
557
655
|
slider={styleKey === "gap"}
|
|
558
656
|
onPatch={onPatch}
|
|
559
657
|
reset={reset}
|
|
658
|
+
viewportUnits={style?.viewportUnits}
|
|
560
659
|
/>
|
|
561
660
|
);
|
|
562
661
|
}
|
|
@@ -569,6 +668,9 @@ export const IMPLEMENTED_STYLE_KEYS: StyleKey[] = [
|
|
|
569
668
|
...COLOR_KEYS,
|
|
570
669
|
"fontFamily",
|
|
571
670
|
"zIndex",
|
|
671
|
+
"flexGrow",
|
|
672
|
+
"flexShrink",
|
|
673
|
+
"order",
|
|
572
674
|
"gridColumnSpan",
|
|
573
675
|
"gridColumnStart",
|
|
574
676
|
"gridRowSpan",
|
|
@@ -576,8 +678,13 @@ export const IMPLEMENTED_STYLE_KEYS: StyleKey[] = [
|
|
|
576
678
|
"opacity",
|
|
577
679
|
"boxShadow",
|
|
578
680
|
"filter",
|
|
681
|
+
"backdropFilter",
|
|
682
|
+
"transform",
|
|
579
683
|
"entrance",
|
|
580
684
|
"scrollMotion",
|
|
685
|
+
"loopMotion",
|
|
686
|
+
// W-974: set by the Height rows' dvh/svh units (LengthRow), never a row of its own.
|
|
687
|
+
"viewportUnits",
|
|
581
688
|
"transition",
|
|
582
689
|
"iconRotate",
|
|
583
690
|
"iconFlip",
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { Button, Checkbox, Input } from "@cloudflare/kumo";
|
|
2
|
+
import { LinkSimpleIcon, TextBIcon, TextItalicIcon, XIcon } from "@phosphor-icons/react";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import {
|
|
5
|
+
hasFormat,
|
|
6
|
+
type LayoutNode,
|
|
7
|
+
MAX_TEXT_MARKS,
|
|
8
|
+
type MarkFormat,
|
|
9
|
+
sanitizeHref,
|
|
10
|
+
setFormat,
|
|
11
|
+
type TextMark,
|
|
12
|
+
unsetFormat,
|
|
13
|
+
} from "../../../../core/index.ts";
|
|
14
|
+
import { BUTTON, FIELD } from "../../../ui.ts";
|
|
15
|
+
import { propsOf, withProp } from "./node-props.ts";
|
|
16
|
+
|
|
17
|
+
type Range = { start: number; end: number };
|
|
18
|
+
|
|
19
|
+
/** The element's Text field, next to this control in the panel. */
|
|
20
|
+
function textField(from: HTMLElement | null): HTMLInputElement | HTMLTextAreaElement | null {
|
|
21
|
+
const scope =
|
|
22
|
+
from?.closest("[data-emvb-fields]") ?? from?.parentElement?.parentElement ?? document;
|
|
23
|
+
const holder = scope.querySelector('[data-emvb-field="text"]');
|
|
24
|
+
if (holder instanceof HTMLInputElement || holder instanceof HTMLTextAreaElement) return holder;
|
|
25
|
+
return holder?.querySelector("textarea, input") ?? null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Buttons keep the Text field's selection: pressing one doesn't move focus there first. */
|
|
29
|
+
const keep = (event: React.MouseEvent) => event.preventDefault();
|
|
30
|
+
|
|
31
|
+
const describe = (mark: TextMark): string =>
|
|
32
|
+
[
|
|
33
|
+
mark.bold ? "Bold" : null,
|
|
34
|
+
mark.italic ? "Italic" : null,
|
|
35
|
+
typeof mark.color === "string" ? `Color ${mark.color}` : mark.color ? "Color" : null,
|
|
36
|
+
mark.href ? `Link ${mark.href}${mark.newTab ? " (new tab)" : ""}` : null,
|
|
37
|
+
]
|
|
38
|
+
.filter(Boolean)
|
|
39
|
+
.join(", ");
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Formatting (W-950): bold, italic, colour and links on the words selected in the Text field.
|
|
43
|
+
* The text stays plain; each format is a range over it, listed below with a Remove button.
|
|
44
|
+
*/
|
|
45
|
+
export function TextMarksControl({
|
|
46
|
+
node,
|
|
47
|
+
onChange,
|
|
48
|
+
}: {
|
|
49
|
+
node: LayoutNode;
|
|
50
|
+
onChange: (node: LayoutNode) => void;
|
|
51
|
+
}) {
|
|
52
|
+
const props = propsOf(node);
|
|
53
|
+
const text = typeof props["text"] === "string" ? props["text"] : "";
|
|
54
|
+
const marks = Array.isArray(props["marks"]) ? (props["marks"] as TextMark[]) : [];
|
|
55
|
+
const ref = React.useRef<HTMLDivElement>(null);
|
|
56
|
+
const colorRef = React.useRef<HTMLInputElement>(null);
|
|
57
|
+
const [message, setMessage] = React.useState<string>();
|
|
58
|
+
const [linkFor, setLinkFor] = React.useState<Range>();
|
|
59
|
+
const [href, setHref] = React.useState("");
|
|
60
|
+
const [newTab, setNewTab] = React.useState(false);
|
|
61
|
+
const linkedHeading = node.type === "heading" && typeof props["href"] === "string";
|
|
62
|
+
|
|
63
|
+
/** The selected words, or a message saying why there are none. */
|
|
64
|
+
const selection = (): Range | undefined => {
|
|
65
|
+
const field = textField(ref.current);
|
|
66
|
+
if (!field) return undefined;
|
|
67
|
+
if (field.value !== text) {
|
|
68
|
+
setMessage("Finish editing the text first (press Enter or leave the field).");
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
const start = field.selectionStart ?? 0;
|
|
72
|
+
const end = field.selectionEnd ?? 0;
|
|
73
|
+
if (end <= start) {
|
|
74
|
+
setMessage("Select some words in the Text field first.");
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
setMessage(undefined);
|
|
78
|
+
return { start, end };
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const save = (next: TextMark[]) => {
|
|
82
|
+
if (next.length > MAX_TEXT_MARKS) {
|
|
83
|
+
setMessage(`A text can have up to ${MAX_TEXT_MARKS} formatted parts.`);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
onChange(withProp(node, "marks", next.length > 0 ? next : undefined));
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const toggle = (format: Extract<MarkFormat, "bold" | "italic">) => {
|
|
90
|
+
const range = selection();
|
|
91
|
+
if (!range) return;
|
|
92
|
+
save(
|
|
93
|
+
hasFormat(marks, range.start, range.end, format)
|
|
94
|
+
? unsetFormat(marks, range.start, range.end, format)
|
|
95
|
+
: setFormat(marks, range.start, range.end, { [format]: true }),
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// A colour is applied when the picker closes, not on every step of a drag.
|
|
100
|
+
React.useEffect(() => {
|
|
101
|
+
const input = colorRef.current;
|
|
102
|
+
if (!input) return;
|
|
103
|
+
const apply = () => {
|
|
104
|
+
const range = selection();
|
|
105
|
+
if (range) save(setFormat(marks, range.start, range.end, { color: input.value }));
|
|
106
|
+
};
|
|
107
|
+
input.addEventListener("change", apply);
|
|
108
|
+
return () => input.removeEventListener("change", apply);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const applyLink = () => {
|
|
112
|
+
if (!linkFor) return;
|
|
113
|
+
const safe = sanitizeHref(href.trim());
|
|
114
|
+
if (!safe) {
|
|
115
|
+
setMessage("Enter a link such as /contact or https://example.com.");
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
save(
|
|
119
|
+
setFormat(marks, linkFor.start, linkFor.end, {
|
|
120
|
+
href: safe,
|
|
121
|
+
...(newTab ? { newTab: true } : {}),
|
|
122
|
+
}),
|
|
123
|
+
);
|
|
124
|
+
setLinkFor(undefined);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const clear = () => {
|
|
128
|
+
const range = selection();
|
|
129
|
+
if (!range) return;
|
|
130
|
+
let next = marks;
|
|
131
|
+
for (const format of ["bold", "italic", "color", "href"] as const)
|
|
132
|
+
next = unsetFormat(next, range.start, range.end, format);
|
|
133
|
+
save(next);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<div ref={ref} className="emvb-marks" data-emvb-field="marks">
|
|
138
|
+
<span className="emvb-import-label">Formatting</span>
|
|
139
|
+
<div className="emvb-marks-bar" role="toolbar" aria-label="Formatting">
|
|
140
|
+
<Button
|
|
141
|
+
type="button"
|
|
142
|
+
variant="secondary"
|
|
143
|
+
className={BUTTON}
|
|
144
|
+
aria-label="Bold"
|
|
145
|
+
icon={<TextBIcon aria-hidden="true" />}
|
|
146
|
+
onMouseDown={keep}
|
|
147
|
+
onClick={() => toggle("bold")}
|
|
148
|
+
/>
|
|
149
|
+
<Button
|
|
150
|
+
type="button"
|
|
151
|
+
variant="secondary"
|
|
152
|
+
className={BUTTON}
|
|
153
|
+
aria-label="Italic"
|
|
154
|
+
icon={<TextItalicIcon aria-hidden="true" />}
|
|
155
|
+
onMouseDown={keep}
|
|
156
|
+
onClick={() => toggle("italic")}
|
|
157
|
+
/>
|
|
158
|
+
<label className="emvb-marks-color">
|
|
159
|
+
<span className="emvb-helper">Color</span>
|
|
160
|
+
<input
|
|
161
|
+
ref={colorRef}
|
|
162
|
+
type="color"
|
|
163
|
+
aria-label="Color of selected words"
|
|
164
|
+
defaultValue="#000000"
|
|
165
|
+
/>
|
|
166
|
+
</label>
|
|
167
|
+
{!linkedHeading && (
|
|
168
|
+
<Button
|
|
169
|
+
type="button"
|
|
170
|
+
variant="secondary"
|
|
171
|
+
className={BUTTON}
|
|
172
|
+
aria-label="Link selected words"
|
|
173
|
+
icon={<LinkSimpleIcon aria-hidden="true" />}
|
|
174
|
+
onMouseDown={keep}
|
|
175
|
+
onClick={() => {
|
|
176
|
+
const range = selection();
|
|
177
|
+
if (!range) return;
|
|
178
|
+
setLinkFor(range);
|
|
179
|
+
setHref("");
|
|
180
|
+
setNewTab(false);
|
|
181
|
+
}}
|
|
182
|
+
/>
|
|
183
|
+
)}
|
|
184
|
+
<Button
|
|
185
|
+
type="button"
|
|
186
|
+
variant="secondary"
|
|
187
|
+
className={BUTTON}
|
|
188
|
+
onMouseDown={keep}
|
|
189
|
+
onClick={clear}
|
|
190
|
+
>
|
|
191
|
+
Clear
|
|
192
|
+
</Button>
|
|
193
|
+
</div>
|
|
194
|
+
{linkFor && (
|
|
195
|
+
<div className="emvb-marks-link" data-emvb-marks-link="">
|
|
196
|
+
<Input
|
|
197
|
+
label={`Link for "${text.slice(linkFor.start, linkFor.end)}"`}
|
|
198
|
+
className={FIELD}
|
|
199
|
+
value={href}
|
|
200
|
+
placeholder="/contact"
|
|
201
|
+
onChange={(event) => setHref(event.target.value)}
|
|
202
|
+
/>
|
|
203
|
+
<Checkbox
|
|
204
|
+
label="Open in a new tab"
|
|
205
|
+
checked={newTab}
|
|
206
|
+
onCheckedChange={(checked: boolean) => setNewTab(checked)}
|
|
207
|
+
/>
|
|
208
|
+
<div className="emvb-marks-bar">
|
|
209
|
+
<Button type="button" variant="primary" className={BUTTON} onClick={applyLink}>
|
|
210
|
+
Apply link
|
|
211
|
+
</Button>
|
|
212
|
+
<Button
|
|
213
|
+
type="button"
|
|
214
|
+
variant="secondary"
|
|
215
|
+
className={BUTTON}
|
|
216
|
+
onClick={() => setLinkFor(undefined)}
|
|
217
|
+
>
|
|
218
|
+
Cancel
|
|
219
|
+
</Button>
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
222
|
+
)}
|
|
223
|
+
<p className="emvb-helper" role="status">
|
|
224
|
+
{message ?? "Select words in the Text field, then choose a format."}
|
|
225
|
+
</p>
|
|
226
|
+
{marks.length > 0 && (
|
|
227
|
+
<ul className="emvb-marks-list" aria-label="Formatted words">
|
|
228
|
+
{marks.map((mark, index) => (
|
|
229
|
+
<li key={`${mark.start}-${mark.end}-${index}`}>
|
|
230
|
+
<span>
|
|
231
|
+
<strong>“{text.slice(mark.start, mark.end) || "…"}”</strong> {describe(mark)}
|
|
232
|
+
</span>
|
|
233
|
+
<Button
|
|
234
|
+
type="button"
|
|
235
|
+
variant="ghost"
|
|
236
|
+
className={BUTTON}
|
|
237
|
+
aria-label={`Remove formatting from "${text.slice(mark.start, mark.end)}"`}
|
|
238
|
+
icon={<XIcon aria-hidden="true" />}
|
|
239
|
+
onClick={() => save(marks.filter((_, i) => i !== index))}
|
|
240
|
+
/>
|
|
241
|
+
</li>
|
|
242
|
+
))}
|
|
243
|
+
</ul>
|
|
244
|
+
)}
|
|
245
|
+
</div>
|
|
246
|
+
);
|
|
247
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DropdownMenu } from "@cloudflare/kumo";
|
|
2
2
|
import { BracketsCurlyIcon, RulerIcon, TextAaIcon, TextTIcon, XIcon } from "@phosphor-icons/react";
|
|
3
|
-
import type { DesignSystem,
|
|
3
|
+
import type { DesignSystem, FlatStyleProps } from "../../../../core/index.ts";
|
|
4
4
|
import type { StyleKey } from "./style-sections.ts";
|
|
5
5
|
|
|
6
6
|
/** Variable kinds a length or font property can bind to. Colours bind through ColorControl. */
|
|
@@ -77,7 +77,7 @@ export function VariableButton({
|
|
|
77
77
|
kind: BindKind;
|
|
78
78
|
design: DesignSystem;
|
|
79
79
|
current: string | null;
|
|
80
|
-
onBind: (ref: NonNullable<
|
|
80
|
+
onBind: (ref: NonNullable<FlatStyleProps["gap"]>) => void;
|
|
81
81
|
}) {
|
|
82
82
|
const list = variablesOf(design, kind);
|
|
83
83
|
return (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FlatStyleProps } from "../../../../core/index.ts";
|
|
2
2
|
import { STYLE_UI } from "./style-sections.ts";
|
|
3
3
|
import { NEW_GRADIENT } from "./BackgroundControls.tsx";
|
|
4
4
|
|
|
@@ -11,14 +11,14 @@ const BOXES = new Set([
|
|
|
11
11
|
"div-block",
|
|
12
12
|
"layout-section",
|
|
13
13
|
"form",
|
|
14
|
-
"
|
|
14
|
+
"part-ref",
|
|
15
15
|
"tab-panel",
|
|
16
16
|
"accordion",
|
|
17
17
|
"accordion-item",
|
|
18
18
|
]);
|
|
19
19
|
|
|
20
20
|
/** Color and gradient everywhere. Image and video on boxes, or when already set. */
|
|
21
|
-
export function fillModes(type: string, style?:
|
|
21
|
+
export function fillModes(type: string, style?: FlatStyleProps): FillMode[] {
|
|
22
22
|
const modes: FillMode[] = ["color", "gradient"];
|
|
23
23
|
const box = BOXES.has(type) || !(type in STYLE_UI);
|
|
24
24
|
if (box || type === "button" || type === "submit" || style?.backgroundImage !== undefined)
|
|
@@ -28,7 +28,7 @@ export function fillModes(type: string, style?: StyleProps): FillMode[] {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/** The fill the page is showing. Video wins, then image, then gradient, then a solid color. */
|
|
31
|
-
export function activeFill(style:
|
|
31
|
+
export function activeFill(style: FlatStyleProps | undefined): FillMode {
|
|
32
32
|
if (style?.backgroundVideo) return "video";
|
|
33
33
|
if (style?.backgroundImage) return "image";
|
|
34
34
|
if (style?.gradient) return "gradient";
|
|
@@ -36,7 +36,7 @@ export function activeFill(style: StyleProps | undefined): FillMode {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/** More than one fill is stored, so the page paints a stack the type switcher will collapse. */
|
|
39
|
-
export function fillIsMixed(style:
|
|
39
|
+
export function fillIsMixed(style: FlatStyleProps | undefined): boolean {
|
|
40
40
|
return (
|
|
41
41
|
[
|
|
42
42
|
style?.backgroundColor !== undefined,
|
|
@@ -59,7 +59,7 @@ const CLEARED = {
|
|
|
59
59
|
} as const;
|
|
60
60
|
|
|
61
61
|
/** Choosing a type removes the other fills. Overlay stays with an image or a video. */
|
|
62
|
-
function switchFill(style:
|
|
62
|
+
function switchFill(style: FlatStyleProps | undefined, mode: FillMode): Partial<FlatStyleProps> {
|
|
63
63
|
if (mode === "gradient") return { ...CLEARED, gradient: style?.gradient ?? NEW_GRADIENT };
|
|
64
64
|
if (mode === "image") {
|
|
65
65
|
return {
|
|
@@ -78,7 +78,10 @@ function switchFill(style: StyleProps | undefined, mode: FillMode): Partial<Styl
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/** The fields a fill type owns as stored now, or undefined when that type has nothing set. */
|
|
81
|
-
function heldFill(
|
|
81
|
+
function heldFill(
|
|
82
|
+
style: FlatStyleProps | undefined,
|
|
83
|
+
mode: FillMode,
|
|
84
|
+
): Partial<FlatStyleProps> | undefined {
|
|
82
85
|
const main = {
|
|
83
86
|
color: style?.backgroundColor,
|
|
84
87
|
gradient: style?.gradient,
|
|
@@ -88,22 +91,22 @@ function heldFill(style: StyleProps | undefined, mode: FillMode): Partial<StyleP
|
|
|
88
91
|
if (main === undefined) return undefined;
|
|
89
92
|
return Object.fromEntries(
|
|
90
93
|
Object.entries(switchFill(style, mode)).filter(([, value]) => value !== undefined),
|
|
91
|
-
) as Partial<
|
|
94
|
+
) as Partial<FlatStyleProps>;
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
/** What each fill type last held while this element was being edited (W-184). */
|
|
95
|
-
export type FillMemory = Partial<Record<FillMode, Partial<
|
|
98
|
+
export type FillMemory = Partial<Record<FillMode, Partial<FlatStyleProps>>>;
|
|
96
99
|
|
|
97
100
|
/**
|
|
98
101
|
* Like `switchFill`, but the type being left is remembered in `memory`, and an empty type being
|
|
99
102
|
* chosen gets back what it last held, so Gradient → Color → Gradient keeps the gradient (W-184).
|
|
100
103
|
*/
|
|
101
104
|
export function switchFillRemembered(
|
|
102
|
-
style:
|
|
105
|
+
style: FlatStyleProps | undefined,
|
|
103
106
|
from: FillMode,
|
|
104
107
|
to: FillMode,
|
|
105
108
|
memory: FillMemory,
|
|
106
|
-
): Partial<
|
|
109
|
+
): Partial<FlatStyleProps> {
|
|
107
110
|
const held = heldFill(style, from);
|
|
108
111
|
if (held) memory[from] = held;
|
|
109
112
|
const remembered = memory[to];
|
|
@@ -5,7 +5,7 @@ import { nodeChildren } from "../../../../core/tree-ops.ts";
|
|
|
5
5
|
const TEXT_PROPS = ["text", "label", "summary", "title", "alt"] as const;
|
|
6
6
|
|
|
7
7
|
/** Elements whose text comes from the post or another layout; assume they name the link. */
|
|
8
|
-
const DYNAMIC = new Set(["
|
|
8
|
+
const DYNAMIC = new Set(["part-ref", "loop"]);
|
|
9
9
|
|
|
10
10
|
const hasName = (node: LayoutNode): boolean => {
|
|
11
11
|
if (DYNAMIC.has(node.type) || node.type.startsWith("post-")) return true;
|