@elementor/editor-canvas 4.2.0-930 → 4.2.0-932
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/dist/index.d.mts +18 -7
- package/dist/index.d.ts +18 -7
- package/dist/index.js +243 -282
- package/dist/index.mjs +227 -266
- package/package.json +19 -18
- package/src/composition-builder/composition-builder.ts +2 -9
- package/src/index.ts +7 -1
- package/src/mcp/canvas-mcp.ts +3 -0
- package/src/mcp/mcp-description.ts +9 -13
- package/src/mcp/resources/widgets-schema-resource.ts +1 -41
- package/src/mcp/tools/build-composition/prompt.ts +12 -13
- package/src/mcp/tools/build-composition/schema.ts +5 -12
- package/src/mcp/tools/build-composition/tool.ts +25 -3
- package/src/mcp/tools/configure-element/prompt.ts +22 -44
- package/src/mcp/tools/configure-element/schema.ts +12 -6
- package/src/mcp/tools/configure-element/tool.ts +43 -38
- package/src/mcp/utils/__tests__/convert-css-to-atomic.test.ts +109 -0
- package/src/mcp/utils/__tests__/do-update-element-property.test.ts +39 -1
- package/src/mcp/utils/convert-css-to-atomic.ts +39 -0
- package/src/mcp/utils/do-update-element-property.ts +3 -0
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,6 @@ import { ResourceTemplate } from "@elementor/editor-mcp";
|
|
|
7
7
|
import {
|
|
8
8
|
Schema
|
|
9
9
|
} from "@elementor/editor-props";
|
|
10
|
-
import { getStylesSchema } from "@elementor/editor-styles";
|
|
11
10
|
|
|
12
11
|
// src/composition-builder/utils/required-default-child-tags.ts
|
|
13
12
|
function getRequiredDefaultChildTemplates(elementConfig) {
|
|
@@ -96,7 +95,6 @@ var CANVAS_SERVER_NAME = "editor-canvas";
|
|
|
96
95
|
var WIDGET_SCHEMA_URI = "elementor://widgets/schema/{widgetType}";
|
|
97
96
|
var WIDGET_SCHEMA_FULL_URI = `${CANVAS_SERVER_NAME}_${WIDGET_SCHEMA_URI}`;
|
|
98
97
|
var STYLE_SCHEMA_URI = "elementor://styles/schema/{category}";
|
|
99
|
-
var STYLE_SCHEMA_FULL_URI = `${CANVAS_SERVER_NAME}_${STYLE_SCHEMA_URI}`;
|
|
100
98
|
var BEST_PRACTICES_URI = "elementor://styles/best-practices";
|
|
101
99
|
var BEST_PRACTICES_FULL_URI = `${CANVAS_SERVER_NAME}_${BEST_PRACTICES_URI}`;
|
|
102
100
|
var initWidgetsSchemaResource = (reg) => {
|
|
@@ -116,8 +114,7 @@ var initWidgetsSchemaResource = (reg) => {
|
|
|
116
114
|
Prefer using "em" and "rem" values for text-related sizes, padding and spacing. Use percentages for dynamic sizing relative to parent containers.
|
|
117
115
|
This flexboxes are by default "flex" with "stretch" alignment. To ensure proper layout, define the "justify-content" and "align-items" as in the schema.
|
|
118
116
|
|
|
119
|
-
|
|
120
|
-
The css string must follow standard CSS syntax, with properties and values separated by semicolons, no selectors, or nesting rules allowed.
|
|
117
|
+
Styling is provided as raw CSS. The css string must follow standard CSS syntax, with properties and values separated by semicolons, no selectors, or nesting rules allowed.
|
|
121
118
|
|
|
122
119
|
** CRITICAL - VARIABLES **
|
|
123
120
|
When using global variables, ensure that the variables are defined in the ${"elementor://global-variables"} resource.
|
|
@@ -129,42 +126,6 @@ Variables from the user context ARE NOT SUPPORTED AND WILL RESOLVE IN ERROR.
|
|
|
129
126
|
};
|
|
130
127
|
}
|
|
131
128
|
);
|
|
132
|
-
resource(
|
|
133
|
-
"styles-schema",
|
|
134
|
-
new ResourceTemplate(STYLE_SCHEMA_URI, {
|
|
135
|
-
list: () => {
|
|
136
|
-
const categories = [...Object.keys(getStylesSchema())].filter((category) => category !== "all");
|
|
137
|
-
return {
|
|
138
|
-
resources: categories.map((category) => ({
|
|
139
|
-
uri: `elementor://styles/schema/${category}`,
|
|
140
|
-
name: "Style schema for " + category
|
|
141
|
-
}))
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
}),
|
|
145
|
-
{
|
|
146
|
-
description: "Common styles schema for the specified category (applicable for V4 elements only)"
|
|
147
|
-
},
|
|
148
|
-
async (uri, variables) => {
|
|
149
|
-
const category = typeof variables.category === "string" ? variables.category : variables.category?.[0];
|
|
150
|
-
const stylesSchema = getStylesSchema()[category];
|
|
151
|
-
if (!stylesSchema) {
|
|
152
|
-
throw new Error(`No styles schema found for category: ${category}`);
|
|
153
|
-
}
|
|
154
|
-
const asJson = Schema.propTypeToJsonSchema(stylesSchema);
|
|
155
|
-
return {
|
|
156
|
-
contents: [
|
|
157
|
-
{
|
|
158
|
-
uri: uri.toString(),
|
|
159
|
-
mimeType: "application/json",
|
|
160
|
-
text: JSON.stringify(
|
|
161
|
-
Schema.enrichWithIntention(asJson, 'Desired CSS in format "property: value;"')
|
|
162
|
-
)
|
|
163
|
-
}
|
|
164
|
-
]
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
);
|
|
168
129
|
resource(
|
|
169
130
|
"widget-schema-by-type",
|
|
170
131
|
new ResourceTemplate(WIDGET_SCHEMA_URI, {
|
|
@@ -309,6 +270,23 @@ var initBreakpointsResource = (reg) => {
|
|
|
309
270
|
});
|
|
310
271
|
};
|
|
311
272
|
|
|
273
|
+
// src/mcp/utils/convert-css-to-atomic.ts
|
|
274
|
+
import { httpService } from "@elementor/http-client";
|
|
275
|
+
var CSS_TO_ATOMIC_URL = "elementor/v1/css-to-atomic";
|
|
276
|
+
var SINGLE_BLOCK_KEY = "default";
|
|
277
|
+
var convertBlocks = async (blocks) => {
|
|
278
|
+
const { data } = await httpService().post(
|
|
279
|
+
CSS_TO_ATOMIC_URL,
|
|
280
|
+
{ blocks }
|
|
281
|
+
);
|
|
282
|
+
return data.data;
|
|
283
|
+
};
|
|
284
|
+
var convertStyleBlocksToAtomic = async (styleByName) => convertBlocks(styleByName);
|
|
285
|
+
var convertCssToAtomic = async (style) => {
|
|
286
|
+
const results = await convertStyleBlocksToAtomic({ [SINGLE_BLOCK_KEY]: style });
|
|
287
|
+
return results[SINGLE_BLOCK_KEY];
|
|
288
|
+
};
|
|
289
|
+
|
|
312
290
|
// src/init.tsx
|
|
313
291
|
import { injectIntoLogic, injectIntoTop } from "@elementor/editor";
|
|
314
292
|
import { getMCPByDomain } from "@elementor/editor-mcp";
|
|
@@ -1345,7 +1323,7 @@ function signalizedProcess(signal, steps = []) {
|
|
|
1345
1323
|
|
|
1346
1324
|
// src/hooks/use-style-prop-resolver.ts
|
|
1347
1325
|
import { useMemo as useMemo3 } from "react";
|
|
1348
|
-
import { getStylesSchema
|
|
1326
|
+
import { getStylesSchema } from "@elementor/editor-styles";
|
|
1349
1327
|
import { enqueueFont } from "@elementor/editor-v1-adapters";
|
|
1350
1328
|
|
|
1351
1329
|
// src/renderers/create-props-resolver.ts
|
|
@@ -1477,7 +1455,7 @@ function useStylePropResolver() {
|
|
|
1477
1455
|
return useMemo3(() => {
|
|
1478
1456
|
return createPropsResolver({
|
|
1479
1457
|
transformers: styleTransformersRegistry,
|
|
1480
|
-
schema:
|
|
1458
|
+
schema: getStylesSchema(),
|
|
1481
1459
|
onPropResolve: ({ key, value }) => {
|
|
1482
1460
|
if (key !== "font-family" || typeof value !== "string") {
|
|
1483
1461
|
return;
|
|
@@ -4579,7 +4557,7 @@ import {
|
|
|
4579
4557
|
createElement as createElement13,
|
|
4580
4558
|
deleteElement as deleteElement2,
|
|
4581
4559
|
getContainer as getContainer5,
|
|
4582
|
-
getWidgetsCache as
|
|
4560
|
+
getWidgetsCache as getWidgetsCache8
|
|
4583
4561
|
} from "@elementor/editor-elements";
|
|
4584
4562
|
|
|
4585
4563
|
// src/composition-builder/composition-builder.ts
|
|
@@ -4588,7 +4566,7 @@ import {
|
|
|
4588
4566
|
deleteElement,
|
|
4589
4567
|
generateElementId as generateElementId2,
|
|
4590
4568
|
getContainer as getContainer4,
|
|
4591
|
-
getWidgetsCache as
|
|
4569
|
+
getWidgetsCache as getWidgetsCache7
|
|
4592
4570
|
} from "@elementor/editor-elements";
|
|
4593
4571
|
|
|
4594
4572
|
// src/mcp/utils/do-update-element-property.ts
|
|
@@ -4600,7 +4578,7 @@ import {
|
|
|
4600
4578
|
updateElementStyle
|
|
4601
4579
|
} from "@elementor/editor-elements";
|
|
4602
4580
|
import { getPropSchemaFromCache, Schema as Schema3 } from "@elementor/editor-props";
|
|
4603
|
-
import { getStylesSchema as
|
|
4581
|
+
import { getStylesSchema as getStylesSchema2, getVariantByMeta } from "@elementor/editor-styles";
|
|
4604
4582
|
import { __privateRunCommandSync as runCommandSync2 } from "@elementor/editor-v1-adapters";
|
|
4605
4583
|
|
|
4606
4584
|
// src/mcp/utils/merge-custom-css.ts
|
|
@@ -4637,7 +4615,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
4637
4615
|
if (propertyName === "_styles") {
|
|
4638
4616
|
const elementStyles = getElementStyles(elementId) || {};
|
|
4639
4617
|
const propertyMapValue = propertyValue;
|
|
4640
|
-
const styleSchema =
|
|
4618
|
+
const styleSchema = getStylesSchema2();
|
|
4641
4619
|
const transformedStyleValues = Object.fromEntries(
|
|
4642
4620
|
Object.entries(propertyMapValue).map(([key, val]) => {
|
|
4643
4621
|
if (key === "custom_css") {
|
|
@@ -4647,6 +4625,9 @@ var doUpdateElementProperty = (params) => {
|
|
|
4647
4625
|
if (!propKey2 && kind !== "union") {
|
|
4648
4626
|
throw new Error(`_styles property ${key} is not supported.`);
|
|
4649
4627
|
}
|
|
4628
|
+
if (val === null) {
|
|
4629
|
+
return [key, null];
|
|
4630
|
+
}
|
|
4650
4631
|
return [key, resolvePropValue(val, propKey2)];
|
|
4651
4632
|
})
|
|
4652
4633
|
);
|
|
@@ -4751,91 +4732,6 @@ Expected Schema: ${jsonSchema}`
|
|
|
4751
4732
|
runCommandSync2("document/save/set-is-modified", { status: true }, { internal: true });
|
|
4752
4733
|
};
|
|
4753
4734
|
|
|
4754
|
-
// src/mcp/utils/validate-input.ts
|
|
4755
|
-
import { getWidgetsCache as getWidgetsCache7 } from "@elementor/editor-elements";
|
|
4756
|
-
import { Schema as Schema4 } from "@elementor/editor-props";
|
|
4757
|
-
import { getStylesSchema as getStylesSchema4 } from "@elementor/editor-styles";
|
|
4758
|
-
var _widgetsSchema = null;
|
|
4759
|
-
var validateInput = {
|
|
4760
|
-
get widgetsSchema() {
|
|
4761
|
-
if (!_widgetsSchema) {
|
|
4762
|
-
const schema2 = {};
|
|
4763
|
-
const cache = getWidgetsCache7();
|
|
4764
|
-
if (!cache) {
|
|
4765
|
-
return {};
|
|
4766
|
-
}
|
|
4767
|
-
Object.entries(cache).forEach(([widgetType, widgetData]) => {
|
|
4768
|
-
if (widgetData.atomic_props_schema) {
|
|
4769
|
-
schema2[widgetType] = structuredClone(widgetData.atomic_props_schema);
|
|
4770
|
-
}
|
|
4771
|
-
});
|
|
4772
|
-
_widgetsSchema = schema2;
|
|
4773
|
-
}
|
|
4774
|
-
return _widgetsSchema;
|
|
4775
|
-
},
|
|
4776
|
-
validateProps(schema2, values, ignore = []) {
|
|
4777
|
-
if (!schema2) {
|
|
4778
|
-
throw new Error("No schema provided for validation.");
|
|
4779
|
-
}
|
|
4780
|
-
const errors = [];
|
|
4781
|
-
let hasInvalidKey = false;
|
|
4782
|
-
Object.entries(values).forEach(([propName, propValue]) => {
|
|
4783
|
-
if (ignore.includes(propName)) {
|
|
4784
|
-
return;
|
|
4785
|
-
}
|
|
4786
|
-
const propSchema = schema2[propName];
|
|
4787
|
-
if (!propSchema) {
|
|
4788
|
-
errors.push(`Property "${propName}" is not defined in the schema.`);
|
|
4789
|
-
hasInvalidKey = true;
|
|
4790
|
-
} else if (!Schema4.isPropKeyConfigurable(propName, propSchema)) {
|
|
4791
|
-
errors.push(`Property "${propName}" is not configurable.`);
|
|
4792
|
-
} else {
|
|
4793
|
-
const { valid } = Schema4.validatePropValue(propSchema, propValue);
|
|
4794
|
-
if (!valid) {
|
|
4795
|
-
errors.push(
|
|
4796
|
-
`Invalid property "${propName}". Validate input with resource [${STYLE_SCHEMA_URI.replace(
|
|
4797
|
-
"{category}",
|
|
4798
|
-
propName
|
|
4799
|
-
)}]`
|
|
4800
|
-
);
|
|
4801
|
-
}
|
|
4802
|
-
}
|
|
4803
|
-
});
|
|
4804
|
-
if (hasInvalidKey) {
|
|
4805
|
-
errors.push("Available properties: " + Object.keys(schema2).join(", "));
|
|
4806
|
-
}
|
|
4807
|
-
return {
|
|
4808
|
-
errors,
|
|
4809
|
-
valid: errors.length === 0
|
|
4810
|
-
};
|
|
4811
|
-
},
|
|
4812
|
-
validateStyles(values) {
|
|
4813
|
-
const styleSchema = getStylesSchema4();
|
|
4814
|
-
const customCssValue = values.custom_css;
|
|
4815
|
-
const result = this.validateProps(styleSchema, values, ["custom_css", "$intention"]);
|
|
4816
|
-
const appendInvalidCustomCssErr = () => {
|
|
4817
|
-
result.valid = false;
|
|
4818
|
-
result.errors = result.errors || [];
|
|
4819
|
-
result.errors.push('Invalid property "custom_css". Expected a string value.');
|
|
4820
|
-
};
|
|
4821
|
-
if (customCssValue && typeof customCssValue === "object") {
|
|
4822
|
-
if (typeof customCssValue.value !== "string") {
|
|
4823
|
-
appendInvalidCustomCssErr();
|
|
4824
|
-
}
|
|
4825
|
-
} else if (typeof customCssValue !== "string" && typeof customCssValue !== "undefined" && customCssValue !== null) {
|
|
4826
|
-
appendInvalidCustomCssErr();
|
|
4827
|
-
}
|
|
4828
|
-
return result;
|
|
4829
|
-
},
|
|
4830
|
-
validatePropSchema(widgetType, values, ignore = []) {
|
|
4831
|
-
const schema2 = this.widgetsSchema[widgetType];
|
|
4832
|
-
if (!schema2) {
|
|
4833
|
-
return { valid: false, errors: [`No schema found for widget type "${widgetType}".`] };
|
|
4834
|
-
}
|
|
4835
|
-
return this.validateProps(schema2, values, ignore);
|
|
4836
|
-
}
|
|
4837
|
-
};
|
|
4838
|
-
|
|
4839
4735
|
// src/composition-builder/utils/required-children-enforcer.ts
|
|
4840
4736
|
var REQUIRED_CHILD_SCHEMA_HINT = "Use the widget schema resource; under llm_guidance.required_direct_children for V4 widgets.";
|
|
4841
4737
|
var RequiredChildrenEnforcer = class {
|
|
@@ -4886,7 +4782,7 @@ var CompositionBuilder = class _CompositionBuilder {
|
|
|
4886
4782
|
api = {
|
|
4887
4783
|
createElement: createElement12,
|
|
4888
4784
|
deleteElement,
|
|
4889
|
-
getWidgetsCache:
|
|
4785
|
+
getWidgetsCache: getWidgetsCache7,
|
|
4890
4786
|
generateElementId: generateElementId2,
|
|
4891
4787
|
getContainer: getContainer4,
|
|
4892
4788
|
doUpdateElementProperty
|
|
@@ -5025,19 +4921,12 @@ var CompositionBuilder = class _CompositionBuilder {
|
|
|
5025
4921
|
}
|
|
5026
4922
|
}
|
|
5027
4923
|
const styleConfig = this.elementStylesConfig[configId];
|
|
5028
|
-
|
|
4924
|
+
const hasInvalidStyles = false;
|
|
5029
4925
|
if (styleConfig) {
|
|
5030
4926
|
const validStylesPropValues = {};
|
|
5031
4927
|
for (const [styleName, stylePropValue] of Object.entries(styleConfig)) {
|
|
5032
4928
|
if (styleName === "$intention") {
|
|
5033
4929
|
continue;
|
|
5034
|
-
}
|
|
5035
|
-
const { valid, errors: validationErrors } = validateInput.validateStyles({
|
|
5036
|
-
[styleName]: stylePropValue
|
|
5037
|
-
});
|
|
5038
|
-
if (!valid) {
|
|
5039
|
-
hasInvalidStyles = true;
|
|
5040
|
-
styleErrors.push(...validationErrors || []);
|
|
5041
4930
|
} else {
|
|
5042
4931
|
validStylesPropValues[styleName] = stylePropValue;
|
|
5043
4932
|
}
|
|
@@ -5151,7 +5040,7 @@ var generatePrompt = () => {
|
|
|
5151
5040
|
This tool support v4 elements only
|
|
5152
5041
|
|
|
5153
5042
|
# WORKFLOW
|
|
5154
|
-
1. Check/create global classes via "
|
|
5043
|
+
1. Check/create global classes via "manage-global-classes" tool
|
|
5155
5044
|
2. Build composition (THIS TOOL) - minimal inline styles
|
|
5156
5045
|
3. Apply classes via "apply-global-class" tool
|
|
5157
5046
|
|
|
@@ -5169,8 +5058,9 @@ Some elements have internal tree structures (nesting). When using these elements
|
|
|
5169
5058
|
- \`allowed_parents\` lists which element types this element can be placed inside
|
|
5170
5059
|
|
|
5171
5060
|
# CONFIGURATION
|
|
5172
|
-
- Map configuration-id \u2192 elementConfig (props) +
|
|
5173
|
-
-
|
|
5061
|
+
- Map configuration-id \u2192 elementConfig (props) + style (raw CSS declarations)
|
|
5062
|
+
- elementConfig PropValues require \`$$type\` matching schema
|
|
5063
|
+
- style is raw CSS (property \u2192 value strings); the server converts it to native styles and stores any unconvertible declarations as the element custom CSS
|
|
5174
5064
|
- NO LINKS in configuration
|
|
5175
5065
|
- Retry on errors up to 10x
|
|
5176
5066
|
|
|
@@ -5256,8 +5146,7 @@ BAD: \`<e-flexbox style="height:100vh"><e-div-block style="height:100vh">overflo
|
|
|
5256
5146
|
# PARAMETERS
|
|
5257
5147
|
- **xmlStructure**: Valid XML with configuration-id attributes
|
|
5258
5148
|
- **elementConfig**: configuration-id \u2192 widget PropValues
|
|
5259
|
-
- **
|
|
5260
|
-
- **customCSS**: configuration-id \u2192 CSS rules (no selectors, semicolon-separated)
|
|
5149
|
+
- **style**: configuration-id \u2192 raw CSS declarations (property \u2192 value strings; no selectors)
|
|
5261
5150
|
`);
|
|
5262
5151
|
buildCompositionsToolPrompt.example(`
|
|
5263
5152
|
Section with heading + button (NO explicit heights - content sizes naturally):
|
|
@@ -5266,13 +5155,12 @@ Section with heading + button (NO explicit heights - content sizes naturally):
|
|
|
5266
5155
|
elementConfig: {
|
|
5267
5156
|
"section1": { "tag": { "$$type": "string", "value": "section" } }
|
|
5268
5157
|
},
|
|
5269
|
-
|
|
5270
|
-
"Section Title": "padding: 6rem 4rem; background: linear-gradient(135deg, #faf8f5 0%, #f0ebe4 100%);"
|
|
5271
|
-
},
|
|
5272
|
-
stylesConfig: {
|
|
5158
|
+
style: {
|
|
5273
5159
|
"Section Title": {
|
|
5274
|
-
"
|
|
5275
|
-
"
|
|
5160
|
+
"padding": "6rem 4rem",
|
|
5161
|
+
"background": "linear-gradient(135deg, #faf8f5 0%, #f0ebe4 100%)",
|
|
5162
|
+
"font-size": "3.5rem",
|
|
5163
|
+
"color": "#2d2a26"
|
|
5276
5164
|
}
|
|
5277
5165
|
}
|
|
5278
5166
|
}
|
|
@@ -5284,8 +5172,8 @@ Note: No height/width specified on any element - flexbox handles layout automati
|
|
|
5284
5172
|
);
|
|
5285
5173
|
buildCompositionsToolPrompt.parameter("elementConfig", `Record mapping configuration IDs to widget PropValues.`);
|
|
5286
5174
|
buildCompositionsToolPrompt.parameter(
|
|
5287
|
-
"
|
|
5288
|
-
`Record mapping configuration IDs to
|
|
5175
|
+
"style",
|
|
5176
|
+
`Record mapping configuration IDs to raw CSS declarations (property \u2192 value strings).`
|
|
5289
5177
|
);
|
|
5290
5178
|
buildCompositionsToolPrompt.instruction(
|
|
5291
5179
|
`Element IDs in the returned XML represent actual widgets. Use these IDs for subsequent styling or configuration changes.`
|
|
@@ -5304,19 +5192,15 @@ var inputSchema = {
|
|
|
5304
5192
|
z.any().describe(`The PropValue for the property, refer to ${WIDGET_SCHEMA_URI}`)
|
|
5305
5193
|
)
|
|
5306
5194
|
).describe("A record mapping element IDs to their configuration objects. REQUIRED"),
|
|
5307
|
-
|
|
5195
|
+
style: z.record(
|
|
5308
5196
|
z.string().describe("The configuration id"),
|
|
5309
5197
|
z.record(
|
|
5310
|
-
z.string().describe(
|
|
5311
|
-
z.
|
|
5198
|
+
z.string().describe('A CSS property name, e.g. "color", "padding".'),
|
|
5199
|
+
z.string().describe('A CSS value, e.g. "6rem 4rem", "#2d2a26".')
|
|
5312
5200
|
)
|
|
5313
5201
|
).describe(
|
|
5314
|
-
|
|
5315
|
-
).default({})
|
|
5316
|
-
customCSS: z.record(
|
|
5317
|
-
z.string().describe("The configuration id"),
|
|
5318
|
-
z.string().describe("The custom CSS for the element. MANDATORY")
|
|
5319
|
-
).describe("A record mapping element IDs to their custom CSS.").default({})
|
|
5202
|
+
"A record mapping element configuration IDs to their raw CSS declarations (property\u2192value). Converted to native styles server-side; any declaration that cannot be converted is stored as the element custom CSS."
|
|
5203
|
+
).default({})
|
|
5320
5204
|
};
|
|
5321
5205
|
var outputSchema = {
|
|
5322
5206
|
errors: z.string().describe("Error message if the composition building failed").optional(),
|
|
@@ -5398,7 +5282,6 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
5398
5282
|
requiredResources: [
|
|
5399
5283
|
{ description: "Build compositions guide", uri: BUILD_COMPOSITIONS_GUIDE_URI },
|
|
5400
5284
|
{ description: "Widgets schema", uri: WIDGET_SCHEMA_URI },
|
|
5401
|
-
{ description: "Styles schema", uri: STYLE_SCHEMA_URI },
|
|
5402
5285
|
{ description: "Global Classes", uri: "elementor://global-classes" },
|
|
5403
5286
|
{ description: "Global Variables", uri: "elementor://global-variables" },
|
|
5404
5287
|
{ description: "Styles best practices", uri: BEST_PRACTICES_URI },
|
|
@@ -5408,9 +5291,11 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
5408
5291
|
outputSchema,
|
|
5409
5292
|
handler: async (rawParams) => {
|
|
5410
5293
|
assertCompositionXmlUsesV4WidgetsOnly(rawParams.xmlStructure);
|
|
5411
|
-
const {
|
|
5294
|
+
const { stylesConfig: convertedStyles, customCSS } = await convertCompositionStyles(rawParams.style);
|
|
5295
|
+
const { xmlStructure, elementConfig, stylesConfig } = adaptLeafRootParams({
|
|
5412
5296
|
...rawParams,
|
|
5413
|
-
|
|
5297
|
+
stylesConfig: convertedStyles,
|
|
5298
|
+
widgetsCache: getWidgetsCache8() ?? {}
|
|
5414
5299
|
});
|
|
5415
5300
|
let generatedXML = "";
|
|
5416
5301
|
const errors = [];
|
|
@@ -5422,7 +5307,7 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
5422
5307
|
const compositionBuilder = CompositionBuilder.fromXMLString(xmlStructure, {
|
|
5423
5308
|
createElement: createElement13,
|
|
5424
5309
|
deleteElement: deleteElement2,
|
|
5425
|
-
getWidgetsCache:
|
|
5310
|
+
getWidgetsCache: getWidgetsCache8
|
|
5426
5311
|
});
|
|
5427
5312
|
compositionBuilder.setElementConfig(elementConfig);
|
|
5428
5313
|
compositionBuilder.setStylesConfig(stylesConfig);
|
|
@@ -5487,12 +5372,27 @@ Remember: Global classes ensure design consistency and reusability. Don't skip a
|
|
|
5487
5372
|
}
|
|
5488
5373
|
});
|
|
5489
5374
|
};
|
|
5375
|
+
async function convertCompositionStyles(style) {
|
|
5376
|
+
const stylesConfig = {};
|
|
5377
|
+
const customCSS = {};
|
|
5378
|
+
if (!style || Object.keys(style).length === 0) {
|
|
5379
|
+
return { stylesConfig, customCSS };
|
|
5380
|
+
}
|
|
5381
|
+
const results = await convertStyleBlocksToAtomic(style);
|
|
5382
|
+
for (const [configId, { props, customCss }] of Object.entries(results)) {
|
|
5383
|
+
stylesConfig[configId] = props;
|
|
5384
|
+
if (customCss) {
|
|
5385
|
+
customCSS[configId] = customCss;
|
|
5386
|
+
}
|
|
5387
|
+
}
|
|
5388
|
+
return { stylesConfig, customCSS };
|
|
5389
|
+
}
|
|
5490
5390
|
function assertCompositionXmlUsesV4WidgetsOnly(xmlStructure) {
|
|
5491
5391
|
const doc = new DOMParser().parseFromString(xmlStructure, "application/xml");
|
|
5492
5392
|
if (doc.querySelector("parsererror")) {
|
|
5493
5393
|
throw new Error("Failed to parse XML string: " + doc);
|
|
5494
5394
|
}
|
|
5495
|
-
const widgetsCache =
|
|
5395
|
+
const widgetsCache = getWidgetsCache8() ?? {};
|
|
5496
5396
|
for (const node of doc.querySelectorAll("*")) {
|
|
5497
5397
|
const type = node.tagName;
|
|
5498
5398
|
const widgetData = widgetsCache[type];
|
|
@@ -5511,6 +5411,91 @@ function assertCompositionXmlUsesV4WidgetsOnly(xmlStructure) {
|
|
|
5511
5411
|
// src/mcp/tools/configure-element/tool.ts
|
|
5512
5412
|
import { getWidgetsCache as getWidgetsCache10 } from "@elementor/editor-elements";
|
|
5513
5413
|
|
|
5414
|
+
// src/mcp/utils/validate-input.ts
|
|
5415
|
+
import { getWidgetsCache as getWidgetsCache9 } from "@elementor/editor-elements";
|
|
5416
|
+
import { Schema as Schema4 } from "@elementor/editor-props";
|
|
5417
|
+
import { getStylesSchema as getStylesSchema3 } from "@elementor/editor-styles";
|
|
5418
|
+
var _widgetsSchema = null;
|
|
5419
|
+
var validateInput = {
|
|
5420
|
+
get widgetsSchema() {
|
|
5421
|
+
if (!_widgetsSchema) {
|
|
5422
|
+
const schema2 = {};
|
|
5423
|
+
const cache = getWidgetsCache9();
|
|
5424
|
+
if (!cache) {
|
|
5425
|
+
return {};
|
|
5426
|
+
}
|
|
5427
|
+
Object.entries(cache).forEach(([widgetType, widgetData]) => {
|
|
5428
|
+
if (widgetData.atomic_props_schema) {
|
|
5429
|
+
schema2[widgetType] = structuredClone(widgetData.atomic_props_schema);
|
|
5430
|
+
}
|
|
5431
|
+
});
|
|
5432
|
+
_widgetsSchema = schema2;
|
|
5433
|
+
}
|
|
5434
|
+
return _widgetsSchema;
|
|
5435
|
+
},
|
|
5436
|
+
validateProps(schema2, values, ignore = []) {
|
|
5437
|
+
if (!schema2) {
|
|
5438
|
+
throw new Error("No schema provided for validation.");
|
|
5439
|
+
}
|
|
5440
|
+
const errors = [];
|
|
5441
|
+
let hasInvalidKey = false;
|
|
5442
|
+
Object.entries(values).forEach(([propName, propValue]) => {
|
|
5443
|
+
if (ignore.includes(propName)) {
|
|
5444
|
+
return;
|
|
5445
|
+
}
|
|
5446
|
+
const propSchema = schema2[propName];
|
|
5447
|
+
if (!propSchema) {
|
|
5448
|
+
errors.push(`Property "${propName}" is not defined in the schema.`);
|
|
5449
|
+
hasInvalidKey = true;
|
|
5450
|
+
} else if (!Schema4.isPropKeyConfigurable(propName, propSchema)) {
|
|
5451
|
+
errors.push(`Property "${propName}" is not configurable.`);
|
|
5452
|
+
} else {
|
|
5453
|
+
const { valid } = Schema4.validatePropValue(propSchema, propValue);
|
|
5454
|
+
if (!valid) {
|
|
5455
|
+
errors.push(
|
|
5456
|
+
`Invalid property "${propName}". Validate input with resource [${STYLE_SCHEMA_URI.replace(
|
|
5457
|
+
"{category}",
|
|
5458
|
+
propName
|
|
5459
|
+
)}]`
|
|
5460
|
+
);
|
|
5461
|
+
}
|
|
5462
|
+
}
|
|
5463
|
+
});
|
|
5464
|
+
if (hasInvalidKey) {
|
|
5465
|
+
errors.push("Available properties: " + Object.keys(schema2).join(", "));
|
|
5466
|
+
}
|
|
5467
|
+
return {
|
|
5468
|
+
errors,
|
|
5469
|
+
valid: errors.length === 0
|
|
5470
|
+
};
|
|
5471
|
+
},
|
|
5472
|
+
validateStyles(values) {
|
|
5473
|
+
const styleSchema = getStylesSchema3();
|
|
5474
|
+
const customCssValue = values.custom_css;
|
|
5475
|
+
const result = this.validateProps(styleSchema, values, ["custom_css", "$intention"]);
|
|
5476
|
+
const appendInvalidCustomCssErr = () => {
|
|
5477
|
+
result.valid = false;
|
|
5478
|
+
result.errors = result.errors || [];
|
|
5479
|
+
result.errors.push('Invalid property "custom_css". Expected a string value.');
|
|
5480
|
+
};
|
|
5481
|
+
if (customCssValue && typeof customCssValue === "object") {
|
|
5482
|
+
if (typeof customCssValue.value !== "string") {
|
|
5483
|
+
appendInvalidCustomCssErr();
|
|
5484
|
+
}
|
|
5485
|
+
} else if (typeof customCssValue !== "string" && typeof customCssValue !== "undefined" && customCssValue !== null) {
|
|
5486
|
+
appendInvalidCustomCssErr();
|
|
5487
|
+
}
|
|
5488
|
+
return result;
|
|
5489
|
+
},
|
|
5490
|
+
validatePropSchema(widgetType, values, ignore = []) {
|
|
5491
|
+
const schema2 = this.widgetsSchema[widgetType];
|
|
5492
|
+
if (!schema2) {
|
|
5493
|
+
return { valid: false, errors: [`No schema found for widget type "${widgetType}".`] };
|
|
5494
|
+
}
|
|
5495
|
+
return this.validateProps(schema2, values, ignore);
|
|
5496
|
+
}
|
|
5497
|
+
};
|
|
5498
|
+
|
|
5514
5499
|
// src/mcp/tools/configure-element/prompt.ts
|
|
5515
5500
|
import { toolPrompts as toolPrompts2 } from "@elementor/editor-mcp";
|
|
5516
5501
|
var CONFIGURE_ELEMENT_GUIDE_URI = "elementor://canvas/tools/configure-element-guide";
|
|
@@ -5520,54 +5505,43 @@ var generatePrompt2 = () => {
|
|
|
5520
5505
|
Configure an existing element on the page.
|
|
5521
5506
|
|
|
5522
5507
|
# **CRITICAL - REQUIRED INFORMATION (Must read before using this tool)**
|
|
5523
|
-
1. [${WIDGET_SCHEMA_URI}]
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
3. If not sure about the PropValues schema, you can use the "get-element-configuration-values" tool to retrieve the current PropValues configuration of the element.
|
|
5530
|
-
|
|
5531
|
-
Before using this tool, check the definitions of the elements PropTypes at the resource "widget-schema-by-type" at editor-canvas__elementor://widgets/schema/{widgetType}
|
|
5532
|
-
All widgets share a common _style property for styling, which uses the common styles schema.
|
|
5533
|
-
Retrieve and check the common styles schema at the resource list "styles-schema" at editor-canvas__elementor://styles/schema/{category}
|
|
5508
|
+
1. [${WIDGET_SCHEMA_URI}] \u2014 **Widget properties** (\`propertiesToChange\`): each widgetType (e.g. e-heading, e-button) has its own PropType schema; values must be PropValues with \`$$type\`.
|
|
5509
|
+
2. [elementor://global-variables] \u2014 **Design tokens for styling**: use labels in CSS as \`var(--label)\` or \`var(--label, fallback)\`; only variables listed here are valid.
|
|
5510
|
+
3. **Styling** (\`style\` parameter): flat map of CSS property \u2192 value strings \u2014 **not** PropValues. The server converts to native styles; unconvertible declarations become custom CSS.
|
|
5511
|
+
4. **Current state**: \`get-element-configuration-values\` returns \`properties\` as PropValues and \`style\` in stored form; when writing, send raw CSS in \`style\`, not copied PropValues.
|
|
5512
|
+
|
|
5513
|
+
Before using this tool, read the widget PropType schema at editor-canvas__elementor://widgets/schema/{widgetType}
|
|
5534
5514
|
|
|
5535
5515
|
# When to use this tool
|
|
5536
5516
|
When a user requires to change anything in an element, such as updating text, colors, sizes, or other configurable properties.
|
|
5537
5517
|
This tool handles elements of type "widget".
|
|
5538
|
-
This tool handles styling elements, using the "
|
|
5518
|
+
This tool handles styling elements, using the "style" parameter (raw CSS as a property \u2192 value map).
|
|
5539
5519
|
|
|
5540
|
-
To CLEAR a property (i.e., set it to default or none), provide null as a value
|
|
5520
|
+
To CLEAR a property (i.e., set it to default or none), provide null as a value - example: \`background-color: null\`.
|
|
5541
5521
|
|
|
5542
5522
|
The element's schema must be known before using this tool.
|
|
5543
|
-
The style schema must be known before using this tool.
|
|
5544
|
-
|
|
5545
|
-
Attached resource link describing how PropType schema should be parsed as PropValue for this tool.
|
|
5546
5523
|
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
PropValue structure:
|
|
5524
|
+
**PropValue structure (for \`propertiesToChange\` only \u2014 not for \`style\`):**
|
|
5550
5525
|
{
|
|
5551
5526
|
"$$type": string, // MANDATORY as defined in the PropType schema under the "key" property
|
|
5552
5527
|
value: unknown // The value according to the PropType schema for kinds of "array", use array with PropValues items inside. For "object", read the shape property of the PropType schema. For "plain", use strings.
|
|
5553
5528
|
}
|
|
5554
5529
|
|
|
5555
5530
|
<IMPORTANT>
|
|
5556
|
-
ALWAYS MAKE SURE you have the PropType schemas for the element you are configuring
|
|
5531
|
+
ALWAYS MAKE SURE you have the PropType schemas for the element you are configuring. If you are not sure, retrieve the schema from the resources mentioned above.
|
|
5557
5532
|
</IMPORTANT>
|
|
5558
5533
|
|
|
5559
|
-
You can use multiple property changes at once by providing multiple entries in the propertiesToChange object
|
|
5534
|
+
You can use multiple property changes at once by providing multiple entries in the propertiesToChange object.
|
|
5560
5535
|
Some properties are nested, use the root property name, then objects with nested values inside, as the complete schema suggests.
|
|
5561
5536
|
|
|
5562
5537
|
Make sure you have the "widget-schema-by-type" resource available to retrieve the PropType schema for the element type you are configuring.
|
|
5563
|
-
Make sure you have the "styles-schema" resources available to retrieve the common styles schema.
|
|
5564
5538
|
|
|
5565
5539
|
# How to configure elements
|
|
5566
|
-
We use a dedicated PropType Schema for configuring
|
|
5567
|
-
For
|
|
5568
|
-
For all non-primitive
|
|
5540
|
+
We use a dedicated PropType Schema for configuring element properties (propertiesToChange). When you configure an element property, you must use the EXACT PropType Value as defined in the schema.
|
|
5541
|
+
For styling, use the "style" parameter with raw CSS declarations (property \u2192 value strings) - e.g. \`color: var(--primary-text, #000); height: 4rem;\`;
|
|
5542
|
+
For all non-primitive entries in \`propertiesToChange\`, provide the schema \`key\` as \`$$type\` in the generated object, as it is MANDATORY for parsing.
|
|
5569
5543
|
|
|
5570
|
-
Use the EXACT
|
|
5544
|
+
Use the EXACT PropType schema given, and ALWAYS include the \`key\` from the schema for every property you are changing in \`propertiesToChange\`.
|
|
5571
5545
|
|
|
5572
5546
|
# Dynamic tags
|
|
5573
5547
|
A value can be made dynamic wherever its schema exposes a variant with "$$type": "dynamic". This may be the property root OR a NESTED field: for example an image is made dynamic on its "src" (the root stays "image"), NOT on the whole "image" value.
|
|
@@ -5594,8 +5568,8 @@ Do NOT send "group" (it is resolved automatically). Use { "settings": {} } only
|
|
|
5594
5568
|
"An object containing the properties to change, with their new values. MANDATORY. When updating a style only, provide an empty object."
|
|
5595
5569
|
);
|
|
5596
5570
|
configureElementToolPrompt.parameter(
|
|
5597
|
-
"
|
|
5598
|
-
"
|
|
5571
|
+
"style",
|
|
5572
|
+
'A flat map of raw CSS declarations (property \u2192 value), e.g. { "line-height": "1.25rem", "color": "var(--primary-text, #000)" }. Set a value to null to reset that property to its default. OPTIONAL.'
|
|
5599
5573
|
);
|
|
5600
5574
|
configureElementToolPrompt.example(`
|
|
5601
5575
|
\`\`\`json
|
|
@@ -5611,20 +5585,9 @@ Do NOT send "group" (it is resolved automatically). Use { "settings": {} } only
|
|
|
5611
5585
|
value: false
|
|
5612
5586
|
},
|
|
5613
5587
|
},
|
|
5614
|
-
|
|
5615
|
-
'line-height':
|
|
5616
|
-
|
|
5617
|
-
value: {
|
|
5618
|
-
size: {
|
|
5619
|
-
$$type: 'number',
|
|
5620
|
-
value: 20
|
|
5621
|
-
},
|
|
5622
|
-
unit: {
|
|
5623
|
-
$$type: 'string',
|
|
5624
|
-
value: 'px'
|
|
5625
|
-
}
|
|
5626
|
-
}
|
|
5627
|
-
}
|
|
5588
|
+
style: {
|
|
5589
|
+
'line-height': '1.25rem',
|
|
5590
|
+
'color': 'var(--primary-text, #000)'
|
|
5628
5591
|
},
|
|
5629
5592
|
elementId: 'element-id',
|
|
5630
5593
|
elementType: 'element-type'
|
|
@@ -5632,7 +5595,7 @@ Do NOT send "group" (it is resolved automatically). Use { "settings": {} } only
|
|
|
5632
5595
|
\`\`\`
|
|
5633
5596
|
`);
|
|
5634
5597
|
configureElementToolPrompt.instruction(
|
|
5635
|
-
"The $$type property is MANDATORY for every value; it is
|
|
5598
|
+
"The $$type property is MANDATORY for every value in propertiesToChange; it is not used in the style parameter (raw CSS only)."
|
|
5636
5599
|
);
|
|
5637
5600
|
configureElementToolPrompt.instruction(`
|
|
5638
5601
|
V4 only: If MCP fails, give manual steps using V4 UI.
|
|
@@ -5653,11 +5616,14 @@ var inputSchema2 = {
|
|
|
5653
5616
|
z2.any().describe(`PropValue, refer to [${WIDGET_SCHEMA_URI}] by correct type, as appears in elementType`),
|
|
5654
5617
|
z2.any()
|
|
5655
5618
|
).describe("An object record containing property names and their new values to be set on the element"),
|
|
5656
|
-
|
|
5657
|
-
z2.string().describe(
|
|
5658
|
-
z2.
|
|
5659
|
-
|
|
5660
|
-
|
|
5619
|
+
style: z2.record(
|
|
5620
|
+
z2.string().describe('A CSS property name, e.g. "color", "margin-top".'),
|
|
5621
|
+
z2.string().nullable().describe(
|
|
5622
|
+
'A CSS value, e.g. "red", "10px", "1px solid #000". Use null to reset the property to its default.'
|
|
5623
|
+
)
|
|
5624
|
+
).describe(
|
|
5625
|
+
"Raw CSS declarations as a flat property\u2192value map. Converted to native styles server-side; any declaration that cannot be converted is stored as the element custom CSS. A null value resets that property to its default."
|
|
5626
|
+
).default({}),
|
|
5661
5627
|
elementType: z2.string().describe("The type of the element to retrieve the schema"),
|
|
5662
5628
|
elementId: z2.string().describe("The unique id of the element to configure")
|
|
5663
5629
|
};
|
|
@@ -5689,11 +5655,10 @@ var initConfigureElementTool = (reg) => {
|
|
|
5689
5655
|
outputSchema: outputSchema2,
|
|
5690
5656
|
requiredResources: [
|
|
5691
5657
|
{ description: "Widgets schema", uri: WIDGET_SCHEMA_URI },
|
|
5692
|
-
{ description: "Styles schema", uri: STYLE_SCHEMA_URI },
|
|
5693
5658
|
{ description: "Configure element guide", uri: CONFIGURE_ELEMENT_GUIDE_URI },
|
|
5694
5659
|
{ description: "Dynamic tags catalog", uri: DYNAMIC_TAGS_URI }
|
|
5695
5660
|
],
|
|
5696
|
-
handler: ({ elementId, propertiesToChange, elementType,
|
|
5661
|
+
handler: async ({ elementId, propertiesToChange, elementType, style }) => {
|
|
5697
5662
|
const widgetData = getWidgetsCache10()?.[elementType];
|
|
5698
5663
|
if (!widgetData) {
|
|
5699
5664
|
throw new Error(
|
|
@@ -5707,21 +5672,12 @@ var initConfigureElementTool = (reg) => {
|
|
|
5707
5672
|
}
|
|
5708
5673
|
const toUpdate = Object.entries(propertiesToChange);
|
|
5709
5674
|
const { valid, errors } = validateInput.validatePropSchema(elementType, propertiesToChange);
|
|
5710
|
-
const { valid: stylesValid, errors: stylesErrors } = validateInput.validateStyles(
|
|
5711
|
-
stylePropertiesToChange || {}
|
|
5712
|
-
);
|
|
5713
5675
|
if (!valid) {
|
|
5714
5676
|
const errorMessage = `Failed to configure element "${elementId}" due to invalid properties: ${errors?.join(
|
|
5715
5677
|
"\n- "
|
|
5716
5678
|
)}`;
|
|
5717
5679
|
throw new Error(errorMessage);
|
|
5718
5680
|
}
|
|
5719
|
-
if (!stylesValid) {
|
|
5720
|
-
const errorMessage = `Failed to configure element "${elementId}" due to invalid style properties: ${stylesErrors?.join(
|
|
5721
|
-
"\n- "
|
|
5722
|
-
)}`;
|
|
5723
|
-
throw new Error(errorMessage);
|
|
5724
|
-
}
|
|
5725
5681
|
for (const [propertyName, propertyValue] of toUpdate) {
|
|
5726
5682
|
try {
|
|
5727
5683
|
doUpdateElementProperty({
|
|
@@ -5741,33 +5697,46 @@ var initConfigureElementTool = (reg) => {
|
|
|
5741
5697
|
throw new Error(errorMessage);
|
|
5742
5698
|
}
|
|
5743
5699
|
}
|
|
5744
|
-
|
|
5745
|
-
try {
|
|
5746
|
-
doUpdateElementProperty({
|
|
5747
|
-
elementId,
|
|
5748
|
-
elementType,
|
|
5749
|
-
propertyName: "_styles",
|
|
5750
|
-
propertyValue: {
|
|
5751
|
-
[stylePropertyName]: stylePropertyValue
|
|
5752
|
-
}
|
|
5753
|
-
});
|
|
5754
|
-
} catch (error) {
|
|
5755
|
-
const errorMessage = createUpdateErrorMessage({
|
|
5756
|
-
propertyName: `(style) ${stylePropertyName}`,
|
|
5757
|
-
elementId,
|
|
5758
|
-
elementType,
|
|
5759
|
-
propertyType: "style",
|
|
5760
|
-
error
|
|
5761
|
-
});
|
|
5762
|
-
throw new Error(errorMessage);
|
|
5763
|
-
}
|
|
5764
|
-
}
|
|
5700
|
+
await applyStyleFromCss({ elementId, elementType, style });
|
|
5765
5701
|
return {
|
|
5766
5702
|
success: true
|
|
5767
5703
|
};
|
|
5768
5704
|
}
|
|
5769
5705
|
});
|
|
5770
5706
|
};
|
|
5707
|
+
async function applyStyleFromCss(opts) {
|
|
5708
|
+
const { elementId, elementType, style } = opts;
|
|
5709
|
+
if (!style || Object.keys(style).length === 0) {
|
|
5710
|
+
return;
|
|
5711
|
+
}
|
|
5712
|
+
const { props, customCss } = await convertCssToAtomic(style);
|
|
5713
|
+
const styleValue = { ...props };
|
|
5714
|
+
if (customCss) {
|
|
5715
|
+
styleValue.custom_css = customCss;
|
|
5716
|
+
}
|
|
5717
|
+
if (Object.keys(styleValue).length === 0) {
|
|
5718
|
+
return;
|
|
5719
|
+
}
|
|
5720
|
+
try {
|
|
5721
|
+
doUpdateElementProperty({
|
|
5722
|
+
elementId,
|
|
5723
|
+
elementType,
|
|
5724
|
+
propertyName: "_styles",
|
|
5725
|
+
propertyValue: styleValue,
|
|
5726
|
+
customCssWriteMode: "merge-with-stored"
|
|
5727
|
+
});
|
|
5728
|
+
} catch (error) {
|
|
5729
|
+
throw new Error(
|
|
5730
|
+
createUpdateErrorMessage({
|
|
5731
|
+
propertyName: "(style)",
|
|
5732
|
+
elementId,
|
|
5733
|
+
elementType,
|
|
5734
|
+
propertyType: "style",
|
|
5735
|
+
error
|
|
5736
|
+
})
|
|
5737
|
+
);
|
|
5738
|
+
}
|
|
5739
|
+
}
|
|
5771
5740
|
function createUpdateErrorMessage(opts) {
|
|
5772
5741
|
const { propertyName, elementId, elementType, error, propertyType } = opts;
|
|
5773
5742
|
return `Failed to update property "${propertyName}" on element "${elementId}": ${error.message}.
|
|
@@ -5777,11 +5746,7 @@ Check the element's PropType schema at the resource [${WIDGET_SCHEMA_URI.replace
|
|
|
5777
5746
|
elementType
|
|
5778
5747
|
)}] for type "${elementType}" to ensure the property exists and the value matches the expected PropType.
|
|
5779
5748
|
Now that you have this information, ensure you have the schema and try again.` : `
|
|
5780
|
-
|
|
5781
|
-
"{category}",
|
|
5782
|
-
propertyName
|
|
5783
|
-
)}] at editor-canvas__elementor://styles/schema/{category} to ensure the style property exists and the value matches the expected PropType.
|
|
5784
|
-
`};
|
|
5749
|
+
Provide styling as raw CSS via the "style" parameter (a flat map of CSS property \u2192 value). Declarations that cannot be converted are stored as the element custom CSS.`};
|
|
5785
5750
|
}`;
|
|
5786
5751
|
}
|
|
5787
5752
|
|
|
@@ -5915,7 +5880,6 @@ The \`$$type\` defines how Elementor interprets the value. Providing the correct
|
|
|
5915
5880
|
- **Global Variables**: Reusable colors, sizes, and fonts (\`elementor://global-variables\`)
|
|
5916
5881
|
- **Global Classes**: Reusable style sets that can be applied to elements (\`elementor://global-classes\`)
|
|
5917
5882
|
- **Widget Schemas**: Configuration options for each widget type (\`${WIDGET_SCHEMA_URI}\`)
|
|
5918
|
-
- **Style Schema**: Common styles shared across all widgets and containers (\`${STYLE_SCHEMA_URI}\`)
|
|
5919
5883
|
|
|
5920
5884
|
# Building Compositions with build_composition
|
|
5921
5885
|
|
|
@@ -5964,28 +5928,25 @@ Map each configuration-id to its widget properties using PropValues:
|
|
|
5964
5928
|
}
|
|
5965
5929
|
\`\`\`
|
|
5966
5930
|
|
|
5967
|
-
### 6. Create
|
|
5968
|
-
Map each configuration-id to
|
|
5969
|
-
-
|
|
5970
|
-
- Example using global variable:
|
|
5931
|
+
### 6. Create style
|
|
5932
|
+
Map each configuration-id to raw CSS declarations (property \u2192 value strings). The server converts them to native styles and stores any unconvertible declarations as the element custom CSS.
|
|
5933
|
+
- Example:
|
|
5971
5934
|
\`\`\`json
|
|
5972
5935
|
{
|
|
5973
|
-
"heading-1":
|
|
5974
|
-
"color": { "$$type": "global-color-variable", "value": "primary-color-id" },
|
|
5975
|
-
"font-size": { "$$type": "size", "value": "2rem" }
|
|
5936
|
+
"heading-1": "color: #1a1a1a; font-size: 2rem;"
|
|
5976
5937
|
}
|
|
5977
5938
|
}
|
|
5978
5939
|
\`\`\`
|
|
5979
5940
|
|
|
5980
5941
|
### 7. Execute build_composition
|
|
5981
|
-
Call the tool with your XML structure, elementConfig, and
|
|
5942
|
+
Call the tool with your XML structure, elementConfig, and style. The response will contain the created element IDs.
|
|
5982
5943
|
At the response you will also find llm_instructions for you to do afterwards, read and follow them!
|
|
5983
5944
|
|
|
5984
5945
|
## Key Points
|
|
5985
5946
|
|
|
5986
5947
|
- **PropValue Types**: Arrays that accept union types are typed as mixed arrays
|
|
5987
|
-
- **Visual Sizing**: Widget sizes MUST be defined
|
|
5988
|
-
- **Global Variables**: Reference by
|
|
5948
|
+
- **Visual Sizing**: Widget sizes MUST be defined via the style parameter (raw CSS). Widget properties like image "size" control resolution, not visual appearance
|
|
5949
|
+
- **Global Variables**: Reference by label/name: (e.g. var(--card-background-color)
|
|
5989
5950
|
- **Naming Conventions**: Use meaningful, purpose-based names (e.g., "primary-button", "heading-large"), not value-based names (e.g., "blue-style", "20px-padding")
|
|
5990
5951
|
|
|
5991
5952
|
## Example: e-image PropValue Structure
|
|
@@ -6003,7 +5964,7 @@ At the response you will also find llm_instructions for you to do afterwards, re
|
|
|
6003
5964
|
}
|
|
6004
5965
|
}
|
|
6005
5966
|
\`\`\`
|
|
6006
|
-
Note: The "size" property controls image resolution/loading, not visual size. Set visual dimensions
|
|
5967
|
+
Note: The "size" property controls image resolution/loading, not visual size. Set visual dimensions via the style parameter (raw CSS).
|
|
6007
5968
|
`;
|
|
6008
5969
|
|
|
6009
5970
|
// src/prevent-link-in-link-commands.ts
|
|
@@ -6547,14 +6508,14 @@ export {
|
|
|
6547
6508
|
BREAKPOINTS_SCHEMA_URI,
|
|
6548
6509
|
DOCUMENT_STRUCTURE_URI,
|
|
6549
6510
|
GLOBAL_STYLES_IMPORTED_EVENT,
|
|
6550
|
-
STYLE_SCHEMA_FULL_URI,
|
|
6551
|
-
STYLE_SCHEMA_URI,
|
|
6552
6511
|
SpotlightBackdrop,
|
|
6553
6512
|
UnknownStyleStateError,
|
|
6554
6513
|
UnknownStyleTypeError,
|
|
6555
6514
|
WIDGET_SCHEMA_FULL_URI,
|
|
6556
6515
|
WIDGET_SCHEMA_URI,
|
|
6557
6516
|
canBeNestedTemplated,
|
|
6517
|
+
convertCssToAtomic,
|
|
6518
|
+
convertStyleBlocksToAtomic,
|
|
6558
6519
|
createNestedTemplatedElementType,
|
|
6559
6520
|
createNestedTemplatedElementView,
|
|
6560
6521
|
createPropsResolver,
|