@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.
Files changed (187) hide show
  1. package/README.md +10 -1
  2. package/package.json +2 -2
  3. package/src/admin/agents-api.ts +45 -0
  4. package/src/admin/bulk-api.ts +67 -0
  5. package/src/admin/content-api.ts +10 -6
  6. package/src/admin/copy-rich-text.ts +119 -0
  7. package/src/admin/dialog-tab-wrap.ts +78 -0
  8. package/src/admin/editor/A11yCopilot.tsx +3 -1
  9. package/src/admin/editor/Editor.tsx +311 -250
  10. package/src/admin/editor/Timeline.tsx +8 -3
  11. package/src/admin/editor/TopBar.tsx +29 -7
  12. package/src/admin/editor/canvas/CanvasFrame.tsx +7 -2
  13. package/src/admin/editor/canvas/DeviceBar.tsx +31 -10
  14. package/src/admin/editor/canvas/canvas-scale.ts +3 -3
  15. package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
  16. package/src/admin/editor/co-design.ts +190 -0
  17. package/src/admin/editor/dnd/new-element.ts +48 -4
  18. package/src/admin/editor/editor-chrome.tsx +8 -6
  19. package/src/admin/editor/editor-commands.ts +15 -4
  20. package/src/admin/editor/editor-css.ts +2 -1
  21. package/src/admin/editor/element-chrome.ts +3 -1
  22. package/src/admin/editor/extension-manifests.ts +20 -0
  23. package/src/admin/editor/extensions/ExtensionPanels.tsx +26 -0
  24. package/src/admin/editor/extensions-context.tsx +27 -0
  25. package/src/admin/editor/feature-css.ts +17 -0
  26. package/src/admin/editor/palette-items.ts +2 -2
  27. package/src/admin/editor/panels/AddPanel.tsx +31 -1
  28. package/src/admin/editor/panels/AgentRequestBox.tsx +116 -0
  29. package/src/admin/editor/panels/ClassesSection.tsx +9 -6
  30. package/src/admin/editor/panels/CoDesignPanel.tsx +170 -0
  31. package/src/admin/editor/panels/ColorControl.tsx +2 -2
  32. package/src/admin/editor/panels/ElementPanel.tsx +68 -20
  33. package/src/admin/editor/panels/LanguagesSection.tsx +152 -0
  34. package/src/admin/editor/panels/LayersPanel.tsx +10 -6
  35. package/src/admin/editor/panels/LeftPanel.tsx +33 -5
  36. package/src/admin/editor/panels/PageSettings.tsx +4 -0
  37. package/src/admin/editor/panels/SettingsPanel.tsx +21 -2
  38. package/src/admin/editor/panels/SiteStylesDrawer.tsx +7 -7
  39. package/src/admin/editor/panels/settings/BackgroundControls.tsx +72 -15
  40. package/src/admin/editor/panels/settings/BackgroundFill.tsx +8 -6
  41. package/src/admin/editor/panels/settings/BoxControl.tsx +5 -5
  42. package/src/admin/editor/panels/settings/EffectsControls.tsx +183 -10
  43. package/src/admin/editor/panels/settings/FieldControl.tsx +9 -3
  44. package/src/admin/editor/panels/settings/IconControls.tsx +25 -11
  45. package/src/admin/editor/panels/settings/LengthRow.tsx +63 -19
  46. package/src/admin/editor/panels/settings/LoopControl.tsx +269 -0
  47. package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +19 -1
  48. package/src/admin/editor/panels/settings/MotionControl.tsx +12 -11
  49. package/src/admin/editor/panels/settings/QueryStyleRows.tsx +7 -4
  50. package/src/admin/editor/panels/settings/StyleRow.tsx +120 -13
  51. package/src/admin/editor/panels/settings/TextMarksControl.tsx +247 -0
  52. package/src/admin/editor/panels/settings/VariableBinding.tsx +2 -2
  53. package/src/admin/editor/panels/settings/background-mode.ts +14 -11
  54. package/src/admin/editor/panels/settings/box-link-name.ts +1 -1
  55. package/src/admin/editor/panels/settings/box-sides.ts +22 -14
  56. package/src/admin/editor/panels/settings/heading-warning.ts +5 -1
  57. package/src/admin/editor/panels/settings/length-units.ts +68 -4
  58. package/src/admin/editor/panels/settings/query-style.ts +3 -3
  59. package/src/admin/editor/panels/settings/style-sections.ts +52 -10
  60. package/src/admin/editor/panels/style-target.ts +22 -7
  61. package/src/admin/editor/presence.ts +60 -0
  62. package/src/admin/editor/section-templates.ts +26 -4
  63. package/src/admin/editor/store.ts +14 -4
  64. package/src/admin/editor/useCoDesign.ts +177 -0
  65. package/src/admin/editor/useEditorCommands.ts +7 -5
  66. package/src/admin/editor/useExtensions.ts +45 -0
  67. package/src/admin/editor/useNodeActions.ts +18 -7
  68. package/src/admin/editor/useProposals.ts +81 -0
  69. package/src/admin/export-api.ts +221 -0
  70. package/src/admin/index.tsx +6 -1
  71. package/src/admin/languages-api.ts +61 -0
  72. package/src/admin/pages/AgentSetup.tsx +148 -0
  73. package/src/admin/pages/AgentsPage.tsx +9 -26
  74. package/src/admin/pages/CreateDialog.tsx +15 -0
  75. package/src/admin/pages/ExportDialog.tsx +395 -0
  76. package/src/admin/pages/ImportButton.tsx +18 -0
  77. package/src/admin/pages/ImportElementorDialog.tsx +669 -0
  78. package/src/admin/pages/ImportPageLinks.tsx +86 -0
  79. package/src/admin/pages/PageList.tsx +82 -3
  80. package/src/admin/pages/ThemePartList.tsx +52 -2
  81. package/src/admin/pages/bulk.tsx +303 -0
  82. package/src/admin/pages/section-head.tsx +27 -0
  83. package/src/admin/proposals-api.ts +91 -0
  84. package/src/admin/search.ts +20 -0
  85. package/src/admin/theme-api.ts +4 -0
  86. package/src/admin/ui.ts +50 -4
  87. package/src/admin/widgets/CanvasField.tsx +8 -0
  88. package/src/admin/widgets/ConvertToRichText.tsx +136 -0
  89. package/src/admin/widgets/ExportEntryHtml.tsx +92 -0
  90. package/src/admin/widgets/convert-body.ts +73 -2
  91. package/src/astro/content-port.ts +14 -1
  92. package/src/astro/render.ts +6 -6
  93. package/src/astro/resolve-theme.ts +25 -8
  94. package/src/astro/resolve.ts +89 -2
  95. package/src/astro/tabs/runtime.ts +16 -6
  96. package/src/constants.ts +1 -1
  97. package/src/core/a11y/audit.ts +45 -14
  98. package/src/core/arrange.ts +5 -1
  99. package/src/core/bounded-array.ts +31 -0
  100. package/src/core/clipboard.ts +9 -0
  101. package/src/core/contract.ts +305 -0
  102. package/src/core/css/generate.ts +151 -20
  103. package/src/core/css/scope.ts +10 -2
  104. package/src/core/css/trace.ts +47 -13
  105. package/src/core/css-keywords.ts +51 -1
  106. package/src/core/design/cascade.ts +12 -9
  107. package/src/core/design/classes.ts +28 -9
  108. package/src/core/design/devices.ts +89 -13
  109. package/src/core/design/states.ts +5 -3
  110. package/src/core/design/transfer.ts +5 -0
  111. package/src/core/design/variables.ts +31 -5
  112. package/src/core/elements/dynamic-elements.ts +3 -3
  113. package/src/core/elements/index.ts +73 -9
  114. package/src/core/export/runtimes.generated.ts +9 -0
  115. package/src/core/export/site.ts +562 -0
  116. package/src/core/export/zip.ts +95 -0
  117. package/src/core/extensions/define.ts +13 -0
  118. package/src/core/extensions/index.ts +41 -0
  119. package/src/core/extensions/namespace.ts +82 -0
  120. package/src/core/extensions/normalize.ts +141 -0
  121. package/src/core/extensions/placeholder.ts +41 -0
  122. package/src/core/extensions/registry.ts +94 -0
  123. package/src/core/extensions/render-ext.ts +118 -0
  124. package/src/core/extensions/safe-nodes.ts +93 -0
  125. package/src/core/extensions/schema.ts +112 -0
  126. package/src/core/extensions/types.ts +159 -0
  127. package/src/core/forms/binding.ts +1 -1
  128. package/src/core/history/diff.ts +26 -1
  129. package/src/core/import/elementor/atomic.ts +1608 -0
  130. package/src/core/import/elementor/classes.ts +127 -0
  131. package/src/core/import/elementor/context.ts +429 -0
  132. package/src/core/import/elementor/counter-steps.ts +72 -0
  133. package/src/core/import/elementor/css.ts +445 -0
  134. package/src/core/import/elementor/html.ts +500 -0
  135. package/src/core/import/elementor/index.ts +967 -0
  136. package/src/core/import/elementor/inline-marks.ts +81 -0
  137. package/src/core/import/elementor/snapshots.ts +48 -0
  138. package/src/core/import/elementor/style.ts +429 -0
  139. package/src/core/import/elementor/values.ts +241 -0
  140. package/src/core/import/elementor/widgets.ts +1897 -0
  141. package/src/core/index.ts +96 -0
  142. package/src/core/json-schema.ts +114 -0
  143. package/src/core/limits.ts +19 -0
  144. package/src/core/migrate/index.ts +6 -1
  145. package/src/core/migrate/v18.ts +222 -0
  146. package/src/core/perf/meter.ts +42 -24
  147. package/src/core/portable-text-export.ts +243 -0
  148. package/src/core/proposals-safety.ts +102 -0
  149. package/src/core/proposals.ts +357 -0
  150. package/src/core/public-attributes.ts +30 -0
  151. package/src/core/recipes/index.ts +2 -2
  152. package/src/core/render/extras.ts +3 -3
  153. package/src/core/render/index.ts +222 -23
  154. package/src/core/render/loop.ts +1 -1
  155. package/src/core/render/section.ts +4 -4
  156. package/src/core/render/tabs.ts +18 -11
  157. package/src/core/render/vnode.ts +1 -1
  158. package/src/core/sanitize/css.ts +151 -10
  159. package/src/core/sanitize/motion.ts +116 -0
  160. package/src/core/saved-sections.ts +6 -0
  161. package/src/core/schema/descriptors.ts +3 -1
  162. package/src/core/schema/design.ts +4 -3
  163. package/src/core/schema/layout.ts +92 -16
  164. package/src/core/schema/style.ts +296 -112
  165. package/src/core/search-text.ts +70 -0
  166. package/src/core/text-marks.ts +227 -0
  167. package/src/core/theme/dynamic.ts +9 -4
  168. package/src/core/theme/float.ts +2 -0
  169. package/src/core/theme/popup-rules.ts +33 -1
  170. package/src/core/translatable.ts +34 -0
  171. package/src/core/validate.ts +13 -1
  172. package/src/index.ts +24 -0
  173. package/src/mcp/errors.ts +3 -1
  174. package/src/mcp/ports.ts +67 -0
  175. package/src/mcp/prompts.ts +1 -11
  176. package/src/mcp/proposals.ts +281 -0
  177. package/src/mcp/read.ts +10 -10
  178. package/src/mcp/tools.ts +71 -3
  179. package/src/mcp/write.ts +66 -11
  180. package/src/server/agent-settings.ts +5 -1
  181. package/src/server/icon-routes.ts +52 -12
  182. package/src/server/mcp-routes.ts +15 -0
  183. package/src/server/plugin.ts +35 -2
  184. package/src/server/presence.ts +78 -0
  185. package/src/server/proposals.ts +261 -0
  186. package/src/server/requests.ts +196 -0
  187. package/src/server/tools-served.ts +45 -0
@@ -1,5 +1,5 @@
1
- import type { StyleProps } from "../../../../core/index.ts";
2
- import type { LengthUnit } from "./length-units.ts";
1
+ import type { FlatStyleProps } from "../../../../core/index.ts";
2
+ import { fluidDraft, isFluid, type LengthUnit } from "./length-units.ts";
3
3
  import type { StyleKey } from "./style-sections.ts";
4
4
 
5
5
  type Four<T> = readonly [T, T, T, T];
@@ -73,7 +73,7 @@ const groupKeys = (group: BoxGroup): StyleKey[] => [
73
73
  ];
74
74
 
75
75
  /** What each box shows: its own value, else the all-sides value. */
76
- export function sideValues(group: BoxGroup, style: StyleProps | undefined): unknown[] {
76
+ export function sideValues(group: BoxGroup, style: FlatStyleProps | undefined): unknown[] {
77
77
  const all = group.all ? style?.[group.all] : undefined;
78
78
  return group.sides.map((key) => style?.[key] ?? all);
79
79
  }
@@ -84,11 +84,11 @@ const same = (a: unknown, b: unknown) => JSON.stringify(a) === JSON.stringify(b)
84
84
  export const allSame = (values: readonly unknown[]) => values.every((v) => same(v, values[0]));
85
85
 
86
86
  /** True when the edited target sets any of the control's keys. */
87
- export const groupSet = (group: BoxGroup, style: StyleProps | undefined) =>
87
+ export const groupSet = (group: BoxGroup, style: FlatStyleProps | undefined) =>
88
88
  groupKeys(group).some((key) => style?.[key] !== undefined);
89
89
 
90
90
  /** One value on every box. Border width and radius use their all-sides key and drop the sides. */
91
- export function linkedPatch(group: BoxGroup, value: unknown): Partial<StyleProps> {
91
+ export function linkedPatch(group: BoxGroup, value: unknown): Partial<FlatStyleProps> {
92
92
  const patch: Record<string, unknown> = {};
93
93
  if (group.all) {
94
94
  patch[group.all] = value;
@@ -96,15 +96,22 @@ export function linkedPatch(group: BoxGroup, value: unknown): Partial<StyleProps
96
96
  } else {
97
97
  for (const key of group.sides) patch[key] = value;
98
98
  }
99
- return patch as Partial<StyleProps>;
99
+ return patch as Partial<FlatStyleProps>;
100
100
  }
101
101
 
102
102
  /** One box's value. */
103
- export const sidePatch = (group: BoxGroup, index: number, value: unknown): Partial<StyleProps> =>
104
- ({ [group.sides[index] as StyleKey]: value }) as Partial<StyleProps>;
103
+ export const sidePatch = (
104
+ group: BoxGroup,
105
+ index: number,
106
+ value: unknown,
107
+ ): Partial<FlatStyleProps> =>
108
+ ({ [group.sides[index] as StyleKey]: value }) as Partial<FlatStyleProps>;
105
109
 
106
110
  /** Linking copies the first box that has a value to all four. */
107
- export function linkPatch(group: BoxGroup, style: StyleProps | undefined): Partial<StyleProps> {
111
+ export function linkPatch(
112
+ group: BoxGroup,
113
+ style: FlatStyleProps | undefined,
114
+ ): Partial<FlatStyleProps> {
108
115
  return linkedPatch(
109
116
  group,
110
117
  sideValues(group, style).find((value) => value !== undefined),
@@ -112,10 +119,10 @@ export function linkPatch(group: BoxGroup, style: StyleProps | undefined): Parti
112
119
  }
113
120
 
114
121
  /** Clears every key of the control. */
115
- export function resetPatch(group: BoxGroup): Partial<StyleProps> {
122
+ export function resetPatch(group: BoxGroup): Partial<FlatStyleProps> {
116
123
  const patch: Record<string, unknown> = {};
117
124
  for (const key of groupKeys(group)) patch[key] = undefined;
118
- return patch as Partial<StyleProps>;
125
+ return patch as Partial<FlatStyleProps>;
119
126
  }
120
127
 
121
128
  const isLiteral = (value: unknown): value is { value: number; unit: LengthUnit } =>
@@ -127,15 +134,15 @@ const isLiteral = (value: unknown): value is { value: number; unit: LengthUnit }
127
134
  /** The shared unit menu: every number the control sets keeps its value in the new unit. */
128
135
  export function unitPatch(
129
136
  group: BoxGroup,
130
- style: StyleProps | undefined,
137
+ style: FlatStyleProps | undefined,
131
138
  unit: LengthUnit,
132
- ): Partial<StyleProps> {
139
+ ): Partial<FlatStyleProps> {
133
140
  const patch: Record<string, unknown> = {};
134
141
  for (const key of groupKeys(group)) {
135
142
  const value = style?.[key];
136
143
  if (isLiteral(value) && value.unit !== unit) patch[key] = { value: value.value, unit };
137
144
  }
138
- return patch as Partial<StyleProps>;
145
+ return patch as Partial<FlatStyleProps>;
139
146
  }
140
147
 
141
148
  /** The unit the shared menu shows: the first box with a number, else `fallback`. */
@@ -148,6 +155,7 @@ export function sideDraft(value: unknown, unit: LengthUnit, varName?: string): s
148
155
  if (isLiteral(value))
149
156
  return value.unit === unit ? String(value.value) : `${value.value}${value.unit}`;
150
157
  if (value === "auto") return "auto";
158
+ if (isFluid(value)) return fluidDraft(value);
151
159
  if (typeof value === "object" && value !== null && "var" in value) return varName ?? "";
152
160
  return "";
153
161
  }
@@ -11,13 +11,17 @@ const SHARED_PARTS: ReadonlySet<ThemePartType> = new Set([
11
11
  "loop_item",
12
12
  ]);
13
13
 
14
+ /** True for a part that lands on pages with their own H1, so a new Heading stays H2 (W-946). */
15
+ export const isSharedPart = (partType: ThemePartType | undefined): boolean =>
16
+ partType !== undefined && SHARED_PARTS.has(partType);
17
+
14
18
  /**
15
19
  * W-208: true for an H1 (a Heading, or a Post title, at level 1) in a header, footer, popup, float,
16
20
  * synced section or loop item. The page it lands on then has two H1s (or one per post), which
17
21
  * confuses screen readers and search engines.
18
22
  */
19
23
  export function sharedPartH1(node: LayoutNode, partType: ThemePartType | undefined): boolean {
20
- if (!partType || !SHARED_PARTS.has(partType)) return false;
24
+ if (!isSharedPart(partType)) return false;
21
25
  const level = (node.props as { level?: number } | undefined)?.level;
22
26
  if (node.type === "heading") return level === 1;
23
27
  if (node.type === "post-title") return (level ?? 1) === 1;
@@ -1,17 +1,30 @@
1
1
  import { STYLE_LABELS, type StyleKey } from "./style-sections.ts";
2
2
 
3
- export type LengthUnit = "px" | "rem" | "em" | "%" | "vw" | "vh" | "ch";
3
+ export type LengthUnit = "px" | "rem" | "em" | "%" | "vw" | "vh" | "ch" | ViewportUnit;
4
+ /**
5
+ * W-974: dynamic and small viewport height, for full-height sections on phones. Stored as `vh`
6
+ * plus the record's `viewportUnits`, so 1.0 still draws them as `vh`.
7
+ */
8
+ export type ViewportUnit = "dvh" | "svh";
9
+ export const isViewportUnit = (unit: unknown): unit is ViewportUnit =>
10
+ unit === "dvh" || unit === "svh";
4
11
  /** `x` is a unitless number, for Line height only (W-213). */
5
12
  export type UnitChoice = LengthUnit | "auto" | "x";
6
13
  export type LengthLiteral = { value: number; unit: LengthUnit };
7
14
 
8
15
  const BOX: readonly UnitChoice[] = ["px", "%", "rem", "em", "vw", "vh", "ch"];
9
16
  const BOX_AUTO: readonly UnitChoice[] = [...BOX, "auto"];
17
+ /** Heights also take dvh and svh (W-974). */
18
+ const HEIGHT: readonly UnitChoice[] = ["px", "%", "rem", "em", "vw", "vh", "dvh", "svh", "ch"];
19
+ const HEIGHT_AUTO: readonly UnitChoice[] = [...HEIGHT, "auto"];
10
20
 
11
21
  /** Units each length property offers in its unit menu (DESIGN.md § Inputs). */
12
22
  const UNITS: Partial<Record<StyleKey, readonly UnitChoice[]>> = {
13
23
  width: BOX_AUTO,
14
- height: BOX_AUTO,
24
+ height: HEIGHT_AUTO,
25
+ minHeight: HEIGHT,
26
+ maxHeight: HEIGHT,
27
+ flexBasis: BOX_AUTO,
15
28
  marginTop: BOX_AUTO,
16
29
  marginRight: BOX_AUTO,
17
30
  marginBottom: BOX_AUTO,
@@ -25,6 +38,7 @@ const UNITS: Partial<Record<StyleKey, readonly UnitChoice[]>> = {
25
38
  // em first, so a typed 1.5 means 1.5 times the font size, not 1.5 px (W-125).
26
39
  lineHeight: ["em", "px", "rem", "%", "x"],
27
40
  letterSpacing: ["px", "rem", "em"],
41
+ markerSize: ["em", "px", "rem", "%"],
28
42
  borderWidth: ["px", "rem", "em"],
29
43
  borderTopWidth: ["px", "rem", "em"],
30
44
  borderRightWidth: ["px", "rem", "em"],
@@ -52,11 +66,49 @@ const NEGATIVE = new Set<StyleKey>([
52
66
  "marginLeft",
53
67
  ]);
54
68
 
69
+ /** W-955: a fluid size, px on small screens to px on large ones. */
70
+ export type FluidLiteral = { fluid: { min: number; max: number } };
71
+
72
+ /** Keys that take a fluid size ("32–56"): type, gap, sizes, padding and margins (W-955). */
73
+ const FLUID = new Set<StyleKey>([
74
+ "fontSize",
75
+ "gap",
76
+ "width",
77
+ "minWidth",
78
+ "maxWidth",
79
+ "height",
80
+ "minHeight",
81
+ "maxHeight",
82
+ "paddingTop",
83
+ "paddingRight",
84
+ "paddingBottom",
85
+ "paddingLeft",
86
+ "marginTop",
87
+ "marginRight",
88
+ "marginBottom",
89
+ "marginLeft",
90
+ ]);
91
+
92
+ export const takesFluid = (key: StyleKey) => FLUID.has(key);
93
+
94
+ export const isFluid = (value: unknown): value is FluidLiteral =>
95
+ typeof value === "object" &&
96
+ value !== null &&
97
+ "fluid" in value &&
98
+ typeof (value as FluidLiteral).fluid?.min === "number" &&
99
+ typeof (value as FluidLiteral).fluid?.max === "number";
100
+
101
+ /** How a fluid size reads in a length field: "32–56" (px). */
102
+ export const fluidDraft = (value: FluidLiteral) => `${value.fluid.min}–${value.fluid.max}`;
103
+
104
+ /** "32–56", "32-56px", "32 to 56": small-screen and large-screen px. */
105
+ const FLUID_DRAFT = /^(\d+(?:\.\d+)?)\s*(?:px)?\s*(?:–|—|-|to|→)\s*(\d+(?:\.\d+)?)\s*(?:px)?$/i;
106
+
55
107
  export type ParsedLength =
56
- | { ok: true; value: LengthLiteral | "auto" | number | undefined }
108
+ | { ok: true; value: LengthLiteral | FluidLiteral | "auto" | number | undefined }
57
109
  | { ok: false; message: string };
58
110
 
59
- const DRAFT = /^([+-]?(?:\d+(?:\.\d*)?|\.\d+))\s*(px|rem|em|%|vw|vh|ch)?$/i;
111
+ const DRAFT = /^([+-]?(?:\d+(?:\.\d*)?|\.\d+))\s*(px|rem|em|%|vw|dvh|svh|vh|ch)?$/i;
60
112
  /** A number with a unit EmVB doesn't take ("100dvh", "12pt"), or a comma decimal ("1,5") (W-262). */
61
113
  const OTHER_UNIT = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)\s*[a-z%]+$/i;
62
114
  const COMMA_DECIMAL = /^[+-]?\d*,\d+\s*[a-z%]*$/i;
@@ -82,6 +134,18 @@ export function parseLengthDraft(
82
134
  ? { ok: true, value: "auto" }
83
135
  : { ok: false, message: `${label} can't be auto. Enter a number.` };
84
136
  }
137
+ const range = FLUID_DRAFT.exec(text);
138
+ if (range) {
139
+ if (!FLUID.has(key)) {
140
+ return { ok: false, message: `${label} takes one number, not a range.` };
141
+ }
142
+ const min = Number(range[1]);
143
+ const max = Number(range[2]);
144
+ if (min > 10_000 || max > 10_000) {
145
+ return { ok: false, message: `${label} can be up to 10000. Enter a smaller number.` };
146
+ }
147
+ return { ok: true, value: { fluid: { min, max } } };
148
+ }
85
149
  const match = DRAFT.exec(text);
86
150
  const n = match ? Number(match[1]) : Number.NaN;
87
151
  if (!match || !Number.isFinite(n)) {
@@ -1,7 +1,7 @@
1
- import { StyleProps } from "../../../../core/index.ts";
1
+ import { FlatStyleProps } from "../../../../core/index.ts";
2
2
 
3
3
  /** Style keys a container-query style may set (W-398). */
4
- export const QUERY_STYLE_KEYS: readonly string[] = Object.keys(StyleProps.shape).toSorted();
4
+ export const QUERY_STYLE_KEYS: readonly string[] = Object.keys(FlatStyleProps.shape).toSorted();
5
5
 
6
6
  /** A stored style value as one line of text: `16px`, `auto`, `#112233`, `var(--name)` (W-398). */
7
7
  export function formatStyleValue(value: unknown): string {
@@ -77,7 +77,7 @@ function candidates(text: string, key: string): unknown[] {
77
77
  /** The value `key` would store for `text`, or why it can't (W-398). */
78
78
  export function parseStyleValue(key: string, text: string): { value: unknown } | { error: string } {
79
79
  // W-542: an inherited name ("constructor") is not a style property; it used to throw.
80
- const shape = StyleProps.shape as Record<
80
+ const shape = FlatStyleProps.shape as Record<
81
81
  string,
82
82
  { safeParse: (v: unknown) => { success: boolean } }
83
83
  >;
@@ -1,4 +1,4 @@
1
- import type { StyleProps } from "../../../../core/index.ts";
1
+ import type { FlatStyleProps } from "../../../../core/index.ts";
2
2
 
3
3
  export type StyleSectionId =
4
4
  | "icon"
@@ -12,7 +12,7 @@ export type StyleSectionId =
12
12
  | "effects"
13
13
  | "advanced";
14
14
 
15
- export type StyleKey = keyof StyleProps;
15
+ export type StyleKey = keyof FlatStyleProps;
16
16
 
17
17
  /** Elementor v4 order (W-088); every list below follows it. */
18
18
  const SECTION_ORDER: StyleSectionId[] = [
@@ -139,7 +139,7 @@ export const SECTION_LABELS: Record<StyleSectionId, string> = {
139
139
  advanced: "Advanced",
140
140
  };
141
141
 
142
- /** Style property keys shown in each section (subset of StyleProps). */
142
+ /** Style property keys shown in each section (subset of FlatStyleProps). */
143
143
  const SECTION_KEYS: Record<StyleSectionId, StyleKey[]> = {
144
144
  layout: [
145
145
  "flexDirection",
@@ -170,10 +170,16 @@ const SECTION_KEYS: Record<StyleSectionId, StyleKey[]> = {
170
170
  "maxWidth",
171
171
  "maxHeight",
172
172
  "overflow",
173
+ "overflowX",
174
+ "overflowY",
173
175
  "aspectRatio",
174
176
  "objectFit",
177
+ "objectPosition",
178
+ "flexGrow",
179
+ "flexShrink",
180
+ "flexBasis",
175
181
  ],
176
- position: ["position", "top", "right", "bottom", "left", "zIndex"],
182
+ position: ["position", "top", "right", "bottom", "left", "zIndex", "alignSelf", "order"],
177
183
  typography: [
178
184
  "fontFamily",
179
185
  "fontSize",
@@ -183,7 +189,12 @@ const SECTION_KEYS: Record<StyleSectionId, StyleKey[]> = {
183
189
  "textAlign",
184
190
  "textTransform",
185
191
  "textDecoration",
192
+ "fontStyle",
193
+ "whiteSpace",
194
+ "overflowWrap",
186
195
  "color",
196
+ "markerColor",
197
+ "markerSize",
187
198
  ],
188
199
  background: [
189
200
  "backgroundColor",
@@ -209,7 +220,18 @@ const SECTION_KEYS: Record<StyleSectionId, StyleKey[]> = {
209
220
  "borderBottomRightRadius",
210
221
  "borderBottomLeftRadius",
211
222
  ],
212
- effects: ["opacity", "boxShadow", "filter", "cursor", "entrance", "scrollMotion", "transition"],
223
+ effects: [
224
+ "opacity",
225
+ "boxShadow",
226
+ "filter",
227
+ "backdropFilter",
228
+ "transform",
229
+ "cursor",
230
+ "entrance",
231
+ "scrollMotion",
232
+ "loopMotion",
233
+ "transition",
234
+ ],
213
235
  icon: ["iconRotate", "iconFlip", "iconScale", "iconStrokeWidth", "iconShadow", "iconAnimation"],
214
236
  advanced: [],
215
237
  };
@@ -223,6 +245,9 @@ const ICON_MOVED: StyleKey[] = ["color", "transition"];
223
245
  /** Keys that only make sense on some element types. */
224
246
  const ONLY_FOR: Partial<Record<StyleKey, string[]>> = {
225
247
  objectFit: ["image", "video"],
248
+ objectPosition: ["image", "video"],
249
+ markerColor: ["list"],
250
+ markerSize: ["list"],
226
251
  ...Object.fromEntries(
227
252
  ["iconRotate", "iconFlip", "iconScale", "iconStrokeWidth", "iconShadow", "iconAnimation"].map(
228
253
  (key) => [key, ["icon"]],
@@ -276,7 +301,7 @@ const TYPE_SECTION_KEYS: Record<string, Partial<Record<StyleSectionId, StyleKey[
276
301
  const OFFSETS = new Set<StyleKey>(["top", "right", "bottom", "left"]);
277
302
 
278
303
  /** Offsets only do anything once the element is positioned (W-088). */
279
- export const offsetsApply = (position: StyleProps["position"]) =>
304
+ export const offsetsApply = (position: FlatStyleProps["position"]) =>
280
305
  position !== undefined && position !== "static";
281
306
 
282
307
  /**
@@ -287,8 +312,8 @@ export const offsetsApply = (position: StyleProps["position"]) =>
287
312
  export function keysFor(
288
313
  type: string,
289
314
  section: StyleSectionId,
290
- style?: StyleProps,
291
- position?: StyleProps["position"],
315
+ style?: FlatStyleProps,
316
+ position?: FlatStyleProps["position"],
292
317
  ): StyleKey[] {
293
318
  const offered = new Set(
294
319
  (
@@ -307,7 +332,7 @@ export function keysFor(
307
332
  /** The type's sections, plus any other section holding a set value, in section order. */
308
333
  export function sectionsFor(
309
334
  sections: StyleSectionId[],
310
- style: StyleProps | undefined,
335
+ style: FlatStyleProps | undefined,
311
336
  type?: string,
312
337
  ): StyleSectionId[] {
313
338
  const moved = type === "icon" ? ICON_MOVED : [];
@@ -337,6 +362,21 @@ export const STYLE_LABELS: Record<StyleKey, string> = {
337
362
  overflow: "Overflow",
338
363
  aspectRatio: "Aspect ratio",
339
364
  objectFit: "Object fit",
365
+ objectPosition: "Object position",
366
+ overflowX: "Overflow X",
367
+ overflowY: "Overflow Y",
368
+ fontStyle: "Style",
369
+ whiteSpace: "Line wrapping",
370
+ overflowWrap: "Long words",
371
+ backdropFilter: "Backdrop filters",
372
+ transform: "Transform",
373
+ flexGrow: "Grow",
374
+ flexShrink: "Shrink",
375
+ flexBasis: "Basis",
376
+ alignSelf: "Align self",
377
+ order: "Order",
378
+ markerColor: "Marker color",
379
+ markerSize: "Marker size",
340
380
  paddingTop: "Padding top",
341
381
  paddingRight: "Padding right",
342
382
  paddingBottom: "Padding bottom",
@@ -386,6 +426,8 @@ export const STYLE_LABELS: Record<StyleKey, string> = {
386
426
  cursor: "Cursor",
387
427
  entrance: "Entrance",
388
428
  scrollMotion: "Scroll motion",
429
+ loopMotion: "Loop",
430
+ viewportUnits: "Viewport units",
389
431
  iconRotate: "Rotate",
390
432
  iconFlip: "Flip",
391
433
  iconScale: "Scale",
@@ -395,5 +437,5 @@ export const STYLE_LABELS: Record<StyleKey, string> = {
395
437
  transition: "Transition",
396
438
  };
397
439
 
398
- /** Every StyleProps key that the settings panel must be able to edit. */
440
+ /** Every FlatStyleProps key that the settings panel must be able to edit. */
399
441
  export const CONTROLLED_STYLE_KEYS: StyleKey[] = Object.values(SECTION_KEYS).flat();
@@ -2,13 +2,17 @@ import {
2
2
  patchClassDevices,
3
3
  patchClassState,
4
4
  patchClassStyle,
5
+ patchClassWide,
5
6
  patchDeviceStyle,
6
7
  patchStates,
8
+ patchWideStyle,
7
9
  type DesignSystem,
8
10
  type DeviceStyles,
9
11
  type LayoutNode,
10
- type PopupDevice,
12
+ type EditorDevice,
13
+ type FlatStyleProps,
11
14
  type StyleProps,
15
+ patchNestedStyle,
12
16
  type StyleStateName,
13
17
  type StyleStates,
14
18
  } from "../../../core/index.ts";
@@ -17,7 +21,8 @@ import type { StyleStateChoice } from "./settings/StateSwitcher.tsx";
17
21
  export type StyleSlot =
18
22
  | { owner: "element" | "class"; slot: "style" }
19
23
  | { owner: "element" | "class"; slot: "state"; state: StyleStateName }
20
- | { owner: "element" | "class"; slot: "device"; device: "tablet" | "mobile" };
24
+ | { owner: "element" | "class"; slot: "device"; device: "laptop" | "tablet" | "mobile" }
25
+ | { owner: "element" | "class"; slot: "wide" };
21
26
 
22
27
  /** Which style object a patch writes: the element's own, a class, a state, or a device. */
23
28
  export function styleTarget({
@@ -26,17 +31,19 @@ export function styleTarget({
26
31
  state,
27
32
  }: {
28
33
  classId: string | null;
29
- device: PopupDevice;
34
+ device: EditorDevice;
30
35
  state: StyleStateChoice;
31
36
  }): StyleSlot {
32
37
  const owner = classId ? "class" : "element";
38
+ // W-959: Wide screen writes the own style's `wide` record.
39
+ if (device === "wide") return { owner, slot: "wide" };
33
40
  if (device !== "desktop") return { owner, slot: "device", device };
34
41
  if (state === "normal") return { owner, slot: "style" };
35
42
  return { owner, slot: "state", state };
36
43
  }
37
44
 
38
- const withStyle = (node: LayoutNode, patch: Partial<StyleProps>): LayoutNode => {
39
- const style: Record<string, unknown> = { ...node.style, ...patch };
45
+ const withStyle = (node: LayoutNode, patch: Partial<FlatStyleProps>): LayoutNode => {
46
+ const style = patchNestedStyle(node.style, patch);
40
47
  for (const key of Object.keys(style)) if (style[key] === undefined) delete style[key];
41
48
  return {
42
49
  ...node,
@@ -70,11 +77,19 @@ export function applyStylePatch({
70
77
  node: LayoutNode;
71
78
  design: DesignSystem;
72
79
  classId: string | null;
73
- device: PopupDevice;
80
+ device: EditorDevice;
74
81
  state: StyleStateChoice;
75
- patch: Partial<StyleProps>;
82
+ patch: Partial<FlatStyleProps>;
76
83
  }): StyleWrite {
77
84
  const target = styleTarget({ classId, device, state });
85
+ if (target.slot === "wide") {
86
+ if (!classId) {
87
+ const { style: _old, ...rest } = node;
88
+ const style = patchWideStyle(node.style, patch);
89
+ return { kind: "node", node: (style ? { ...rest, style } : rest) as LayoutNode };
90
+ }
91
+ return { kind: "design", design: patchClassWide(design, classId, patch) };
92
+ }
78
93
  if (target.slot === "device") {
79
94
  if (!classId) {
80
95
  return {
@@ -0,0 +1,60 @@
1
+ import * as React from "react";
2
+ import { PLUGIN_ID } from "../../constants.ts";
3
+ import { requestJson, type Fetcher } from "../api.ts";
4
+
5
+ /** Matches the server's PRESENCE_LEASE_MS / 3 (W-929): two missed beats still leave it live. */
6
+ const PRESENCE_BEAT_MS = 30_000;
7
+ const ROUTE = `/_emdash/api/plugins/${PLUGIN_ID}/presence`;
8
+
9
+ const bodyOf = (collection: string, id: string, open: boolean) => ({
10
+ target: { collection, id },
11
+ open,
12
+ });
13
+
14
+ function sendPresence(
15
+ fetcher: Fetcher,
16
+ collection: string,
17
+ id: string,
18
+ open: boolean,
19
+ ): Promise<unknown> {
20
+ return requestJson(fetcher, ROUTE, { method: "POST", body: bodyOf(collection, id, open) });
21
+ }
22
+
23
+ /** The closing beat outlives the page (keepalive), so leaving the admin frees the page at once. */
24
+ function sendClosed(fetcher: Fetcher, collection: string, id: string): void {
25
+ fetcher(ROUTE, {
26
+ method: "POST",
27
+ keepalive: true,
28
+ headers: { "content-type": "application/json" },
29
+ body: JSON.stringify(bodyOf(collection, id, false)),
30
+ }).catch(() => undefined);
31
+ }
32
+
33
+ /**
34
+ * W-929 (D-064): tells the site this page is open in the editor while it is, so an agent's direct
35
+ * writes are refused and it proposes changes for review instead. Best effort: a failed beat only
36
+ * means an agent may write directly, which the editor's remote-change notice (W-466) still reports.
37
+ */
38
+ export function useEditorPresence(fetcher: Fetcher, collection: string, id: string): void {
39
+ React.useEffect(() => {
40
+ const beat = () => {
41
+ sendPresence(fetcher, collection, id, true).catch(() => undefined);
42
+ };
43
+ const close = () => sendClosed(fetcher, collection, id);
44
+ const show = () => {
45
+ if (document.visibilityState === "visible") beat();
46
+ };
47
+ beat();
48
+ const timer = setInterval(beat, PRESENCE_BEAT_MS);
49
+ window.addEventListener("pagehide", close);
50
+ window.addEventListener("pageshow", beat);
51
+ document.addEventListener("visibilitychange", show);
52
+ return () => {
53
+ clearInterval(timer);
54
+ window.removeEventListener("pagehide", close);
55
+ window.removeEventListener("pageshow", beat);
56
+ document.removeEventListener("visibilitychange", show);
57
+ close();
58
+ };
59
+ }, [fetcher, collection, id]);
60
+ }
@@ -6,7 +6,7 @@ import {
6
6
  type ThemePartType,
7
7
  } from "../../core/index.ts";
8
8
  import type { Fetcher } from "../api.ts";
9
- import { themePartLayout } from "../theme-api.ts";
9
+ import { listThemeParts, themePartLayout } from "../theme-api.ts";
10
10
 
11
11
  const MAX_DEPTH = 8;
12
12
 
@@ -48,6 +48,8 @@ export async function loadSectionTemplates(
48
48
  export interface PartTemplates {
49
49
  sectionTemplates: Record<string, Layout>;
50
50
  loopTemplates: Record<string, Layout>;
51
+ /** W-970: each loaded part's publish state ("published", "changed", "draft"…). */
52
+ partStatus?: Record<string, string>;
51
53
  }
52
54
 
53
55
  const MAX_PARTS = 64;
@@ -124,9 +126,21 @@ export function usePartTemplates(layout: Layout | null, fetcher: Fetcher): PartT
124
126
  return;
125
127
  }
126
128
  let cancelled = false;
127
- void loadPartTemplates(fetcher, current).then(
128
- (acc) => {
129
- if (!cancelled) setTemplates(acc);
129
+ void Promise.all([
130
+ loadPartTemplates(fetcher, current),
131
+ // W-970: the canvas draws parts' latest saved version; the list says which are published.
132
+ listThemeParts(fetcher).catch(() => []),
133
+ ]).then(
134
+ ([acc, parts]) => {
135
+ if (cancelled) return;
136
+ const loaded = new Set([
137
+ ...Object.keys(acc.sectionTemplates),
138
+ ...Object.keys(acc.loopTemplates),
139
+ ]);
140
+ const partStatus = Object.fromEntries(
141
+ parts.filter((part) => loaded.has(part.id)).map((part) => [part.id, part.status]),
142
+ );
143
+ setTemplates({ ...acc, partStatus });
130
144
  },
131
145
  () => {
132
146
  if (!cancelled) setTemplates(NO_PARTS);
@@ -139,3 +153,11 @@ export function usePartTemplates(layout: Layout | null, fetcher: Fetcher): PartT
139
153
 
140
154
  return templates;
141
155
  }
156
+
157
+ /** W-970: the canvas label's suffix for a part visitors don't see as drawn. */
158
+ export const partDraftLabel = (status: string): string =>
159
+ status === "changed"
160
+ ? "unpublished changes"
161
+ : status === "scheduled"
162
+ ? "scheduled"
163
+ : "not published";
@@ -13,8 +13,9 @@ import {
13
13
  type LayoutNode,
14
14
  type Removed,
15
15
  LAYOUT_SCHEMA_VERSION,
16
+ withShiftedMarks,
16
17
  } from "../../core/index.ts";
17
- import { withPageHeadingLevel } from "./dnd/new-element.ts";
18
+ import { withLoopPostTitleLevel, withPageHeadingLevel } from "./dnd/new-element.ts";
18
19
  import type { PageDraft } from "../content-api.ts";
19
20
 
20
21
  /** Editor state (A-07): a pure reducer, so every edit is testable without a browser. */
@@ -184,7 +185,10 @@ export function editorReducer(state: EditorState, action: EditorAction): EditorS
184
185
  if (!state.page.layout || !findNode(state.page.layout, action.id)) return state;
185
186
  return edited(state, {
186
187
  ...state.page,
187
- layout: updateNode(state.page.layout, action.id, action.update),
188
+ // W-950: formatted words follow an edit of the text, wherever it was made.
189
+ layout: updateNode(state.page.layout, action.id, (node) =>
190
+ withShiftedMarks(node, action.update(node)),
191
+ ),
188
192
  });
189
193
  case "delete-node": {
190
194
  if (!state.page.layout) return state;
@@ -211,8 +215,14 @@ export function editorReducer(state: EditorState, action: EditorAction): EditorS
211
215
  case "add-node": {
212
216
  if (!state.page.layout) return state;
213
217
  const place = { parentId: action.parentId, index: action.index };
214
- const node = withPageHeadingLevel(action.node, state.page.layout);
215
- return arranged(state, addNode(state.page.layout, node, place));
218
+ const node = withPageHeadingLevel(action.node, state.page.layout, state.page.partType);
219
+ const added = addNode(state.page.layout, node, place);
220
+ return arranged(
221
+ state,
222
+ added.ok
223
+ ? { ...added, layout: withLoopPostTitleLevel(added.layout, node.id, state.page.partType) }
224
+ : added,
225
+ );
216
226
  }
217
227
  case "move-node":
218
228
  if (!state.page.layout) return state;