@elementor/editor-canvas 4.1.0-801 → 4.1.0-803
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 +625 -95
- package/dist/index.mjs +575 -40
- package/package.json +18 -18
- package/src/mcp/canvas-mcp.ts +8 -0
- package/src/mcp/resources/available-widgets-resource.ts +67 -0
- package/src/mcp/resources/document-structure-resource.ts +51 -36
- package/src/mcp/resources/editor-state-resource.ts +122 -0
- package/src/mcp/resources/general-context-resource.ts +99 -0
- package/src/mcp/resources/selected-element-resource.ts +217 -0
- package/src/mcp/resources/widgets-schema-resource.ts +71 -6
- package/src/mcp/tools/build-composition/prompt.ts +6 -0
- package/src/mcp/tools/build-composition/tool.ts +26 -0
- package/src/mcp/tools/configure-element/tool.ts +12 -0
- package/src/mcp/tools/get-element-config/tool.ts +13 -3
- package/src/mcp/utils/element-data-util.ts +46 -0
- package/src/mcp/utils/generate-available-tags.ts +0 -23
package/dist/index.js
CHANGED
|
@@ -102,10 +102,79 @@ var initBreakpointsResource = (reg) => {
|
|
|
102
102
|
};
|
|
103
103
|
|
|
104
104
|
// src/mcp/resources/widgets-schema-resource.ts
|
|
105
|
-
var
|
|
105
|
+
var import_editor_elements2 = require("@elementor/editor-elements");
|
|
106
106
|
var import_editor_mcp = require("@elementor/editor-mcp");
|
|
107
107
|
var import_editor_props = require("@elementor/editor-props");
|
|
108
108
|
var import_editor_styles = require("@elementor/editor-styles");
|
|
109
|
+
|
|
110
|
+
// src/mcp/utils/element-data-util.ts
|
|
111
|
+
var import_editor_elements = require("@elementor/editor-elements");
|
|
112
|
+
function hasV3Controls(controls) {
|
|
113
|
+
return typeof controls === "object" && controls !== null && Object.keys(controls).length > 0;
|
|
114
|
+
}
|
|
115
|
+
function isWidgetAvailableForLLM(config) {
|
|
116
|
+
if (!config) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
if (config.meta?.llm_support === false) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
if (config.atomic_props_schema) {
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
return hasV3Controls(config.controls);
|
|
126
|
+
}
|
|
127
|
+
function getWidgetVersion(config) {
|
|
128
|
+
return config?.atomic_props_schema ? "v4" : "v3";
|
|
129
|
+
}
|
|
130
|
+
function getAvailableWidgets() {
|
|
131
|
+
const cache = (0, import_editor_elements.getWidgetsCache)() ?? {};
|
|
132
|
+
return Object.keys(cache).filter((widgetType) => isWidgetAvailableForLLM(cache[widgetType])).sort().map((widgetType) => {
|
|
133
|
+
const config = cache[widgetType];
|
|
134
|
+
const description = typeof config?.meta?.description === "string" ? config.meta.description : void 0;
|
|
135
|
+
return {
|
|
136
|
+
type: widgetType,
|
|
137
|
+
version: getWidgetVersion(config),
|
|
138
|
+
...description && { description }
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// src/mcp/resources/widgets-schema-resource.ts
|
|
144
|
+
var V3_LAYOUT_CONTROL_TYPES = /* @__PURE__ */ new Set(["section", "tab", "tabs"]);
|
|
145
|
+
function extractV3ControlsMetadata(controls) {
|
|
146
|
+
if (!hasV3Controls(controls)) {
|
|
147
|
+
return {};
|
|
148
|
+
}
|
|
149
|
+
const result = {};
|
|
150
|
+
for (const [controlKey, raw] of Object.entries(controls)) {
|
|
151
|
+
if (!raw || typeof raw !== "object") {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
const control = raw;
|
|
155
|
+
const controlType = typeof control.type === "string" ? control.type : void 0;
|
|
156
|
+
if (controlType && V3_LAYOUT_CONTROL_TYPES.has(controlType)) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
const entry = {};
|
|
160
|
+
if (Object.prototype.hasOwnProperty.call(control, "default")) {
|
|
161
|
+
entry.default = control.default;
|
|
162
|
+
}
|
|
163
|
+
if (controlType) {
|
|
164
|
+
entry.type = controlType;
|
|
165
|
+
}
|
|
166
|
+
if (Object.prototype.hasOwnProperty.call(control, "options") && control.options !== void 0) {
|
|
167
|
+
const options = control.options;
|
|
168
|
+
if (options && typeof options === "object" && !Array.isArray(options)) {
|
|
169
|
+
entry.options = Object.keys(options);
|
|
170
|
+
} else {
|
|
171
|
+
entry.options = options;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
result[controlKey] = entry;
|
|
175
|
+
}
|
|
176
|
+
return result;
|
|
177
|
+
}
|
|
109
178
|
var WIDGET_SCHEMA_URI = "elementor://widgets/schema/{widgetType}";
|
|
110
179
|
var STYLE_SCHEMA_URI = "elementor://styles/schema/{category}";
|
|
111
180
|
var BEST_PRACTICES_URI = "elementor://styles/best-practices";
|
|
@@ -153,7 +222,7 @@ Variables from the user context ARE NOT SUPPORTED AND WILL RESOLVE IN ERROR.
|
|
|
153
222
|
}
|
|
154
223
|
}),
|
|
155
224
|
{
|
|
156
|
-
description: "Common styles schema for the specified category"
|
|
225
|
+
description: "Common styles schema for the specified category (applicable for V4 elements only)"
|
|
157
226
|
},
|
|
158
227
|
async (uri, variables) => {
|
|
159
228
|
const category = typeof variables.category === "string" ? variables.category : variables.category?.[0];
|
|
@@ -179,9 +248,9 @@ Variables from the user context ARE NOT SUPPORTED AND WILL RESOLVE IN ERROR.
|
|
|
179
248
|
"widget-schema-by-type",
|
|
180
249
|
new import_editor_mcp.ResourceTemplate(WIDGET_SCHEMA_URI, {
|
|
181
250
|
list: () => {
|
|
182
|
-
const cache = (0,
|
|
183
|
-
const availableWidgets = Object.keys(cache
|
|
184
|
-
(widgetType) => cache[widgetType]
|
|
251
|
+
const cache = (0, import_editor_elements2.getWidgetsCache)() || {};
|
|
252
|
+
const availableWidgets = Object.keys(cache).filter(
|
|
253
|
+
(widgetType) => isWidgetAvailableForLLM(cache[widgetType])
|
|
185
254
|
);
|
|
186
255
|
return {
|
|
187
256
|
resources: availableWidgets.map((widgetType) => ({
|
|
@@ -196,11 +265,31 @@ Variables from the user context ARE NOT SUPPORTED AND WILL RESOLVE IN ERROR.
|
|
|
196
265
|
},
|
|
197
266
|
async (uri, variables) => {
|
|
198
267
|
const widgetType = typeof variables.widgetType === "string" ? variables.widgetType : variables.widgetType?.[0];
|
|
199
|
-
const widgetData = (0,
|
|
200
|
-
|
|
201
|
-
if (!propSchema || !widgetData) {
|
|
268
|
+
const widgetData = (0, import_editor_elements2.getWidgetsCache)()?.[widgetType];
|
|
269
|
+
if (!widgetData) {
|
|
202
270
|
throw new Error(`No prop schema found for element type: ${widgetType}`);
|
|
203
271
|
}
|
|
272
|
+
const propSchema = widgetData.atomic_props_schema;
|
|
273
|
+
if (!propSchema) {
|
|
274
|
+
if (!hasV3Controls(widgetData.controls)) {
|
|
275
|
+
throw new Error(`No prop schema found for element type: ${widgetType}`);
|
|
276
|
+
}
|
|
277
|
+
const controlMetadata = extractV3ControlsMetadata(widgetData.controls);
|
|
278
|
+
return {
|
|
279
|
+
contents: [
|
|
280
|
+
{
|
|
281
|
+
uri: uri.toString(),
|
|
282
|
+
mimeType: "application/json",
|
|
283
|
+
text: JSON.stringify({
|
|
284
|
+
widget_version: "v3",
|
|
285
|
+
message: "This widget exists in the editor but has no atomic props schema (V4). Use control_metadata as non-authoritative hints from legacy controls.",
|
|
286
|
+
fields_note: "All settings are optional; there is no JSON schema for this widget type.",
|
|
287
|
+
properties: controlMetadata
|
|
288
|
+
})
|
|
289
|
+
}
|
|
290
|
+
]
|
|
291
|
+
};
|
|
292
|
+
}
|
|
204
293
|
const asJson = Object.fromEntries(
|
|
205
294
|
Object.entries(propSchema).map(([key, propType]) => [
|
|
206
295
|
key,
|
|
@@ -229,7 +318,7 @@ Variables from the user context ARE NOT SUPPORTED AND WILL RESOLVE IN ERROR.
|
|
|
229
318
|
llmGuidance.default_styles = defaultStyles;
|
|
230
319
|
}
|
|
231
320
|
const allowedChildTypes = widgetData.allowed_child_types;
|
|
232
|
-
const allWidgets = (0,
|
|
321
|
+
const allWidgets = (0, import_editor_elements2.getWidgetsCache)() || {};
|
|
233
322
|
const allowedParents = Object.entries(allWidgets).filter(([, parentConfig]) => parentConfig.allowed_child_types?.includes(widgetType)).map(([parentType]) => parentType);
|
|
234
323
|
if (allowedChildTypes?.length || allowedParents.length) {
|
|
235
324
|
llmGuidance.nesting = {
|
|
@@ -303,7 +392,7 @@ var renameClass = (oldClassName, newClassName) => {
|
|
|
303
392
|
|
|
304
393
|
// src/components/elements-overlays.tsx
|
|
305
394
|
var React2 = __toESM(require("react"));
|
|
306
|
-
var
|
|
395
|
+
var import_editor_elements3 = require("@elementor/editor-elements");
|
|
307
396
|
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
308
397
|
|
|
309
398
|
// src/components/outline-overlay.tsx
|
|
@@ -444,7 +533,7 @@ var overlayRegistry = [
|
|
|
444
533
|
}
|
|
445
534
|
];
|
|
446
535
|
function ElementsOverlays() {
|
|
447
|
-
const selected = (0,
|
|
536
|
+
const selected = (0, import_editor_elements3.useSelectedElement)();
|
|
448
537
|
const elements = useElementsDom();
|
|
449
538
|
const currentEditMode = (0, import_editor_v1_adapters2.useEditMode)();
|
|
450
539
|
const isEditMode = currentEditMode === "edit";
|
|
@@ -473,7 +562,7 @@ function useElementsDom() {
|
|
|
473
562
|
return (0, import_editor_v1_adapters2.__privateUseListenTo)(
|
|
474
563
|
[(0, import_editor_v1_adapters2.windowEvent)("elementor/editor/element-rendered"), (0, import_editor_v1_adapters2.windowEvent)("elementor/editor/element-destroyed")],
|
|
475
564
|
() => {
|
|
476
|
-
return (0,
|
|
565
|
+
return (0, import_editor_elements3.getElements)().filter((el) => ELEMENTS_DATA_ATTR in (el.view?.el?.dataset ?? {})).map((element) => ({
|
|
477
566
|
id: element.id,
|
|
478
567
|
domElement: element.view?.getDomElement?.()?.get?.(0),
|
|
479
568
|
isGlobal: element.model.get("isGlobal") ?? false
|
|
@@ -1204,7 +1293,7 @@ var import_editor_v1_adapters10 = require("@elementor/editor-v1-adapters");
|
|
|
1204
1293
|
var import_i18n = require("@wordpress/i18n");
|
|
1205
1294
|
|
|
1206
1295
|
// src/form-structure/utils.ts
|
|
1207
|
-
var
|
|
1296
|
+
var import_editor_elements4 = require("@elementor/editor-elements");
|
|
1208
1297
|
var FORM_ELEMENT_TYPE = "e-form";
|
|
1209
1298
|
var FORM_FIELD_ELEMENT_TYPES = /* @__PURE__ */ new Set([
|
|
1210
1299
|
"e-form-input",
|
|
@@ -1230,10 +1319,10 @@ function isWithinForm(element) {
|
|
|
1230
1319
|
return isElementWithinFormSelector(element);
|
|
1231
1320
|
}
|
|
1232
1321
|
function hasElementType(element, type) {
|
|
1233
|
-
return (0,
|
|
1322
|
+
return (0, import_editor_elements4.getAllDescendants)(element).some((item) => getElementType(item) === type);
|
|
1234
1323
|
}
|
|
1235
1324
|
function hasElementTypes(element, types) {
|
|
1236
|
-
return (0,
|
|
1325
|
+
return (0, import_editor_elements4.getAllDescendants)(element).some((item) => {
|
|
1237
1326
|
const itemType = getElementType(item);
|
|
1238
1327
|
return itemType ? types.has(itemType) : false;
|
|
1239
1328
|
});
|
|
@@ -1910,7 +1999,7 @@ function initStyleTransformers() {
|
|
|
1910
1999
|
}
|
|
1911
2000
|
|
|
1912
2001
|
// src/legacy/init-legacy-views.ts
|
|
1913
|
-
var
|
|
2002
|
+
var import_editor_elements7 = require("@elementor/editor-elements");
|
|
1914
2003
|
var import_editor_v1_adapters13 = require("@elementor/editor-v1-adapters");
|
|
1915
2004
|
|
|
1916
2005
|
// src/renderers/create-dom-renderer.ts
|
|
@@ -2039,7 +2128,7 @@ function createElementViewClassDeclaration() {
|
|
|
2039
2128
|
}
|
|
2040
2129
|
|
|
2041
2130
|
// src/legacy/create-nested-templated-element-type.ts
|
|
2042
|
-
var
|
|
2131
|
+
var import_editor_elements5 = require("@elementor/editor-elements");
|
|
2043
2132
|
|
|
2044
2133
|
// src/legacy/twig-rendering-utils.ts
|
|
2045
2134
|
function setupTwigRenderer({ renderer, element }) {
|
|
@@ -2297,7 +2386,7 @@ function createNestedTemplatedElementView({
|
|
|
2297
2386
|
this._initAlpine();
|
|
2298
2387
|
});
|
|
2299
2388
|
this.model.trigger("render:complete");
|
|
2300
|
-
window.dispatchEvent(new CustomEvent(
|
|
2389
|
+
window.dispatchEvent(new CustomEvent(import_editor_elements5.ELEMENT_STYLE_CHANGE_EVENT));
|
|
2301
2390
|
},
|
|
2302
2391
|
async _renderTemplate() {
|
|
2303
2392
|
const model = this.model;
|
|
@@ -2533,7 +2622,7 @@ var import_client = require("react-dom/client");
|
|
|
2533
2622
|
|
|
2534
2623
|
// src/legacy/replacements/inline-editing/inline-editing-elements.tsx
|
|
2535
2624
|
var React6 = __toESM(require("react"));
|
|
2536
|
-
var
|
|
2625
|
+
var import_editor_elements6 = require("@elementor/editor-elements");
|
|
2537
2626
|
var import_editor_props4 = require("@elementor/editor-props");
|
|
2538
2627
|
var import_editor_v1_adapters12 = require("@elementor/editor-v1-adapters");
|
|
2539
2628
|
var import_i18n3 = require("@wordpress/i18n");
|
|
@@ -2909,7 +2998,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
2909
2998
|
return INLINE_EDITING_PROPERTY_PER_TYPE[this.type] ?? "";
|
|
2910
2999
|
}
|
|
2911
3000
|
getInlineEditablePropType() {
|
|
2912
|
-
const propSchema = (0,
|
|
3001
|
+
const propSchema = (0, import_editor_elements6.getElementType)(this.type)?.propsSchema;
|
|
2913
3002
|
const propertyName = this.getInlineEditablePropertyName();
|
|
2914
3003
|
return propSchema?.[propertyName] ?? null;
|
|
2915
3004
|
}
|
|
@@ -2943,7 +3032,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
2943
3032
|
}
|
|
2944
3033
|
},
|
|
2945
3034
|
{
|
|
2946
|
-
title: (0,
|
|
3035
|
+
title: (0, import_editor_elements6.getElementLabel)(this.id),
|
|
2947
3036
|
// translators: %s is the name of the property that was edited.
|
|
2948
3037
|
subtitle: (0, import_i18n3.__)("%s edited", "elementor").replace(
|
|
2949
3038
|
"%s",
|
|
@@ -2976,7 +3065,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
2976
3065
|
(0, import_editor_v1_adapters12.__privateRunCommandSync)(
|
|
2977
3066
|
"document/elements/set-settings",
|
|
2978
3067
|
{
|
|
2979
|
-
container: (0,
|
|
3068
|
+
container: (0, import_editor_elements6.getContainer)(this.id),
|
|
2980
3069
|
settings: {
|
|
2981
3070
|
[key]: value
|
|
2982
3071
|
}
|
|
@@ -2991,7 +3080,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
2991
3080
|
return import_editor_props4.stringPropTypeUtil.extract(this.getSetting(tagSettingKey) ?? null) ?? import_editor_props4.stringPropTypeUtil.extract(tagPropType?.default ?? null) ?? null;
|
|
2992
3081
|
}
|
|
2993
3082
|
getTagPropType() {
|
|
2994
|
-
const propsSchema = (0,
|
|
3083
|
+
const propsSchema = (0, import_editor_elements6.getElementType)(this.type)?.propsSchema;
|
|
2995
3084
|
if (!propsSchema?.tag) {
|
|
2996
3085
|
return null;
|
|
2997
3086
|
}
|
|
@@ -3151,7 +3240,7 @@ function registerElementType(type, elementTypeGenerator) {
|
|
|
3151
3240
|
}
|
|
3152
3241
|
function initLegacyViews() {
|
|
3153
3242
|
(0, import_editor_v1_adapters13.__privateListenTo)((0, import_editor_v1_adapters13.v1ReadyEvent)(), () => {
|
|
3154
|
-
const widgetsCache = (0,
|
|
3243
|
+
const widgetsCache = (0, import_editor_elements7.getWidgetsCache)() ?? {};
|
|
3155
3244
|
const legacyWindow = window;
|
|
3156
3245
|
const renderer = createDomRenderer();
|
|
3157
3246
|
registerProPromotionTypes(widgetsCache);
|
|
@@ -3237,8 +3326,66 @@ function initTabsModelExtensions() {
|
|
|
3237
3326
|
registerModelExtensions("e-tab", tabModelExtensions);
|
|
3238
3327
|
}
|
|
3239
3328
|
|
|
3240
|
-
// src/mcp/resources/
|
|
3329
|
+
// src/mcp/resources/available-widgets-resource.ts
|
|
3241
3330
|
var import_editor_v1_adapters14 = require("@elementor/editor-v1-adapters");
|
|
3331
|
+
var AVAILABLE_WIDGETS_URI = "elementor://context/available-widgets";
|
|
3332
|
+
var AVAILABLE_WIDGETS_URI_V4 = "elementor://context/available-widgets/v4";
|
|
3333
|
+
var initAvailableWidgetsResource = (reg) => {
|
|
3334
|
+
const { resource, sendResourceUpdated } = reg;
|
|
3335
|
+
const buildContents = (uri, filterFunction = () => true) => {
|
|
3336
|
+
const widgets = getAvailableWidgets().filter(filterFunction);
|
|
3337
|
+
return {
|
|
3338
|
+
contents: [
|
|
3339
|
+
{
|
|
3340
|
+
uri,
|
|
3341
|
+
mimeType: "application/json",
|
|
3342
|
+
text: JSON.stringify(widgets, null, 2)
|
|
3343
|
+
}
|
|
3344
|
+
]
|
|
3345
|
+
};
|
|
3346
|
+
};
|
|
3347
|
+
const notifyResourcesUpdated = () => {
|
|
3348
|
+
sendResourceUpdated({
|
|
3349
|
+
uri: AVAILABLE_WIDGETS_URI,
|
|
3350
|
+
...buildContents(AVAILABLE_WIDGETS_URI)
|
|
3351
|
+
});
|
|
3352
|
+
sendResourceUpdated({
|
|
3353
|
+
uri: AVAILABLE_WIDGETS_URI_V4,
|
|
3354
|
+
...buildContents(AVAILABLE_WIDGETS_URI_V4, (w) => w.version === "v4")
|
|
3355
|
+
});
|
|
3356
|
+
};
|
|
3357
|
+
resource(
|
|
3358
|
+
"available-widgets-v4",
|
|
3359
|
+
AVAILABLE_WIDGETS_URI_V4,
|
|
3360
|
+
{
|
|
3361
|
+
description: "All registered v4 version widgets"
|
|
3362
|
+
},
|
|
3363
|
+
async () => buildContents(AVAILABLE_WIDGETS_URI_V4, (w) => w.version === "v4")
|
|
3364
|
+
);
|
|
3365
|
+
resource(
|
|
3366
|
+
"available-widgets",
|
|
3367
|
+
AVAILABLE_WIDGETS_URI,
|
|
3368
|
+
{
|
|
3369
|
+
description: "All registered widget types with v3/v4 version metadata and description."
|
|
3370
|
+
},
|
|
3371
|
+
async () => buildContents(AVAILABLE_WIDGETS_URI)
|
|
3372
|
+
);
|
|
3373
|
+
const eventName = (0, import_editor_v1_adapters14.v1ReadyEvent)().name;
|
|
3374
|
+
const onV1Ready = () => {
|
|
3375
|
+
const widgets = getAvailableWidgets();
|
|
3376
|
+
if (widgets.length === 0) {
|
|
3377
|
+
return;
|
|
3378
|
+
}
|
|
3379
|
+
window.removeEventListener(eventName, onV1Ready);
|
|
3380
|
+
notifyResourcesUpdated();
|
|
3381
|
+
};
|
|
3382
|
+
window.addEventListener(eventName, onV1Ready);
|
|
3383
|
+
onV1Ready();
|
|
3384
|
+
};
|
|
3385
|
+
|
|
3386
|
+
// src/mcp/resources/document-structure-resource.ts
|
|
3387
|
+
var import_editor_elements8 = require("@elementor/editor-elements");
|
|
3388
|
+
var import_editor_v1_adapters15 = require("@elementor/editor-v1-adapters");
|
|
3242
3389
|
var DOCUMENT_STRUCTURE_URI = "elementor://document/structure";
|
|
3243
3390
|
var initDocumentStructureResource = (reg) => {
|
|
3244
3391
|
const { resource, sendResourceUpdated } = reg;
|
|
@@ -3251,14 +3398,15 @@ var initDocumentStructureResource = (reg) => {
|
|
|
3251
3398
|
sendResourceUpdated({ uri: DOCUMENT_STRUCTURE_URI });
|
|
3252
3399
|
}
|
|
3253
3400
|
};
|
|
3254
|
-
(0,
|
|
3401
|
+
(0, import_editor_v1_adapters15.__privateListenTo)(
|
|
3255
3402
|
[
|
|
3256
|
-
(0,
|
|
3257
|
-
(0,
|
|
3258
|
-
(0,
|
|
3259
|
-
(0,
|
|
3260
|
-
(0,
|
|
3261
|
-
(0,
|
|
3403
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("document/elements/create"),
|
|
3404
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("document/elements/delete"),
|
|
3405
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("document/elements/move"),
|
|
3406
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("document/elements/copy"),
|
|
3407
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("document/elements/paste"),
|
|
3408
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("editor/documents/attach-preview"),
|
|
3409
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("editor/documents/switch")
|
|
3262
3410
|
],
|
|
3263
3411
|
updateDocumentStructure
|
|
3264
3412
|
);
|
|
@@ -3288,9 +3436,7 @@ function getDocumentStructure() {
|
|
|
3288
3436
|
return { error: "No active document found" };
|
|
3289
3437
|
}
|
|
3290
3438
|
const containers = document2.container?.children || [];
|
|
3291
|
-
const elements = containers.map(
|
|
3292
|
-
(container) => extractElementData(container)
|
|
3293
|
-
);
|
|
3439
|
+
const elements = containers.map((container) => extractElementData(container));
|
|
3294
3440
|
return {
|
|
3295
3441
|
documentId: document2.id,
|
|
3296
3442
|
documentType: document2.config.type,
|
|
@@ -3298,6 +3444,16 @@ function getDocumentStructure() {
|
|
|
3298
3444
|
elements: elements.filter((el) => el !== null)
|
|
3299
3445
|
};
|
|
3300
3446
|
}
|
|
3447
|
+
function resolveElementVersion(element) {
|
|
3448
|
+
if (element.model?.config?.atomic) {
|
|
3449
|
+
return "v4";
|
|
3450
|
+
}
|
|
3451
|
+
const widgetType = element.model?.attributes?.widgetType;
|
|
3452
|
+
if (widgetType && (0, import_editor_elements8.getWidgetsCache)()?.[widgetType]?.atomic_props_schema) {
|
|
3453
|
+
return "v4";
|
|
3454
|
+
}
|
|
3455
|
+
return "v3";
|
|
3456
|
+
}
|
|
3301
3457
|
function extractElementData(element) {
|
|
3302
3458
|
if (!element || !element.model) {
|
|
3303
3459
|
return null;
|
|
@@ -3306,7 +3462,8 @@ function extractElementData(element) {
|
|
|
3306
3462
|
const result = {
|
|
3307
3463
|
id: model.id,
|
|
3308
3464
|
elType: model.elType,
|
|
3309
|
-
widgetType: model.widgetType || void 0
|
|
3465
|
+
widgetType: model.widgetType || void 0,
|
|
3466
|
+
version: resolveElementVersion(element)
|
|
3310
3467
|
};
|
|
3311
3468
|
const title = model.title || element.model?.editor_settings?.title;
|
|
3312
3469
|
if (title) {
|
|
@@ -3318,15 +3475,330 @@ function extractElementData(element) {
|
|
|
3318
3475
|
return result;
|
|
3319
3476
|
}
|
|
3320
3477
|
|
|
3478
|
+
// src/mcp/resources/editor-state-resource.ts
|
|
3479
|
+
var import_editor_v1_adapters16 = require("@elementor/editor-v1-adapters");
|
|
3480
|
+
var CURRENTLY_VIEWED_SCREEN = "The user is currently viewing the Elementor editor";
|
|
3481
|
+
var PAGE_CONTENT_CHARACTER_LIMIT = 500;
|
|
3482
|
+
var PREVIEW_TEXT_NODE_MIN_LENGTH = 2;
|
|
3483
|
+
var EDITOR_STATE_URI = "elementor://context/editor-state";
|
|
3484
|
+
var initEditorStateResource = (reg) => {
|
|
3485
|
+
const { resource, sendResourceUpdated } = reg;
|
|
3486
|
+
let lastSerializedState = "";
|
|
3487
|
+
const buildState = () => ({
|
|
3488
|
+
currentlyViewedScreen: CURRENTLY_VIEWED_SCREEN,
|
|
3489
|
+
pageContent: getPageContentFromPreview(),
|
|
3490
|
+
pageTitle: getPageTitle()
|
|
3491
|
+
});
|
|
3492
|
+
const notifyIfChanged = () => {
|
|
3493
|
+
const serialized = JSON.stringify(buildState());
|
|
3494
|
+
if (serialized === lastSerializedState) {
|
|
3495
|
+
return;
|
|
3496
|
+
}
|
|
3497
|
+
lastSerializedState = serialized;
|
|
3498
|
+
sendResourceUpdated({ uri: EDITOR_STATE_URI });
|
|
3499
|
+
};
|
|
3500
|
+
(0, import_editor_v1_adapters16.__privateListenTo)(
|
|
3501
|
+
[(0, import_editor_v1_adapters16.commandEndEvent)("editor/documents/switch"), (0, import_editor_v1_adapters16.commandEndEvent)("editor/documents/attach-preview")],
|
|
3502
|
+
notifyIfChanged
|
|
3503
|
+
);
|
|
3504
|
+
lastSerializedState = JSON.stringify(buildState());
|
|
3505
|
+
resource(
|
|
3506
|
+
"editor-state",
|
|
3507
|
+
EDITOR_STATE_URI,
|
|
3508
|
+
{
|
|
3509
|
+
description: "Editor page title, preview text snapshot, and viewed screen label."
|
|
3510
|
+
},
|
|
3511
|
+
async () => {
|
|
3512
|
+
return {
|
|
3513
|
+
contents: [
|
|
3514
|
+
{
|
|
3515
|
+
uri: EDITOR_STATE_URI,
|
|
3516
|
+
text: JSON.stringify(buildState(), null, 2)
|
|
3517
|
+
}
|
|
3518
|
+
]
|
|
3519
|
+
};
|
|
3520
|
+
}
|
|
3521
|
+
);
|
|
3522
|
+
};
|
|
3523
|
+
function getPageContentFromPreview() {
|
|
3524
|
+
try {
|
|
3525
|
+
const root = window.elementor?.$previewContents?.[0];
|
|
3526
|
+
if (!root) {
|
|
3527
|
+
return null;
|
|
3528
|
+
}
|
|
3529
|
+
const content = [];
|
|
3530
|
+
const clone = root.cloneNode(true);
|
|
3531
|
+
clone.querySelectorAll(".elementor-editor-element-settings, #elementor-add-new-section").forEach((el) => {
|
|
3532
|
+
el.remove();
|
|
3533
|
+
});
|
|
3534
|
+
const walk = (node, insideElementorElement = false) => {
|
|
3535
|
+
const isInside = node.classList?.contains("elementor-element") || insideElementorElement;
|
|
3536
|
+
if (node.nodeType === Node.TEXT_NODE && isInside) {
|
|
3537
|
+
const text2 = node.textContent?.trim().replace(/\s+/g, " ");
|
|
3538
|
+
if (text2 && text2.length > PREVIEW_TEXT_NODE_MIN_LENGTH) {
|
|
3539
|
+
content.push(text2);
|
|
3540
|
+
}
|
|
3541
|
+
} else {
|
|
3542
|
+
node.childNodes.forEach((child) => {
|
|
3543
|
+
walk(child, isInside);
|
|
3544
|
+
});
|
|
3545
|
+
}
|
|
3546
|
+
};
|
|
3547
|
+
walk(clone);
|
|
3548
|
+
const text = content.join(" ");
|
|
3549
|
+
if (text.length > PAGE_CONTENT_CHARACTER_LIMIT) {
|
|
3550
|
+
return text.slice(0, PAGE_CONTENT_CHARACTER_LIMIT) + "...";
|
|
3551
|
+
}
|
|
3552
|
+
return text;
|
|
3553
|
+
} catch {
|
|
3554
|
+
return null;
|
|
3555
|
+
}
|
|
3556
|
+
}
|
|
3557
|
+
function getPageTitle() {
|
|
3558
|
+
try {
|
|
3559
|
+
const extendedWindow = window;
|
|
3560
|
+
const currentDocument = extendedWindow.elementor?.documents?.getCurrent?.();
|
|
3561
|
+
const postTitle = currentDocument?.config?.settings?.post_title;
|
|
3562
|
+
if (postTitle) {
|
|
3563
|
+
return postTitle;
|
|
3564
|
+
}
|
|
3565
|
+
let title = document.title || "Page";
|
|
3566
|
+
title = title.split(/\s*[‹»|–—-]\s*/)[0];
|
|
3567
|
+
const trimmed = title.trim();
|
|
3568
|
+
return trimmed || "Page";
|
|
3569
|
+
} catch {
|
|
3570
|
+
return "Page";
|
|
3571
|
+
}
|
|
3572
|
+
}
|
|
3573
|
+
|
|
3574
|
+
// src/mcp/resources/general-context-resource.ts
|
|
3575
|
+
var import_editor_v1_adapters17 = require("@elementor/editor-v1-adapters");
|
|
3576
|
+
var GENERAL_CONTEXT_URI = "elementor://context/general";
|
|
3577
|
+
var initGeneralContextResource = (reg) => {
|
|
3578
|
+
const { resource, sendResourceUpdated } = reg;
|
|
3579
|
+
let lastSerializedPayload = null;
|
|
3580
|
+
const getPageTitle2 = () => {
|
|
3581
|
+
const extendedWindow = window;
|
|
3582
|
+
const title = extendedWindow.elementor?.documents?.getCurrent?.()?.config?.settings?.post_title;
|
|
3583
|
+
if (!title?.trim()) {
|
|
3584
|
+
return null;
|
|
3585
|
+
}
|
|
3586
|
+
return title;
|
|
3587
|
+
};
|
|
3588
|
+
const buildPayload = () => {
|
|
3589
|
+
const extendedWindow = window;
|
|
3590
|
+
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
3591
|
+
const postParam = new URLSearchParams(location.search).get("post");
|
|
3592
|
+
const parsedPostId = postParam ? Number(postParam) : null;
|
|
3593
|
+
const postId = parsedPostId !== null && Number.isFinite(parsedPostId) ? parsedPostId : null;
|
|
3594
|
+
const pageTitle = getPageTitle2();
|
|
3595
|
+
const urlObject = new URL(window.location.href);
|
|
3596
|
+
const pageUrl = urlObject.pathname + urlObject.search;
|
|
3597
|
+
const pageName = pageTitle || "Elementor Editor";
|
|
3598
|
+
const plugins = extendedWindow.angieConfig?.plugins;
|
|
3599
|
+
return {
|
|
3600
|
+
timezone,
|
|
3601
|
+
postId,
|
|
3602
|
+
currentPage: {
|
|
3603
|
+
pageName,
|
|
3604
|
+
pageTitle,
|
|
3605
|
+
pageUrl
|
|
3606
|
+
},
|
|
3607
|
+
...plugins && { plugins }
|
|
3608
|
+
};
|
|
3609
|
+
};
|
|
3610
|
+
const pushUpdateIfChanged = () => {
|
|
3611
|
+
const serialized = JSON.stringify(buildPayload());
|
|
3612
|
+
if (serialized === lastSerializedPayload) {
|
|
3613
|
+
return;
|
|
3614
|
+
}
|
|
3615
|
+
lastSerializedPayload = serialized;
|
|
3616
|
+
sendResourceUpdated({ uri: GENERAL_CONTEXT_URI });
|
|
3617
|
+
};
|
|
3618
|
+
resource(
|
|
3619
|
+
"general-context",
|
|
3620
|
+
GENERAL_CONTEXT_URI,
|
|
3621
|
+
{
|
|
3622
|
+
description: "General context: timezone, post id, and current page."
|
|
3623
|
+
},
|
|
3624
|
+
async () => {
|
|
3625
|
+
return {
|
|
3626
|
+
contents: [
|
|
3627
|
+
{
|
|
3628
|
+
uri: GENERAL_CONTEXT_URI,
|
|
3629
|
+
mimeType: "application/json",
|
|
3630
|
+
text: JSON.stringify(buildPayload(), null, 2)
|
|
3631
|
+
}
|
|
3632
|
+
]
|
|
3633
|
+
};
|
|
3634
|
+
}
|
|
3635
|
+
);
|
|
3636
|
+
(0, import_editor_v1_adapters17.__privateListenTo)(
|
|
3637
|
+
[
|
|
3638
|
+
(0, import_editor_v1_adapters17.commandEndEvent)("editor/documents/switch"),
|
|
3639
|
+
(0, import_editor_v1_adapters17.commandEndEvent)("editor/documents/attach-preview"),
|
|
3640
|
+
(0, import_editor_v1_adapters17.commandEndEvent)("document/elements/settings")
|
|
3641
|
+
],
|
|
3642
|
+
pushUpdateIfChanged
|
|
3643
|
+
);
|
|
3644
|
+
pushUpdateIfChanged();
|
|
3645
|
+
};
|
|
3646
|
+
|
|
3647
|
+
// src/mcp/resources/selected-element-resource.ts
|
|
3648
|
+
var import_editor_elements9 = require("@elementor/editor-elements");
|
|
3649
|
+
var import_editor_v1_adapters18 = require("@elementor/editor-v1-adapters");
|
|
3650
|
+
var SELECTED_ELEMENT_URI = "elementor://context/selected-element";
|
|
3651
|
+
var initSelectedElementResource = (reg) => {
|
|
3652
|
+
const { resource, sendResourceUpdated } = reg;
|
|
3653
|
+
let currentPayloadText = null;
|
|
3654
|
+
const publishIfChanged = (payload) => {
|
|
3655
|
+
const nextText = JSON.stringify(payload);
|
|
3656
|
+
if (nextText !== currentPayloadText) {
|
|
3657
|
+
currentPayloadText = nextText;
|
|
3658
|
+
sendResourceUpdated({ uri: SELECTED_ELEMENT_URI });
|
|
3659
|
+
}
|
|
3660
|
+
};
|
|
3661
|
+
const onCommand = (e) => {
|
|
3662
|
+
if (e.type !== "command") {
|
|
3663
|
+
return;
|
|
3664
|
+
}
|
|
3665
|
+
const commandEvent = e;
|
|
3666
|
+
if (commandEvent.command === "document/elements/deselect-all") {
|
|
3667
|
+
publishIfChanged(createEmptySelectedElementPayload());
|
|
3668
|
+
return;
|
|
3669
|
+
}
|
|
3670
|
+
if (commandEvent.command !== "document/elements/select" && commandEvent.command !== "document/elements/settings") {
|
|
3671
|
+
return;
|
|
3672
|
+
}
|
|
3673
|
+
const { container } = commandEvent.args || {};
|
|
3674
|
+
if (container?.id) {
|
|
3675
|
+
publishIfChanged(buildPayloadFromContainer(container));
|
|
3676
|
+
return;
|
|
3677
|
+
}
|
|
3678
|
+
publishIfChanged(readSelectionFromEditor());
|
|
3679
|
+
};
|
|
3680
|
+
(0, import_editor_v1_adapters18.__privateListenTo)(
|
|
3681
|
+
[
|
|
3682
|
+
(0, import_editor_v1_adapters18.commandEndEvent)("document/elements/select"),
|
|
3683
|
+
(0, import_editor_v1_adapters18.commandEndEvent)("document/elements/deselect-all"),
|
|
3684
|
+
(0, import_editor_v1_adapters18.commandEndEvent)("document/elements/settings")
|
|
3685
|
+
],
|
|
3686
|
+
onCommand
|
|
3687
|
+
);
|
|
3688
|
+
publishIfChanged(readSelectionFromEditor());
|
|
3689
|
+
resource(
|
|
3690
|
+
"selected-element",
|
|
3691
|
+
SELECTED_ELEMENT_URI,
|
|
3692
|
+
{
|
|
3693
|
+
description: "Currently selected Elementor element context."
|
|
3694
|
+
},
|
|
3695
|
+
async () => {
|
|
3696
|
+
return {
|
|
3697
|
+
contents: [
|
|
3698
|
+
{
|
|
3699
|
+
uri: SELECTED_ELEMENT_URI,
|
|
3700
|
+
text: JSON.stringify(readSelectionFromEditor(), null, 2)
|
|
3701
|
+
}
|
|
3702
|
+
]
|
|
3703
|
+
};
|
|
3704
|
+
}
|
|
3705
|
+
);
|
|
3706
|
+
};
|
|
3707
|
+
function createEmptySelectedElementPayload() {
|
|
3708
|
+
return {
|
|
3709
|
+
elementDisplayName: null,
|
|
3710
|
+
elementType: null,
|
|
3711
|
+
properties: null,
|
|
3712
|
+
selectedElementId: null,
|
|
3713
|
+
selectedParentId: null,
|
|
3714
|
+
version: null,
|
|
3715
|
+
widgetType: null
|
|
3716
|
+
};
|
|
3717
|
+
}
|
|
3718
|
+
function readSelectionFromEditor() {
|
|
3719
|
+
const elements = (0, import_editor_elements9.getSelectedElements)();
|
|
3720
|
+
if (elements.length !== 1) {
|
|
3721
|
+
return createEmptySelectedElementPayload();
|
|
3722
|
+
}
|
|
3723
|
+
const container = (0, import_editor_elements9.getContainer)(elements[0].id);
|
|
3724
|
+
return buildPayloadFromContainer(container);
|
|
3725
|
+
}
|
|
3726
|
+
function buildPayloadFromContainer(container) {
|
|
3727
|
+
if (!container?.id) {
|
|
3728
|
+
return createEmptySelectedElementPayload();
|
|
3729
|
+
}
|
|
3730
|
+
const widgetType = container.model.get("widgetType") ?? null;
|
|
3731
|
+
const elementType = container.type ?? "widget";
|
|
3732
|
+
return {
|
|
3733
|
+
elementDisplayName: getElementDisplayName(container),
|
|
3734
|
+
elementType,
|
|
3735
|
+
properties: getElementProperties(container, widgetType),
|
|
3736
|
+
selectedElementId: container.id,
|
|
3737
|
+
selectedParentId: container.parent?.id ?? null,
|
|
3738
|
+
version: resolveElementVersion2(container, widgetType),
|
|
3739
|
+
widgetType
|
|
3740
|
+
};
|
|
3741
|
+
}
|
|
3742
|
+
function resolveElementVersion2(container, widgetType) {
|
|
3743
|
+
if (container.model?.config?.atomic) {
|
|
3744
|
+
return "v4";
|
|
3745
|
+
}
|
|
3746
|
+
if (widgetType && (0, import_editor_elements9.getWidgetsCache)()?.[widgetType]?.atomic_props_schema) {
|
|
3747
|
+
return "v4";
|
|
3748
|
+
}
|
|
3749
|
+
return "v3";
|
|
3750
|
+
}
|
|
3751
|
+
function getElementProperties(container, widgetType) {
|
|
3752
|
+
const settings = container.settings?.toJSON?.();
|
|
3753
|
+
if (!settings || typeof settings !== "object") {
|
|
3754
|
+
return null;
|
|
3755
|
+
}
|
|
3756
|
+
const widgetConfig = widgetType ? (0, import_editor_elements9.getWidgetsCache)()?.[widgetType] : null;
|
|
3757
|
+
const controls = widgetConfig?.controls;
|
|
3758
|
+
const filtered = {};
|
|
3759
|
+
for (const [key, value] of Object.entries(settings)) {
|
|
3760
|
+
if (value === void 0 || value === null || value === "") {
|
|
3761
|
+
continue;
|
|
3762
|
+
}
|
|
3763
|
+
const controlDefault = controls?.[key]?.default;
|
|
3764
|
+
if (controlDefault !== void 0 && JSON.stringify(value) === JSON.stringify(controlDefault)) {
|
|
3765
|
+
continue;
|
|
3766
|
+
}
|
|
3767
|
+
filtered[key] = value;
|
|
3768
|
+
}
|
|
3769
|
+
return Object.keys(filtered).length > 0 ? filtered : null;
|
|
3770
|
+
}
|
|
3771
|
+
function getElementDisplayName(container) {
|
|
3772
|
+
try {
|
|
3773
|
+
if (container.label) {
|
|
3774
|
+
return container.label;
|
|
3775
|
+
}
|
|
3776
|
+
const widgetType = container.model?.get?.("widgetType");
|
|
3777
|
+
if (widgetType) {
|
|
3778
|
+
const capitalizedType = widgetType.charAt(0).toUpperCase() + widgetType.slice(1);
|
|
3779
|
+
return capitalizedType.replace(/-/g, " ");
|
|
3780
|
+
}
|
|
3781
|
+
if (container.type === "container") {
|
|
3782
|
+
return "Container";
|
|
3783
|
+
}
|
|
3784
|
+
if (container.type === "section") {
|
|
3785
|
+
return "Section";
|
|
3786
|
+
}
|
|
3787
|
+
return `Element ${container.id}`;
|
|
3788
|
+
} catch {
|
|
3789
|
+
return `Element ${container.id}`;
|
|
3790
|
+
}
|
|
3791
|
+
}
|
|
3792
|
+
|
|
3321
3793
|
// src/mcp/tools/build-composition/tool.ts
|
|
3322
3794
|
var import_editor_documents3 = require("@elementor/editor-documents");
|
|
3323
|
-
var
|
|
3795
|
+
var import_editor_elements13 = require("@elementor/editor-elements");
|
|
3324
3796
|
|
|
3325
3797
|
// src/composition-builder/composition-builder.ts
|
|
3326
|
-
var
|
|
3798
|
+
var import_editor_elements12 = require("@elementor/editor-elements");
|
|
3327
3799
|
|
|
3328
3800
|
// src/mcp/utils/do-update-element-property.ts
|
|
3329
|
-
var
|
|
3801
|
+
var import_editor_elements10 = require("@elementor/editor-elements");
|
|
3330
3802
|
var import_editor_props6 = require("@elementor/editor-props");
|
|
3331
3803
|
var import_editor_styles5 = require("@elementor/editor-styles");
|
|
3332
3804
|
function resolvePropValue(value, forceKey) {
|
|
@@ -3339,7 +3811,7 @@ function resolvePropValue(value, forceKey) {
|
|
|
3339
3811
|
var doUpdateElementProperty = (params) => {
|
|
3340
3812
|
const { elementId, propertyName, propertyValue, elementType } = params;
|
|
3341
3813
|
if (propertyName === "_styles") {
|
|
3342
|
-
const elementStyles = (0,
|
|
3814
|
+
const elementStyles = (0, import_editor_elements10.getElementStyles)(elementId) || {};
|
|
3343
3815
|
const propertyMapValue = propertyValue;
|
|
3344
3816
|
const styleSchema = (0, import_editor_styles5.getStylesSchema)();
|
|
3345
3817
|
const transformedStyleValues = Object.fromEntries(
|
|
@@ -3387,7 +3859,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
3387
3859
|
delete transformedStyleValues.custom_css;
|
|
3388
3860
|
const localStyle = Object.values(elementStyles).find((style) => style.label === "local");
|
|
3389
3861
|
if (!localStyle) {
|
|
3390
|
-
(0,
|
|
3862
|
+
(0, import_editor_elements10.createElementStyle)({
|
|
3391
3863
|
elementId,
|
|
3392
3864
|
...typeof customCss !== "undefined" ? { custom_css: customCss } : {},
|
|
3393
3865
|
classesProp: "classes",
|
|
@@ -3401,7 +3873,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
3401
3873
|
}
|
|
3402
3874
|
});
|
|
3403
3875
|
} else {
|
|
3404
|
-
(0,
|
|
3876
|
+
(0, import_editor_elements10.updateElementStyle)({
|
|
3405
3877
|
elementId,
|
|
3406
3878
|
styleId: localStyle.id,
|
|
3407
3879
|
meta: {
|
|
@@ -3416,7 +3888,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
3416
3888
|
}
|
|
3417
3889
|
return;
|
|
3418
3890
|
}
|
|
3419
|
-
const elementPropSchema = (0,
|
|
3891
|
+
const elementPropSchema = (0, import_editor_elements10.getWidgetsCache)()?.[elementType]?.atomic_props_schema;
|
|
3420
3892
|
if (!elementPropSchema) {
|
|
3421
3893
|
throw new Error(`No prop schema found for element type: ${elementType}`);
|
|
3422
3894
|
}
|
|
@@ -3430,7 +3902,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
3430
3902
|
}
|
|
3431
3903
|
const propKey = elementPropSchema[propertyName].key;
|
|
3432
3904
|
const value = resolvePropValue(propertyValue, propKey);
|
|
3433
|
-
(0,
|
|
3905
|
+
(0, import_editor_elements10.updateElementSettings)({
|
|
3434
3906
|
id: elementId,
|
|
3435
3907
|
props: {
|
|
3436
3908
|
[propertyName]: value
|
|
@@ -3440,7 +3912,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
3440
3912
|
};
|
|
3441
3913
|
|
|
3442
3914
|
// src/mcp/utils/validate-input.ts
|
|
3443
|
-
var
|
|
3915
|
+
var import_editor_elements11 = require("@elementor/editor-elements");
|
|
3444
3916
|
var import_editor_props7 = require("@elementor/editor-props");
|
|
3445
3917
|
var import_editor_styles6 = require("@elementor/editor-styles");
|
|
3446
3918
|
var _widgetsSchema = null;
|
|
@@ -3448,7 +3920,7 @@ var validateInput = {
|
|
|
3448
3920
|
get widgetsSchema() {
|
|
3449
3921
|
if (!_widgetsSchema) {
|
|
3450
3922
|
const schema2 = {};
|
|
3451
|
-
const cache = (0,
|
|
3923
|
+
const cache = (0, import_editor_elements11.getWidgetsCache)();
|
|
3452
3924
|
if (!cache) {
|
|
3453
3925
|
return {};
|
|
3454
3926
|
}
|
|
@@ -3531,10 +4003,10 @@ var CompositionBuilder = class _CompositionBuilder {
|
|
|
3531
4003
|
elementCusomCSS = {};
|
|
3532
4004
|
rootContainers = [];
|
|
3533
4005
|
api = {
|
|
3534
|
-
createElement:
|
|
3535
|
-
getWidgetsCache:
|
|
3536
|
-
generateElementId:
|
|
3537
|
-
getContainer:
|
|
4006
|
+
createElement: import_editor_elements12.createElement,
|
|
4007
|
+
getWidgetsCache: import_editor_elements12.getWidgetsCache,
|
|
4008
|
+
generateElementId: import_editor_elements12.generateElementId,
|
|
4009
|
+
getContainer: import_editor_elements12.getContainer,
|
|
3538
4010
|
doUpdateElementProperty
|
|
3539
4011
|
};
|
|
3540
4012
|
xml;
|
|
@@ -3777,6 +4249,10 @@ var generatePrompt = () => {
|
|
|
3777
4249
|
# RESOURCES (Read before use)
|
|
3778
4250
|
- [elementor://global-classes] - Check FIRST for reusable classes
|
|
3779
4251
|
- [elementor://global-variables] - ONLY use variables defined here
|
|
4252
|
+
- [${AVAILABLE_WIDGETS_URI}/v4]
|
|
4253
|
+
|
|
4254
|
+
# TOOL SUUPORT
|
|
4255
|
+
This tool support v4 elements only
|
|
3780
4256
|
|
|
3781
4257
|
# WORKFLOW
|
|
3782
4258
|
1. Check/create global classes via "create-global-class" tool
|
|
@@ -3958,24 +4434,26 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
3958
4434
|
{ description: "Styles schema", uri: STYLE_SCHEMA_URI },
|
|
3959
4435
|
{ description: "Global Classes", uri: "elementor://global-classes" },
|
|
3960
4436
|
{ description: "Global Variables", uri: "elementor://global-variables" },
|
|
3961
|
-
{ description: "Styles best practices", uri: BEST_PRACTICES_URI }
|
|
4437
|
+
{ description: "Styles best practices", uri: BEST_PRACTICES_URI },
|
|
4438
|
+
{ description: "Available widgets for this tool", uri: AVAILABLE_WIDGETS_URI_V4 }
|
|
3962
4439
|
],
|
|
3963
4440
|
outputSchema,
|
|
3964
4441
|
modelPreferences: {
|
|
3965
4442
|
hints: [{ name: "claude-sonnet-4-5" }]
|
|
3966
4443
|
},
|
|
3967
4444
|
handler: async (params) => {
|
|
4445
|
+
assertCompositionXmlUsesV4WidgetsOnly(params.xmlStructure);
|
|
3968
4446
|
const { xmlStructure, elementConfig, stylesConfig, customCSS } = params;
|
|
3969
4447
|
let generatedXML = "";
|
|
3970
4448
|
const errors = [];
|
|
3971
4449
|
const rootContainers = [];
|
|
3972
|
-
const documentContainer = (0,
|
|
4450
|
+
const documentContainer = (0, import_editor_elements13.getContainer)("document");
|
|
3973
4451
|
const currentDocument = (0, import_editor_documents3.getCurrentDocument)();
|
|
3974
4452
|
const targetContainer = getCompositionTargetContainer(documentContainer, currentDocument?.type.value);
|
|
3975
4453
|
try {
|
|
3976
4454
|
const compositionBuilder = CompositionBuilder.fromXMLString(xmlStructure, {
|
|
3977
|
-
createElement:
|
|
3978
|
-
getWidgetsCache:
|
|
4455
|
+
createElement: import_editor_elements13.createElement,
|
|
4456
|
+
getWidgetsCache: import_editor_elements13.getWidgetsCache
|
|
3979
4457
|
});
|
|
3980
4458
|
compositionBuilder.setElementConfig(elementConfig);
|
|
3981
4459
|
compositionBuilder.setStylesConfig(stylesConfig);
|
|
@@ -4003,7 +4481,7 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
4003
4481
|
}
|
|
4004
4482
|
if (errors.length) {
|
|
4005
4483
|
rootContainers.forEach((rootContainer) => {
|
|
4006
|
-
(0,
|
|
4484
|
+
(0, import_editor_elements13.deleteElement)({
|
|
4007
4485
|
container: rootContainer,
|
|
4008
4486
|
options: { useHistory: false }
|
|
4009
4487
|
});
|
|
@@ -4052,6 +4530,31 @@ Remember: Global classes ensure design consistency and reusability. Don't skip a
|
|
|
4052
4530
|
}
|
|
4053
4531
|
});
|
|
4054
4532
|
};
|
|
4533
|
+
function assertCompositionXmlUsesV4WidgetsOnly(xmlStructure) {
|
|
4534
|
+
const doc = new DOMParser().parseFromString(xmlStructure, "application/xml");
|
|
4535
|
+
if (doc.querySelector("parsererror")) {
|
|
4536
|
+
throw new Error("Failed to parse XML string: " + doc);
|
|
4537
|
+
}
|
|
4538
|
+
const widgetsCache = (0, import_editor_elements13.getWidgetsCache)() ?? {};
|
|
4539
|
+
for (const node of doc.querySelectorAll("*")) {
|
|
4540
|
+
const type = node.tagName;
|
|
4541
|
+
const widgetData = widgetsCache[type];
|
|
4542
|
+
if (!widgetData) {
|
|
4543
|
+
continue;
|
|
4544
|
+
}
|
|
4545
|
+
if (widgetData.elType !== "widget") {
|
|
4546
|
+
continue;
|
|
4547
|
+
}
|
|
4548
|
+
if (!widgetData.atomic_props_schema) {
|
|
4549
|
+
throw new Error(
|
|
4550
|
+
`This tool does not support V3 elements. Please use the elementor-v3-mcp tools instead for element type: ${type}`
|
|
4551
|
+
);
|
|
4552
|
+
}
|
|
4553
|
+
}
|
|
4554
|
+
}
|
|
4555
|
+
|
|
4556
|
+
// src/mcp/tools/configure-element/tool.ts
|
|
4557
|
+
var import_editor_elements14 = require("@elementor/editor-elements");
|
|
4055
4558
|
|
|
4056
4559
|
// src/mcp/tools/configure-element/prompt.ts
|
|
4057
4560
|
var configureElementToolPrompt = `Configure an existing element on the page.
|
|
@@ -4191,6 +4694,17 @@ var initConfigureElementTool = (reg) => {
|
|
|
4191
4694
|
speedPriority: 0.7
|
|
4192
4695
|
},
|
|
4193
4696
|
handler: ({ elementId, propertiesToChange, elementType, stylePropertiesToChange }) => {
|
|
4697
|
+
const widgetData = (0, import_editor_elements14.getWidgetsCache)()?.[elementType];
|
|
4698
|
+
if (!widgetData) {
|
|
4699
|
+
throw new Error(
|
|
4700
|
+
`Unknown element type: ${elementType}. Check the available-widgets resource for valid types.`
|
|
4701
|
+
);
|
|
4702
|
+
}
|
|
4703
|
+
if (!widgetData.atomic_props_schema) {
|
|
4704
|
+
throw new Error(
|
|
4705
|
+
`This tool does not support V3 elements. Please use the elementor-v3-mcp tools instead for element type: ${elementType}`
|
|
4706
|
+
);
|
|
4707
|
+
}
|
|
4194
4708
|
const toUpdate = Object.entries(propertiesToChange);
|
|
4195
4709
|
const { valid, errors } = validateInput.validatePropSchema(elementType, propertiesToChange);
|
|
4196
4710
|
const { valid: stylesValid, errors: stylesErrors } = validateInput.validateStyles(
|
|
@@ -4272,7 +4786,7 @@ Check the styles schema at the resource [${STYLE_SCHEMA_URI.replace(
|
|
|
4272
4786
|
}
|
|
4273
4787
|
|
|
4274
4788
|
// src/mcp/tools/get-element-config/tool.ts
|
|
4275
|
-
var
|
|
4789
|
+
var import_editor_elements15 = require("@elementor/editor-elements");
|
|
4276
4790
|
var import_editor_props8 = require("@elementor/editor-props");
|
|
4277
4791
|
var import_schema5 = require("@elementor/schema");
|
|
4278
4792
|
var schema = {
|
|
@@ -4311,12 +4825,24 @@ var initGetElementConfigTool = (reg) => {
|
|
|
4311
4825
|
speedPriority: 0.9
|
|
4312
4826
|
},
|
|
4313
4827
|
handler: async ({ elementId }) => {
|
|
4314
|
-
const element = (0,
|
|
4828
|
+
const element = (0, import_editor_elements15.getContainer)(elementId);
|
|
4315
4829
|
if (!element) {
|
|
4316
4830
|
throw new Error(`Element with ID ${elementId} not found.`);
|
|
4317
4831
|
}
|
|
4832
|
+
const elementType = element.model.get("widgetType") || element.model.get("elType") || "";
|
|
4833
|
+
const widgetData = (0, import_editor_elements15.getWidgetsCache)()?.[elementType];
|
|
4834
|
+
if (!widgetData) {
|
|
4835
|
+
throw new Error(
|
|
4836
|
+
`Unknown element type: ${elementType}. Check the available-widgets resource for valid types.`
|
|
4837
|
+
);
|
|
4838
|
+
}
|
|
4839
|
+
if (!widgetData.atomic_props_schema) {
|
|
4840
|
+
throw new Error(
|
|
4841
|
+
`This tool does not support V3 elements. Please use the elementor-v3-mcp tools instead for element type: ${elementType}`
|
|
4842
|
+
);
|
|
4843
|
+
}
|
|
4318
4844
|
const elementRawSettings = element.settings;
|
|
4319
|
-
const propSchema = (0,
|
|
4845
|
+
const propSchema = (0, import_editor_elements15.getWidgetsCache)()?.[elementType]?.atomic_props_schema;
|
|
4320
4846
|
if (!elementRawSettings || !propSchema) {
|
|
4321
4847
|
throw new Error(`No settings or prop schema found for element ID: ${elementId}`);
|
|
4322
4848
|
}
|
|
@@ -4325,7 +4851,7 @@ var initGetElementConfigTool = (reg) => {
|
|
|
4325
4851
|
import_editor_props8.Schema.configurableKeys(propSchema).forEach((key) => {
|
|
4326
4852
|
propValues[key] = structuredClone(elementRawSettings.get(key));
|
|
4327
4853
|
});
|
|
4328
|
-
const elementStyles = (0,
|
|
4854
|
+
const elementStyles = (0, import_editor_elements15.getElementStyles)(elementId) || {};
|
|
4329
4855
|
const localStyle = Object.values(elementStyles).find((style) => style.label === "local");
|
|
4330
4856
|
if (localStyle) {
|
|
4331
4857
|
const defaultVariant = localStyle.variants.find(
|
|
@@ -4368,7 +4894,11 @@ var initCanvasMcp = (reg) => {
|
|
|
4368
4894
|
`
|
|
4369
4895
|
);
|
|
4370
4896
|
initWidgetsSchemaResource(reg);
|
|
4897
|
+
initAvailableWidgetsResource(reg);
|
|
4371
4898
|
initDocumentStructureResource(reg);
|
|
4899
|
+
initSelectedElementResource(reg);
|
|
4900
|
+
initEditorStateResource(reg);
|
|
4901
|
+
initGeneralContextResource(reg);
|
|
4372
4902
|
initBuildCompositionsTool(reg);
|
|
4373
4903
|
initGetElementConfigTool(reg);
|
|
4374
4904
|
initConfigureElementTool(reg);
|
|
@@ -4488,16 +5018,16 @@ Note: The "size" property controls image resolution/loading, not visual size. Se
|
|
|
4488
5018
|
`;
|
|
4489
5019
|
|
|
4490
5020
|
// src/prevent-link-in-link-commands.ts
|
|
4491
|
-
var
|
|
5021
|
+
var import_editor_elements16 = require("@elementor/editor-elements");
|
|
4492
5022
|
var import_editor_notifications3 = require("@elementor/editor-notifications");
|
|
4493
|
-
var
|
|
5023
|
+
var import_editor_v1_adapters19 = require("@elementor/editor-v1-adapters");
|
|
4494
5024
|
var import_i18n4 = require("@wordpress/i18n");
|
|
4495
5025
|
function initLinkInLinkPrevention() {
|
|
4496
|
-
(0,
|
|
5026
|
+
(0, import_editor_v1_adapters19.blockCommand)({
|
|
4497
5027
|
command: "document/elements/paste",
|
|
4498
5028
|
condition: blockLinkInLinkPaste
|
|
4499
5029
|
});
|
|
4500
|
-
(0,
|
|
5030
|
+
(0, import_editor_v1_adapters19.blockCommand)({
|
|
4501
5031
|
command: "document/elements/move",
|
|
4502
5032
|
condition: blockLinkInLinkMove
|
|
4503
5033
|
});
|
|
@@ -4559,24 +5089,24 @@ function shouldBlock(sourceElements, targetElements) {
|
|
|
4559
5089
|
return false;
|
|
4560
5090
|
}
|
|
4561
5091
|
const isSourceContainsAnAnchor = sourceElements.some((src) => {
|
|
4562
|
-
return src?.id ? (0,
|
|
5092
|
+
return src?.id ? (0, import_editor_elements16.isElementAnchored)(src.id) || !!(0, import_editor_elements16.getAnchoredDescendantId)(src.id) : false;
|
|
4563
5093
|
});
|
|
4564
5094
|
if (!isSourceContainsAnAnchor) {
|
|
4565
5095
|
return false;
|
|
4566
5096
|
}
|
|
4567
5097
|
const isTargetContainsAnAnchor = targetElements.some((target) => {
|
|
4568
|
-
return target?.id ? (0,
|
|
5098
|
+
return target?.id ? (0, import_editor_elements16.isElementAnchored)(target.id) || !!(0, import_editor_elements16.getAnchoredAncestorId)(target.id) : false;
|
|
4569
5099
|
});
|
|
4570
5100
|
return isTargetContainsAnAnchor;
|
|
4571
5101
|
}
|
|
4572
5102
|
|
|
4573
5103
|
// src/style-commands/paste-style.ts
|
|
4574
|
-
var
|
|
5104
|
+
var import_editor_elements19 = require("@elementor/editor-elements");
|
|
4575
5105
|
var import_editor_props10 = require("@elementor/editor-props");
|
|
4576
|
-
var
|
|
5106
|
+
var import_editor_v1_adapters21 = require("@elementor/editor-v1-adapters");
|
|
4577
5107
|
|
|
4578
5108
|
// src/utils/command-utils.ts
|
|
4579
|
-
var
|
|
5109
|
+
var import_editor_elements17 = require("@elementor/editor-elements");
|
|
4580
5110
|
var import_editor_props9 = require("@elementor/editor-props");
|
|
4581
5111
|
var import_i18n5 = require("@wordpress/i18n");
|
|
4582
5112
|
function hasAtomicWidgets(args) {
|
|
@@ -4601,7 +5131,7 @@ function getClassesProp(container) {
|
|
|
4601
5131
|
}
|
|
4602
5132
|
function getContainerSchema(container) {
|
|
4603
5133
|
const type = container?.model.get("widgetType") || container?.model.get("elType");
|
|
4604
|
-
const widgetsCache = (0,
|
|
5134
|
+
const widgetsCache = (0, import_editor_elements17.getWidgetsCache)();
|
|
4605
5135
|
const elementType = widgetsCache?.[type];
|
|
4606
5136
|
return elementType?.atomic_props_schema ?? null;
|
|
4607
5137
|
}
|
|
@@ -4614,15 +5144,15 @@ function getClipboardElements(storageKey = "clipboard") {
|
|
|
4614
5144
|
}
|
|
4615
5145
|
}
|
|
4616
5146
|
function getTitleForContainers(containers) {
|
|
4617
|
-
return containers.length > 1 ? (0, import_i18n5.__)("Elements", "elementor") : (0,
|
|
5147
|
+
return containers.length > 1 ? (0, import_i18n5.__)("Elements", "elementor") : (0, import_editor_elements17.getElementLabel)(containers[0].id);
|
|
4618
5148
|
}
|
|
4619
5149
|
|
|
4620
5150
|
// src/style-commands/undoable-actions/paste-element-style.ts
|
|
4621
|
-
var
|
|
5151
|
+
var import_editor_elements18 = require("@elementor/editor-elements");
|
|
4622
5152
|
var import_editor_styles_repository4 = require("@elementor/editor-styles-repository");
|
|
4623
|
-
var
|
|
5153
|
+
var import_editor_v1_adapters20 = require("@elementor/editor-v1-adapters");
|
|
4624
5154
|
var import_i18n6 = require("@wordpress/i18n");
|
|
4625
|
-
var undoablePasteElementStyle = () => (0,
|
|
5155
|
+
var undoablePasteElementStyle = () => (0, import_editor_v1_adapters20.undoable)(
|
|
4626
5156
|
{
|
|
4627
5157
|
do: ({ containers, newStyle }) => {
|
|
4628
5158
|
return containers.map((container) => {
|
|
@@ -4631,7 +5161,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters16.undoable)(
|
|
|
4631
5161
|
if (!classesProp) {
|
|
4632
5162
|
return null;
|
|
4633
5163
|
}
|
|
4634
|
-
const originalStyles = (0,
|
|
5164
|
+
const originalStyles = (0, import_editor_elements18.getElementStyles)(container.id);
|
|
4635
5165
|
const [styleId, styleDef] = Object.entries(originalStyles ?? {})[0] ?? [];
|
|
4636
5166
|
const originalStyle = Object.keys(styleDef ?? {}).length ? styleDef : null;
|
|
4637
5167
|
const revertData = {
|
|
@@ -4640,7 +5170,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters16.undoable)(
|
|
|
4640
5170
|
};
|
|
4641
5171
|
if (styleId) {
|
|
4642
5172
|
newStyle.variants.forEach(({ meta, props, custom_css: customCss }) => {
|
|
4643
|
-
(0,
|
|
5173
|
+
(0, import_editor_elements18.updateElementStyle)({
|
|
4644
5174
|
elementId,
|
|
4645
5175
|
styleId,
|
|
4646
5176
|
meta,
|
|
@@ -4651,7 +5181,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters16.undoable)(
|
|
|
4651
5181
|
} else {
|
|
4652
5182
|
const [firstVariant] = newStyle.variants;
|
|
4653
5183
|
const additionalVariants = newStyle.variants.slice(1);
|
|
4654
|
-
revertData.styleId = (0,
|
|
5184
|
+
revertData.styleId = (0, import_editor_elements18.createElementStyle)({
|
|
4655
5185
|
elementId,
|
|
4656
5186
|
classesProp,
|
|
4657
5187
|
label: import_editor_styles_repository4.ELEMENTS_STYLES_RESERVED_LABEL,
|
|
@@ -4669,7 +5199,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters16.undoable)(
|
|
|
4669
5199
|
return;
|
|
4670
5200
|
}
|
|
4671
5201
|
if (!revertData.originalStyle) {
|
|
4672
|
-
(0,
|
|
5202
|
+
(0, import_editor_elements18.deleteElementStyle)(container.id, revertData.styleId);
|
|
4673
5203
|
return;
|
|
4674
5204
|
}
|
|
4675
5205
|
const classesProp = getClassesProp(container);
|
|
@@ -4678,7 +5208,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters16.undoable)(
|
|
|
4678
5208
|
}
|
|
4679
5209
|
const [firstVariant] = revertData.originalStyle.variants;
|
|
4680
5210
|
const additionalVariants = revertData.originalStyle.variants.slice(1);
|
|
4681
|
-
(0,
|
|
5211
|
+
(0, import_editor_elements18.createElementStyle)({
|
|
4682
5212
|
elementId: container.id,
|
|
4683
5213
|
classesProp,
|
|
4684
5214
|
label: import_editor_styles_repository4.ELEMENTS_STYLES_RESERVED_LABEL,
|
|
@@ -4698,12 +5228,12 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters16.undoable)(
|
|
|
4698
5228
|
// src/style-commands/paste-style.ts
|
|
4699
5229
|
function initPasteStyleCommand() {
|
|
4700
5230
|
const pasteElementStyleCommand = undoablePasteElementStyle();
|
|
4701
|
-
(0,
|
|
5231
|
+
(0, import_editor_v1_adapters21.blockCommand)({
|
|
4702
5232
|
command: "document/elements/paste-style",
|
|
4703
5233
|
condition: hasAtomicWidgets
|
|
4704
5234
|
});
|
|
4705
|
-
(0,
|
|
4706
|
-
(0,
|
|
5235
|
+
(0, import_editor_v1_adapters21.__privateListenTo)(
|
|
5236
|
+
(0, import_editor_v1_adapters21.commandStartEvent)("document/elements/paste-style"),
|
|
4707
5237
|
(e) => pasteStyles(e.args, pasteElementStyleCommand)
|
|
4708
5238
|
);
|
|
4709
5239
|
}
|
|
@@ -4715,7 +5245,7 @@ function pasteStyles(args, pasteLocalStyle) {
|
|
|
4715
5245
|
}
|
|
4716
5246
|
const clipboardElements = getClipboardElements(storageKey);
|
|
4717
5247
|
const [clipboardElement] = clipboardElements ?? [];
|
|
4718
|
-
const clipboardContainer = (0,
|
|
5248
|
+
const clipboardContainer = (0, import_editor_elements19.getContainer)(clipboardElement.id);
|
|
4719
5249
|
if (!clipboardElement || !clipboardContainer || !isAtomicWidget(clipboardContainer)) {
|
|
4720
5250
|
return;
|
|
4721
5251
|
}
|
|
@@ -4734,7 +5264,7 @@ function getClassesWithoutLocalStyle(clipboardContainer, style) {
|
|
|
4734
5264
|
if (!classesProp) {
|
|
4735
5265
|
return [];
|
|
4736
5266
|
}
|
|
4737
|
-
const classesSetting = (0,
|
|
5267
|
+
const classesSetting = (0, import_editor_elements19.getElementSetting)(clipboardContainer.id, classesProp);
|
|
4738
5268
|
return classesSetting?.value.filter((styleId) => styleId !== style?.id) ?? [];
|
|
4739
5269
|
}
|
|
4740
5270
|
function pasteClasses(containers, classes) {
|
|
@@ -4743,10 +5273,10 @@ function pasteClasses(containers, classes) {
|
|
|
4743
5273
|
if (!classesProp) {
|
|
4744
5274
|
return;
|
|
4745
5275
|
}
|
|
4746
|
-
const classesSetting = (0,
|
|
5276
|
+
const classesSetting = (0, import_editor_elements19.getElementSetting)(container.id, classesProp);
|
|
4747
5277
|
const currentClasses = import_editor_props10.classesPropTypeUtil.extract(classesSetting) ?? [];
|
|
4748
5278
|
const newClasses = import_editor_props10.classesPropTypeUtil.create(Array.from(/* @__PURE__ */ new Set([...classes, ...currentClasses])));
|
|
4749
|
-
(0,
|
|
5279
|
+
(0, import_editor_elements19.updateElementSettings)({
|
|
4750
5280
|
id: container.id,
|
|
4751
5281
|
props: { [classesProp]: newClasses }
|
|
4752
5282
|
});
|
|
@@ -4754,21 +5284,21 @@ function pasteClasses(containers, classes) {
|
|
|
4754
5284
|
}
|
|
4755
5285
|
|
|
4756
5286
|
// src/style-commands/reset-style.ts
|
|
4757
|
-
var
|
|
5287
|
+
var import_editor_v1_adapters23 = require("@elementor/editor-v1-adapters");
|
|
4758
5288
|
|
|
4759
5289
|
// src/style-commands/undoable-actions/reset-element-style.ts
|
|
4760
|
-
var
|
|
5290
|
+
var import_editor_elements20 = require("@elementor/editor-elements");
|
|
4761
5291
|
var import_editor_styles_repository5 = require("@elementor/editor-styles-repository");
|
|
4762
|
-
var
|
|
5292
|
+
var import_editor_v1_adapters22 = require("@elementor/editor-v1-adapters");
|
|
4763
5293
|
var import_i18n7 = require("@wordpress/i18n");
|
|
4764
|
-
var undoableResetElementStyle = () => (0,
|
|
5294
|
+
var undoableResetElementStyle = () => (0, import_editor_v1_adapters22.undoable)(
|
|
4765
5295
|
{
|
|
4766
5296
|
do: ({ containers }) => {
|
|
4767
5297
|
return containers.map((container) => {
|
|
4768
5298
|
const elementId = container.model.get("id");
|
|
4769
|
-
const containerStyles = (0,
|
|
5299
|
+
const containerStyles = (0, import_editor_elements20.getElementStyles)(elementId);
|
|
4770
5300
|
Object.keys(containerStyles ?? {}).forEach(
|
|
4771
|
-
(styleId) => (0,
|
|
5301
|
+
(styleId) => (0, import_editor_elements20.deleteElementStyle)(elementId, styleId)
|
|
4772
5302
|
);
|
|
4773
5303
|
return containerStyles;
|
|
4774
5304
|
});
|
|
@@ -4784,7 +5314,7 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters18.undoable)(
|
|
|
4784
5314
|
Object.entries(containerStyles ?? {}).forEach(([styleId, style]) => {
|
|
4785
5315
|
const [firstVariant] = style.variants;
|
|
4786
5316
|
const additionalVariants = style.variants.slice(1);
|
|
4787
|
-
(0,
|
|
5317
|
+
(0, import_editor_elements20.createElementStyle)({
|
|
4788
5318
|
elementId,
|
|
4789
5319
|
classesProp,
|
|
4790
5320
|
styleId,
|
|
@@ -4805,12 +5335,12 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters18.undoable)(
|
|
|
4805
5335
|
// src/style-commands/reset-style.ts
|
|
4806
5336
|
function initResetStyleCommand() {
|
|
4807
5337
|
const resetElementStyles = undoableResetElementStyle();
|
|
4808
|
-
(0,
|
|
5338
|
+
(0, import_editor_v1_adapters23.blockCommand)({
|
|
4809
5339
|
command: "document/elements/reset-style",
|
|
4810
5340
|
condition: hasAtomicWidgets
|
|
4811
5341
|
});
|
|
4812
|
-
(0,
|
|
4813
|
-
(0,
|
|
5342
|
+
(0, import_editor_v1_adapters23.__privateListenTo)(
|
|
5343
|
+
(0, import_editor_v1_adapters23.commandStartEvent)("document/elements/reset-style"),
|
|
4814
5344
|
(e) => resetStyles(e.args, resetElementStyles)
|
|
4815
5345
|
);
|
|
4816
5346
|
}
|