@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,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(["section", "loop"]);
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;
@@ -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;
@@ -12,6 +12,7 @@ const BOX_AUTO: readonly UnitChoice[] = [...BOX, "auto"];
12
12
  const UNITS: Partial<Record<StyleKey, readonly UnitChoice[]>> = {
13
13
  width: BOX_AUTO,
14
14
  height: BOX_AUTO,
15
+ flexBasis: BOX_AUTO,
15
16
  marginTop: BOX_AUTO,
16
17
  marginRight: BOX_AUTO,
17
18
  marginBottom: BOX_AUTO,
@@ -25,6 +26,7 @@ const UNITS: Partial<Record<StyleKey, readonly UnitChoice[]>> = {
25
26
  // em first, so a typed 1.5 means 1.5 times the font size, not 1.5 px (W-125).
26
27
  lineHeight: ["em", "px", "rem", "%", "x"],
27
28
  letterSpacing: ["px", "rem", "em"],
29
+ markerSize: ["em", "px", "rem", "%"],
28
30
  borderWidth: ["px", "rem", "em"],
29
31
  borderTopWidth: ["px", "rem", "em"],
30
32
  borderRightWidth: ["px", "rem", "em"],
@@ -52,8 +54,46 @@ const NEGATIVE = new Set<StyleKey>([
52
54
  "marginLeft",
53
55
  ]);
54
56
 
57
+ /** W-955: a fluid size, px on small screens to px on large ones. */
58
+ export type FluidLiteral = { fluid: { min: number; max: number } };
59
+
60
+ /** Keys that take a fluid size ("32–56"): type, gap, sizes, padding and margins (W-955). */
61
+ const FLUID = new Set<StyleKey>([
62
+ "fontSize",
63
+ "gap",
64
+ "width",
65
+ "minWidth",
66
+ "maxWidth",
67
+ "height",
68
+ "minHeight",
69
+ "maxHeight",
70
+ "paddingTop",
71
+ "paddingRight",
72
+ "paddingBottom",
73
+ "paddingLeft",
74
+ "marginTop",
75
+ "marginRight",
76
+ "marginBottom",
77
+ "marginLeft",
78
+ ]);
79
+
80
+ export const takesFluid = (key: StyleKey) => FLUID.has(key);
81
+
82
+ export const isFluid = (value: unknown): value is FluidLiteral =>
83
+ typeof value === "object" &&
84
+ value !== null &&
85
+ "fluid" in value &&
86
+ typeof (value as FluidLiteral).fluid?.min === "number" &&
87
+ typeof (value as FluidLiteral).fluid?.max === "number";
88
+
89
+ /** How a fluid size reads in a length field: "32–56" (px). */
90
+ export const fluidDraft = (value: FluidLiteral) => `${value.fluid.min}–${value.fluid.max}`;
91
+
92
+ /** "32–56", "32-56px", "32 to 56": small-screen and large-screen px. */
93
+ const FLUID_DRAFT = /^(\d+(?:\.\d+)?)\s*(?:px)?\s*(?:–|—|-|to|→)\s*(\d+(?:\.\d+)?)\s*(?:px)?$/i;
94
+
55
95
  export type ParsedLength =
56
- | { ok: true; value: LengthLiteral | "auto" | number | undefined }
96
+ | { ok: true; value: LengthLiteral | FluidLiteral | "auto" | number | undefined }
57
97
  | { ok: false; message: string };
58
98
 
59
99
  const DRAFT = /^([+-]?(?:\d+(?:\.\d*)?|\.\d+))\s*(px|rem|em|%|vw|vh|ch)?$/i;
@@ -82,6 +122,18 @@ export function parseLengthDraft(
82
122
  ? { ok: true, value: "auto" }
83
123
  : { ok: false, message: `${label} can't be auto. Enter a number.` };
84
124
  }
125
+ const range = FLUID_DRAFT.exec(text);
126
+ if (range) {
127
+ if (!FLUID.has(key)) {
128
+ return { ok: false, message: `${label} takes one number, not a range.` };
129
+ }
130
+ const min = Number(range[1]);
131
+ const max = Number(range[2]);
132
+ if (min > 10_000 || max > 10_000) {
133
+ return { ok: false, message: `${label} can be up to 10000. Enter a smaller number.` };
134
+ }
135
+ return { ok: true, value: { fluid: { min, max } } };
136
+ }
85
137
  const match = DRAFT.exec(text);
86
138
  const n = match ? Number(match[1]) : Number.NaN;
87
139
  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,7 @@ export const STYLE_LABELS: Record<StyleKey, string> = {
386
426
  cursor: "Cursor",
387
427
  entrance: "Entrance",
388
428
  scrollMotion: "Scroll motion",
429
+ loopMotion: "Loop",
389
430
  iconRotate: "Rotate",
390
431
  iconFlip: "Flip",
391
432
  iconScale: "Scale",
@@ -395,5 +436,5 @@ export const STYLE_LABELS: Record<StyleKey, string> = {
395
436
  transition: "Transition",
396
437
  };
397
438
 
398
- /** Every StyleProps key that the settings panel must be able to edit. */
439
+ /** Every FlatStyleProps key that the settings panel must be able to edit. */
399
440
  export const CONTROLLED_STYLE_KEYS: StyleKey[] = Object.values(SECTION_KEYS).flat();
@@ -7,8 +7,10 @@ import {
7
7
  type DesignSystem,
8
8
  type DeviceStyles,
9
9
  type LayoutNode,
10
- type PopupDevice,
10
+ type Device,
11
+ type FlatStyleProps,
11
12
  type StyleProps,
13
+ patchNestedStyle,
12
14
  type StyleStateName,
13
15
  type StyleStates,
14
16
  } from "../../../core/index.ts";
@@ -17,7 +19,7 @@ import type { StyleStateChoice } from "./settings/StateSwitcher.tsx";
17
19
  export type StyleSlot =
18
20
  | { owner: "element" | "class"; slot: "style" }
19
21
  | { owner: "element" | "class"; slot: "state"; state: StyleStateName }
20
- | { owner: "element" | "class"; slot: "device"; device: "tablet" | "mobile" };
22
+ | { owner: "element" | "class"; slot: "device"; device: "laptop" | "tablet" | "mobile" };
21
23
 
22
24
  /** Which style object a patch writes: the element's own, a class, a state, or a device. */
23
25
  export function styleTarget({
@@ -26,7 +28,7 @@ export function styleTarget({
26
28
  state,
27
29
  }: {
28
30
  classId: string | null;
29
- device: PopupDevice;
31
+ device: Device;
30
32
  state: StyleStateChoice;
31
33
  }): StyleSlot {
32
34
  const owner = classId ? "class" : "element";
@@ -35,8 +37,8 @@ export function styleTarget({
35
37
  return { owner, slot: "state", state };
36
38
  }
37
39
 
38
- const withStyle = (node: LayoutNode, patch: Partial<StyleProps>): LayoutNode => {
39
- const style: Record<string, unknown> = { ...node.style, ...patch };
40
+ const withStyle = (node: LayoutNode, patch: Partial<FlatStyleProps>): LayoutNode => {
41
+ const style = patchNestedStyle(node.style, patch);
40
42
  for (const key of Object.keys(style)) if (style[key] === undefined) delete style[key];
41
43
  return {
42
44
  ...node,
@@ -70,9 +72,9 @@ export function applyStylePatch({
70
72
  node: LayoutNode;
71
73
  design: DesignSystem;
72
74
  classId: string | null;
73
- device: PopupDevice;
75
+ device: Device;
74
76
  state: StyleStateChoice;
75
- patch: Partial<StyleProps>;
77
+ patch: Partial<FlatStyleProps>;
76
78
  }): StyleWrite {
77
79
  const target = styleTarget({ classId, device, state });
78
80
  if (target.slot === "device") {
@@ -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
+ }
@@ -13,6 +13,7 @@ import {
13
13
  type LayoutNode,
14
14
  type Removed,
15
15
  LAYOUT_SCHEMA_VERSION,
16
+ withShiftedMarks,
16
17
  } from "../../core/index.ts";
17
18
  import { withPageHeadingLevel } from "./dnd/new-element.ts";
18
19
  import type { PageDraft } from "../content-api.ts";
@@ -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,7 +215,7 @@ 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);
218
+ const node = withPageHeadingLevel(action.node, state.page.layout, state.page.partType);
215
219
  return arranged(state, addNode(state.page.layout, node, place));
216
220
  }
217
221
  case "move-node":