@perkyzz/emvb 0.9.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/package.json +2 -2
- package/src/admin/agents-api.ts +45 -0
- package/src/admin/bulk-api.ts +67 -0
- package/src/admin/content-api.ts +10 -6
- package/src/admin/copy-rich-text.ts +119 -0
- package/src/admin/dialog-tab-wrap.ts +78 -0
- package/src/admin/editor/A11yCopilot.tsx +3 -1
- package/src/admin/editor/Editor.tsx +311 -250
- package/src/admin/editor/Timeline.tsx +8 -3
- package/src/admin/editor/TopBar.tsx +29 -7
- package/src/admin/editor/canvas/CanvasFrame.tsx +7 -2
- package/src/admin/editor/canvas/DeviceBar.tsx +31 -10
- package/src/admin/editor/canvas/canvas-scale.ts +3 -3
- package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
- package/src/admin/editor/co-design.ts +190 -0
- package/src/admin/editor/dnd/new-element.ts +48 -4
- package/src/admin/editor/editor-chrome.tsx +8 -6
- package/src/admin/editor/editor-commands.ts +15 -4
- package/src/admin/editor/editor-css.ts +2 -1
- package/src/admin/editor/element-chrome.ts +3 -1
- package/src/admin/editor/extension-manifests.ts +20 -0
- package/src/admin/editor/extensions/ExtensionPanels.tsx +26 -0
- package/src/admin/editor/extensions-context.tsx +27 -0
- package/src/admin/editor/feature-css.ts +17 -0
- package/src/admin/editor/palette-items.ts +2 -2
- package/src/admin/editor/panels/AddPanel.tsx +31 -1
- package/src/admin/editor/panels/AgentRequestBox.tsx +116 -0
- package/src/admin/editor/panels/ClassesSection.tsx +9 -6
- package/src/admin/editor/panels/CoDesignPanel.tsx +170 -0
- package/src/admin/editor/panels/ColorControl.tsx +2 -2
- package/src/admin/editor/panels/ElementPanel.tsx +68 -20
- package/src/admin/editor/panels/LanguagesSection.tsx +152 -0
- package/src/admin/editor/panels/LayersPanel.tsx +10 -6
- package/src/admin/editor/panels/LeftPanel.tsx +33 -5
- package/src/admin/editor/panels/PageSettings.tsx +4 -0
- package/src/admin/editor/panels/SettingsPanel.tsx +21 -2
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +7 -7
- package/src/admin/editor/panels/settings/BackgroundControls.tsx +72 -15
- package/src/admin/editor/panels/settings/BackgroundFill.tsx +8 -6
- package/src/admin/editor/panels/settings/BoxControl.tsx +5 -5
- package/src/admin/editor/panels/settings/EffectsControls.tsx +183 -10
- package/src/admin/editor/panels/settings/FieldControl.tsx +9 -3
- package/src/admin/editor/panels/settings/IconControls.tsx +25 -11
- package/src/admin/editor/panels/settings/LengthRow.tsx +63 -19
- package/src/admin/editor/panels/settings/LoopControl.tsx +269 -0
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +19 -1
- package/src/admin/editor/panels/settings/MotionControl.tsx +12 -11
- package/src/admin/editor/panels/settings/QueryStyleRows.tsx +7 -4
- package/src/admin/editor/panels/settings/StyleRow.tsx +120 -13
- package/src/admin/editor/panels/settings/TextMarksControl.tsx +247 -0
- package/src/admin/editor/panels/settings/VariableBinding.tsx +2 -2
- package/src/admin/editor/panels/settings/background-mode.ts +14 -11
- package/src/admin/editor/panels/settings/box-link-name.ts +1 -1
- package/src/admin/editor/panels/settings/box-sides.ts +22 -14
- package/src/admin/editor/panels/settings/heading-warning.ts +5 -1
- package/src/admin/editor/panels/settings/length-units.ts +68 -4
- package/src/admin/editor/panels/settings/query-style.ts +3 -3
- package/src/admin/editor/panels/settings/style-sections.ts +52 -10
- package/src/admin/editor/panels/style-target.ts +22 -7
- package/src/admin/editor/presence.ts +60 -0
- package/src/admin/editor/section-templates.ts +26 -4
- package/src/admin/editor/store.ts +14 -4
- package/src/admin/editor/useCoDesign.ts +177 -0
- package/src/admin/editor/useEditorCommands.ts +7 -5
- package/src/admin/editor/useExtensions.ts +45 -0
- package/src/admin/editor/useNodeActions.ts +18 -7
- package/src/admin/editor/useProposals.ts +81 -0
- package/src/admin/export-api.ts +221 -0
- package/src/admin/index.tsx +6 -1
- package/src/admin/languages-api.ts +61 -0
- package/src/admin/pages/AgentSetup.tsx +148 -0
- package/src/admin/pages/AgentsPage.tsx +9 -26
- package/src/admin/pages/CreateDialog.tsx +15 -0
- package/src/admin/pages/ExportDialog.tsx +395 -0
- package/src/admin/pages/ImportButton.tsx +18 -0
- package/src/admin/pages/ImportElementorDialog.tsx +669 -0
- package/src/admin/pages/ImportPageLinks.tsx +86 -0
- package/src/admin/pages/PageList.tsx +82 -3
- package/src/admin/pages/ThemePartList.tsx +52 -2
- package/src/admin/pages/bulk.tsx +303 -0
- package/src/admin/pages/section-head.tsx +27 -0
- package/src/admin/proposals-api.ts +91 -0
- package/src/admin/search.ts +20 -0
- package/src/admin/theme-api.ts +4 -0
- package/src/admin/ui.ts +50 -4
- package/src/admin/widgets/CanvasField.tsx +8 -0
- package/src/admin/widgets/ConvertToRichText.tsx +136 -0
- package/src/admin/widgets/ExportEntryHtml.tsx +92 -0
- package/src/admin/widgets/convert-body.ts +73 -2
- package/src/astro/content-port.ts +14 -1
- package/src/astro/render.ts +6 -6
- package/src/astro/resolve-theme.ts +25 -8
- package/src/astro/resolve.ts +89 -2
- package/src/astro/tabs/runtime.ts +16 -6
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +45 -14
- package/src/core/arrange.ts +5 -1
- package/src/core/bounded-array.ts +31 -0
- package/src/core/clipboard.ts +9 -0
- package/src/core/contract.ts +305 -0
- package/src/core/css/generate.ts +151 -20
- package/src/core/css/scope.ts +10 -2
- package/src/core/css/trace.ts +47 -13
- package/src/core/css-keywords.ts +51 -1
- package/src/core/design/cascade.ts +12 -9
- package/src/core/design/classes.ts +28 -9
- package/src/core/design/devices.ts +89 -13
- package/src/core/design/states.ts +5 -3
- package/src/core/design/transfer.ts +5 -0
- package/src/core/design/variables.ts +31 -5
- package/src/core/elements/dynamic-elements.ts +3 -3
- package/src/core/elements/index.ts +73 -9
- package/src/core/export/runtimes.generated.ts +9 -0
- package/src/core/export/site.ts +562 -0
- package/src/core/export/zip.ts +95 -0
- package/src/core/extensions/define.ts +13 -0
- package/src/core/extensions/index.ts +41 -0
- package/src/core/extensions/namespace.ts +82 -0
- package/src/core/extensions/normalize.ts +141 -0
- package/src/core/extensions/placeholder.ts +41 -0
- package/src/core/extensions/registry.ts +94 -0
- package/src/core/extensions/render-ext.ts +118 -0
- package/src/core/extensions/safe-nodes.ts +93 -0
- package/src/core/extensions/schema.ts +112 -0
- package/src/core/extensions/types.ts +159 -0
- package/src/core/forms/binding.ts +1 -1
- package/src/core/history/diff.ts +26 -1
- package/src/core/import/elementor/atomic.ts +1608 -0
- package/src/core/import/elementor/classes.ts +127 -0
- package/src/core/import/elementor/context.ts +429 -0
- package/src/core/import/elementor/counter-steps.ts +72 -0
- package/src/core/import/elementor/css.ts +445 -0
- package/src/core/import/elementor/html.ts +500 -0
- package/src/core/import/elementor/index.ts +967 -0
- package/src/core/import/elementor/inline-marks.ts +81 -0
- package/src/core/import/elementor/snapshots.ts +48 -0
- package/src/core/import/elementor/style.ts +429 -0
- package/src/core/import/elementor/values.ts +241 -0
- package/src/core/import/elementor/widgets.ts +1897 -0
- package/src/core/index.ts +96 -0
- package/src/core/json-schema.ts +114 -0
- package/src/core/limits.ts +19 -0
- package/src/core/migrate/index.ts +6 -1
- package/src/core/migrate/v18.ts +222 -0
- package/src/core/perf/meter.ts +42 -24
- package/src/core/portable-text-export.ts +243 -0
- package/src/core/proposals-safety.ts +102 -0
- package/src/core/proposals.ts +357 -0
- package/src/core/public-attributes.ts +30 -0
- package/src/core/recipes/index.ts +2 -2
- package/src/core/render/extras.ts +3 -3
- package/src/core/render/index.ts +222 -23
- package/src/core/render/loop.ts +1 -1
- package/src/core/render/section.ts +4 -4
- package/src/core/render/tabs.ts +18 -11
- package/src/core/render/vnode.ts +1 -1
- package/src/core/sanitize/css.ts +151 -10
- package/src/core/sanitize/motion.ts +116 -0
- package/src/core/saved-sections.ts +6 -0
- package/src/core/schema/descriptors.ts +3 -1
- package/src/core/schema/design.ts +4 -3
- package/src/core/schema/layout.ts +92 -16
- package/src/core/schema/style.ts +296 -112
- package/src/core/search-text.ts +70 -0
- package/src/core/text-marks.ts +227 -0
- package/src/core/theme/dynamic.ts +9 -4
- package/src/core/theme/float.ts +2 -0
- package/src/core/theme/popup-rules.ts +33 -1
- package/src/core/translatable.ts +34 -0
- package/src/core/validate.ts +13 -1
- package/src/index.ts +24 -0
- package/src/mcp/errors.ts +3 -1
- package/src/mcp/ports.ts +67 -0
- package/src/mcp/prompts.ts +1 -11
- package/src/mcp/proposals.ts +281 -0
- package/src/mcp/read.ts +10 -10
- package/src/mcp/tools.ts +71 -3
- package/src/mcp/write.ts +66 -11
- package/src/server/agent-settings.ts +5 -1
- package/src/server/icon-routes.ts +52 -12
- package/src/server/mcp-routes.ts +15 -0
- package/src/server/plugin.ts +35 -2
- package/src/server/presence.ts +78 -0
- package/src/server/proposals.ts +261 -0
- package/src/server/requests.ts +196 -0
- package/src/server/tools-served.ts +45 -0
package/src/core/schema/style.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import {
|
|
3
3
|
ALIGN_ITEMS,
|
|
4
|
+
ALIGN_SELF,
|
|
4
5
|
BACKGROUND_POSITIONS,
|
|
5
6
|
BACKGROUND_REPEATS,
|
|
6
7
|
BACKGROUND_SIZES,
|
|
@@ -8,10 +9,12 @@ import {
|
|
|
8
9
|
CURSORS,
|
|
9
10
|
FLEX_DIRECTIONS,
|
|
10
11
|
FLEX_WRAPS,
|
|
12
|
+
FONT_STYLES,
|
|
11
13
|
HEX_COLOR,
|
|
12
14
|
JUSTIFY_CONTENT,
|
|
13
15
|
LENGTH_UNITS,
|
|
14
16
|
OBJECT_FITS,
|
|
17
|
+
OVERFLOW_WRAPS,
|
|
15
18
|
OVERFLOWS,
|
|
16
19
|
POSITIONS,
|
|
17
20
|
TEXT_ALIGNS,
|
|
@@ -19,10 +22,11 @@ import {
|
|
|
19
22
|
TEXT_TRANSFORMS,
|
|
20
23
|
TRANSITION_EASINGS,
|
|
21
24
|
TRANSITION_PROPERTIES,
|
|
25
|
+
WHITE_SPACES,
|
|
22
26
|
} from "../css-keywords.ts";
|
|
23
27
|
import { isSafeFontStack } from "../sanitize/css.ts";
|
|
24
28
|
import { sanitizeMediaUrl } from "../sanitize/media-url.ts";
|
|
25
|
-
import {
|
|
29
|
+
import { DEVICES } from "../theme/popup-rules.ts";
|
|
26
30
|
import { MOTION_EFFECTS, MOTION_LIMITS } from "./motion.ts";
|
|
27
31
|
|
|
28
32
|
/** Colour refs omit `from` (legacy). Length/font refs set `from` (W-028). */
|
|
@@ -50,6 +54,19 @@ export const LengthValue = z.union([Length, VariableRef]);
|
|
|
50
54
|
/** Width, height and margins may also be `auto` (W-088). */
|
|
51
55
|
const SizeValue = z.union([Length, VariableRef, z.literal("auto")]);
|
|
52
56
|
|
|
57
|
+
/**
|
|
58
|
+
* W-955: a fluid size, `min` px on small screens growing to `max` px on large ones, emitted as
|
|
59
|
+
* `clamp()` between 360 and 1280 px wide screens (the design's fluid sizes use the same formula).
|
|
60
|
+
*/
|
|
61
|
+
const FluidLength = z.strictObject({
|
|
62
|
+
fluid: z.strictObject({
|
|
63
|
+
min: z.number().finite().min(0).max(10_000),
|
|
64
|
+
max: z.number().finite().min(0).max(10_000),
|
|
65
|
+
}),
|
|
66
|
+
});
|
|
67
|
+
const FluidLengthValue = z.union([Length, VariableRef, FluidLength]);
|
|
68
|
+
const FluidSizeValue = z.union([Length, VariableRef, FluidLength, z.literal("auto")]);
|
|
69
|
+
|
|
53
70
|
/**
|
|
54
71
|
* Top, right, bottom and left may be negative, `auto` or a spacing variable (W-088); so may
|
|
55
72
|
* margins since W-331, to pull an element over its neighbour.
|
|
@@ -58,6 +75,7 @@ const OffsetValue = z.union([
|
|
|
58
75
|
z.strictObject({ value: z.number().finite().min(-10_000).max(10_000), unit: LengthUnit }),
|
|
59
76
|
VariableRef,
|
|
60
77
|
z.literal("auto"),
|
|
78
|
+
FluidLength,
|
|
61
79
|
]);
|
|
62
80
|
|
|
63
81
|
/** `w/h` with whole numbers 1–9999, emitted as `w / h` (W-088). */
|
|
@@ -76,6 +94,22 @@ const BoxShadow = z.strictObject({
|
|
|
76
94
|
});
|
|
77
95
|
|
|
78
96
|
/** Filter functions, emitted in a fixed order; at least one is set (W-088). */
|
|
97
|
+
/**
|
|
98
|
+
* W-953: move, scale and rotate, written as CSS's own `translate`, `scale` and `rotate` so an
|
|
99
|
+
* entrance (which animates `transform`) never cancels it. In a hover state it is a lift.
|
|
100
|
+
*/
|
|
101
|
+
const Transform = z
|
|
102
|
+
.strictObject({
|
|
103
|
+
/** Pixels, right and down. */
|
|
104
|
+
x: z.number().int().min(-2000).max(2000).optional(),
|
|
105
|
+
y: z.number().int().min(-2000).max(2000).optional(),
|
|
106
|
+
/** Percent, 100 = unchanged. */
|
|
107
|
+
scale: z.number().int().min(10).max(400).optional(),
|
|
108
|
+
/** Degrees, clockwise. */
|
|
109
|
+
rotate: z.number().int().min(-360).max(360).optional(),
|
|
110
|
+
})
|
|
111
|
+
.refine((t) => Object.values(t).some((v) => v !== undefined), "Set at least one transform");
|
|
112
|
+
|
|
79
113
|
const Filter = z
|
|
80
114
|
.strictObject({
|
|
81
115
|
blur: num(0, 100).optional(),
|
|
@@ -101,13 +135,171 @@ const Transition = z.strictObject({
|
|
|
101
135
|
property: z.enum(TRANSITION_PROPERTIES),
|
|
102
136
|
});
|
|
103
137
|
|
|
104
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* A spin or pulse; off for visitors who prefer reduced motion. It stops after about 5 s
|
|
140
|
+
* (W-848) unless `loop` is true (W-853, D-059). `{ type: "none" }` (W-248) stops an animation a
|
|
141
|
+
* device would otherwise inherit from a wider one.
|
|
142
|
+
*/
|
|
143
|
+
const IconAnimation = z.union([
|
|
144
|
+
z.strictObject({
|
|
145
|
+
type: z.enum(["spin", "pulse"]),
|
|
146
|
+
duration: z.number().int().min(200).max(10_000),
|
|
147
|
+
loop: z.literal(true).optional(),
|
|
148
|
+
}),
|
|
149
|
+
z.strictObject({ type: z.literal("none") }),
|
|
150
|
+
]);
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Scroll motion (W-319): effects tied to the element's trip through the screen (or the page's
|
|
154
|
+
* scroll), with CSS scroll-driven animations. Browsers without them, and visitors who prefer
|
|
155
|
+
* reduced motion, see the element still. `{ type: "none" }` stops motion a wider device sets.
|
|
156
|
+
*/
|
|
157
|
+
/** From/to values per effect, each effect once, within MOTION_LIMITS (W-319; loops W-938). */
|
|
158
|
+
const MotionEffects = z
|
|
159
|
+
.array(
|
|
160
|
+
z.strictObject({
|
|
161
|
+
type: z.enum(MOTION_EFFECTS),
|
|
162
|
+
from: z.number().min(-1000).max(1000),
|
|
163
|
+
to: z.number().min(-1000).max(1000),
|
|
164
|
+
}),
|
|
165
|
+
)
|
|
166
|
+
.min(1)
|
|
167
|
+
.max(MOTION_EFFECTS.length)
|
|
168
|
+
.superRefine((effects, ctx) => {
|
|
169
|
+
const seen = new Set<string>();
|
|
170
|
+
for (const effect of effects) {
|
|
171
|
+
const [min, max] = MOTION_LIMITS[effect.type];
|
|
172
|
+
if ([effect.from, effect.to].some((n) => n < min || n > max)) {
|
|
173
|
+
ctx.addIssue({
|
|
174
|
+
code: "custom",
|
|
175
|
+
message: `${effect.type} goes from ${min} to ${max}`,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
if (seen.has(effect.type)) {
|
|
179
|
+
ctx.addIssue({ code: "custom", message: `${effect.type} is set twice` });
|
|
180
|
+
}
|
|
181
|
+
seen.add(effect.type);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const ScrollMotion = z.union([
|
|
186
|
+
z.strictObject({
|
|
187
|
+
effects: MotionEffects,
|
|
188
|
+
range: z.enum(["enter", "cross", "exit", "page"]),
|
|
189
|
+
}),
|
|
190
|
+
z.strictObject({ type: z.literal("none") }),
|
|
191
|
+
]);
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* A looping animation (W-938): the effects play from their `from` to their `to` values over
|
|
195
|
+
* `duration`, and back when `alternate` (the default). Like an Icon's spin (D-057, D-059) it stops
|
|
196
|
+
* after about 5 seconds unless `loop` is true, and it is off for visitors who prefer reduced
|
|
197
|
+
* motion. Presets in the editor (float, pulse, wiggle…) are just effect sets. `{ type: "none" }`
|
|
198
|
+
* stops a loop a wider device sets.
|
|
199
|
+
*/
|
|
200
|
+
const LoopMotion = z.union([
|
|
201
|
+
z.strictObject({
|
|
202
|
+
effects: MotionEffects,
|
|
203
|
+
duration: z.number().int().min(200).max(20_000),
|
|
204
|
+
easing: z.enum(TRANSITION_EASINGS).optional(),
|
|
205
|
+
alternate: z.boolean().optional(),
|
|
206
|
+
loop: z.literal(true).optional(),
|
|
207
|
+
}),
|
|
208
|
+
z.strictObject({ type: z.literal("none") }),
|
|
209
|
+
]);
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Plays once (W-101, W-107). `delay` waits before it starts. `view` starts as the element
|
|
213
|
+
* scrolls into view, using CSS scroll-driven animations, and falls back to playing on load.
|
|
214
|
+
* Not a state style.
|
|
215
|
+
*/
|
|
216
|
+
const Entrance = z.strictObject({
|
|
217
|
+
type: z.enum(["fade", "fade-up", "fade-down", "slide-up", "slide-down", "scale"]),
|
|
218
|
+
duration: z.number().int().min(0).max(2000),
|
|
219
|
+
delay: z.number().int().min(0).max(2000).optional(),
|
|
220
|
+
trigger: z.enum(["load", "view"]).optional(),
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Every motion setting of a style, under one key (W-925, layout 18 / design 17): `entrance`,
|
|
225
|
+
* `scroll` (scroll motion), `transition` and `icon` (an Icon's spin or pulse). Before 1.0 these
|
|
226
|
+
* were the flat style keys `entrance`, `scrollMotion`, `transition` and `iconAnimation`; stored
|
|
227
|
+
* documents are moved here on read. Each part keeps its own rules and its own device cascade.
|
|
228
|
+
*/
|
|
229
|
+
export const Motion = z.strictObject({
|
|
230
|
+
entrance: Entrance.optional(),
|
|
231
|
+
scroll: ScrollMotion.optional(),
|
|
232
|
+
transition: Transition.optional(),
|
|
233
|
+
icon: IconAnimation.optional(),
|
|
234
|
+
loop: LoopMotion.optional(),
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
export type Motion = z.infer<typeof Motion>;
|
|
238
|
+
|
|
239
|
+
/** A gradient: up to 10 stops (W-160). Also the paint of a gradient overlay (W-949). */
|
|
240
|
+
const Gradient = z.strictObject({
|
|
241
|
+
type: z.enum(["linear", "radial", "conic"]),
|
|
242
|
+
angle: z.number().int().min(0).max(360).optional(),
|
|
243
|
+
position: z.enum(BACKGROUND_POSITIONS).optional(),
|
|
244
|
+
stops: z
|
|
245
|
+
.array(
|
|
246
|
+
z.strictObject({
|
|
247
|
+
color: ColorValue,
|
|
248
|
+
at: z.number().int().min(0).max(100),
|
|
249
|
+
}),
|
|
250
|
+
)
|
|
251
|
+
.min(2)
|
|
252
|
+
.max(10),
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
/** A colour or gradient laid over a background (W-094, W-949). */
|
|
256
|
+
const Overlay = z.union([
|
|
257
|
+
z.strictObject({
|
|
258
|
+
color: ColorValue,
|
|
259
|
+
opacity: z.number().finite().min(0).max(1),
|
|
260
|
+
}),
|
|
261
|
+
z.strictObject({
|
|
262
|
+
gradient: Gradient,
|
|
263
|
+
opacity: z.number().finite().min(0).max(1).optional(),
|
|
264
|
+
}),
|
|
265
|
+
]);
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Style properties for layout and text elements (W-017 / R-012). Unknown keys are refused here;
|
|
269
|
+
* `validateLayout` and `validateDesign` keep a newer 1.x key aside and puts it back untouched (D-065, W-925).
|
|
270
|
+
*/
|
|
271
|
+
/** W-974: the length keys whose `vh` can be drawn as `dvh` or `svh`. */
|
|
272
|
+
const VIEWPORT_UNIT_KEYS = [
|
|
273
|
+
"width",
|
|
274
|
+
"minWidth",
|
|
275
|
+
"maxWidth",
|
|
276
|
+
"height",
|
|
277
|
+
"minHeight",
|
|
278
|
+
"maxHeight",
|
|
279
|
+
"flexBasis",
|
|
280
|
+
"gap",
|
|
281
|
+
"fontSize",
|
|
282
|
+
"paddingTop",
|
|
283
|
+
"paddingRight",
|
|
284
|
+
"paddingBottom",
|
|
285
|
+
"paddingLeft",
|
|
286
|
+
"marginTop",
|
|
287
|
+
"marginRight",
|
|
288
|
+
"marginBottom",
|
|
289
|
+
"marginLeft",
|
|
290
|
+
"top",
|
|
291
|
+
"right",
|
|
292
|
+
"bottom",
|
|
293
|
+
"left",
|
|
294
|
+
] as const;
|
|
295
|
+
const VIEWPORT_UNITS = ["dvh", "svh"] as const;
|
|
296
|
+
|
|
105
297
|
export const StyleProps = z.strictObject({
|
|
106
298
|
flexDirection: z.enum(FLEX_DIRECTIONS).optional(),
|
|
107
299
|
flexWrap: z.enum(FLEX_WRAPS).optional(),
|
|
108
300
|
justifyContent: z.enum(JUSTIFY_CONTENT).optional(),
|
|
109
301
|
alignItems: z.enum(ALIGN_ITEMS).optional(),
|
|
110
|
-
gap:
|
|
302
|
+
gap: FluidLengthValue.optional(),
|
|
111
303
|
/** How many grid columns this element spans (1–12). */
|
|
112
304
|
gridColumnSpan: z.number().int().min(1).max(12).optional(),
|
|
113
305
|
/** How many grid rows this element spans (1–12). */
|
|
@@ -116,21 +308,36 @@ export const StyleProps = z.strictObject({
|
|
|
116
308
|
gridColumnStart: z.number().int().min(1).max(13).optional(),
|
|
117
309
|
/** First row line (1–13). With a span, emits `start / span n`. */
|
|
118
310
|
gridRowStart: z.number().int().min(1).max(13).optional(),
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
311
|
+
/**
|
|
312
|
+
* W-954: how a child of a Flexbox or Container shares the row or column: how much it grows into
|
|
313
|
+
* free space, how much it gives up when space is short, its starting size, its own alignment
|
|
314
|
+
* and its place in the order.
|
|
315
|
+
*/
|
|
316
|
+
flexGrow: z.number().finite().min(0).max(100).optional(),
|
|
317
|
+
flexShrink: z.number().finite().min(0).max(100).optional(),
|
|
318
|
+
flexBasis: SizeValue.optional(),
|
|
319
|
+
alignSelf: z.enum(ALIGN_SELF).optional(),
|
|
320
|
+
order: z.number().int().min(-99).max(99).optional(),
|
|
321
|
+
width: FluidSizeValue.optional(),
|
|
322
|
+
minWidth: FluidLengthValue.optional(),
|
|
323
|
+
maxWidth: FluidLengthValue.optional(),
|
|
324
|
+
height: FluidSizeValue.optional(),
|
|
325
|
+
minHeight: FluidLengthValue.optional(),
|
|
326
|
+
maxHeight: FluidLengthValue.optional(),
|
|
125
327
|
overflow: z.enum(OVERFLOWS).optional(),
|
|
328
|
+
/** W-957: one axis only, after `overflow` so it wins (a table that scrolls sideways). */
|
|
329
|
+
overflowX: z.enum(OVERFLOWS).optional(),
|
|
330
|
+
overflowY: z.enum(OVERFLOWS).optional(),
|
|
126
331
|
aspectRatio: z
|
|
127
332
|
.union([z.literal("auto"), z.string().regex(ASPECT_RATIO, "Use a ratio such as 16/9")])
|
|
128
333
|
.optional(),
|
|
129
334
|
objectFit: z.enum(OBJECT_FITS).optional(),
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
335
|
+
/** W-957: which part of an image or video stays in view when it is cropped. */
|
|
336
|
+
objectPosition: z.enum(BACKGROUND_POSITIONS).optional(),
|
|
337
|
+
paddingTop: FluidLengthValue.optional(),
|
|
338
|
+
paddingRight: FluidLengthValue.optional(),
|
|
339
|
+
paddingBottom: FluidLengthValue.optional(),
|
|
340
|
+
paddingLeft: FluidLengthValue.optional(),
|
|
134
341
|
marginTop: OffsetValue.optional(),
|
|
135
342
|
marginRight: OffsetValue.optional(),
|
|
136
343
|
marginBottom: OffsetValue.optional(),
|
|
@@ -147,7 +354,7 @@ export const StyleProps = z.strictObject({
|
|
|
147
354
|
VariableRef,
|
|
148
355
|
])
|
|
149
356
|
.optional(),
|
|
150
|
-
fontSize:
|
|
357
|
+
fontSize: FluidLengthValue.optional(),
|
|
151
358
|
/** W-213: any weight 100–900 in steps of 100 (the font must ship it to look different). */
|
|
152
359
|
fontWeight: z
|
|
153
360
|
.union([
|
|
@@ -176,6 +383,13 @@ export const StyleProps = z.strictObject({
|
|
|
176
383
|
textTransform: z.enum(TEXT_TRANSFORMS).optional(),
|
|
177
384
|
/** W-113. A button sets `none` in its base CSS, so it is not underlined unless a style says so. */
|
|
178
385
|
textDecoration: z.enum(TEXT_DECORATIONS).optional(),
|
|
386
|
+
/** W-952: a List's markers (bullets, numbers, step circles): their colour and size. */
|
|
387
|
+
markerColor: ColorValue.optional(),
|
|
388
|
+
markerSize: LengthValue.optional(),
|
|
389
|
+
/** W-957. */
|
|
390
|
+
fontStyle: z.enum(FONT_STYLES).optional(),
|
|
391
|
+
whiteSpace: z.enum(WHITE_SPACES).optional(),
|
|
392
|
+
overflowWrap: z.enum(OVERFLOW_WRAPS).optional(),
|
|
179
393
|
color: ColorValue.optional(),
|
|
180
394
|
backgroundColor: ColorValue.optional(),
|
|
181
395
|
/** http(s) or a site path. Spaces, quotes and parentheses are refused so the URL can sit inside `url("")`. */
|
|
@@ -205,29 +419,12 @@ export const StyleProps = z.strictObject({
|
|
|
205
419
|
* Background gradient (W-160). Up to 10 stops. `angle` is the linear direction and the conic
|
|
206
420
|
* start; `position` is the radial centre. A stop colour variable is a colour use.
|
|
207
421
|
*/
|
|
208
|
-
gradient:
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
.array(
|
|
215
|
-
z.strictObject({
|
|
216
|
-
color: ColorValue,
|
|
217
|
-
at: z.number().int().min(0).max(100),
|
|
218
|
-
}),
|
|
219
|
-
)
|
|
220
|
-
.min(2)
|
|
221
|
-
.max(10),
|
|
222
|
-
})
|
|
223
|
-
.optional(),
|
|
224
|
-
/** A colour laid over the image and gradient. `opacity` is 0–1 (W-094). */
|
|
225
|
-
overlay: z
|
|
226
|
-
.strictObject({
|
|
227
|
-
color: ColorValue,
|
|
228
|
-
opacity: z.number().finite().min(0).max(1),
|
|
229
|
-
})
|
|
230
|
-
.optional(),
|
|
422
|
+
gradient: Gradient.optional(),
|
|
423
|
+
/**
|
|
424
|
+
* Laid over the image and gradient (W-094): a colour, or since W-949 a gradient (a scrim that
|
|
425
|
+
* fades from dark behind the text to clear). `opacity` 0–1 fades the whole overlay.
|
|
426
|
+
*/
|
|
427
|
+
overlay: Overlay.optional(),
|
|
231
428
|
borderWidth: LengthValue.optional(),
|
|
232
429
|
/** Per-side widths (W-138, D-044), after `borderWidth`, so a side beats the all-sides value. */
|
|
233
430
|
borderTopWidth: LengthValue.optional(),
|
|
@@ -245,8 +442,10 @@ export const StyleProps = z.strictObject({
|
|
|
245
442
|
opacity: z.number().finite().min(0).max(1).optional(),
|
|
246
443
|
boxShadow: BoxShadow.optional(),
|
|
247
444
|
filter: Filter.optional(),
|
|
445
|
+
transform: Transform.optional(),
|
|
446
|
+
/** W-957: the same filters applied to what is behind the element (frosted glass). */
|
|
447
|
+
backdropFilter: Filter.optional(),
|
|
248
448
|
cursor: z.enum(CURSORS).optional(),
|
|
249
|
-
transition: Transition.optional(),
|
|
250
449
|
/**
|
|
251
450
|
* Icon element glyph styling (W-237). Emitted as custom properties on the icon's wrapper, so
|
|
252
451
|
* they work in states, devices and classes; the Icon's base CSS applies them to its `<svg>`.
|
|
@@ -266,87 +465,70 @@ export const StyleProps = z.strictObject({
|
|
|
266
465
|
})
|
|
267
466
|
.optional(),
|
|
268
467
|
/**
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
468
|
+
* W-974 (1.1): which `vh` lengths in this record are drawn in dynamic (`dvh`) or small (`svh`)
|
|
469
|
+
* viewport units, for full-height sections on phones. The length itself stays `vh`, so 1.0
|
|
470
|
+
* (which ignores this key) still draws it in `vh`.
|
|
272
471
|
*/
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
z.strictObject({
|
|
276
|
-
type: z.enum(["spin", "pulse"]),
|
|
277
|
-
duration: z.number().int().min(200).max(10_000),
|
|
278
|
-
loop: z.literal(true).optional(),
|
|
279
|
-
}),
|
|
280
|
-
z.strictObject({ type: z.literal("none") }),
|
|
281
|
-
])
|
|
282
|
-
.optional(),
|
|
283
|
-
/**
|
|
284
|
-
* Scroll motion (W-319): effects tied to the element's trip through the screen (or the page's
|
|
285
|
-
* scroll), with CSS scroll-driven animations. Browsers without them, and visitors who prefer
|
|
286
|
-
* reduced motion, see the element still. `{ type: "none" }` stops motion a wider device sets.
|
|
287
|
-
*/
|
|
288
|
-
scrollMotion: z
|
|
289
|
-
.union([
|
|
290
|
-
z.strictObject({
|
|
291
|
-
effects: z
|
|
292
|
-
.array(
|
|
293
|
-
z.strictObject({
|
|
294
|
-
type: z.enum(MOTION_EFFECTS),
|
|
295
|
-
from: z.number().min(-1000).max(1000),
|
|
296
|
-
to: z.number().min(-1000).max(1000),
|
|
297
|
-
}),
|
|
298
|
-
)
|
|
299
|
-
.min(1)
|
|
300
|
-
.max(MOTION_EFFECTS.length)
|
|
301
|
-
.superRefine((effects, ctx) => {
|
|
302
|
-
const seen = new Set<string>();
|
|
303
|
-
for (const effect of effects) {
|
|
304
|
-
const [min, max] = MOTION_LIMITS[effect.type];
|
|
305
|
-
if ([effect.from, effect.to].some((n) => n < min || n > max)) {
|
|
306
|
-
ctx.addIssue({
|
|
307
|
-
code: "custom",
|
|
308
|
-
message: `${effect.type} goes from ${min} to ${max}`,
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
if (seen.has(effect.type)) {
|
|
312
|
-
ctx.addIssue({ code: "custom", message: `${effect.type} is set twice` });
|
|
313
|
-
}
|
|
314
|
-
seen.add(effect.type);
|
|
315
|
-
}
|
|
316
|
-
}),
|
|
317
|
-
range: z.enum(["enter", "cross", "exit", "page"]),
|
|
318
|
-
}),
|
|
319
|
-
z.strictObject({ type: z.literal("none") }),
|
|
320
|
-
])
|
|
321
|
-
.optional(),
|
|
322
|
-
/**
|
|
323
|
-
* Plays once (W-101, W-107). `delay` waits before it starts. `view` starts as the element
|
|
324
|
-
* scrolls into view, using CSS scroll-driven animations, and falls back to playing on load.
|
|
325
|
-
* Not a state style.
|
|
326
|
-
*/
|
|
327
|
-
entrance: z
|
|
328
|
-
.strictObject({
|
|
329
|
-
type: z.enum(["fade", "fade-up", "fade-down", "slide-up", "slide-down", "scale"]),
|
|
330
|
-
duration: z.number().int().min(0).max(2000),
|
|
331
|
-
delay: z.number().int().min(0).max(2000).optional(),
|
|
332
|
-
trigger: z.enum(["load", "view"]).optional(),
|
|
333
|
-
})
|
|
334
|
-
.optional(),
|
|
472
|
+
viewportUnits: z.partialRecord(z.enum(VIEWPORT_UNIT_KEYS), z.enum(VIEWPORT_UNITS)).optional(),
|
|
473
|
+
motion: Motion.optional(),
|
|
335
474
|
});
|
|
336
475
|
|
|
337
476
|
export type StyleProps = z.infer<typeof StyleProps>;
|
|
338
477
|
|
|
339
478
|
/**
|
|
340
|
-
*
|
|
341
|
-
* the
|
|
342
|
-
*
|
|
479
|
+
* W-959 (1.1): Wide screen, 2400 px and up (Elementor's widescreen breakpoint). Its overrides sit
|
|
480
|
+
* in the element's or class's own `style` as `style.wide`, a key 1.0 keeps and ignores, so a 1.1
|
|
481
|
+
* page still opens in 1.0 and shows its Desktop look on wide screens. `hidden` overrides the
|
|
482
|
+
* Desktop hide on wide screens: true hides it there, false shows it; unset follows Desktop.
|
|
343
483
|
*/
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
484
|
+
export const WideStyle = StyleProps.extend({ hidden: z.boolean().optional() });
|
|
485
|
+
|
|
486
|
+
export type WideStyle = z.infer<typeof WideStyle>;
|
|
487
|
+
|
|
488
|
+
/** An element's or class's own `style`: the Desktop values plus the Wide screen ones. */
|
|
489
|
+
export const OwnStyle = StyleProps.extend({ wide: WideStyle.optional() });
|
|
490
|
+
|
|
491
|
+
export type OwnStyle = z.infer<typeof OwnStyle>;
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* The pre-1.0 flat style shape: `motion`'s parts as the top-level keys `entrance`, `scrollMotion`,
|
|
495
|
+
* `transition` and `iconAnimation` (W-925). The editor's style rows and the CSS sanitizer work on
|
|
496
|
+
* this shape; `flattenMotion` and `nestMotion` convert. It is never stored.
|
|
497
|
+
* Its keys are in the 0.x schema order (`transition` after `cursor`, `iconAnimation` after the
|
|
498
|
+
* other icon keys, then `scrollMotion` and `entrance`): a parsed style's CSS is written in that
|
|
499
|
+
* order, so keeping it keeps 0.x pages byte for byte.
|
|
500
|
+
*/
|
|
501
|
+
const FlatStyleShape = StyleProps.omit({ motion: true }).extend({
|
|
502
|
+
transition: Transition.optional(),
|
|
503
|
+
iconAnimation: IconAnimation.optional(),
|
|
504
|
+
scrollMotion: ScrollMotion.optional(),
|
|
505
|
+
entrance: Entrance.optional(),
|
|
506
|
+
loopMotion: LoopMotion.optional(),
|
|
349
507
|
});
|
|
508
|
+
const flatShape: Record<string, z.ZodType> = {};
|
|
509
|
+
for (const [key, schema] of Object.entries(StyleProps.omit({ motion: true }).shape)) {
|
|
510
|
+
flatShape[key] = schema;
|
|
511
|
+
if (key === "cursor") flatShape["transition"] = Transition.optional();
|
|
512
|
+
if (key === "iconShadow") {
|
|
513
|
+
flatShape["iconAnimation"] = IconAnimation.optional();
|
|
514
|
+
flatShape["scrollMotion"] = ScrollMotion.optional();
|
|
515
|
+
flatShape["entrance"] = Entrance.optional();
|
|
516
|
+
// W-938: added in 1.0, so after every 0.x key (0.x pages keep their CSS order).
|
|
517
|
+
flatShape["loopMotion"] = LoopMotion.optional();
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
export const FlatStyleProps = z.strictObject(flatShape) as unknown as typeof FlatStyleShape;
|
|
521
|
+
|
|
522
|
+
export type FlatStyleProps = z.infer<typeof FlatStyleProps>;
|
|
523
|
+
|
|
524
|
+
/** A style edit: flat motion keys (`undefined` clears), or a whole `motion` record. */
|
|
525
|
+
export type StylePatch = Partial<FlatStyleProps> & { motion?: Motion | undefined };
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* `states` on a node or class (D-032, W-089): hover, focus (`:focus-visible`) and active, each with
|
|
529
|
+
* the same keys and limits as `style` except `motion`. Unknown states are refused.
|
|
530
|
+
*/
|
|
531
|
+
const StateStyle = StyleProps.omit({ motion: true });
|
|
350
532
|
|
|
351
533
|
export const StyleStates = z.strictObject({
|
|
352
534
|
hover: StateStyle.optional(),
|
|
@@ -361,6 +543,8 @@ export type StyleStates = z.infer<typeof StyleStates>;
|
|
|
361
543
|
* are stored. A phone matches both media queries, so mobile wins over tablet for the same key.
|
|
362
544
|
*/
|
|
363
545
|
export const DeviceStyles = z.strictObject({
|
|
546
|
+
/** W-956: up to 1366 px; Tablet and Mobile win over it. */
|
|
547
|
+
laptop: StyleProps.optional(),
|
|
364
548
|
tablet: StyleProps.optional(),
|
|
365
549
|
mobile: StyleProps.optional(),
|
|
366
550
|
});
|
|
@@ -368,6 +552,6 @@ export const DeviceStyles = z.strictObject({
|
|
|
368
552
|
export type DeviceStyles = z.infer<typeof DeviceStyles>;
|
|
369
553
|
|
|
370
554
|
/** Devices on which the element is `display: none`. Empty means shown everywhere. */
|
|
371
|
-
export const HiddenOn = z.array(z.enum(
|
|
555
|
+
export const HiddenOn = z.array(z.enum(DEVICES)).max(4);
|
|
372
556
|
|
|
373
557
|
export type HiddenOn = z.infer<typeof HiddenOn>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { isRecord } from "./record.ts";
|
|
2
|
+
|
|
3
|
+
/** Props whose strings are words a visitor reads (W-978), not ids, URLs or settings. */
|
|
4
|
+
const WORD_KEYS: ReadonlySet<string> = new Set([
|
|
5
|
+
"text",
|
|
6
|
+
"label",
|
|
7
|
+
"summary",
|
|
8
|
+
"alt",
|
|
9
|
+
"caption",
|
|
10
|
+
"placeholder",
|
|
11
|
+
"title",
|
|
12
|
+
"description",
|
|
13
|
+
"items",
|
|
14
|
+
"quote",
|
|
15
|
+
"author",
|
|
16
|
+
"role",
|
|
17
|
+
"prefix",
|
|
18
|
+
"suffix",
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
/** At most this many characters per layout, so a huge page can't slow the list down. */
|
|
22
|
+
const MAX_SEARCH_TEXT = 20_000;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* W-978: the words of a stored layout (headings, text, buttons, list items, labels, alt text),
|
|
26
|
+
* for searching lists by content. Reads raw JSON (or a JSON string), so an unreadable layout
|
|
27
|
+
* gives "" rather than an error. Synced sections are read where they live, not here.
|
|
28
|
+
*/
|
|
29
|
+
export function layoutSearchText(layout: unknown): string {
|
|
30
|
+
let value = layout;
|
|
31
|
+
if (typeof value === "string") {
|
|
32
|
+
try {
|
|
33
|
+
value = JSON.parse(value) as unknown;
|
|
34
|
+
} catch {
|
|
35
|
+
return "";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (!isRecord(value)) return "";
|
|
39
|
+
const out: string[] = [];
|
|
40
|
+
let length = 0;
|
|
41
|
+
const push = (text: string) => {
|
|
42
|
+
if (length >= MAX_SEARCH_TEXT) return;
|
|
43
|
+
const trimmed = text.trim();
|
|
44
|
+
if (!trimmed) return;
|
|
45
|
+
out.push(trimmed);
|
|
46
|
+
length += trimmed.length + 1;
|
|
47
|
+
};
|
|
48
|
+
const stack: unknown[] = [value["root"]];
|
|
49
|
+
while (stack.length > 0) {
|
|
50
|
+
if (length >= MAX_SEARCH_TEXT) break;
|
|
51
|
+
const node = stack.pop();
|
|
52
|
+
if (!isRecord(node)) continue;
|
|
53
|
+
const props = node["props"];
|
|
54
|
+
if (isRecord(props)) {
|
|
55
|
+
for (const [key, prop] of Object.entries(props)) {
|
|
56
|
+
if (!WORD_KEYS.has(key)) continue;
|
|
57
|
+
if (typeof prop === "string") push(prop);
|
|
58
|
+
else if (Array.isArray(prop))
|
|
59
|
+
for (const item of prop) {
|
|
60
|
+
if (typeof item === "string") push(item);
|
|
61
|
+
else if (isRecord(item) && typeof item["label"] === "string") push(item["label"]);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const children = node["children"];
|
|
66
|
+
if (Array.isArray(children))
|
|
67
|
+
for (let i = children.length - 1; i >= 0; i -= 1) stack.push(children[i]);
|
|
68
|
+
}
|
|
69
|
+
return out.join(" ").slice(0, MAX_SEARCH_TEXT);
|
|
70
|
+
}
|