@elementor/editor-canvas 4.2.0-943 → 4.2.0-945
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.js +33 -122
- package/dist/index.mjs +10 -99
- package/package.json +19 -19
- package/src/mcp/tools/configure-element/tool.ts +4 -9
package/dist/index.js
CHANGED
|
@@ -226,7 +226,6 @@ function extractV3ControlsMetadata(controls) {
|
|
|
226
226
|
var CANVAS_SERVER_NAME = "editor-canvas";
|
|
227
227
|
var WIDGET_SCHEMA_URI = "elementor://widgets/schema/{widgetType}";
|
|
228
228
|
var WIDGET_SCHEMA_FULL_URI = `${CANVAS_SERVER_NAME}_${WIDGET_SCHEMA_URI}`;
|
|
229
|
-
var STYLE_SCHEMA_URI = "elementor://styles/schema/{category}";
|
|
230
229
|
var BEST_PRACTICES_URI = "elementor://styles/best-practices";
|
|
231
230
|
var BEST_PRACTICES_FULL_URI = `${CANVAS_SERVER_NAME}_${BEST_PRACTICES_URI}`;
|
|
232
231
|
var initWidgetsSchemaResource = (reg) => {
|
|
@@ -5557,92 +5556,8 @@ function assertCompositionXmlUsesV4WidgetsOnly(xmlStructure) {
|
|
|
5557
5556
|
}
|
|
5558
5557
|
|
|
5559
5558
|
// src/mcp/tools/configure-element/tool.ts
|
|
5560
|
-
var import_editor_elements18 = require("@elementor/editor-elements");
|
|
5561
|
-
|
|
5562
|
-
// src/mcp/utils/validate-input.ts
|
|
5563
5559
|
var import_editor_elements17 = require("@elementor/editor-elements");
|
|
5564
5560
|
var import_editor_props10 = require("@elementor/editor-props");
|
|
5565
|
-
var import_editor_styles5 = require("@elementor/editor-styles");
|
|
5566
|
-
var _widgetsSchema = null;
|
|
5567
|
-
var validateInput = {
|
|
5568
|
-
get widgetsSchema() {
|
|
5569
|
-
if (!_widgetsSchema) {
|
|
5570
|
-
const schema2 = {};
|
|
5571
|
-
const cache = (0, import_editor_elements17.getWidgetsCache)();
|
|
5572
|
-
if (!cache) {
|
|
5573
|
-
return {};
|
|
5574
|
-
}
|
|
5575
|
-
Object.entries(cache).forEach(([widgetType, widgetData]) => {
|
|
5576
|
-
if (widgetData.atomic_props_schema) {
|
|
5577
|
-
schema2[widgetType] = structuredClone(widgetData.atomic_props_schema);
|
|
5578
|
-
}
|
|
5579
|
-
});
|
|
5580
|
-
_widgetsSchema = schema2;
|
|
5581
|
-
}
|
|
5582
|
-
return _widgetsSchema;
|
|
5583
|
-
},
|
|
5584
|
-
validateProps(schema2, values, ignore = []) {
|
|
5585
|
-
if (!schema2) {
|
|
5586
|
-
throw new Error("No schema provided for validation.");
|
|
5587
|
-
}
|
|
5588
|
-
const errors = [];
|
|
5589
|
-
let hasInvalidKey = false;
|
|
5590
|
-
Object.entries(values).forEach(([propName, propValue]) => {
|
|
5591
|
-
if (ignore.includes(propName)) {
|
|
5592
|
-
return;
|
|
5593
|
-
}
|
|
5594
|
-
const propSchema = schema2[propName];
|
|
5595
|
-
if (!propSchema) {
|
|
5596
|
-
errors.push(`Property "${propName}" is not defined in the schema.`);
|
|
5597
|
-
hasInvalidKey = true;
|
|
5598
|
-
} else if (!import_editor_props10.Schema.isPropKeyConfigurable(propName, propSchema)) {
|
|
5599
|
-
errors.push(`Property "${propName}" is not configurable.`);
|
|
5600
|
-
} else {
|
|
5601
|
-
const { valid } = import_editor_props10.Schema.validatePropValue(propSchema, propValue);
|
|
5602
|
-
if (!valid) {
|
|
5603
|
-
errors.push(
|
|
5604
|
-
`Invalid property "${propName}". Validate input with resource [${STYLE_SCHEMA_URI.replace(
|
|
5605
|
-
"{category}",
|
|
5606
|
-
propName
|
|
5607
|
-
)}]`
|
|
5608
|
-
);
|
|
5609
|
-
}
|
|
5610
|
-
}
|
|
5611
|
-
});
|
|
5612
|
-
if (hasInvalidKey) {
|
|
5613
|
-
errors.push("Available properties: " + Object.keys(schema2).join(", "));
|
|
5614
|
-
}
|
|
5615
|
-
return {
|
|
5616
|
-
errors,
|
|
5617
|
-
valid: errors.length === 0
|
|
5618
|
-
};
|
|
5619
|
-
},
|
|
5620
|
-
validateStyles(values) {
|
|
5621
|
-
const styleSchema = (0, import_editor_styles5.getStylesSchema)();
|
|
5622
|
-
const customCssValue = values.custom_css;
|
|
5623
|
-
const result = this.validateProps(styleSchema, values, ["custom_css", "$intention"]);
|
|
5624
|
-
const appendInvalidCustomCssErr = () => {
|
|
5625
|
-
result.valid = false;
|
|
5626
|
-
result.errors = result.errors || [];
|
|
5627
|
-
result.errors.push('Invalid property "custom_css". Expected a string value.');
|
|
5628
|
-
};
|
|
5629
|
-
if (customCssValue && typeof customCssValue === "object") {
|
|
5630
|
-
if (typeof customCssValue.value !== "string") {
|
|
5631
|
-
appendInvalidCustomCssErr();
|
|
5632
|
-
}
|
|
5633
|
-
} else if (typeof customCssValue !== "string" && typeof customCssValue !== "undefined" && customCssValue !== null) {
|
|
5634
|
-
appendInvalidCustomCssErr();
|
|
5635
|
-
}
|
|
5636
|
-
return result;
|
|
5637
|
-
},
|
|
5638
|
-
validatePropSchema(widgetType, values, ignore = []) {
|
|
5639
|
-
const schema2 = this.widgetsSchema[widgetType];
|
|
5640
|
-
if (!schema2) {
|
|
5641
|
-
return { valid: false, errors: [`No schema found for widget type "${widgetType}".`] };
|
|
5642
|
-
}
|
|
5643
|
-
return this.validateProps(schema2, values, ignore);
|
|
5644
|
-
}
|
|
5645
|
-
};
|
|
5646
5561
|
|
|
5647
5562
|
// src/mcp/tools/configure-element/prompt.ts
|
|
5648
5563
|
var import_editor_mcp3 = require("@elementor/editor-mcp");
|
|
@@ -5809,13 +5724,13 @@ var initConfigureElementTool = (reg) => {
|
|
|
5809
5724
|
{ description: "Dynamic tags catalog", uri: DYNAMIC_TAGS_URI }
|
|
5810
5725
|
],
|
|
5811
5726
|
handler: async ({ elementId, propertiesToChange, elementType, style }) => {
|
|
5812
|
-
const widgetData = (0,
|
|
5727
|
+
const widgetData = (0, import_editor_elements17.getWidgetsCache)()?.[elementType];
|
|
5813
5728
|
if (!widgetData) {
|
|
5814
5729
|
throw new Error(
|
|
5815
5730
|
`Unknown element type: ${elementType}. Check the available-widgets resource for valid types.`
|
|
5816
5731
|
);
|
|
5817
5732
|
}
|
|
5818
|
-
const container = (0,
|
|
5733
|
+
const container = (0, import_editor_elements17.getContainer)(elementId);
|
|
5819
5734
|
if (!container) {
|
|
5820
5735
|
throw new Error(`Element with id ${elementId} not found`);
|
|
5821
5736
|
}
|
|
@@ -5830,14 +5745,10 @@ var initConfigureElementTool = (reg) => {
|
|
|
5830
5745
|
}
|
|
5831
5746
|
const propertiesToUpdate = resolveCanonicalPropKeys(elementType, propertiesToChange);
|
|
5832
5747
|
const toUpdate = Object.entries(propertiesToUpdate);
|
|
5833
|
-
const { valid, errors } = validateInput.validatePropSchema(elementType, propertiesToUpdate);
|
|
5834
|
-
if (!valid) {
|
|
5835
|
-
const errorMessage = `Failed to configure element "${elementId}" due to invalid properties: ${errors?.join(
|
|
5836
|
-
"\n- "
|
|
5837
|
-
)}`;
|
|
5838
|
-
throw new Error(errorMessage);
|
|
5839
|
-
}
|
|
5840
5748
|
for (const [propertyName, propertyValue] of toUpdate) {
|
|
5749
|
+
if (!import_editor_props10.Schema.isPropKeyConfigurable(propertyName)) {
|
|
5750
|
+
throw new Error(`Not allowed to update ${propertyName}`);
|
|
5751
|
+
}
|
|
5841
5752
|
try {
|
|
5842
5753
|
doUpdateElementProperty({
|
|
5843
5754
|
elementId,
|
|
@@ -5910,7 +5821,7 @@ Provide styling as raw CSS via the "style" parameter (a flat map of CSS property
|
|
|
5910
5821
|
}
|
|
5911
5822
|
|
|
5912
5823
|
// src/mcp/tools/get-element-config/tool.ts
|
|
5913
|
-
var
|
|
5824
|
+
var import_editor_elements18 = require("@elementor/editor-elements");
|
|
5914
5825
|
var import_editor_props11 = require("@elementor/editor-props");
|
|
5915
5826
|
var import_schema5 = require("@elementor/schema");
|
|
5916
5827
|
var schema = {
|
|
@@ -5945,12 +5856,12 @@ var initGetElementConfigTool = (reg) => {
|
|
|
5945
5856
|
schema,
|
|
5946
5857
|
outputSchema: outputSchema3,
|
|
5947
5858
|
handler: async ({ elementId }) => {
|
|
5948
|
-
const element = (0,
|
|
5859
|
+
const element = (0, import_editor_elements18.getContainer)(elementId);
|
|
5949
5860
|
if (!element) {
|
|
5950
5861
|
throw new Error(`Element with ID ${elementId} not found.`);
|
|
5951
5862
|
}
|
|
5952
5863
|
const elementType = element.model.get("widgetType") || element.model.get("elType") || "";
|
|
5953
|
-
const widgetData = (0,
|
|
5864
|
+
const widgetData = (0, import_editor_elements18.getWidgetsCache)()?.[elementType];
|
|
5954
5865
|
if (!widgetData) {
|
|
5955
5866
|
throw new Error(
|
|
5956
5867
|
`Unknown element type: ${elementType}. Check the available-widgets resource for valid types.`
|
|
@@ -5962,7 +5873,7 @@ var initGetElementConfigTool = (reg) => {
|
|
|
5962
5873
|
);
|
|
5963
5874
|
}
|
|
5964
5875
|
const elementRawSettings = element.settings;
|
|
5965
|
-
const propSchema = (0,
|
|
5876
|
+
const propSchema = (0, import_editor_elements18.getWidgetsCache)()?.[elementType]?.atomic_props_schema;
|
|
5966
5877
|
if (!elementRawSettings || !propSchema) {
|
|
5967
5878
|
throw new Error(`No settings or prop schema found for element ID: ${elementId}`);
|
|
5968
5879
|
}
|
|
@@ -5971,7 +5882,7 @@ var initGetElementConfigTool = (reg) => {
|
|
|
5971
5882
|
import_editor_props11.Schema.configurableKeys(propSchema).forEach((key) => {
|
|
5972
5883
|
propValues[key] = structuredClone(elementRawSettings.get(key));
|
|
5973
5884
|
});
|
|
5974
|
-
const elementStyles = (0,
|
|
5885
|
+
const elementStyles = (0, import_editor_elements18.getElementStyles)(elementId) || {};
|
|
5975
5886
|
const localStyle = Object.values(elementStyles).find((style) => style.label === "local");
|
|
5976
5887
|
if (localStyle) {
|
|
5977
5888
|
const defaultVariant = localStyle.variants.find(
|
|
@@ -6127,7 +6038,7 @@ Note: The "size" property controls image resolution/loading, not visual size. Se
|
|
|
6127
6038
|
`;
|
|
6128
6039
|
|
|
6129
6040
|
// src/prevent-link-in-link-commands.ts
|
|
6130
|
-
var
|
|
6041
|
+
var import_editor_elements19 = require("@elementor/editor-elements");
|
|
6131
6042
|
var import_editor_notifications3 = require("@elementor/editor-notifications");
|
|
6132
6043
|
var import_editor_v1_adapters22 = require("@elementor/editor-v1-adapters");
|
|
6133
6044
|
var import_i18n4 = require("@wordpress/i18n");
|
|
@@ -6198,24 +6109,24 @@ function shouldBlock(sourceElements, targetElements) {
|
|
|
6198
6109
|
return false;
|
|
6199
6110
|
}
|
|
6200
6111
|
const isSourceContainsAnAnchor = sourceElements.some((src) => {
|
|
6201
|
-
return src?.id ? (0,
|
|
6112
|
+
return src?.id ? (0, import_editor_elements19.isElementAnchored)(src.id) || !!(0, import_editor_elements19.getAnchoredDescendantId)(src.id) : false;
|
|
6202
6113
|
});
|
|
6203
6114
|
if (!isSourceContainsAnAnchor) {
|
|
6204
6115
|
return false;
|
|
6205
6116
|
}
|
|
6206
6117
|
const isTargetContainsAnAnchor = targetElements.some((target) => {
|
|
6207
|
-
return target?.id ? (0,
|
|
6118
|
+
return target?.id ? (0, import_editor_elements19.isElementAnchored)(target.id) || !!(0, import_editor_elements19.getAnchoredAncestorId)(target.id) : false;
|
|
6208
6119
|
});
|
|
6209
6120
|
return isTargetContainsAnAnchor;
|
|
6210
6121
|
}
|
|
6211
6122
|
|
|
6212
6123
|
// src/style-commands/paste-style.ts
|
|
6213
|
-
var
|
|
6124
|
+
var import_editor_elements22 = require("@elementor/editor-elements");
|
|
6214
6125
|
var import_editor_props14 = require("@elementor/editor-props");
|
|
6215
6126
|
var import_editor_v1_adapters24 = require("@elementor/editor-v1-adapters");
|
|
6216
6127
|
|
|
6217
6128
|
// src/utils/command-utils.ts
|
|
6218
|
-
var
|
|
6129
|
+
var import_editor_elements20 = require("@elementor/editor-elements");
|
|
6219
6130
|
var import_editor_props13 = require("@elementor/editor-props");
|
|
6220
6131
|
var import_i18n5 = require("@wordpress/i18n");
|
|
6221
6132
|
function hasAtomicWidgets(args) {
|
|
@@ -6240,7 +6151,7 @@ function getClassesProp(container) {
|
|
|
6240
6151
|
}
|
|
6241
6152
|
function getContainerSchema(container) {
|
|
6242
6153
|
const type = container?.model.get("widgetType") || container?.model.get("elType");
|
|
6243
|
-
const widgetsCache = (0,
|
|
6154
|
+
const widgetsCache = (0, import_editor_elements20.getWidgetsCache)();
|
|
6244
6155
|
const elementType = widgetsCache?.[type];
|
|
6245
6156
|
return elementType?.atomic_props_schema ?? null;
|
|
6246
6157
|
}
|
|
@@ -6253,11 +6164,11 @@ function getClipboardElements(storageKey = "clipboard") {
|
|
|
6253
6164
|
}
|
|
6254
6165
|
}
|
|
6255
6166
|
function getTitleForContainers(containers) {
|
|
6256
|
-
return containers.length > 1 ? (0, import_i18n5.__)("Elements", "elementor") : (0,
|
|
6167
|
+
return containers.length > 1 ? (0, import_i18n5.__)("Elements", "elementor") : (0, import_editor_elements20.getElementLabel)(containers[0].id);
|
|
6257
6168
|
}
|
|
6258
6169
|
|
|
6259
6170
|
// src/style-commands/undoable-actions/paste-element-style.ts
|
|
6260
|
-
var
|
|
6171
|
+
var import_editor_elements21 = require("@elementor/editor-elements");
|
|
6261
6172
|
var import_editor_styles_repository4 = require("@elementor/editor-styles-repository");
|
|
6262
6173
|
var import_editor_v1_adapters23 = require("@elementor/editor-v1-adapters");
|
|
6263
6174
|
var import_i18n6 = require("@wordpress/i18n");
|
|
@@ -6270,7 +6181,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters23.undoable)(
|
|
|
6270
6181
|
if (!classesProp) {
|
|
6271
6182
|
return null;
|
|
6272
6183
|
}
|
|
6273
|
-
const originalStyles = (0,
|
|
6184
|
+
const originalStyles = (0, import_editor_elements21.getElementStyles)(container.id);
|
|
6274
6185
|
const [styleId, styleDef] = Object.entries(originalStyles ?? {})[0] ?? [];
|
|
6275
6186
|
const originalStyle = Object.keys(styleDef ?? {}).length ? styleDef : null;
|
|
6276
6187
|
const revertData = {
|
|
@@ -6279,7 +6190,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters23.undoable)(
|
|
|
6279
6190
|
};
|
|
6280
6191
|
if (styleId) {
|
|
6281
6192
|
newStyle.variants.forEach(({ meta, props, custom_css: customCss }) => {
|
|
6282
|
-
(0,
|
|
6193
|
+
(0, import_editor_elements21.updateElementStyle)({
|
|
6283
6194
|
elementId,
|
|
6284
6195
|
styleId,
|
|
6285
6196
|
meta,
|
|
@@ -6290,7 +6201,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters23.undoable)(
|
|
|
6290
6201
|
} else {
|
|
6291
6202
|
const [firstVariant] = newStyle.variants;
|
|
6292
6203
|
const additionalVariants = newStyle.variants.slice(1);
|
|
6293
|
-
revertData.styleId = (0,
|
|
6204
|
+
revertData.styleId = (0, import_editor_elements21.createElementStyle)({
|
|
6294
6205
|
elementId,
|
|
6295
6206
|
classesProp,
|
|
6296
6207
|
label: import_editor_styles_repository4.ELEMENTS_STYLES_RESERVED_LABEL,
|
|
@@ -6308,7 +6219,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters23.undoable)(
|
|
|
6308
6219
|
return;
|
|
6309
6220
|
}
|
|
6310
6221
|
if (!revertData.originalStyle) {
|
|
6311
|
-
(0,
|
|
6222
|
+
(0, import_editor_elements21.deleteElementStyle)(container.id, revertData.styleId);
|
|
6312
6223
|
return;
|
|
6313
6224
|
}
|
|
6314
6225
|
const classesProp = getClassesProp(container);
|
|
@@ -6317,7 +6228,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters23.undoable)(
|
|
|
6317
6228
|
}
|
|
6318
6229
|
const [firstVariant] = revertData.originalStyle.variants;
|
|
6319
6230
|
const additionalVariants = revertData.originalStyle.variants.slice(1);
|
|
6320
|
-
(0,
|
|
6231
|
+
(0, import_editor_elements21.createElementStyle)({
|
|
6321
6232
|
elementId: container.id,
|
|
6322
6233
|
classesProp,
|
|
6323
6234
|
label: import_editor_styles_repository4.ELEMENTS_STYLES_RESERVED_LABEL,
|
|
@@ -6354,7 +6265,7 @@ function pasteStyles(args, pasteLocalStyle) {
|
|
|
6354
6265
|
}
|
|
6355
6266
|
const clipboardElements = getClipboardElements(storageKey);
|
|
6356
6267
|
const [clipboardElement] = clipboardElements ?? [];
|
|
6357
|
-
const clipboardContainer = (0,
|
|
6268
|
+
const clipboardContainer = (0, import_editor_elements22.getContainer)(clipboardElement.id);
|
|
6358
6269
|
if (!clipboardElement || !clipboardContainer || !isAtomicWidget(clipboardContainer)) {
|
|
6359
6270
|
return;
|
|
6360
6271
|
}
|
|
@@ -6373,7 +6284,7 @@ function getClassesWithoutLocalStyle(clipboardContainer, style) {
|
|
|
6373
6284
|
if (!classesProp) {
|
|
6374
6285
|
return [];
|
|
6375
6286
|
}
|
|
6376
|
-
const classesSetting = (0,
|
|
6287
|
+
const classesSetting = (0, import_editor_elements22.getElementSetting)(clipboardContainer.id, classesProp);
|
|
6377
6288
|
return classesSetting?.value.filter((styleId) => styleId !== style?.id) ?? [];
|
|
6378
6289
|
}
|
|
6379
6290
|
function pasteClasses(containers, classes) {
|
|
@@ -6382,10 +6293,10 @@ function pasteClasses(containers, classes) {
|
|
|
6382
6293
|
if (!classesProp) {
|
|
6383
6294
|
return;
|
|
6384
6295
|
}
|
|
6385
|
-
const classesSetting = (0,
|
|
6296
|
+
const classesSetting = (0, import_editor_elements22.getElementSetting)(container.id, classesProp);
|
|
6386
6297
|
const currentClasses = import_editor_props14.classesPropTypeUtil.extract(classesSetting) ?? [];
|
|
6387
6298
|
const newClasses = import_editor_props14.classesPropTypeUtil.create(Array.from(/* @__PURE__ */ new Set([...classes, ...currentClasses])));
|
|
6388
|
-
(0,
|
|
6299
|
+
(0, import_editor_elements22.updateElementSettings)({
|
|
6389
6300
|
id: container.id,
|
|
6390
6301
|
props: { [classesProp]: newClasses }
|
|
6391
6302
|
});
|
|
@@ -6396,7 +6307,7 @@ function pasteClasses(containers, classes) {
|
|
|
6396
6307
|
var import_editor_v1_adapters26 = require("@elementor/editor-v1-adapters");
|
|
6397
6308
|
|
|
6398
6309
|
// src/style-commands/undoable-actions/reset-element-style.ts
|
|
6399
|
-
var
|
|
6310
|
+
var import_editor_elements23 = require("@elementor/editor-elements");
|
|
6400
6311
|
var import_editor_styles_repository5 = require("@elementor/editor-styles-repository");
|
|
6401
6312
|
var import_editor_v1_adapters25 = require("@elementor/editor-v1-adapters");
|
|
6402
6313
|
var import_i18n7 = require("@wordpress/i18n");
|
|
@@ -6405,9 +6316,9 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters25.undoable)(
|
|
|
6405
6316
|
do: ({ containers }) => {
|
|
6406
6317
|
return containers.map((container) => {
|
|
6407
6318
|
const elementId = container.model.get("id");
|
|
6408
|
-
const containerStyles = (0,
|
|
6319
|
+
const containerStyles = (0, import_editor_elements23.getElementStyles)(elementId);
|
|
6409
6320
|
Object.keys(containerStyles ?? {}).forEach(
|
|
6410
|
-
(styleId) => (0,
|
|
6321
|
+
(styleId) => (0, import_editor_elements23.deleteElementStyle)(elementId, styleId)
|
|
6411
6322
|
);
|
|
6412
6323
|
return containerStyles;
|
|
6413
6324
|
});
|
|
@@ -6423,7 +6334,7 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters25.undoable)(
|
|
|
6423
6334
|
Object.entries(containerStyles ?? {}).forEach(([styleId, style]) => {
|
|
6424
6335
|
const [firstVariant] = style.variants;
|
|
6425
6336
|
const additionalVariants = style.variants.slice(1);
|
|
6426
|
-
(0,
|
|
6337
|
+
(0, import_editor_elements23.createElementStyle)({
|
|
6427
6338
|
elementId,
|
|
6428
6339
|
classesProp,
|
|
6429
6340
|
styleId,
|
|
@@ -6623,10 +6534,10 @@ function useEscapeOnCanvas(canvasDocument, onEscape) {
|
|
|
6623
6534
|
}
|
|
6624
6535
|
|
|
6625
6536
|
// src/utils/after-render.ts
|
|
6626
|
-
var
|
|
6537
|
+
var import_editor_elements24 = require("@elementor/editor-elements");
|
|
6627
6538
|
function doAfterRender(elementIds, callback) {
|
|
6628
6539
|
const pending = elementIds.map((elementId) => {
|
|
6629
|
-
const view = (0,
|
|
6540
|
+
const view = (0, import_editor_elements24.getContainer)(elementId)?.view;
|
|
6630
6541
|
if (!view || !hasDoAfterRender(view)) {
|
|
6631
6542
|
return void 0;
|
|
6632
6543
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -160,7 +160,6 @@ function extractV3ControlsMetadata(controls) {
|
|
|
160
160
|
var CANVAS_SERVER_NAME = "editor-canvas";
|
|
161
161
|
var WIDGET_SCHEMA_URI = "elementor://widgets/schema/{widgetType}";
|
|
162
162
|
var WIDGET_SCHEMA_FULL_URI = `${CANVAS_SERVER_NAME}_${WIDGET_SCHEMA_URI}`;
|
|
163
|
-
var STYLE_SCHEMA_URI = "elementor://styles/schema/{category}";
|
|
164
163
|
var BEST_PRACTICES_URI = "elementor://styles/best-practices";
|
|
165
164
|
var BEST_PRACTICES_FULL_URI = `${CANVAS_SERVER_NAME}_${BEST_PRACTICES_URI}`;
|
|
166
165
|
var initWidgetsSchemaResource = (reg) => {
|
|
@@ -5543,92 +5542,8 @@ function assertCompositionXmlUsesV4WidgetsOnly(xmlStructure) {
|
|
|
5543
5542
|
}
|
|
5544
5543
|
|
|
5545
5544
|
// src/mcp/tools/configure-element/tool.ts
|
|
5546
|
-
import { getContainer as getContainer6, getWidgetsCache as
|
|
5547
|
-
|
|
5548
|
-
// src/mcp/utils/validate-input.ts
|
|
5549
|
-
import { getWidgetsCache as getWidgetsCache10 } from "@elementor/editor-elements";
|
|
5545
|
+
import { getContainer as getContainer6, getWidgetsCache as getWidgetsCache10 } from "@elementor/editor-elements";
|
|
5550
5546
|
import { Schema as Schema4 } from "@elementor/editor-props";
|
|
5551
|
-
import { getStylesSchema as getStylesSchema3 } from "@elementor/editor-styles";
|
|
5552
|
-
var _widgetsSchema = null;
|
|
5553
|
-
var validateInput = {
|
|
5554
|
-
get widgetsSchema() {
|
|
5555
|
-
if (!_widgetsSchema) {
|
|
5556
|
-
const schema2 = {};
|
|
5557
|
-
const cache = getWidgetsCache10();
|
|
5558
|
-
if (!cache) {
|
|
5559
|
-
return {};
|
|
5560
|
-
}
|
|
5561
|
-
Object.entries(cache).forEach(([widgetType, widgetData]) => {
|
|
5562
|
-
if (widgetData.atomic_props_schema) {
|
|
5563
|
-
schema2[widgetType] = structuredClone(widgetData.atomic_props_schema);
|
|
5564
|
-
}
|
|
5565
|
-
});
|
|
5566
|
-
_widgetsSchema = schema2;
|
|
5567
|
-
}
|
|
5568
|
-
return _widgetsSchema;
|
|
5569
|
-
},
|
|
5570
|
-
validateProps(schema2, values, ignore = []) {
|
|
5571
|
-
if (!schema2) {
|
|
5572
|
-
throw new Error("No schema provided for validation.");
|
|
5573
|
-
}
|
|
5574
|
-
const errors = [];
|
|
5575
|
-
let hasInvalidKey = false;
|
|
5576
|
-
Object.entries(values).forEach(([propName, propValue]) => {
|
|
5577
|
-
if (ignore.includes(propName)) {
|
|
5578
|
-
return;
|
|
5579
|
-
}
|
|
5580
|
-
const propSchema = schema2[propName];
|
|
5581
|
-
if (!propSchema) {
|
|
5582
|
-
errors.push(`Property "${propName}" is not defined in the schema.`);
|
|
5583
|
-
hasInvalidKey = true;
|
|
5584
|
-
} else if (!Schema4.isPropKeyConfigurable(propName, propSchema)) {
|
|
5585
|
-
errors.push(`Property "${propName}" is not configurable.`);
|
|
5586
|
-
} else {
|
|
5587
|
-
const { valid } = Schema4.validatePropValue(propSchema, propValue);
|
|
5588
|
-
if (!valid) {
|
|
5589
|
-
errors.push(
|
|
5590
|
-
`Invalid property "${propName}". Validate input with resource [${STYLE_SCHEMA_URI.replace(
|
|
5591
|
-
"{category}",
|
|
5592
|
-
propName
|
|
5593
|
-
)}]`
|
|
5594
|
-
);
|
|
5595
|
-
}
|
|
5596
|
-
}
|
|
5597
|
-
});
|
|
5598
|
-
if (hasInvalidKey) {
|
|
5599
|
-
errors.push("Available properties: " + Object.keys(schema2).join(", "));
|
|
5600
|
-
}
|
|
5601
|
-
return {
|
|
5602
|
-
errors,
|
|
5603
|
-
valid: errors.length === 0
|
|
5604
|
-
};
|
|
5605
|
-
},
|
|
5606
|
-
validateStyles(values) {
|
|
5607
|
-
const styleSchema = getStylesSchema3();
|
|
5608
|
-
const customCssValue = values.custom_css;
|
|
5609
|
-
const result = this.validateProps(styleSchema, values, ["custom_css", "$intention"]);
|
|
5610
|
-
const appendInvalidCustomCssErr = () => {
|
|
5611
|
-
result.valid = false;
|
|
5612
|
-
result.errors = result.errors || [];
|
|
5613
|
-
result.errors.push('Invalid property "custom_css". Expected a string value.');
|
|
5614
|
-
};
|
|
5615
|
-
if (customCssValue && typeof customCssValue === "object") {
|
|
5616
|
-
if (typeof customCssValue.value !== "string") {
|
|
5617
|
-
appendInvalidCustomCssErr();
|
|
5618
|
-
}
|
|
5619
|
-
} else if (typeof customCssValue !== "string" && typeof customCssValue !== "undefined" && customCssValue !== null) {
|
|
5620
|
-
appendInvalidCustomCssErr();
|
|
5621
|
-
}
|
|
5622
|
-
return result;
|
|
5623
|
-
},
|
|
5624
|
-
validatePropSchema(widgetType, values, ignore = []) {
|
|
5625
|
-
const schema2 = this.widgetsSchema[widgetType];
|
|
5626
|
-
if (!schema2) {
|
|
5627
|
-
return { valid: false, errors: [`No schema found for widget type "${widgetType}".`] };
|
|
5628
|
-
}
|
|
5629
|
-
return this.validateProps(schema2, values, ignore);
|
|
5630
|
-
}
|
|
5631
|
-
};
|
|
5632
5547
|
|
|
5633
5548
|
// src/mcp/tools/configure-element/prompt.ts
|
|
5634
5549
|
import { toolPrompts as toolPrompts2 } from "@elementor/editor-mcp";
|
|
@@ -5795,7 +5710,7 @@ var initConfigureElementTool = (reg) => {
|
|
|
5795
5710
|
{ description: "Dynamic tags catalog", uri: DYNAMIC_TAGS_URI }
|
|
5796
5711
|
],
|
|
5797
5712
|
handler: async ({ elementId, propertiesToChange, elementType, style }) => {
|
|
5798
|
-
const widgetData =
|
|
5713
|
+
const widgetData = getWidgetsCache10()?.[elementType];
|
|
5799
5714
|
if (!widgetData) {
|
|
5800
5715
|
throw new Error(
|
|
5801
5716
|
`Unknown element type: ${elementType}. Check the available-widgets resource for valid types.`
|
|
@@ -5816,14 +5731,10 @@ var initConfigureElementTool = (reg) => {
|
|
|
5816
5731
|
}
|
|
5817
5732
|
const propertiesToUpdate = resolveCanonicalPropKeys(elementType, propertiesToChange);
|
|
5818
5733
|
const toUpdate = Object.entries(propertiesToUpdate);
|
|
5819
|
-
const { valid, errors } = validateInput.validatePropSchema(elementType, propertiesToUpdate);
|
|
5820
|
-
if (!valid) {
|
|
5821
|
-
const errorMessage = `Failed to configure element "${elementId}" due to invalid properties: ${errors?.join(
|
|
5822
|
-
"\n- "
|
|
5823
|
-
)}`;
|
|
5824
|
-
throw new Error(errorMessage);
|
|
5825
|
-
}
|
|
5826
5734
|
for (const [propertyName, propertyValue] of toUpdate) {
|
|
5735
|
+
if (!Schema4.isPropKeyConfigurable(propertyName)) {
|
|
5736
|
+
throw new Error(`Not allowed to update ${propertyName}`);
|
|
5737
|
+
}
|
|
5827
5738
|
try {
|
|
5828
5739
|
doUpdateElementProperty({
|
|
5829
5740
|
elementId,
|
|
@@ -5896,7 +5807,7 @@ Provide styling as raw CSS via the "style" parameter (a flat map of CSS property
|
|
|
5896
5807
|
}
|
|
5897
5808
|
|
|
5898
5809
|
// src/mcp/tools/get-element-config/tool.ts
|
|
5899
|
-
import { getContainer as getContainer7, getElementStyles as getElementStyles2, getWidgetsCache as
|
|
5810
|
+
import { getContainer as getContainer7, getElementStyles as getElementStyles2, getWidgetsCache as getWidgetsCache11 } from "@elementor/editor-elements";
|
|
5900
5811
|
import { Schema as Schema5 } from "@elementor/editor-props";
|
|
5901
5812
|
import { z as z3 } from "@elementor/schema";
|
|
5902
5813
|
var schema = {
|
|
@@ -5936,7 +5847,7 @@ var initGetElementConfigTool = (reg) => {
|
|
|
5936
5847
|
throw new Error(`Element with ID ${elementId} not found.`);
|
|
5937
5848
|
}
|
|
5938
5849
|
const elementType = element.model.get("widgetType") || element.model.get("elType") || "";
|
|
5939
|
-
const widgetData =
|
|
5850
|
+
const widgetData = getWidgetsCache11()?.[elementType];
|
|
5940
5851
|
if (!widgetData) {
|
|
5941
5852
|
throw new Error(
|
|
5942
5853
|
`Unknown element type: ${elementType}. Check the available-widgets resource for valid types.`
|
|
@@ -5948,7 +5859,7 @@ var initGetElementConfigTool = (reg) => {
|
|
|
5948
5859
|
);
|
|
5949
5860
|
}
|
|
5950
5861
|
const elementRawSettings = element.settings;
|
|
5951
|
-
const propSchema =
|
|
5862
|
+
const propSchema = getWidgetsCache11()?.[elementType]?.atomic_props_schema;
|
|
5952
5863
|
if (!elementRawSettings || !propSchema) {
|
|
5953
5864
|
throw new Error(`No settings or prop schema found for element ID: ${elementId}`);
|
|
5954
5865
|
}
|
|
@@ -6209,7 +6120,7 @@ import {
|
|
|
6209
6120
|
} from "@elementor/editor-v1-adapters";
|
|
6210
6121
|
|
|
6211
6122
|
// src/utils/command-utils.ts
|
|
6212
|
-
import { getElementLabel as getElementLabel2, getWidgetsCache as
|
|
6123
|
+
import { getElementLabel as getElementLabel2, getWidgetsCache as getWidgetsCache12 } from "@elementor/editor-elements";
|
|
6213
6124
|
import { CLASSES_PROP_KEY } from "@elementor/editor-props";
|
|
6214
6125
|
import { __ as __5 } from "@wordpress/i18n";
|
|
6215
6126
|
function hasAtomicWidgets(args) {
|
|
@@ -6234,7 +6145,7 @@ function getClassesProp(container) {
|
|
|
6234
6145
|
}
|
|
6235
6146
|
function getContainerSchema(container) {
|
|
6236
6147
|
const type = container?.model.get("widgetType") || container?.model.get("elType");
|
|
6237
|
-
const widgetsCache =
|
|
6148
|
+
const widgetsCache = getWidgetsCache12();
|
|
6238
6149
|
const elementType = widgetsCache?.[type];
|
|
6239
6150
|
return elementType?.atomic_props_schema ?? null;
|
|
6240
6151
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-canvas",
|
|
3
3
|
"description": "Elementor Editor Canvas",
|
|
4
|
-
"version": "4.2.0-
|
|
4
|
+
"version": "4.2.0-945",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -37,26 +37,26 @@
|
|
|
37
37
|
"react-dom": "^18.3.1"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@elementor/editor": "4.2.0-
|
|
40
|
+
"@elementor/editor": "4.2.0-945",
|
|
41
41
|
"dompurify": "^3.2.6",
|
|
42
|
-
"@elementor/editor-controls": "4.2.0-
|
|
43
|
-
"@elementor/editor-documents": "4.2.0-
|
|
44
|
-
"@elementor/editor-elements": "4.2.0-
|
|
45
|
-
"@elementor/editor-interactions": "4.2.0-
|
|
46
|
-
"@elementor/editor-mcp": "4.2.0-
|
|
47
|
-
"@elementor/editor-notifications": "4.2.0-
|
|
48
|
-
"@elementor/editor-props": "4.2.0-
|
|
49
|
-
"@elementor/editor-responsive": "4.2.0-
|
|
50
|
-
"@elementor/editor-styles": "4.2.0-
|
|
51
|
-
"@elementor/editor-styles-repository": "4.2.0-
|
|
52
|
-
"@elementor/editor-ui": "4.2.0-
|
|
53
|
-
"@elementor/editor-v1-adapters": "4.2.0-
|
|
54
|
-
"@elementor/http-client": "4.2.0-
|
|
55
|
-
"@elementor/schema": "4.2.0-
|
|
56
|
-
"@elementor/twing": "4.2.0-
|
|
42
|
+
"@elementor/editor-controls": "4.2.0-945",
|
|
43
|
+
"@elementor/editor-documents": "4.2.0-945",
|
|
44
|
+
"@elementor/editor-elements": "4.2.0-945",
|
|
45
|
+
"@elementor/editor-interactions": "4.2.0-945",
|
|
46
|
+
"@elementor/editor-mcp": "4.2.0-945",
|
|
47
|
+
"@elementor/editor-notifications": "4.2.0-945",
|
|
48
|
+
"@elementor/editor-props": "4.2.0-945",
|
|
49
|
+
"@elementor/editor-responsive": "4.2.0-945",
|
|
50
|
+
"@elementor/editor-styles": "4.2.0-945",
|
|
51
|
+
"@elementor/editor-styles-repository": "4.2.0-945",
|
|
52
|
+
"@elementor/editor-ui": "4.2.0-945",
|
|
53
|
+
"@elementor/editor-v1-adapters": "4.2.0-945",
|
|
54
|
+
"@elementor/http-client": "4.2.0-945",
|
|
55
|
+
"@elementor/schema": "4.2.0-945",
|
|
56
|
+
"@elementor/twing": "4.2.0-945",
|
|
57
57
|
"@elementor/ui": "1.37.5",
|
|
58
|
-
"@elementor/utils": "4.2.0-
|
|
59
|
-
"@elementor/wp-media": "4.2.0-
|
|
58
|
+
"@elementor/utils": "4.2.0-945",
|
|
59
|
+
"@elementor/wp-media": "4.2.0-945",
|
|
60
60
|
"@floating-ui/react": "^0.27.5",
|
|
61
61
|
"@wordpress/i18n": "^5.13.0"
|
|
62
62
|
},
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { getContainer, getWidgetsCache } from '@elementor/editor-elements';
|
|
2
2
|
import { type MCPRegistryEntry } from '@elementor/editor-mcp';
|
|
3
|
-
import { type PropValue } from '@elementor/editor-props';
|
|
3
|
+
import { type PropValue, Schema } from '@elementor/editor-props';
|
|
4
4
|
|
|
5
5
|
import { DYNAMIC_TAGS_URI } from '../../resources/dynamic-tags-resource';
|
|
6
6
|
import { WIDGET_SCHEMA_URI } from '../../resources/widgets-schema-resource';
|
|
7
7
|
import { convertCssToAtomic } from '../../utils/convert-css-to-atomic';
|
|
8
8
|
import { doUpdateElementProperty } from '../../utils/do-update-element-property';
|
|
9
9
|
import { resolveCanonicalPropKeys } from '../../utils/resolve-canonical-prop-name';
|
|
10
|
-
import { validateInput } from '../../utils/validate-input';
|
|
11
10
|
import { CONFIGURE_ELEMENT_GUIDE_URI, generatePrompt } from './prompt';
|
|
12
11
|
import { inputSchema as schema, outputSchema } from './schema';
|
|
13
12
|
|
|
@@ -61,14 +60,10 @@ export const initConfigureElementTool = ( reg: MCPRegistryEntry ) => {
|
|
|
61
60
|
}
|
|
62
61
|
const propertiesToUpdate = resolveCanonicalPropKeys( elementType, propertiesToChange );
|
|
63
62
|
const toUpdate = Object.entries( propertiesToUpdate );
|
|
64
|
-
const { valid, errors } = validateInput.validatePropSchema( elementType, propertiesToUpdate );
|
|
65
|
-
if ( ! valid ) {
|
|
66
|
-
const errorMessage = `Failed to configure element "${ elementId }" due to invalid properties: ${ errors?.join(
|
|
67
|
-
'\n- '
|
|
68
|
-
) }`;
|
|
69
|
-
throw new Error( errorMessage );
|
|
70
|
-
}
|
|
71
63
|
for ( const [ propertyName, propertyValue ] of toUpdate as [ string, PropValue ][] ) {
|
|
64
|
+
if ( ! Schema.isPropKeyConfigurable( propertyName ) ) {
|
|
65
|
+
throw new Error( `Not allowed to update ${ propertyName }` );
|
|
66
|
+
}
|
|
72
67
|
try {
|
|
73
68
|
doUpdateElementProperty( {
|
|
74
69
|
elementId,
|