@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.
Files changed (160) hide show
  1. package/README.md +1 -1
  2. package/package.json +2 -2
  3. package/src/admin/agents-api.ts +45 -0
  4. package/src/admin/editor/A11yCopilot.tsx +1 -1
  5. package/src/admin/editor/Editor.tsx +297 -248
  6. package/src/admin/editor/Timeline.tsx +2 -1
  7. package/src/admin/editor/TopBar.tsx +4 -2
  8. package/src/admin/editor/canvas/CanvasFrame.tsx +2 -2
  9. package/src/admin/editor/canvas/DeviceBar.tsx +17 -9
  10. package/src/admin/editor/canvas/canvas-scale.ts +2 -2
  11. package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
  12. package/src/admin/editor/co-design.ts +190 -0
  13. package/src/admin/editor/dnd/new-element.ts +26 -4
  14. package/src/admin/editor/editor-chrome.tsx +3 -3
  15. package/src/admin/editor/editor-commands.ts +8 -3
  16. package/src/admin/editor/element-chrome.ts +3 -1
  17. package/src/admin/editor/extension-manifests.ts +20 -0
  18. package/src/admin/editor/extensions/ExtensionPanels.tsx +26 -0
  19. package/src/admin/editor/extensions-context.tsx +27 -0
  20. package/src/admin/editor/feature-css.ts +17 -0
  21. package/src/admin/editor/palette-items.ts +2 -2
  22. package/src/admin/editor/panels/AddPanel.tsx +31 -1
  23. package/src/admin/editor/panels/AgentRequestBox.tsx +116 -0
  24. package/src/admin/editor/panels/ClassesSection.tsx +9 -6
  25. package/src/admin/editor/panels/CoDesignPanel.tsx +170 -0
  26. package/src/admin/editor/panels/ColorControl.tsx +2 -2
  27. package/src/admin/editor/panels/ElementPanel.tsx +49 -14
  28. package/src/admin/editor/panels/LanguagesSection.tsx +152 -0
  29. package/src/admin/editor/panels/LayersPanel.tsx +10 -6
  30. package/src/admin/editor/panels/LeftPanel.tsx +33 -5
  31. package/src/admin/editor/panels/PageSettings.tsx +4 -0
  32. package/src/admin/editor/panels/SettingsPanel.tsx +21 -2
  33. package/src/admin/editor/panels/SiteStylesDrawer.tsx +7 -7
  34. package/src/admin/editor/panels/settings/BackgroundControls.tsx +72 -15
  35. package/src/admin/editor/panels/settings/BackgroundFill.tsx +8 -6
  36. package/src/admin/editor/panels/settings/BoxControl.tsx +5 -5
  37. package/src/admin/editor/panels/settings/EffectsControls.tsx +104 -9
  38. package/src/admin/editor/panels/settings/FieldControl.tsx +9 -3
  39. package/src/admin/editor/panels/settings/IconControls.tsx +14 -11
  40. package/src/admin/editor/panels/settings/LengthRow.tsx +27 -16
  41. package/src/admin/editor/panels/settings/LoopControl.tsx +269 -0
  42. package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +1 -1
  43. package/src/admin/editor/panels/settings/MotionControl.tsx +12 -11
  44. package/src/admin/editor/panels/settings/QueryStyleRows.tsx +7 -4
  45. package/src/admin/editor/panels/settings/StyleRow.tsx +113 -13
  46. package/src/admin/editor/panels/settings/TextMarksControl.tsx +247 -0
  47. package/src/admin/editor/panels/settings/VariableBinding.tsx +2 -2
  48. package/src/admin/editor/panels/settings/background-mode.ts +14 -11
  49. package/src/admin/editor/panels/settings/box-link-name.ts +1 -1
  50. package/src/admin/editor/panels/settings/box-sides.ts +22 -14
  51. package/src/admin/editor/panels/settings/heading-warning.ts +5 -1
  52. package/src/admin/editor/panels/settings/length-units.ts +53 -1
  53. package/src/admin/editor/panels/settings/query-style.ts +3 -3
  54. package/src/admin/editor/panels/settings/style-sections.ts +51 -10
  55. package/src/admin/editor/panels/style-target.ts +9 -7
  56. package/src/admin/editor/presence.ts +60 -0
  57. package/src/admin/editor/store.ts +6 -2
  58. package/src/admin/editor/useCoDesign.ts +177 -0
  59. package/src/admin/editor/useEditorCommands.ts +4 -4
  60. package/src/admin/editor/useExtensions.ts +45 -0
  61. package/src/admin/editor/useNodeActions.ts +15 -6
  62. package/src/admin/editor/useProposals.ts +81 -0
  63. package/src/admin/languages-api.ts +61 -0
  64. package/src/admin/pages/AgentSetup.tsx +148 -0
  65. package/src/admin/pages/AgentsPage.tsx +9 -26
  66. package/src/admin/pages/CreateDialog.tsx +15 -0
  67. package/src/admin/pages/ImportButton.tsx +18 -0
  68. package/src/admin/pages/ImportElementorDialog.tsx +669 -0
  69. package/src/admin/pages/ImportPageLinks.tsx +86 -0
  70. package/src/admin/pages/PageList.tsx +15 -1
  71. package/src/admin/pages/ThemePartList.tsx +15 -1
  72. package/src/admin/pages/section-head.tsx +27 -0
  73. package/src/admin/proposals-api.ts +91 -0
  74. package/src/admin/ui.ts +39 -2
  75. package/src/astro/content-port.ts +14 -1
  76. package/src/astro/resolve-theme.ts +14 -1
  77. package/src/astro/resolve.ts +89 -2
  78. package/src/constants.ts +1 -1
  79. package/src/core/a11y/audit.ts +44 -14
  80. package/src/core/arrange.ts +5 -1
  81. package/src/core/bounded-array.ts +31 -0
  82. package/src/core/clipboard.ts +9 -0
  83. package/src/core/contract.ts +285 -0
  84. package/src/core/css/generate.ts +89 -20
  85. package/src/core/css/trace.ts +18 -9
  86. package/src/core/css-keywords.ts +51 -1
  87. package/src/core/design/cascade.ts +12 -9
  88. package/src/core/design/classes.ts +4 -5
  89. package/src/core/design/devices.ts +13 -13
  90. package/src/core/design/states.ts +5 -3
  91. package/src/core/design/transfer.ts +5 -0
  92. package/src/core/design/variables.ts +17 -4
  93. package/src/core/elements/dynamic-elements.ts +3 -3
  94. package/src/core/elements/index.ts +73 -9
  95. package/src/core/extensions/define.ts +13 -0
  96. package/src/core/extensions/index.ts +41 -0
  97. package/src/core/extensions/namespace.ts +82 -0
  98. package/src/core/extensions/normalize.ts +141 -0
  99. package/src/core/extensions/placeholder.ts +41 -0
  100. package/src/core/extensions/registry.ts +94 -0
  101. package/src/core/extensions/render-ext.ts +118 -0
  102. package/src/core/extensions/safe-nodes.ts +93 -0
  103. package/src/core/extensions/schema.ts +112 -0
  104. package/src/core/extensions/types.ts +159 -0
  105. package/src/core/forms/binding.ts +1 -1
  106. package/src/core/history/diff.ts +1 -1
  107. package/src/core/import/elementor/atomic.ts +1595 -0
  108. package/src/core/import/elementor/classes.ts +127 -0
  109. package/src/core/import/elementor/context.ts +429 -0
  110. package/src/core/import/elementor/counter-steps.ts +72 -0
  111. package/src/core/import/elementor/css.ts +445 -0
  112. package/src/core/import/elementor/html.ts +500 -0
  113. package/src/core/import/elementor/index.ts +949 -0
  114. package/src/core/import/elementor/inline-marks.ts +81 -0
  115. package/src/core/import/elementor/snapshots.ts +48 -0
  116. package/src/core/import/elementor/style.ts +409 -0
  117. package/src/core/import/elementor/values.ts +241 -0
  118. package/src/core/import/elementor/widgets.ts +1897 -0
  119. package/src/core/index.ts +82 -0
  120. package/src/core/json-schema.ts +107 -0
  121. package/src/core/limits.ts +19 -0
  122. package/src/core/migrate/index.ts +6 -1
  123. package/src/core/migrate/v18.ts +222 -0
  124. package/src/core/perf/meter.ts +5 -5
  125. package/src/core/proposals-safety.ts +102 -0
  126. package/src/core/proposals.ts +357 -0
  127. package/src/core/recipes/index.ts +2 -2
  128. package/src/core/render/extras.ts +3 -3
  129. package/src/core/render/index.ts +140 -20
  130. package/src/core/render/loop.ts +1 -1
  131. package/src/core/render/section.ts +4 -4
  132. package/src/core/render/vnode.ts +1 -1
  133. package/src/core/sanitize/css.ts +125 -10
  134. package/src/core/sanitize/motion.ts +116 -0
  135. package/src/core/saved-sections.ts +6 -0
  136. package/src/core/schema/descriptors.ts +3 -1
  137. package/src/core/schema/design.ts +2 -1
  138. package/src/core/schema/layout.ts +82 -14
  139. package/src/core/schema/style.ts +251 -114
  140. package/src/core/text-marks.ts +227 -0
  141. package/src/core/theme/dynamic.ts +9 -4
  142. package/src/core/theme/float.ts +1 -0
  143. package/src/core/theme/popup-rules.ts +17 -1
  144. package/src/core/translatable.ts +34 -0
  145. package/src/core/validate.ts +13 -1
  146. package/src/index.ts +24 -0
  147. package/src/mcp/errors.ts +3 -1
  148. package/src/mcp/ports.ts +67 -0
  149. package/src/mcp/prompts.ts +1 -11
  150. package/src/mcp/proposals.ts +281 -0
  151. package/src/mcp/read.ts +10 -9
  152. package/src/mcp/tools.ts +71 -3
  153. package/src/mcp/write.ts +66 -11
  154. package/src/server/agent-settings.ts +5 -1
  155. package/src/server/mcp-routes.ts +15 -0
  156. package/src/server/plugin.ts +35 -2
  157. package/src/server/presence.ts +78 -0
  158. package/src/server/proposals.ts +261 -0
  159. package/src/server/requests.ts +196 -0
  160. package/src/server/tools-served.ts +45 -0
@@ -5,24 +5,25 @@ import {
5
5
  MOTION_EFFECTS,
6
6
  MOTION_LIMITS,
7
7
  type MotionEffect,
8
- type StyleProps,
8
+ type FlatStyleProps,
9
9
  } from "../../../../core/index.ts";
10
10
  import { BUTTON } from "../../../ui.ts";
11
11
  import { TransitionSelect } from "./EffectsControls.tsx";
12
12
  import { NumberField, type NumberSpec } from "./NumberRow.tsx";
13
13
 
14
- type Motion = NonNullable<StyleProps["scrollMotion"]>;
14
+ type Motion = NonNullable<FlatStyleProps["scrollMotion"]>;
15
15
  type Playing = Extract<Motion, { effects: unknown }>;
16
16
  type Effect = Playing["effects"][number];
17
17
 
18
- const EFFECT_LABELS: Record<MotionEffect, { label: string; unit: string; neutral: number }> = {
19
- fade: { label: "Opacity", unit: "%", neutral: 100 },
20
- "move-x": { label: "Move sideways", unit: "px", neutral: 0 },
21
- "move-y": { label: "Move up/down", unit: "px", neutral: 0 },
22
- scale: { label: "Scale", unit: "%", neutral: 100 },
23
- rotate: { label: "Rotate", unit: "°", neutral: 0 },
24
- blur: { label: "Blur", unit: "px", neutral: 0 },
25
- };
18
+ export const EFFECT_LABELS: Record<MotionEffect, { label: string; unit: string; neutral: number }> =
19
+ {
20
+ fade: { label: "Opacity", unit: "%", neutral: 100 },
21
+ "move-x": { label: "Move sideways", unit: "px", neutral: 0 },
22
+ "move-y": { label: "Move up/down", unit: "px", neutral: 0 },
23
+ scale: { label: "Scale", unit: "%", neutral: 100 },
24
+ rotate: { label: "Rotate", unit: "°", neutral: 0 },
25
+ blur: { label: "Blur", unit: "px", neutral: 0 },
26
+ };
26
27
 
27
28
  const RANGES: { value: Playing["range"]; label: string }[] = [
28
29
  { value: "enter", label: "As it comes into view" },
@@ -87,7 +88,7 @@ export const MOTION_PRESETS: { id: string; label: string; value: Playing }[] = [
87
88
  },
88
89
  ];
89
90
 
90
- const specFor = (type: MotionEffect): NumberSpec => {
91
+ export const specFor = (type: MotionEffect): NumberSpec => {
91
92
  const [min, max] = MOTION_LIMITS[type];
92
93
  return {
93
94
  min,
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import type { LayoutNode } from "../../../../core/index.ts";
2
+ import { flattenMotion, nestMotion, type LayoutNode } from "../../../../core/index.ts";
3
3
  import { FIELD } from "../../../ui.ts";
4
4
  import { savableNode } from "./DraftTextField.tsx";
5
5
  import { formatStyleValue, parseStyleValue, QUERY_STYLE_KEYS } from "./query-style.ts";
@@ -15,7 +15,10 @@ type QueryStyle = NonNullable<LayoutNode["query"]>["style"];
15
15
  function withQueryStyle(node: LayoutNode, style: Record<string, unknown>): LayoutNode | string {
16
16
  const query = node.query;
17
17
  if (!query) return "Set a container width first.";
18
- const next = { ...node, query: { ...query, style: style as QueryStyle } } as LayoutNode;
18
+ const next = {
19
+ ...node,
20
+ query: { ...query, style: nestMotion(style) as QueryStyle },
21
+ } as LayoutNode;
19
22
  return savableNode(next) || !savableNode(node) ? next : "That value can't be saved here.";
20
23
  }
21
24
 
@@ -32,7 +35,7 @@ function QueryStyleRow({
32
35
  styleKey: string;
33
36
  onChange: (node: LayoutNode) => void;
34
37
  }) {
35
- const style = (node.query?.style ?? {}) as Record<string, unknown>;
38
+ const style = flattenMotion(node.query?.style ?? {}) as Record<string, unknown>;
36
39
  const stored = formatStyleValue(style[styleKey]);
37
40
  const [draft, setDraft] = React.useState(stored);
38
41
  const [error, setError] = React.useState<string | null>(null);
@@ -105,7 +108,7 @@ export function QueryStyleRows({
105
108
  node: LayoutNode;
106
109
  onChange: (node: LayoutNode) => void;
107
110
  }) {
108
- const style = (node.query?.style ?? {}) as Record<string, unknown>;
111
+ const style = flattenMotion(node.query?.style ?? {}) as Record<string, unknown>;
109
112
  const keys = Object.keys(style).filter((key) => style[key] !== undefined);
110
113
  const free = QUERY_STYLE_KEYS.filter((key) => !keys.includes(key));
111
114
  const [newKey, setNewKey] = React.useState("");
@@ -1,6 +1,7 @@
1
1
  import { Input, Select } from "@cloudflare/kumo";
2
2
  import { MotionControl } from "./MotionControl.tsx";
3
- import { isSafeFontStack, type DesignSystem, type StyleProps } from "../../../../core/index.ts";
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: StyleProps | undefined;
268
+ style: FlatStyleProps | undefined;
214
269
  /** The Normal styles while a state is edited (W-089): shown as placeholders, never saved. */
215
- inherited?: StyleProps;
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<StyleProps>) => void;
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 StyleProps["color"]}
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<StyleProps["fontWeight"]>)
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 StyleProps["fontFamily"] })}
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 === "opacity"
429
- ? OPACITY
430
- : styleKey === "gridColumnStart" || styleKey === "gridRowStart"
431
- ? GRID_LINE
432
- : GRID_SPAN;
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}
@@ -525,6 +587,16 @@ export function StyleRow({
525
587
  );
526
588
  }
527
589
 
590
+ if (styleKey === "loopMotion") {
591
+ return (
592
+ <LoopControl
593
+ value={style?.loopMotion}
594
+ onChange={(loopMotion) => onPatch({ loopMotion })}
595
+ reset={reset}
596
+ />
597
+ );
598
+ }
599
+
528
600
  if (styleKey === "transition") {
529
601
  return (
530
602
  <TransitionControl
@@ -545,6 +617,28 @@ export function StyleRow({
545
617
  );
546
618
  }
547
619
 
620
+ if (styleKey === "transform") {
621
+ return (
622
+ <TransformControl
623
+ value={style?.transform}
624
+ inherited={inherited?.transform}
625
+ onChange={(transform) => onPatch({ transform })}
626
+ />
627
+ );
628
+ }
629
+
630
+ if (styleKey === "backdropFilter") {
631
+ return (
632
+ <FiltersControl
633
+ styleKey="backdropFilter"
634
+ label="Backdrop filters"
635
+ value={style?.backdropFilter}
636
+ inherited={inherited?.backdropFilter}
637
+ onChange={(backdropFilter) => onPatch({ backdropFilter })}
638
+ />
639
+ );
640
+ }
641
+
548
642
  if (LENGTH_KEYS.has(styleKey)) {
549
643
  return (
550
644
  <LengthRow
@@ -569,6 +663,9 @@ export const IMPLEMENTED_STYLE_KEYS: StyleKey[] = [
569
663
  ...COLOR_KEYS,
570
664
  "fontFamily",
571
665
  "zIndex",
666
+ "flexGrow",
667
+ "flexShrink",
668
+ "order",
572
669
  "gridColumnSpan",
573
670
  "gridColumnStart",
574
671
  "gridRowSpan",
@@ -576,8 +673,11 @@ export const IMPLEMENTED_STYLE_KEYS: StyleKey[] = [
576
673
  "opacity",
577
674
  "boxShadow",
578
675
  "filter",
676
+ "backdropFilter",
677
+ "transform",
579
678
  "entrance",
580
679
  "scrollMotion",
680
+ "loopMotion",
581
681
  "transition",
582
682
  "iconRotate",
583
683
  "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, StyleProps } from "../../../../core/index.ts";
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<StyleProps["gap"]>) => void;
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 { StyleProps } from "../../../../core/index.ts";
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
- "section",
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?: StyleProps): FillMode[] {
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: StyleProps | undefined): FillMode {
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: StyleProps | undefined): boolean {
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: StyleProps | undefined, mode: FillMode): Partial<StyleProps> {
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(style: StyleProps | undefined, mode: FillMode): Partial<StyleProps> | undefined {
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<StyleProps>;
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<StyleProps>>>;
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: StyleProps | undefined,
105
+ style: FlatStyleProps | undefined,
103
106
  from: FillMode,
104
107
  to: FillMode,
105
108
  memory: FillMemory,
106
- ): Partial<StyleProps> {
109
+ ): Partial<FlatStyleProps> {
107
110
  const held = heldFill(style, from);
108
111
  if (held) memory[from] = held;
109
112
  const remembered = memory[to];