@elementor/editor-canvas 4.1.0-manual → 4.2.0-839
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +22 -4
- package/dist/index.d.ts +22 -4
- package/dist/index.js +773 -137
- package/dist/index.mjs +730 -86
- package/package.json +18 -18
- package/src/__tests__/settings-props-resolver.test.ts +3 -0
- package/src/composition-builder/composition-builder.ts +5 -5
- package/src/form-structure/utils.ts +4 -0
- package/src/hooks/__tests__/use-style-items.test.ts +55 -0
- package/src/hooks/use-style-items.ts +12 -14
- package/src/index.ts +2 -0
- package/src/init-settings-transformers.ts +4 -0
- package/src/init-style-transformers.ts +2 -0
- package/src/legacy/create-nested-templated-element-type.ts +11 -2
- package/src/legacy/create-pending-element.ts +74 -0
- package/src/legacy/create-templated-element-type.ts +2 -2
- package/src/legacy/types.ts +9 -1
- 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 +74 -14
- 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/prompt.ts +6 -6
- package/src/mcp/tools/configure-element/schema.ts +1 -1
- 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/do-update-element-property.ts +1 -1
- package/src/mcp/utils/element-data-util.ts +46 -0
- package/src/mcp/utils/validate-input.ts +1 -1
- package/src/sync/global-styles-imported-event.ts +8 -0
- package/src/transformers/settings/date-range-transformer.ts +12 -0
- package/src/transformers/settings/time-range-transformer.ts +12 -0
- package/src/transformers/shared/image-src-transformer.ts +2 -0
- package/src/transformers/shared/image-transformer.ts +4 -1
- package/src/transformers/styles/span-transformer.ts +5 -0
- package/src/utils/after-render.ts +26 -0
- package/src/mcp/utils/generate-available-tags.ts +0 -23
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
BREAKPOINTS_SCHEMA_URI: () => BREAKPOINTS_SCHEMA_URI,
|
|
34
34
|
DOCUMENT_STRUCTURE_URI: () => DOCUMENT_STRUCTURE_URI,
|
|
35
|
+
GLOBAL_STYLES_IMPORTED_EVENT: () => GLOBAL_STYLES_IMPORTED_EVENT,
|
|
35
36
|
STYLE_SCHEMA_URI: () => STYLE_SCHEMA_URI,
|
|
36
37
|
UnknownStyleStateError: () => UnknownStyleStateError,
|
|
37
38
|
UnknownStyleTypeError: () => UnknownStyleTypeError,
|
|
@@ -43,6 +44,7 @@ __export(index_exports, {
|
|
|
43
44
|
createTemplatedElementView: () => createTemplatedElementView,
|
|
44
45
|
createTransformer: () => createTransformer,
|
|
45
46
|
createTransformersRegistry: () => createTransformersRegistry,
|
|
47
|
+
doAfterRender: () => doAfterRender,
|
|
46
48
|
endDragElementFromPanel: () => endDragElementFromPanel,
|
|
47
49
|
init: () => init,
|
|
48
50
|
isAtomicWidget: () => isAtomicWidget,
|
|
@@ -102,10 +104,79 @@ var initBreakpointsResource = (reg) => {
|
|
|
102
104
|
};
|
|
103
105
|
|
|
104
106
|
// src/mcp/resources/widgets-schema-resource.ts
|
|
105
|
-
var
|
|
107
|
+
var import_editor_elements2 = require("@elementor/editor-elements");
|
|
106
108
|
var import_editor_mcp = require("@elementor/editor-mcp");
|
|
107
109
|
var import_editor_props = require("@elementor/editor-props");
|
|
108
110
|
var import_editor_styles = require("@elementor/editor-styles");
|
|
111
|
+
|
|
112
|
+
// src/mcp/utils/element-data-util.ts
|
|
113
|
+
var import_editor_elements = require("@elementor/editor-elements");
|
|
114
|
+
function hasV3Controls(controls) {
|
|
115
|
+
return typeof controls === "object" && controls !== null && Object.keys(controls).length > 0;
|
|
116
|
+
}
|
|
117
|
+
function isWidgetAvailableForLLM(config) {
|
|
118
|
+
if (!config) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
if (config.meta?.llm_support === false) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
if (config.atomic_props_schema) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
return hasV3Controls(config.controls);
|
|
128
|
+
}
|
|
129
|
+
function getWidgetVersion(config) {
|
|
130
|
+
return config?.atomic_props_schema ? "v4" : "v3";
|
|
131
|
+
}
|
|
132
|
+
function getAvailableWidgets() {
|
|
133
|
+
const cache = (0, import_editor_elements.getWidgetsCache)() ?? {};
|
|
134
|
+
return Object.keys(cache).filter((widgetType) => isWidgetAvailableForLLM(cache[widgetType])).sort().map((widgetType) => {
|
|
135
|
+
const config = cache[widgetType];
|
|
136
|
+
const description = typeof config?.meta?.description === "string" ? config.meta.description : void 0;
|
|
137
|
+
return {
|
|
138
|
+
type: widgetType,
|
|
139
|
+
version: getWidgetVersion(config),
|
|
140
|
+
...description && { description }
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// src/mcp/resources/widgets-schema-resource.ts
|
|
146
|
+
var V3_LAYOUT_CONTROL_TYPES = /* @__PURE__ */ new Set(["section", "tab", "tabs"]);
|
|
147
|
+
function extractV3ControlsMetadata(controls) {
|
|
148
|
+
if (!hasV3Controls(controls)) {
|
|
149
|
+
return {};
|
|
150
|
+
}
|
|
151
|
+
const result = {};
|
|
152
|
+
for (const [controlKey, raw] of Object.entries(controls)) {
|
|
153
|
+
if (!raw || typeof raw !== "object") {
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
const control = raw;
|
|
157
|
+
const controlType = typeof control.type === "string" ? control.type : void 0;
|
|
158
|
+
if (controlType && V3_LAYOUT_CONTROL_TYPES.has(controlType)) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const entry = {};
|
|
162
|
+
if (Object.prototype.hasOwnProperty.call(control, "default")) {
|
|
163
|
+
entry.default = control.default;
|
|
164
|
+
}
|
|
165
|
+
if (controlType) {
|
|
166
|
+
entry.type = controlType;
|
|
167
|
+
}
|
|
168
|
+
if (Object.prototype.hasOwnProperty.call(control, "options") && control.options !== void 0) {
|
|
169
|
+
const options = control.options;
|
|
170
|
+
if (options && typeof options === "object" && !Array.isArray(options)) {
|
|
171
|
+
entry.options = Object.keys(options);
|
|
172
|
+
} else {
|
|
173
|
+
entry.options = options;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
result[controlKey] = entry;
|
|
177
|
+
}
|
|
178
|
+
return result;
|
|
179
|
+
}
|
|
109
180
|
var WIDGET_SCHEMA_URI = "elementor://widgets/schema/{widgetType}";
|
|
110
181
|
var STYLE_SCHEMA_URI = "elementor://styles/schema/{category}";
|
|
111
182
|
var BEST_PRACTICES_URI = "elementor://styles/best-practices";
|
|
@@ -153,7 +224,7 @@ Variables from the user context ARE NOT SUPPORTED AND WILL RESOLVE IN ERROR.
|
|
|
153
224
|
}
|
|
154
225
|
}),
|
|
155
226
|
{
|
|
156
|
-
description: "Common styles schema for the specified category"
|
|
227
|
+
description: "Common styles schema for the specified category (applicable for V4 elements only)"
|
|
157
228
|
},
|
|
158
229
|
async (uri, variables) => {
|
|
159
230
|
const category = typeof variables.category === "string" ? variables.category : variables.category?.[0];
|
|
@@ -179,9 +250,9 @@ Variables from the user context ARE NOT SUPPORTED AND WILL RESOLVE IN ERROR.
|
|
|
179
250
|
"widget-schema-by-type",
|
|
180
251
|
new import_editor_mcp.ResourceTemplate(WIDGET_SCHEMA_URI, {
|
|
181
252
|
list: () => {
|
|
182
|
-
const cache = (0,
|
|
183
|
-
const availableWidgets = Object.keys(cache
|
|
184
|
-
(widgetType) => cache[widgetType]
|
|
253
|
+
const cache = (0, import_editor_elements2.getWidgetsCache)() || {};
|
|
254
|
+
const availableWidgets = Object.keys(cache).filter(
|
|
255
|
+
(widgetType) => isWidgetAvailableForLLM(cache[widgetType])
|
|
185
256
|
);
|
|
186
257
|
return {
|
|
187
258
|
resources: availableWidgets.map((widgetType) => ({
|
|
@@ -196,20 +267,34 @@ Variables from the user context ARE NOT SUPPORTED AND WILL RESOLVE IN ERROR.
|
|
|
196
267
|
},
|
|
197
268
|
async (uri, variables) => {
|
|
198
269
|
const widgetType = typeof variables.widgetType === "string" ? variables.widgetType : variables.widgetType?.[0];
|
|
199
|
-
const widgetData = (0,
|
|
200
|
-
|
|
201
|
-
if (!propSchema || !widgetData) {
|
|
270
|
+
const widgetData = (0, import_editor_elements2.getWidgetsCache)()?.[widgetType];
|
|
271
|
+
if (!widgetData) {
|
|
202
272
|
throw new Error(`No prop schema found for element type: ${widgetType}`);
|
|
203
273
|
}
|
|
274
|
+
const propSchema = widgetData.atomic_props_schema;
|
|
275
|
+
if (!propSchema) {
|
|
276
|
+
if (!hasV3Controls(widgetData.controls)) {
|
|
277
|
+
throw new Error(`No prop schema found for element type: ${widgetType}`);
|
|
278
|
+
}
|
|
279
|
+
const controlMetadata = extractV3ControlsMetadata(widgetData.controls);
|
|
280
|
+
return {
|
|
281
|
+
contents: [
|
|
282
|
+
{
|
|
283
|
+
uri: uri.toString(),
|
|
284
|
+
mimeType: "application/json",
|
|
285
|
+
text: JSON.stringify({
|
|
286
|
+
widget_version: "v3",
|
|
287
|
+
message: "This widget exists in the editor but has no atomic props schema (V4). Use control_metadata as non-authoritative hints from legacy controls.",
|
|
288
|
+
fields_note: "All settings are optional; there is no JSON schema for this widget type.",
|
|
289
|
+
properties: controlMetadata
|
|
290
|
+
})
|
|
291
|
+
}
|
|
292
|
+
]
|
|
293
|
+
};
|
|
294
|
+
}
|
|
204
295
|
const asJson = Object.fromEntries(
|
|
205
|
-
Object.entries(propSchema).map(([key, propType]) => [
|
|
206
|
-
key,
|
|
207
|
-
import_editor_props.Schema.propTypeToJsonSchema(propType)
|
|
208
|
-
])
|
|
296
|
+
Object.entries(propSchema).filter(([key, propType]) => import_editor_props.Schema.isPropKeyConfigurable(key, propType)).map(([key, propType]) => [key, import_editor_props.Schema.propTypeToJsonSchema(propType)])
|
|
209
297
|
);
|
|
210
|
-
import_editor_props.Schema.nonConfigurablePropKeys.forEach((key) => {
|
|
211
|
-
delete asJson[key];
|
|
212
|
-
});
|
|
213
298
|
const description = typeof widgetData?.meta?.description === "string" ? widgetData.meta.description : void 0;
|
|
214
299
|
const defaultStyles = {};
|
|
215
300
|
const baseStyleSchema = widgetData?.base_styles;
|
|
@@ -229,7 +314,7 @@ Variables from the user context ARE NOT SUPPORTED AND WILL RESOLVE IN ERROR.
|
|
|
229
314
|
llmGuidance.default_styles = defaultStyles;
|
|
230
315
|
}
|
|
231
316
|
const allowedChildTypes = widgetData.allowed_child_types;
|
|
232
|
-
const allWidgets = (0,
|
|
317
|
+
const allWidgets = (0, import_editor_elements2.getWidgetsCache)() || {};
|
|
233
318
|
const allowedParents = Object.entries(allWidgets).filter(([, parentConfig]) => parentConfig.allowed_child_types?.includes(widgetType)).map(([parentType]) => parentType);
|
|
234
319
|
if (allowedChildTypes?.length || allowedParents.length) {
|
|
235
320
|
llmGuidance.nesting = {
|
|
@@ -303,7 +388,7 @@ var renameClass = (oldClassName, newClassName) => {
|
|
|
303
388
|
|
|
304
389
|
// src/components/elements-overlays.tsx
|
|
305
390
|
var React2 = __toESM(require("react"));
|
|
306
|
-
var
|
|
391
|
+
var import_editor_elements3 = require("@elementor/editor-elements");
|
|
307
392
|
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
308
393
|
|
|
309
394
|
// src/components/outline-overlay.tsx
|
|
@@ -444,7 +529,7 @@ var overlayRegistry = [
|
|
|
444
529
|
}
|
|
445
530
|
];
|
|
446
531
|
function ElementsOverlays() {
|
|
447
|
-
const selected = (0,
|
|
532
|
+
const selected = (0, import_editor_elements3.useSelectedElement)();
|
|
448
533
|
const elements = useElementsDom();
|
|
449
534
|
const currentEditMode = (0, import_editor_v1_adapters2.useEditMode)();
|
|
450
535
|
const isEditMode = currentEditMode === "edit";
|
|
@@ -473,7 +558,7 @@ function useElementsDom() {
|
|
|
473
558
|
return (0, import_editor_v1_adapters2.__privateUseListenTo)(
|
|
474
559
|
[(0, import_editor_v1_adapters2.windowEvent)("elementor/editor/element-rendered"), (0, import_editor_v1_adapters2.windowEvent)("elementor/editor/element-destroyed")],
|
|
475
560
|
() => {
|
|
476
|
-
return (0,
|
|
561
|
+
return (0, import_editor_elements3.getElements)().filter((el) => ELEMENTS_DATA_ATTR in (el.view?.el?.dataset ?? {})).map((element) => ({
|
|
477
562
|
id: element.id,
|
|
478
563
|
domElement: element.view?.getDomElement?.()?.get?.(0),
|
|
479
564
|
isGlobal: element.model.get("isGlobal") ?? false
|
|
@@ -1083,8 +1168,9 @@ function createProviderSubscriber2({ provider, renderStyles, setStyleItems, getC
|
|
|
1083
1168
|
...style,
|
|
1084
1169
|
cssName: provider.actions.resolveCssName(style.id)
|
|
1085
1170
|
}));
|
|
1086
|
-
|
|
1087
|
-
|
|
1171
|
+
const breakpointSplit = breakToBreakpoints(changedStyles);
|
|
1172
|
+
return renderStyles({ styles: breakpointSplit, signal }).then((rendered) => {
|
|
1173
|
+
updateCacheItems(cache, changedIds, rendered);
|
|
1088
1174
|
return getOrderedItems(cache);
|
|
1089
1175
|
});
|
|
1090
1176
|
}
|
|
@@ -1141,19 +1227,14 @@ function getChangedStyleIds(previous, current) {
|
|
|
1141
1227
|
function getOrderedItems(cache) {
|
|
1142
1228
|
return cache.orderedIds.map((id) => cache.itemsById.get(id)).filter((items) => items !== void 0).flat();
|
|
1143
1229
|
}
|
|
1144
|
-
function updateCacheItems(cache, changedItems) {
|
|
1230
|
+
function updateCacheItems(cache, changedIds, changedItems) {
|
|
1231
|
+
for (const id of changedIds) {
|
|
1232
|
+
cache.itemsById.delete(id);
|
|
1233
|
+
}
|
|
1145
1234
|
for (const item of changedItems) {
|
|
1146
|
-
const existing = cache.itemsById.get(item.id);
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
if (idx >= 0) {
|
|
1150
|
-
existing[idx] = item;
|
|
1151
|
-
} else {
|
|
1152
|
-
existing.push(item);
|
|
1153
|
-
}
|
|
1154
|
-
} else {
|
|
1155
|
-
cache.itemsById.set(item.id, [item]);
|
|
1156
|
-
}
|
|
1235
|
+
const existing = cache.itemsById.get(item.id) || [];
|
|
1236
|
+
existing.push(item);
|
|
1237
|
+
cache.itemsById.set(item.id, existing);
|
|
1157
1238
|
}
|
|
1158
1239
|
}
|
|
1159
1240
|
function rebuildCache(cache, allStyles, items) {
|
|
@@ -1204,7 +1285,7 @@ var import_editor_v1_adapters10 = require("@elementor/editor-v1-adapters");
|
|
|
1204
1285
|
var import_i18n = require("@wordpress/i18n");
|
|
1205
1286
|
|
|
1206
1287
|
// src/form-structure/utils.ts
|
|
1207
|
-
var
|
|
1288
|
+
var import_editor_elements4 = require("@elementor/editor-elements");
|
|
1208
1289
|
var FORM_ELEMENT_TYPE = "e-form";
|
|
1209
1290
|
var FORM_FIELD_ELEMENT_TYPES = /* @__PURE__ */ new Set([
|
|
1210
1291
|
"e-form-input",
|
|
@@ -1212,7 +1293,11 @@ var FORM_FIELD_ELEMENT_TYPES = /* @__PURE__ */ new Set([
|
|
|
1212
1293
|
"e-form-label",
|
|
1213
1294
|
"e-form-checkbox",
|
|
1214
1295
|
"e-form-submit-button",
|
|
1215
|
-
"e-form-select"
|
|
1296
|
+
"e-form-select",
|
|
1297
|
+
"e-form-radio-button",
|
|
1298
|
+
"e-form-file-upload",
|
|
1299
|
+
"e-form-date-picker",
|
|
1300
|
+
"e-form-time-picker"
|
|
1216
1301
|
]);
|
|
1217
1302
|
function getArgsElementType(args) {
|
|
1218
1303
|
return args.model?.widgetType || args.model?.elType;
|
|
@@ -1230,10 +1315,10 @@ function isWithinForm(element) {
|
|
|
1230
1315
|
return isElementWithinFormSelector(element);
|
|
1231
1316
|
}
|
|
1232
1317
|
function hasElementType(element, type) {
|
|
1233
|
-
return (0,
|
|
1318
|
+
return (0, import_editor_elements4.getAllDescendants)(element).some((item) => getElementType(item) === type);
|
|
1234
1319
|
}
|
|
1235
1320
|
function hasElementTypes(element, types) {
|
|
1236
|
-
return (0,
|
|
1321
|
+
return (0, import_editor_elements4.getAllDescendants)(element).some((item) => {
|
|
1237
1322
|
const itemType = getElementType(item);
|
|
1238
1323
|
return itemType ? types.has(itemType) : false;
|
|
1239
1324
|
});
|
|
@@ -1427,6 +1512,17 @@ function createClassesTransformer() {
|
|
|
1427
1512
|
});
|
|
1428
1513
|
}
|
|
1429
1514
|
|
|
1515
|
+
// src/transformers/settings/date-range-transformer.ts
|
|
1516
|
+
var dateRangeTransformer = createTransformer((value) => {
|
|
1517
|
+
if (!value || Object.keys(value).length === 0) {
|
|
1518
|
+
return null;
|
|
1519
|
+
}
|
|
1520
|
+
return {
|
|
1521
|
+
min: value.min || null,
|
|
1522
|
+
max: value.max || null
|
|
1523
|
+
};
|
|
1524
|
+
});
|
|
1525
|
+
|
|
1430
1526
|
// src/transformers/settings/date-time-transformer.ts
|
|
1431
1527
|
var dateTimeTransformer = createTransformer((values) => {
|
|
1432
1528
|
return values.map((value) => {
|
|
@@ -1461,10 +1557,22 @@ var queryTransformer = createTransformer(({ id }) => {
|
|
|
1461
1557
|
return id ?? null;
|
|
1462
1558
|
});
|
|
1463
1559
|
|
|
1560
|
+
// src/transformers/settings/time-range-transformer.ts
|
|
1561
|
+
var timeRangeTransformer = createTransformer((value) => {
|
|
1562
|
+
if (!value || Object.keys(value).length === 0) {
|
|
1563
|
+
return null;
|
|
1564
|
+
}
|
|
1565
|
+
return {
|
|
1566
|
+
min: value.min || null,
|
|
1567
|
+
max: value.max || null
|
|
1568
|
+
};
|
|
1569
|
+
});
|
|
1570
|
+
|
|
1464
1571
|
// src/transformers/shared/image-src-transformer.ts
|
|
1465
1572
|
var imageSrcTransformer = createTransformer((value) => ({
|
|
1466
1573
|
id: value.id ?? null,
|
|
1467
|
-
url: value.url ?? null
|
|
1574
|
+
url: value.url ?? null,
|
|
1575
|
+
alt: value.alt ?? null
|
|
1468
1576
|
}));
|
|
1469
1577
|
|
|
1470
1578
|
// src/transformers/shared/image-transformer.ts
|
|
@@ -1472,7 +1580,7 @@ var import_wp_media = require("@elementor/wp-media");
|
|
|
1472
1580
|
var imageTransformer = createTransformer(async (value) => {
|
|
1473
1581
|
const { src, size: size2 } = value;
|
|
1474
1582
|
if (!src?.id) {
|
|
1475
|
-
return src?.url ? { src: src.url } : null;
|
|
1583
|
+
return src?.url ? { src: src.url, alt: src.alt ?? "" } : null;
|
|
1476
1584
|
}
|
|
1477
1585
|
const attachment = await (0, import_wp_media.getMediaAttachment)({ id: src.id });
|
|
1478
1586
|
const sizedAttachment = attachment?.sizes?.[size2 ?? ""];
|
|
@@ -1480,14 +1588,16 @@ var imageTransformer = createTransformer(async (value) => {
|
|
|
1480
1588
|
return {
|
|
1481
1589
|
src: sizedAttachment.url,
|
|
1482
1590
|
height: sizedAttachment.height,
|
|
1483
|
-
width: sizedAttachment.width
|
|
1591
|
+
width: sizedAttachment.width,
|
|
1592
|
+
alt: attachment.alt
|
|
1484
1593
|
};
|
|
1485
1594
|
}
|
|
1486
1595
|
if (attachment) {
|
|
1487
1596
|
return {
|
|
1488
1597
|
src: attachment.url,
|
|
1489
1598
|
height: attachment.height,
|
|
1490
|
-
width: attachment.width
|
|
1599
|
+
width: attachment.width,
|
|
1600
|
+
alt: attachment.alt
|
|
1491
1601
|
};
|
|
1492
1602
|
}
|
|
1493
1603
|
return null;
|
|
@@ -1574,7 +1684,7 @@ var videoSrcTransformer = createTransformer(async (value) => {
|
|
|
1574
1684
|
|
|
1575
1685
|
// src/init-settings-transformers.ts
|
|
1576
1686
|
function initSettingsTransformers() {
|
|
1577
|
-
settingsTransformersRegistry.register("classes", createClassesTransformer()).register("link", linkTransformer).register("query", queryTransformer).register("image", imageTransformer).register("image-src", imageSrcTransformer).register("svg-src", svgSrcTransformer).register("video-src", videoSrcTransformer).register("attributes", attributesTransformer).register("date-time", dateTimeTransformer).register("html-v2", htmlV2Transformer).register("html-v3", htmlV3Transformer).registerFallback(plainTransformer);
|
|
1687
|
+
settingsTransformersRegistry.register("classes", createClassesTransformer()).register("link", linkTransformer).register("query", queryTransformer).register("image", imageTransformer).register("image-src", imageSrcTransformer).register("svg-src", svgSrcTransformer).register("video-src", videoSrcTransformer).register("attributes", attributesTransformer).register("date-time", dateTimeTransformer).register("html-v2", htmlV2Transformer).register("html-v3", htmlV3Transformer).register("date-range", dateRangeTransformer).register("time-range", timeRangeTransformer).registerFallback(plainTransformer);
|
|
1578
1688
|
}
|
|
1579
1689
|
|
|
1580
1690
|
// src/transformers/styles/background-color-overlay-transformer.ts
|
|
@@ -1779,6 +1889,11 @@ var sizeTransformer = createTransformer((value) => {
|
|
|
1779
1889
|
return value.unit === "custom" ? value.size : `${value.size}${value.unit}`;
|
|
1780
1890
|
});
|
|
1781
1891
|
|
|
1892
|
+
// src/transformers/styles/span-transformer.ts
|
|
1893
|
+
var spanTransformer = createTransformer((value) => {
|
|
1894
|
+
return value || 0 === value ? "span " + value : null;
|
|
1895
|
+
});
|
|
1896
|
+
|
|
1782
1897
|
// src/transformers/styles/stroke-transformer.ts
|
|
1783
1898
|
var strokeTransformer = createTransformer((value) => {
|
|
1784
1899
|
const parsed = {
|
|
@@ -1885,7 +2000,7 @@ function initStyleTransformers() {
|
|
|
1885
2000
|
["block-start", "block-end", "inline-start", "inline-end"],
|
|
1886
2001
|
({ propKey, key }) => `${propKey}-${key}`
|
|
1887
2002
|
)
|
|
1888
|
-
).register("filter", filterTransformer).register("backdrop-filter", filterTransformer).register("box-shadow", createCombineArrayTransformer(",")).register("background", backgroundTransformer).register("background-overlay", backgroundOverlayTransformer).register("background-color-overlay", backgroundColorOverlayTransformer).register("background-image-overlay", backgroundImageOverlayTransformer).register("background-gradient-overlay", backgroundGradientOverlayTransformer).register("gradient-color-stop", createCombineArrayTransformer(",")).register("color-stop", colorStopTransformer).register("background-image-position-offset", positionTransformer).register("background-image-size-scale", backgroundImageSizeScaleTransformer).register("image-src", imageSrcTransformer).register("image", imageTransformer).register("object-position", positionTransformer).register("transform-origin", transformOriginTransformer).register("perspective-origin", perspectiveOriginTransformer).register("transform-move", transformMoveTransformer).register("transform-scale", transformScaleTransformer).register("transform-rotate", transformRotateTransformer).register("transform-skew", transformSkewTransformer).register("transform-functions", transformFunctionsTransformer).register(
|
|
2003
|
+
).register("filter", filterTransformer).register("backdrop-filter", filterTransformer).register("box-shadow", createCombineArrayTransformer(",")).register("background", backgroundTransformer).register("background-overlay", backgroundOverlayTransformer).register("background-color-overlay", backgroundColorOverlayTransformer).register("background-image-overlay", backgroundImageOverlayTransformer).register("background-gradient-overlay", backgroundGradientOverlayTransformer).register("gradient-color-stop", createCombineArrayTransformer(",")).register("color-stop", colorStopTransformer).register("background-image-position-offset", positionTransformer).register("background-image-size-scale", backgroundImageSizeScaleTransformer).register("image-src", imageSrcTransformer).register("image", imageTransformer).register("object-position", positionTransformer).register("span", spanTransformer).register("transform-origin", transformOriginTransformer).register("perspective-origin", perspectiveOriginTransformer).register("transform-move", transformMoveTransformer).register("transform-scale", transformScaleTransformer).register("transform-rotate", transformRotateTransformer).register("transform-skew", transformSkewTransformer).register("transform-functions", transformFunctionsTransformer).register(
|
|
1889
2004
|
"transform",
|
|
1890
2005
|
createMultiPropsTransformer(
|
|
1891
2006
|
["transform-functions", "transform-origin", "perspective", "perspective-origin"],
|
|
@@ -1910,7 +2025,7 @@ function initStyleTransformers() {
|
|
|
1910
2025
|
}
|
|
1911
2026
|
|
|
1912
2027
|
// src/legacy/init-legacy-views.ts
|
|
1913
|
-
var
|
|
2028
|
+
var import_editor_elements8 = require("@elementor/editor-elements");
|
|
1914
2029
|
var import_editor_v1_adapters13 = require("@elementor/editor-v1-adapters");
|
|
1915
2030
|
|
|
1916
2031
|
// src/renderers/create-dom-renderer.ts
|
|
@@ -2039,7 +2154,56 @@ function createElementViewClassDeclaration() {
|
|
|
2039
2154
|
}
|
|
2040
2155
|
|
|
2041
2156
|
// src/legacy/create-nested-templated-element-type.ts
|
|
2042
|
-
var
|
|
2157
|
+
var import_editor_elements6 = require("@elementor/editor-elements");
|
|
2158
|
+
|
|
2159
|
+
// src/legacy/create-pending-element.ts
|
|
2160
|
+
var import_editor_elements5 = require("@elementor/editor-elements");
|
|
2161
|
+
function createPendingElement(wrapperView, data, options = {}) {
|
|
2162
|
+
const parentContainer = wrapperView.getContainer();
|
|
2163
|
+
const model = { ...data };
|
|
2164
|
+
if (!model.id) {
|
|
2165
|
+
model.id = (0, import_editor_elements5.generateElementId)();
|
|
2166
|
+
}
|
|
2167
|
+
if (!model.elements) {
|
|
2168
|
+
model.elements = [];
|
|
2169
|
+
}
|
|
2170
|
+
const added = (0, import_editor_elements5.addModelToParent)(parentContainer.id, model, options);
|
|
2171
|
+
if (!added) {
|
|
2172
|
+
return void 0;
|
|
2173
|
+
}
|
|
2174
|
+
const childId = model.id;
|
|
2175
|
+
const childModel = (0, import_editor_elements5.findModelInDocument)(childId);
|
|
2176
|
+
if (!childModel) {
|
|
2177
|
+
return void 0;
|
|
2178
|
+
}
|
|
2179
|
+
const pendingContainer = {
|
|
2180
|
+
id: childId,
|
|
2181
|
+
settings: { get: () => ({}), set: () => ({}), toJSON: () => ({}) },
|
|
2182
|
+
parent: parentContainer,
|
|
2183
|
+
model: childModel,
|
|
2184
|
+
view: void 0,
|
|
2185
|
+
lookup() {
|
|
2186
|
+
return (0, import_editor_elements5.getContainer)(childId) ?? pendingContainer;
|
|
2187
|
+
}
|
|
2188
|
+
};
|
|
2189
|
+
wrapperView.once("render", () => {
|
|
2190
|
+
wrapperView.model?.trigger?.("navigator:add", childModel, options);
|
|
2191
|
+
});
|
|
2192
|
+
if (options.edit !== false) {
|
|
2193
|
+
selectChildWhenWrapperRenders(wrapperView, childId);
|
|
2194
|
+
}
|
|
2195
|
+
return { getContainer: () => pendingContainer };
|
|
2196
|
+
}
|
|
2197
|
+
function selectChildWhenWrapperRenders(wrapperView, childId) {
|
|
2198
|
+
wrapperView.once("render", () => {
|
|
2199
|
+
const childContainer = (0, import_editor_elements5.getContainer)(childId);
|
|
2200
|
+
if (childContainer?.model?.trigger) {
|
|
2201
|
+
childContainer.model.trigger("request:edit");
|
|
2202
|
+
return;
|
|
2203
|
+
}
|
|
2204
|
+
wrapperView.model?.trigger?.("request:edit");
|
|
2205
|
+
});
|
|
2206
|
+
}
|
|
2043
2207
|
|
|
2044
2208
|
// src/legacy/twig-rendering-utils.ts
|
|
2045
2209
|
function setupTwigRenderer({ renderer, element }) {
|
|
@@ -2258,6 +2422,7 @@ function createNestedTemplatedElementView({
|
|
|
2258
2422
|
const AtomicElementBaseView = legacyWindow.elementor.modules.elements.views.createAtomicElementBase(type);
|
|
2259
2423
|
const parentRenderChildren = AtomicElementBaseView.prototype._renderChildren;
|
|
2260
2424
|
const parentOpenEditingPanel = AtomicElementBaseView.prototype._openEditingPanel;
|
|
2425
|
+
const parentAddElement = AtomicElementBaseView.prototype.addElement;
|
|
2261
2426
|
return AtomicElementBaseView.extend({
|
|
2262
2427
|
_abortController: null,
|
|
2263
2428
|
_lastResolvedSettingsHash: null,
|
|
@@ -2297,7 +2462,7 @@ function createNestedTemplatedElementView({
|
|
|
2297
2462
|
this._initAlpine();
|
|
2298
2463
|
});
|
|
2299
2464
|
this.model.trigger("render:complete");
|
|
2300
|
-
window.dispatchEvent(new CustomEvent(
|
|
2465
|
+
window.dispatchEvent(new CustomEvent(import_editor_elements6.ELEMENT_STYLE_CHANGE_EVENT));
|
|
2301
2466
|
},
|
|
2302
2467
|
async _renderTemplate() {
|
|
2303
2468
|
const model = this.model;
|
|
@@ -2365,7 +2530,6 @@ function createNestedTemplatedElementView({
|
|
|
2365
2530
|
Array.from(newEl.attributes).forEach((attr) => {
|
|
2366
2531
|
targetEl.setAttribute(attr.name, attr.value);
|
|
2367
2532
|
});
|
|
2368
|
-
targetEl.setAttribute("draggable", "true");
|
|
2369
2533
|
targetEl.innerHTML = overlayHTML + newEl.innerHTML;
|
|
2370
2534
|
if (needsTagSwap) {
|
|
2371
2535
|
oldEl.replaceWith(targetEl);
|
|
@@ -2457,6 +2621,12 @@ function createNestedTemplatedElementView({
|
|
|
2457
2621
|
_openEditingPanel(options) {
|
|
2458
2622
|
this._doAfterRender(() => parentOpenEditingPanel.call(this, options));
|
|
2459
2623
|
},
|
|
2624
|
+
addElement(data, options) {
|
|
2625
|
+
if (this.isRendered) {
|
|
2626
|
+
return parentAddElement.call(this, data, options);
|
|
2627
|
+
}
|
|
2628
|
+
return createPendingElement(this, data, options);
|
|
2629
|
+
},
|
|
2460
2630
|
getInteractionId() {
|
|
2461
2631
|
const originId = this.model.get("originId");
|
|
2462
2632
|
const id = this.model.get("id");
|
|
@@ -2533,7 +2703,7 @@ var import_client = require("react-dom/client");
|
|
|
2533
2703
|
|
|
2534
2704
|
// src/legacy/replacements/inline-editing/inline-editing-elements.tsx
|
|
2535
2705
|
var React6 = __toESM(require("react"));
|
|
2536
|
-
var
|
|
2706
|
+
var import_editor_elements7 = require("@elementor/editor-elements");
|
|
2537
2707
|
var import_editor_props4 = require("@elementor/editor-props");
|
|
2538
2708
|
var import_editor_v1_adapters12 = require("@elementor/editor-v1-adapters");
|
|
2539
2709
|
var import_i18n3 = require("@wordpress/i18n");
|
|
@@ -2909,7 +3079,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
2909
3079
|
return INLINE_EDITING_PROPERTY_PER_TYPE[this.type] ?? "";
|
|
2910
3080
|
}
|
|
2911
3081
|
getInlineEditablePropType() {
|
|
2912
|
-
const propSchema = (0,
|
|
3082
|
+
const propSchema = (0, import_editor_elements7.getElementType)(this.type)?.propsSchema;
|
|
2913
3083
|
const propertyName = this.getInlineEditablePropertyName();
|
|
2914
3084
|
return propSchema?.[propertyName] ?? null;
|
|
2915
3085
|
}
|
|
@@ -2943,7 +3113,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
2943
3113
|
}
|
|
2944
3114
|
},
|
|
2945
3115
|
{
|
|
2946
|
-
title: (0,
|
|
3116
|
+
title: (0, import_editor_elements7.getElementLabel)(this.id),
|
|
2947
3117
|
// translators: %s is the name of the property that was edited.
|
|
2948
3118
|
subtitle: (0, import_i18n3.__)("%s edited", "elementor").replace(
|
|
2949
3119
|
"%s",
|
|
@@ -2976,7 +3146,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
2976
3146
|
(0, import_editor_v1_adapters12.__privateRunCommandSync)(
|
|
2977
3147
|
"document/elements/set-settings",
|
|
2978
3148
|
{
|
|
2979
|
-
container: (0,
|
|
3149
|
+
container: (0, import_editor_elements7.getContainer)(this.id),
|
|
2980
3150
|
settings: {
|
|
2981
3151
|
[key]: value
|
|
2982
3152
|
}
|
|
@@ -2991,7 +3161,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
2991
3161
|
return import_editor_props4.stringPropTypeUtil.extract(this.getSetting(tagSettingKey) ?? null) ?? import_editor_props4.stringPropTypeUtil.extract(tagPropType?.default ?? null) ?? null;
|
|
2992
3162
|
}
|
|
2993
3163
|
getTagPropType() {
|
|
2994
|
-
const propsSchema = (0,
|
|
3164
|
+
const propsSchema = (0, import_editor_elements7.getElementType)(this.type)?.propsSchema;
|
|
2995
3165
|
if (!propsSchema?.tag) {
|
|
2996
3166
|
return null;
|
|
2997
3167
|
}
|
|
@@ -3151,7 +3321,7 @@ function registerElementType(type, elementTypeGenerator) {
|
|
|
3151
3321
|
}
|
|
3152
3322
|
function initLegacyViews() {
|
|
3153
3323
|
(0, import_editor_v1_adapters13.__privateListenTo)((0, import_editor_v1_adapters13.v1ReadyEvent)(), () => {
|
|
3154
|
-
const widgetsCache = (0,
|
|
3324
|
+
const widgetsCache = (0, import_editor_elements8.getWidgetsCache)() ?? {};
|
|
3155
3325
|
const legacyWindow = window;
|
|
3156
3326
|
const renderer = createDomRenderer();
|
|
3157
3327
|
registerProPromotionTypes(widgetsCache);
|
|
@@ -3237,8 +3407,66 @@ function initTabsModelExtensions() {
|
|
|
3237
3407
|
registerModelExtensions("e-tab", tabModelExtensions);
|
|
3238
3408
|
}
|
|
3239
3409
|
|
|
3240
|
-
// src/mcp/resources/
|
|
3410
|
+
// src/mcp/resources/available-widgets-resource.ts
|
|
3241
3411
|
var import_editor_v1_adapters14 = require("@elementor/editor-v1-adapters");
|
|
3412
|
+
var AVAILABLE_WIDGETS_URI = "elementor://context/available-widgets";
|
|
3413
|
+
var AVAILABLE_WIDGETS_URI_V4 = "elementor://context/available-widgets/v4";
|
|
3414
|
+
var initAvailableWidgetsResource = (reg) => {
|
|
3415
|
+
const { resource, sendResourceUpdated } = reg;
|
|
3416
|
+
const buildContents = (uri, filterFunction = () => true) => {
|
|
3417
|
+
const widgets = getAvailableWidgets().filter(filterFunction);
|
|
3418
|
+
return {
|
|
3419
|
+
contents: [
|
|
3420
|
+
{
|
|
3421
|
+
uri,
|
|
3422
|
+
mimeType: "application/json",
|
|
3423
|
+
text: JSON.stringify(widgets, null, 2)
|
|
3424
|
+
}
|
|
3425
|
+
]
|
|
3426
|
+
};
|
|
3427
|
+
};
|
|
3428
|
+
const notifyResourcesUpdated = () => {
|
|
3429
|
+
sendResourceUpdated({
|
|
3430
|
+
uri: AVAILABLE_WIDGETS_URI,
|
|
3431
|
+
...buildContents(AVAILABLE_WIDGETS_URI)
|
|
3432
|
+
});
|
|
3433
|
+
sendResourceUpdated({
|
|
3434
|
+
uri: AVAILABLE_WIDGETS_URI_V4,
|
|
3435
|
+
...buildContents(AVAILABLE_WIDGETS_URI_V4, (w) => w.version === "v4")
|
|
3436
|
+
});
|
|
3437
|
+
};
|
|
3438
|
+
resource(
|
|
3439
|
+
"available-widgets-v4",
|
|
3440
|
+
AVAILABLE_WIDGETS_URI_V4,
|
|
3441
|
+
{
|
|
3442
|
+
description: "All registered v4 version widgets"
|
|
3443
|
+
},
|
|
3444
|
+
async () => buildContents(AVAILABLE_WIDGETS_URI_V4, (w) => w.version === "v4")
|
|
3445
|
+
);
|
|
3446
|
+
resource(
|
|
3447
|
+
"available-widgets",
|
|
3448
|
+
AVAILABLE_WIDGETS_URI,
|
|
3449
|
+
{
|
|
3450
|
+
description: "All registered widget types with v3/v4 version metadata and description."
|
|
3451
|
+
},
|
|
3452
|
+
async () => buildContents(AVAILABLE_WIDGETS_URI)
|
|
3453
|
+
);
|
|
3454
|
+
const eventName = (0, import_editor_v1_adapters14.v1ReadyEvent)().name;
|
|
3455
|
+
const onV1Ready = () => {
|
|
3456
|
+
const widgets = getAvailableWidgets();
|
|
3457
|
+
if (widgets.length === 0) {
|
|
3458
|
+
return;
|
|
3459
|
+
}
|
|
3460
|
+
window.removeEventListener(eventName, onV1Ready);
|
|
3461
|
+
notifyResourcesUpdated();
|
|
3462
|
+
};
|
|
3463
|
+
window.addEventListener(eventName, onV1Ready);
|
|
3464
|
+
onV1Ready();
|
|
3465
|
+
};
|
|
3466
|
+
|
|
3467
|
+
// src/mcp/resources/document-structure-resource.ts
|
|
3468
|
+
var import_editor_elements9 = require("@elementor/editor-elements");
|
|
3469
|
+
var import_editor_v1_adapters15 = require("@elementor/editor-v1-adapters");
|
|
3242
3470
|
var DOCUMENT_STRUCTURE_URI = "elementor://document/structure";
|
|
3243
3471
|
var initDocumentStructureResource = (reg) => {
|
|
3244
3472
|
const { resource, sendResourceUpdated } = reg;
|
|
@@ -3251,14 +3479,15 @@ var initDocumentStructureResource = (reg) => {
|
|
|
3251
3479
|
sendResourceUpdated({ uri: DOCUMENT_STRUCTURE_URI });
|
|
3252
3480
|
}
|
|
3253
3481
|
};
|
|
3254
|
-
(0,
|
|
3482
|
+
(0, import_editor_v1_adapters15.__privateListenTo)(
|
|
3255
3483
|
[
|
|
3256
|
-
(0,
|
|
3257
|
-
(0,
|
|
3258
|
-
(0,
|
|
3259
|
-
(0,
|
|
3260
|
-
(0,
|
|
3261
|
-
(0,
|
|
3484
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("document/elements/create"),
|
|
3485
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("document/elements/delete"),
|
|
3486
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("document/elements/move"),
|
|
3487
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("document/elements/copy"),
|
|
3488
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("document/elements/paste"),
|
|
3489
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("editor/documents/attach-preview"),
|
|
3490
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("editor/documents/switch")
|
|
3262
3491
|
],
|
|
3263
3492
|
updateDocumentStructure
|
|
3264
3493
|
);
|
|
@@ -3288,9 +3517,7 @@ function getDocumentStructure() {
|
|
|
3288
3517
|
return { error: "No active document found" };
|
|
3289
3518
|
}
|
|
3290
3519
|
const containers = document2.container?.children || [];
|
|
3291
|
-
const elements = containers.map(
|
|
3292
|
-
(container) => extractElementData(container)
|
|
3293
|
-
);
|
|
3520
|
+
const elements = containers.map((container) => extractElementData(container));
|
|
3294
3521
|
return {
|
|
3295
3522
|
documentId: document2.id,
|
|
3296
3523
|
documentType: document2.config.type,
|
|
@@ -3298,6 +3525,16 @@ function getDocumentStructure() {
|
|
|
3298
3525
|
elements: elements.filter((el) => el !== null)
|
|
3299
3526
|
};
|
|
3300
3527
|
}
|
|
3528
|
+
function resolveElementVersion(element) {
|
|
3529
|
+
if (element.model?.config?.atomic) {
|
|
3530
|
+
return "v4";
|
|
3531
|
+
}
|
|
3532
|
+
const widgetType = element.model?.attributes?.widgetType;
|
|
3533
|
+
if (widgetType && (0, import_editor_elements9.getWidgetsCache)()?.[widgetType]?.atomic_props_schema) {
|
|
3534
|
+
return "v4";
|
|
3535
|
+
}
|
|
3536
|
+
return "v3";
|
|
3537
|
+
}
|
|
3301
3538
|
function extractElementData(element) {
|
|
3302
3539
|
if (!element || !element.model) {
|
|
3303
3540
|
return null;
|
|
@@ -3306,7 +3543,8 @@ function extractElementData(element) {
|
|
|
3306
3543
|
const result = {
|
|
3307
3544
|
id: model.id,
|
|
3308
3545
|
elType: model.elType,
|
|
3309
|
-
widgetType: model.widgetType || void 0
|
|
3546
|
+
widgetType: model.widgetType || void 0,
|
|
3547
|
+
version: resolveElementVersion(element)
|
|
3310
3548
|
};
|
|
3311
3549
|
const title = model.title || element.model?.editor_settings?.title;
|
|
3312
3550
|
if (title) {
|
|
@@ -3318,15 +3556,330 @@ function extractElementData(element) {
|
|
|
3318
3556
|
return result;
|
|
3319
3557
|
}
|
|
3320
3558
|
|
|
3559
|
+
// src/mcp/resources/editor-state-resource.ts
|
|
3560
|
+
var import_editor_v1_adapters16 = require("@elementor/editor-v1-adapters");
|
|
3561
|
+
var CURRENTLY_VIEWED_SCREEN = "The user is currently viewing the Elementor editor";
|
|
3562
|
+
var PAGE_CONTENT_CHARACTER_LIMIT = 500;
|
|
3563
|
+
var PREVIEW_TEXT_NODE_MIN_LENGTH = 2;
|
|
3564
|
+
var EDITOR_STATE_URI = "elementor://context/editor-state";
|
|
3565
|
+
var initEditorStateResource = (reg) => {
|
|
3566
|
+
const { resource, sendResourceUpdated } = reg;
|
|
3567
|
+
let lastSerializedState = "";
|
|
3568
|
+
const buildState = () => ({
|
|
3569
|
+
currentlyViewedScreen: CURRENTLY_VIEWED_SCREEN,
|
|
3570
|
+
pageContent: getPageContentFromPreview(),
|
|
3571
|
+
pageTitle: getPageTitle()
|
|
3572
|
+
});
|
|
3573
|
+
const notifyIfChanged = () => {
|
|
3574
|
+
const serialized = JSON.stringify(buildState());
|
|
3575
|
+
if (serialized === lastSerializedState) {
|
|
3576
|
+
return;
|
|
3577
|
+
}
|
|
3578
|
+
lastSerializedState = serialized;
|
|
3579
|
+
sendResourceUpdated({ uri: EDITOR_STATE_URI });
|
|
3580
|
+
};
|
|
3581
|
+
(0, import_editor_v1_adapters16.__privateListenTo)(
|
|
3582
|
+
[(0, import_editor_v1_adapters16.commandEndEvent)("editor/documents/switch"), (0, import_editor_v1_adapters16.commandEndEvent)("editor/documents/attach-preview")],
|
|
3583
|
+
notifyIfChanged
|
|
3584
|
+
);
|
|
3585
|
+
lastSerializedState = JSON.stringify(buildState());
|
|
3586
|
+
resource(
|
|
3587
|
+
"editor-state",
|
|
3588
|
+
EDITOR_STATE_URI,
|
|
3589
|
+
{
|
|
3590
|
+
description: "Editor page title, preview text snapshot, and viewed screen label."
|
|
3591
|
+
},
|
|
3592
|
+
async () => {
|
|
3593
|
+
return {
|
|
3594
|
+
contents: [
|
|
3595
|
+
{
|
|
3596
|
+
uri: EDITOR_STATE_URI,
|
|
3597
|
+
text: JSON.stringify(buildState(), null, 2)
|
|
3598
|
+
}
|
|
3599
|
+
]
|
|
3600
|
+
};
|
|
3601
|
+
}
|
|
3602
|
+
);
|
|
3603
|
+
};
|
|
3604
|
+
function getPageContentFromPreview() {
|
|
3605
|
+
try {
|
|
3606
|
+
const root = window.elementor?.$previewContents?.[0];
|
|
3607
|
+
if (!root) {
|
|
3608
|
+
return null;
|
|
3609
|
+
}
|
|
3610
|
+
const content = [];
|
|
3611
|
+
const clone = root.cloneNode(true);
|
|
3612
|
+
clone.querySelectorAll(".elementor-editor-element-settings, #elementor-add-new-section").forEach((el) => {
|
|
3613
|
+
el.remove();
|
|
3614
|
+
});
|
|
3615
|
+
const walk = (node, insideElementorElement = false) => {
|
|
3616
|
+
const isInside = node.classList?.contains("elementor-element") || insideElementorElement;
|
|
3617
|
+
if (node.nodeType === Node.TEXT_NODE && isInside) {
|
|
3618
|
+
const text2 = node.textContent?.trim().replace(/\s+/g, " ");
|
|
3619
|
+
if (text2 && text2.length > PREVIEW_TEXT_NODE_MIN_LENGTH) {
|
|
3620
|
+
content.push(text2);
|
|
3621
|
+
}
|
|
3622
|
+
} else {
|
|
3623
|
+
node.childNodes.forEach((child) => {
|
|
3624
|
+
walk(child, isInside);
|
|
3625
|
+
});
|
|
3626
|
+
}
|
|
3627
|
+
};
|
|
3628
|
+
walk(clone);
|
|
3629
|
+
const text = content.join(" ");
|
|
3630
|
+
if (text.length > PAGE_CONTENT_CHARACTER_LIMIT) {
|
|
3631
|
+
return text.slice(0, PAGE_CONTENT_CHARACTER_LIMIT) + "...";
|
|
3632
|
+
}
|
|
3633
|
+
return text;
|
|
3634
|
+
} catch {
|
|
3635
|
+
return null;
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3638
|
+
function getPageTitle() {
|
|
3639
|
+
try {
|
|
3640
|
+
const extendedWindow = window;
|
|
3641
|
+
const currentDocument = extendedWindow.elementor?.documents?.getCurrent?.();
|
|
3642
|
+
const postTitle = currentDocument?.config?.settings?.post_title;
|
|
3643
|
+
if (postTitle) {
|
|
3644
|
+
return postTitle;
|
|
3645
|
+
}
|
|
3646
|
+
let title = document.title || "Page";
|
|
3647
|
+
title = title.split(/\s*[‹»|–—-]\s*/)[0];
|
|
3648
|
+
const trimmed = title.trim();
|
|
3649
|
+
return trimmed || "Page";
|
|
3650
|
+
} catch {
|
|
3651
|
+
return "Page";
|
|
3652
|
+
}
|
|
3653
|
+
}
|
|
3654
|
+
|
|
3655
|
+
// src/mcp/resources/general-context-resource.ts
|
|
3656
|
+
var import_editor_v1_adapters17 = require("@elementor/editor-v1-adapters");
|
|
3657
|
+
var GENERAL_CONTEXT_URI = "elementor://context/general";
|
|
3658
|
+
var initGeneralContextResource = (reg) => {
|
|
3659
|
+
const { resource, sendResourceUpdated } = reg;
|
|
3660
|
+
let lastSerializedPayload = null;
|
|
3661
|
+
const getPageTitle2 = () => {
|
|
3662
|
+
const extendedWindow = window;
|
|
3663
|
+
const title = extendedWindow.elementor?.documents?.getCurrent?.()?.config?.settings?.post_title;
|
|
3664
|
+
if (!title?.trim()) {
|
|
3665
|
+
return null;
|
|
3666
|
+
}
|
|
3667
|
+
return title;
|
|
3668
|
+
};
|
|
3669
|
+
const buildPayload = () => {
|
|
3670
|
+
const extendedWindow = window;
|
|
3671
|
+
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
3672
|
+
const postParam = new URLSearchParams(location.search).get("post");
|
|
3673
|
+
const parsedPostId = postParam ? Number(postParam) : null;
|
|
3674
|
+
const postId = parsedPostId !== null && Number.isFinite(parsedPostId) ? parsedPostId : null;
|
|
3675
|
+
const pageTitle = getPageTitle2();
|
|
3676
|
+
const urlObject = new URL(window.location.href);
|
|
3677
|
+
const pageUrl = urlObject.pathname + urlObject.search;
|
|
3678
|
+
const pageName = pageTitle || "Elementor Editor";
|
|
3679
|
+
const plugins = extendedWindow.angieConfig?.plugins;
|
|
3680
|
+
return {
|
|
3681
|
+
timezone,
|
|
3682
|
+
postId,
|
|
3683
|
+
currentPage: {
|
|
3684
|
+
pageName,
|
|
3685
|
+
pageTitle,
|
|
3686
|
+
pageUrl
|
|
3687
|
+
},
|
|
3688
|
+
...plugins && { plugins }
|
|
3689
|
+
};
|
|
3690
|
+
};
|
|
3691
|
+
const pushUpdateIfChanged = () => {
|
|
3692
|
+
const serialized = JSON.stringify(buildPayload());
|
|
3693
|
+
if (serialized === lastSerializedPayload) {
|
|
3694
|
+
return;
|
|
3695
|
+
}
|
|
3696
|
+
lastSerializedPayload = serialized;
|
|
3697
|
+
sendResourceUpdated({ uri: GENERAL_CONTEXT_URI });
|
|
3698
|
+
};
|
|
3699
|
+
resource(
|
|
3700
|
+
"general-context",
|
|
3701
|
+
GENERAL_CONTEXT_URI,
|
|
3702
|
+
{
|
|
3703
|
+
description: "General context: timezone, post id, and current page."
|
|
3704
|
+
},
|
|
3705
|
+
async () => {
|
|
3706
|
+
return {
|
|
3707
|
+
contents: [
|
|
3708
|
+
{
|
|
3709
|
+
uri: GENERAL_CONTEXT_URI,
|
|
3710
|
+
mimeType: "application/json",
|
|
3711
|
+
text: JSON.stringify(buildPayload(), null, 2)
|
|
3712
|
+
}
|
|
3713
|
+
]
|
|
3714
|
+
};
|
|
3715
|
+
}
|
|
3716
|
+
);
|
|
3717
|
+
(0, import_editor_v1_adapters17.__privateListenTo)(
|
|
3718
|
+
[
|
|
3719
|
+
(0, import_editor_v1_adapters17.commandEndEvent)("editor/documents/switch"),
|
|
3720
|
+
(0, import_editor_v1_adapters17.commandEndEvent)("editor/documents/attach-preview"),
|
|
3721
|
+
(0, import_editor_v1_adapters17.commandEndEvent)("document/elements/settings")
|
|
3722
|
+
],
|
|
3723
|
+
pushUpdateIfChanged
|
|
3724
|
+
);
|
|
3725
|
+
pushUpdateIfChanged();
|
|
3726
|
+
};
|
|
3727
|
+
|
|
3728
|
+
// src/mcp/resources/selected-element-resource.ts
|
|
3729
|
+
var import_editor_elements10 = require("@elementor/editor-elements");
|
|
3730
|
+
var import_editor_v1_adapters18 = require("@elementor/editor-v1-adapters");
|
|
3731
|
+
var SELECTED_ELEMENT_URI = "elementor://context/selected-element";
|
|
3732
|
+
var initSelectedElementResource = (reg) => {
|
|
3733
|
+
const { resource, sendResourceUpdated } = reg;
|
|
3734
|
+
let currentPayloadText = null;
|
|
3735
|
+
const publishIfChanged = (payload) => {
|
|
3736
|
+
const nextText = JSON.stringify(payload);
|
|
3737
|
+
if (nextText !== currentPayloadText) {
|
|
3738
|
+
currentPayloadText = nextText;
|
|
3739
|
+
sendResourceUpdated({ uri: SELECTED_ELEMENT_URI });
|
|
3740
|
+
}
|
|
3741
|
+
};
|
|
3742
|
+
const onCommand = (e) => {
|
|
3743
|
+
if (e.type !== "command") {
|
|
3744
|
+
return;
|
|
3745
|
+
}
|
|
3746
|
+
const commandEvent = e;
|
|
3747
|
+
if (commandEvent.command === "document/elements/deselect-all") {
|
|
3748
|
+
publishIfChanged(createEmptySelectedElementPayload());
|
|
3749
|
+
return;
|
|
3750
|
+
}
|
|
3751
|
+
if (commandEvent.command !== "document/elements/select" && commandEvent.command !== "document/elements/settings") {
|
|
3752
|
+
return;
|
|
3753
|
+
}
|
|
3754
|
+
const { container } = commandEvent.args || {};
|
|
3755
|
+
if (container?.id) {
|
|
3756
|
+
publishIfChanged(buildPayloadFromContainer(container));
|
|
3757
|
+
return;
|
|
3758
|
+
}
|
|
3759
|
+
publishIfChanged(readSelectionFromEditor());
|
|
3760
|
+
};
|
|
3761
|
+
(0, import_editor_v1_adapters18.__privateListenTo)(
|
|
3762
|
+
[
|
|
3763
|
+
(0, import_editor_v1_adapters18.commandEndEvent)("document/elements/select"),
|
|
3764
|
+
(0, import_editor_v1_adapters18.commandEndEvent)("document/elements/deselect-all"),
|
|
3765
|
+
(0, import_editor_v1_adapters18.commandEndEvent)("document/elements/settings")
|
|
3766
|
+
],
|
|
3767
|
+
onCommand
|
|
3768
|
+
);
|
|
3769
|
+
publishIfChanged(readSelectionFromEditor());
|
|
3770
|
+
resource(
|
|
3771
|
+
"selected-element",
|
|
3772
|
+
SELECTED_ELEMENT_URI,
|
|
3773
|
+
{
|
|
3774
|
+
description: "Currently selected Elementor element context."
|
|
3775
|
+
},
|
|
3776
|
+
async () => {
|
|
3777
|
+
return {
|
|
3778
|
+
contents: [
|
|
3779
|
+
{
|
|
3780
|
+
uri: SELECTED_ELEMENT_URI,
|
|
3781
|
+
text: JSON.stringify(readSelectionFromEditor(), null, 2)
|
|
3782
|
+
}
|
|
3783
|
+
]
|
|
3784
|
+
};
|
|
3785
|
+
}
|
|
3786
|
+
);
|
|
3787
|
+
};
|
|
3788
|
+
function createEmptySelectedElementPayload() {
|
|
3789
|
+
return {
|
|
3790
|
+
elementDisplayName: null,
|
|
3791
|
+
elementType: null,
|
|
3792
|
+
properties: null,
|
|
3793
|
+
selectedElementId: null,
|
|
3794
|
+
selectedParentId: null,
|
|
3795
|
+
version: null,
|
|
3796
|
+
widgetType: null
|
|
3797
|
+
};
|
|
3798
|
+
}
|
|
3799
|
+
function readSelectionFromEditor() {
|
|
3800
|
+
const elements = (0, import_editor_elements10.getSelectedElements)();
|
|
3801
|
+
if (elements.length !== 1) {
|
|
3802
|
+
return createEmptySelectedElementPayload();
|
|
3803
|
+
}
|
|
3804
|
+
const container = (0, import_editor_elements10.getContainer)(elements[0].id);
|
|
3805
|
+
return buildPayloadFromContainer(container);
|
|
3806
|
+
}
|
|
3807
|
+
function buildPayloadFromContainer(container) {
|
|
3808
|
+
if (!container?.id) {
|
|
3809
|
+
return createEmptySelectedElementPayload();
|
|
3810
|
+
}
|
|
3811
|
+
const widgetType = container.model.get("widgetType") ?? null;
|
|
3812
|
+
const elementType = container.type ?? "widget";
|
|
3813
|
+
return {
|
|
3814
|
+
elementDisplayName: getElementDisplayName(container),
|
|
3815
|
+
elementType,
|
|
3816
|
+
properties: getElementProperties(container, widgetType),
|
|
3817
|
+
selectedElementId: container.id,
|
|
3818
|
+
selectedParentId: container.parent?.id ?? null,
|
|
3819
|
+
version: resolveElementVersion2(container, widgetType),
|
|
3820
|
+
widgetType
|
|
3821
|
+
};
|
|
3822
|
+
}
|
|
3823
|
+
function resolveElementVersion2(container, widgetType) {
|
|
3824
|
+
if (container.model?.config?.atomic) {
|
|
3825
|
+
return "v4";
|
|
3826
|
+
}
|
|
3827
|
+
if (widgetType && (0, import_editor_elements10.getWidgetsCache)()?.[widgetType]?.atomic_props_schema) {
|
|
3828
|
+
return "v4";
|
|
3829
|
+
}
|
|
3830
|
+
return "v3";
|
|
3831
|
+
}
|
|
3832
|
+
function getElementProperties(container, widgetType) {
|
|
3833
|
+
const settings = container.settings?.toJSON?.();
|
|
3834
|
+
if (!settings || typeof settings !== "object") {
|
|
3835
|
+
return null;
|
|
3836
|
+
}
|
|
3837
|
+
const widgetConfig = widgetType ? (0, import_editor_elements10.getWidgetsCache)()?.[widgetType] : null;
|
|
3838
|
+
const controls = widgetConfig?.controls;
|
|
3839
|
+
const filtered = {};
|
|
3840
|
+
for (const [key, value] of Object.entries(settings)) {
|
|
3841
|
+
if (value === void 0 || value === null || value === "") {
|
|
3842
|
+
continue;
|
|
3843
|
+
}
|
|
3844
|
+
const controlDefault = controls?.[key]?.default;
|
|
3845
|
+
if (controlDefault !== void 0 && JSON.stringify(value) === JSON.stringify(controlDefault)) {
|
|
3846
|
+
continue;
|
|
3847
|
+
}
|
|
3848
|
+
filtered[key] = value;
|
|
3849
|
+
}
|
|
3850
|
+
return Object.keys(filtered).length > 0 ? filtered : null;
|
|
3851
|
+
}
|
|
3852
|
+
function getElementDisplayName(container) {
|
|
3853
|
+
try {
|
|
3854
|
+
if (container.label) {
|
|
3855
|
+
return container.label;
|
|
3856
|
+
}
|
|
3857
|
+
const widgetType = container.model?.get?.("widgetType");
|
|
3858
|
+
if (widgetType) {
|
|
3859
|
+
const capitalizedType = widgetType.charAt(0).toUpperCase() + widgetType.slice(1);
|
|
3860
|
+
return capitalizedType.replace(/-/g, " ");
|
|
3861
|
+
}
|
|
3862
|
+
if (container.type === "container") {
|
|
3863
|
+
return "Container";
|
|
3864
|
+
}
|
|
3865
|
+
if (container.type === "section") {
|
|
3866
|
+
return "Section";
|
|
3867
|
+
}
|
|
3868
|
+
return `Element ${container.id}`;
|
|
3869
|
+
} catch {
|
|
3870
|
+
return `Element ${container.id}`;
|
|
3871
|
+
}
|
|
3872
|
+
}
|
|
3873
|
+
|
|
3321
3874
|
// src/mcp/tools/build-composition/tool.ts
|
|
3322
3875
|
var import_editor_documents3 = require("@elementor/editor-documents");
|
|
3323
|
-
var
|
|
3876
|
+
var import_editor_elements14 = require("@elementor/editor-elements");
|
|
3324
3877
|
|
|
3325
3878
|
// src/composition-builder/composition-builder.ts
|
|
3326
|
-
var
|
|
3879
|
+
var import_editor_elements13 = require("@elementor/editor-elements");
|
|
3327
3880
|
|
|
3328
3881
|
// src/mcp/utils/do-update-element-property.ts
|
|
3329
|
-
var
|
|
3882
|
+
var import_editor_elements11 = require("@elementor/editor-elements");
|
|
3330
3883
|
var import_editor_props6 = require("@elementor/editor-props");
|
|
3331
3884
|
var import_editor_styles5 = require("@elementor/editor-styles");
|
|
3332
3885
|
function resolvePropValue(value, forceKey) {
|
|
@@ -3339,7 +3892,7 @@ function resolvePropValue(value, forceKey) {
|
|
|
3339
3892
|
var doUpdateElementProperty = (params) => {
|
|
3340
3893
|
const { elementId, propertyName, propertyValue, elementType } = params;
|
|
3341
3894
|
if (propertyName === "_styles") {
|
|
3342
|
-
const elementStyles = (0,
|
|
3895
|
+
const elementStyles = (0, import_editor_elements11.getElementStyles)(elementId) || {};
|
|
3343
3896
|
const propertyMapValue = propertyValue;
|
|
3344
3897
|
const styleSchema = (0, import_editor_styles5.getStylesSchema)();
|
|
3345
3898
|
const transformedStyleValues = Object.fromEntries(
|
|
@@ -3387,7 +3940,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
3387
3940
|
delete transformedStyleValues.custom_css;
|
|
3388
3941
|
const localStyle = Object.values(elementStyles).find((style) => style.label === "local");
|
|
3389
3942
|
if (!localStyle) {
|
|
3390
|
-
(0,
|
|
3943
|
+
(0, import_editor_elements11.createElementStyle)({
|
|
3391
3944
|
elementId,
|
|
3392
3945
|
...typeof customCss !== "undefined" ? { custom_css: customCss } : {},
|
|
3393
3946
|
classesProp: "classes",
|
|
@@ -3401,7 +3954,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
3401
3954
|
}
|
|
3402
3955
|
});
|
|
3403
3956
|
} else {
|
|
3404
|
-
(0,
|
|
3957
|
+
(0, import_editor_elements11.updateElementStyle)({
|
|
3405
3958
|
elementId,
|
|
3406
3959
|
styleId: localStyle.id,
|
|
3407
3960
|
meta: {
|
|
@@ -3416,7 +3969,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
3416
3969
|
}
|
|
3417
3970
|
return;
|
|
3418
3971
|
}
|
|
3419
|
-
const elementPropSchema = (0,
|
|
3972
|
+
const elementPropSchema = (0, import_editor_elements11.getWidgetsCache)()?.[elementType]?.atomic_props_schema;
|
|
3420
3973
|
if (!elementPropSchema) {
|
|
3421
3974
|
throw new Error(`No prop schema found for element type: ${elementType}`);
|
|
3422
3975
|
}
|
|
@@ -3430,7 +3983,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
3430
3983
|
}
|
|
3431
3984
|
const propKey = elementPropSchema[propertyName].key;
|
|
3432
3985
|
const value = resolvePropValue(propertyValue, propKey);
|
|
3433
|
-
(0,
|
|
3986
|
+
(0, import_editor_elements11.updateElementSettings)({
|
|
3434
3987
|
id: elementId,
|
|
3435
3988
|
props: {
|
|
3436
3989
|
[propertyName]: value
|
|
@@ -3440,7 +3993,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
3440
3993
|
};
|
|
3441
3994
|
|
|
3442
3995
|
// src/mcp/utils/validate-input.ts
|
|
3443
|
-
var
|
|
3996
|
+
var import_editor_elements12 = require("@elementor/editor-elements");
|
|
3444
3997
|
var import_editor_props7 = require("@elementor/editor-props");
|
|
3445
3998
|
var import_editor_styles6 = require("@elementor/editor-styles");
|
|
3446
3999
|
var _widgetsSchema = null;
|
|
@@ -3448,7 +4001,7 @@ var validateInput = {
|
|
|
3448
4001
|
get widgetsSchema() {
|
|
3449
4002
|
if (!_widgetsSchema) {
|
|
3450
4003
|
const schema2 = {};
|
|
3451
|
-
const cache = (0,
|
|
4004
|
+
const cache = (0, import_editor_elements12.getWidgetsCache)();
|
|
3452
4005
|
if (!cache) {
|
|
3453
4006
|
return {};
|
|
3454
4007
|
}
|
|
@@ -3475,7 +4028,7 @@ var validateInput = {
|
|
|
3475
4028
|
if (!propSchema) {
|
|
3476
4029
|
errors.push(`Property "${propName}" is not defined in the schema.`);
|
|
3477
4030
|
hasInvalidKey = true;
|
|
3478
|
-
} else if (!import_editor_props7.Schema.isPropKeyConfigurable(propName)) {
|
|
4031
|
+
} else if (!import_editor_props7.Schema.isPropKeyConfigurable(propName, propSchema)) {
|
|
3479
4032
|
errors.push(`Property "${propName}" is not configurable.`);
|
|
3480
4033
|
} else {
|
|
3481
4034
|
const { valid } = import_editor_props7.Schema.validatePropValue(propSchema, propValue);
|
|
@@ -3528,13 +4081,13 @@ var validateInput = {
|
|
|
3528
4081
|
var CompositionBuilder = class _CompositionBuilder {
|
|
3529
4082
|
elementConfig = {};
|
|
3530
4083
|
elementStylesConfig = {};
|
|
3531
|
-
|
|
4084
|
+
elementCustomCSS = {};
|
|
3532
4085
|
rootContainers = [];
|
|
3533
4086
|
api = {
|
|
3534
|
-
createElement:
|
|
3535
|
-
getWidgetsCache:
|
|
3536
|
-
generateElementId:
|
|
3537
|
-
getContainer:
|
|
4087
|
+
createElement: import_editor_elements13.createElement,
|
|
4088
|
+
getWidgetsCache: import_editor_elements13.getWidgetsCache,
|
|
4089
|
+
generateElementId: import_editor_elements13.generateElementId,
|
|
4090
|
+
getContainer: import_editor_elements13.getContainer,
|
|
3538
4091
|
doUpdateElementProperty
|
|
3539
4092
|
};
|
|
3540
4093
|
xml;
|
|
@@ -3565,7 +4118,7 @@ var CompositionBuilder = class _CompositionBuilder {
|
|
|
3565
4118
|
this.elementStylesConfig = config;
|
|
3566
4119
|
}
|
|
3567
4120
|
setCustomCSS(config) {
|
|
3568
|
-
this.
|
|
4121
|
+
this.elementCustomCSS = config;
|
|
3569
4122
|
}
|
|
3570
4123
|
getXML() {
|
|
3571
4124
|
return this.xml;
|
|
@@ -3645,7 +4198,7 @@ var CompositionBuilder = class _CompositionBuilder {
|
|
|
3645
4198
|
const allConfigIds = /* @__PURE__ */ new Set([
|
|
3646
4199
|
...Object.keys(this.elementConfig),
|
|
3647
4200
|
...Object.keys(this.elementStylesConfig),
|
|
3648
|
-
...Object.keys(this.
|
|
4201
|
+
...Object.keys(this.elementCustomCSS)
|
|
3649
4202
|
]);
|
|
3650
4203
|
for (const configId of allConfigIds) {
|
|
3651
4204
|
let element, node;
|
|
@@ -3656,7 +4209,7 @@ var CompositionBuilder = class _CompositionBuilder {
|
|
|
3656
4209
|
if (this.elementConfig[configId]) {
|
|
3657
4210
|
configErrors.push(msg);
|
|
3658
4211
|
}
|
|
3659
|
-
if (this.elementStylesConfig[configId] || this.
|
|
4212
|
+
if (this.elementStylesConfig[configId] || this.elementCustomCSS[configId]) {
|
|
3660
4213
|
styleErrors.push(msg);
|
|
3661
4214
|
}
|
|
3662
4215
|
continue;
|
|
@@ -3706,7 +4259,7 @@ var CompositionBuilder = class _CompositionBuilder {
|
|
|
3706
4259
|
}
|
|
3707
4260
|
}
|
|
3708
4261
|
}
|
|
3709
|
-
const customCSS = this.
|
|
4262
|
+
const customCSS = this.elementCustomCSS[configId];
|
|
3710
4263
|
if (customCSS) {
|
|
3711
4264
|
try {
|
|
3712
4265
|
this.api.doUpdateElementProperty({
|
|
@@ -3777,6 +4330,10 @@ var generatePrompt = () => {
|
|
|
3777
4330
|
# RESOURCES (Read before use)
|
|
3778
4331
|
- [elementor://global-classes] - Check FIRST for reusable classes
|
|
3779
4332
|
- [elementor://global-variables] - ONLY use variables defined here
|
|
4333
|
+
- [${AVAILABLE_WIDGETS_URI}/v4]
|
|
4334
|
+
|
|
4335
|
+
# TOOL SUPPORT
|
|
4336
|
+
This tool support v4 elements only
|
|
3780
4337
|
|
|
3781
4338
|
# WORKFLOW
|
|
3782
4339
|
1. Check/create global classes via "create-global-class" tool
|
|
@@ -3958,24 +4515,26 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
3958
4515
|
{ description: "Styles schema", uri: STYLE_SCHEMA_URI },
|
|
3959
4516
|
{ description: "Global Classes", uri: "elementor://global-classes" },
|
|
3960
4517
|
{ description: "Global Variables", uri: "elementor://global-variables" },
|
|
3961
|
-
{ description: "Styles best practices", uri: BEST_PRACTICES_URI }
|
|
4518
|
+
{ description: "Styles best practices", uri: BEST_PRACTICES_URI },
|
|
4519
|
+
{ description: "Available widgets for this tool", uri: AVAILABLE_WIDGETS_URI_V4 }
|
|
3962
4520
|
],
|
|
3963
4521
|
outputSchema,
|
|
3964
4522
|
modelPreferences: {
|
|
3965
4523
|
hints: [{ name: "claude-sonnet-4-5" }]
|
|
3966
4524
|
},
|
|
3967
4525
|
handler: async (params) => {
|
|
4526
|
+
assertCompositionXmlUsesV4WidgetsOnly(params.xmlStructure);
|
|
3968
4527
|
const { xmlStructure, elementConfig, stylesConfig, customCSS } = params;
|
|
3969
4528
|
let generatedXML = "";
|
|
3970
4529
|
const errors = [];
|
|
3971
4530
|
const rootContainers = [];
|
|
3972
|
-
const documentContainer = (0,
|
|
4531
|
+
const documentContainer = (0, import_editor_elements14.getContainer)("document");
|
|
3973
4532
|
const currentDocument = (0, import_editor_documents3.getCurrentDocument)();
|
|
3974
4533
|
const targetContainer = getCompositionTargetContainer(documentContainer, currentDocument?.type.value);
|
|
3975
4534
|
try {
|
|
3976
4535
|
const compositionBuilder = CompositionBuilder.fromXMLString(xmlStructure, {
|
|
3977
|
-
createElement:
|
|
3978
|
-
getWidgetsCache:
|
|
4536
|
+
createElement: import_editor_elements14.createElement,
|
|
4537
|
+
getWidgetsCache: import_editor_elements14.getWidgetsCache
|
|
3979
4538
|
});
|
|
3980
4539
|
compositionBuilder.setElementConfig(elementConfig);
|
|
3981
4540
|
compositionBuilder.setStylesConfig(stylesConfig);
|
|
@@ -4003,7 +4562,7 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
4003
4562
|
}
|
|
4004
4563
|
if (errors.length) {
|
|
4005
4564
|
rootContainers.forEach((rootContainer) => {
|
|
4006
|
-
(0,
|
|
4565
|
+
(0, import_editor_elements14.deleteElement)({
|
|
4007
4566
|
container: rootContainer,
|
|
4008
4567
|
options: { useHistory: false }
|
|
4009
4568
|
});
|
|
@@ -4052,6 +4611,31 @@ Remember: Global classes ensure design consistency and reusability. Don't skip a
|
|
|
4052
4611
|
}
|
|
4053
4612
|
});
|
|
4054
4613
|
};
|
|
4614
|
+
function assertCompositionXmlUsesV4WidgetsOnly(xmlStructure) {
|
|
4615
|
+
const doc = new DOMParser().parseFromString(xmlStructure, "application/xml");
|
|
4616
|
+
if (doc.querySelector("parsererror")) {
|
|
4617
|
+
throw new Error("Failed to parse XML string: " + doc);
|
|
4618
|
+
}
|
|
4619
|
+
const widgetsCache = (0, import_editor_elements14.getWidgetsCache)() ?? {};
|
|
4620
|
+
for (const node of doc.querySelectorAll("*")) {
|
|
4621
|
+
const type = node.tagName;
|
|
4622
|
+
const widgetData = widgetsCache[type];
|
|
4623
|
+
if (!widgetData) {
|
|
4624
|
+
continue;
|
|
4625
|
+
}
|
|
4626
|
+
if (widgetData.elType !== "widget") {
|
|
4627
|
+
continue;
|
|
4628
|
+
}
|
|
4629
|
+
if (!widgetData.atomic_props_schema) {
|
|
4630
|
+
throw new Error(
|
|
4631
|
+
`This tool does not support V3 elements. Please use the elementor-v3-mcp tools instead for element type: ${type}`
|
|
4632
|
+
);
|
|
4633
|
+
}
|
|
4634
|
+
}
|
|
4635
|
+
}
|
|
4636
|
+
|
|
4637
|
+
// src/mcp/tools/configure-element/tool.ts
|
|
4638
|
+
var import_editor_elements15 = require("@elementor/editor-elements");
|
|
4055
4639
|
|
|
4056
4640
|
// src/mcp/tools/configure-element/prompt.ts
|
|
4057
4641
|
var configureElementToolPrompt = `Configure an existing element on the page.
|
|
@@ -4063,11 +4647,11 @@ var configureElementToolPrompt = `Configure an existing element on the page.
|
|
|
4063
4647
|
2. [${STYLE_SCHEMA_URI}]
|
|
4064
4648
|
Required to understand the styles schema for the widgets. All widgets share the same styles schema, grouped by categories.
|
|
4065
4649
|
Use this resource to understand which style properties are available for each element, and how to structure the "stylePropertiesToChange" parameter.
|
|
4066
|
-
3. If not sure about the PropValues schema, you can use the "get-element-configuration-values" tool to
|
|
4650
|
+
3. If not sure about the PropValues schema, you can use the "get-element-configuration-values" tool to retrieve the current PropValues configuration of the element.
|
|
4067
4651
|
|
|
4068
4652
|
Before using this tool, check the definitions of the elements PropTypes at the resource "widget-schema-by-type" at editor-canvas__elementor://widgets/schema/{widgetType}
|
|
4069
4653
|
All widgets share a common _style property for styling, which uses the common styles schema.
|
|
4070
|
-
|
|
4654
|
+
Retrieve and check the common styles schema at the resource list "styles-schema" at editor-canvas__elementor://styles/schema/{category}
|
|
4071
4655
|
|
|
4072
4656
|
# Parameters
|
|
4073
4657
|
- propertiesToChange: An object containing the properties to change, with their new values. MANDATORY. When updating a style only, provide an empty object.
|
|
@@ -4096,19 +4680,19 @@ PropValue structure:
|
|
|
4096
4680
|
}
|
|
4097
4681
|
|
|
4098
4682
|
<IMPORTANT>
|
|
4099
|
-
ALWAYS MAKE SURE you have the PropType schemas for the element you are configuring, and the common-styles schema for styling. If you are not sure,
|
|
4683
|
+
ALWAYS MAKE SURE you have the PropType schemas for the element you are configuring, and the common-styles schema for styling. If you are not sure, retrieve the schema from the resources mentioned above.
|
|
4100
4684
|
</IMPORTANT>
|
|
4101
4685
|
|
|
4102
4686
|
You can use multiple property changes at once by providing multiple entries in the propertiesToChange object, including _style alongside non-style props.
|
|
4103
4687
|
Some properties are nested, use the root property name, then objects with nested values inside, as the complete schema suggests.
|
|
4104
4688
|
|
|
4105
|
-
Make sure you have the "widget-schema-by-type" resource available to
|
|
4106
|
-
Make sure you have to "styles-schema" resources available to
|
|
4689
|
+
Make sure you have the "widget-schema-by-type" resource available to retrieve the PropType schema for the element type you are configuring.
|
|
4690
|
+
Make sure you have to "styles-schema" resources available to retrieve the common styles schema.
|
|
4107
4691
|
|
|
4108
4692
|
# How to configure elements
|
|
4109
4693
|
We use a dedicated PropType Schema for configuring elements, including styles. When you configure an element, you must use the EXACT PropType Value as defined in the schema.
|
|
4110
4694
|
For styleProperties, use the style schema provided, as it also uses the PropType format.
|
|
4111
|
-
For all non-primitive types, provide the key property as defined in the schema as $$type in the generated
|
|
4695
|
+
For all non-primitive types, provide the key property as defined in the schema as $$type in the generated object, as it is MANDATORY for parsing.
|
|
4112
4696
|
|
|
4113
4697
|
Use the EXACT "PROP-TYPE" Schema given, and ALWAYS include the "key" property from the original configuration for every property you are changing.
|
|
4114
4698
|
|
|
@@ -4164,7 +4748,7 @@ var inputSchema2 = {
|
|
|
4164
4748
|
import_schema3.z.any().describe(`The style PropValue, refer to [${STYLE_SCHEMA_URI}] how to generate values`),
|
|
4165
4749
|
import_schema3.z.any()
|
|
4166
4750
|
).describe("An object record containing style property names and their new values to be set on the element").default({}),
|
|
4167
|
-
elementType: import_schema3.z.string().describe("The type of the element to
|
|
4751
|
+
elementType: import_schema3.z.string().describe("The type of the element to retrieve the schema"),
|
|
4168
4752
|
elementId: import_schema3.z.string().describe("The unique id of the element to configure")
|
|
4169
4753
|
};
|
|
4170
4754
|
var outputSchema2 = {
|
|
@@ -4191,6 +4775,17 @@ var initConfigureElementTool = (reg) => {
|
|
|
4191
4775
|
speedPriority: 0.7
|
|
4192
4776
|
},
|
|
4193
4777
|
handler: ({ elementId, propertiesToChange, elementType, stylePropertiesToChange }) => {
|
|
4778
|
+
const widgetData = (0, import_editor_elements15.getWidgetsCache)()?.[elementType];
|
|
4779
|
+
if (!widgetData) {
|
|
4780
|
+
throw new Error(
|
|
4781
|
+
`Unknown element type: ${elementType}. Check the available-widgets resource for valid types.`
|
|
4782
|
+
);
|
|
4783
|
+
}
|
|
4784
|
+
if (!widgetData.atomic_props_schema) {
|
|
4785
|
+
throw new Error(
|
|
4786
|
+
`This tool does not support V3 elements. Please use the elementor-v3-mcp tools instead for element type: ${elementType}`
|
|
4787
|
+
);
|
|
4788
|
+
}
|
|
4194
4789
|
const toUpdate = Object.entries(propertiesToChange);
|
|
4195
4790
|
const { valid, errors } = validateInput.validatePropSchema(elementType, propertiesToChange);
|
|
4196
4791
|
const { valid: stylesValid, errors: stylesErrors } = validateInput.validateStyles(
|
|
@@ -4272,7 +4867,7 @@ Check the styles schema at the resource [${STYLE_SCHEMA_URI.replace(
|
|
|
4272
4867
|
}
|
|
4273
4868
|
|
|
4274
4869
|
// src/mcp/tools/get-element-config/tool.ts
|
|
4275
|
-
var
|
|
4870
|
+
var import_editor_elements16 = require("@elementor/editor-elements");
|
|
4276
4871
|
var import_editor_props8 = require("@elementor/editor-props");
|
|
4277
4872
|
var import_schema5 = require("@elementor/schema");
|
|
4278
4873
|
var schema = {
|
|
@@ -4311,12 +4906,24 @@ var initGetElementConfigTool = (reg) => {
|
|
|
4311
4906
|
speedPriority: 0.9
|
|
4312
4907
|
},
|
|
4313
4908
|
handler: async ({ elementId }) => {
|
|
4314
|
-
const element = (0,
|
|
4909
|
+
const element = (0, import_editor_elements16.getContainer)(elementId);
|
|
4315
4910
|
if (!element) {
|
|
4316
4911
|
throw new Error(`Element with ID ${elementId} not found.`);
|
|
4317
4912
|
}
|
|
4913
|
+
const elementType = element.model.get("widgetType") || element.model.get("elType") || "";
|
|
4914
|
+
const widgetData = (0, import_editor_elements16.getWidgetsCache)()?.[elementType];
|
|
4915
|
+
if (!widgetData) {
|
|
4916
|
+
throw new Error(
|
|
4917
|
+
`Unknown element type: ${elementType}. Check the available-widgets resource for valid types.`
|
|
4918
|
+
);
|
|
4919
|
+
}
|
|
4920
|
+
if (!widgetData.atomic_props_schema) {
|
|
4921
|
+
throw new Error(
|
|
4922
|
+
`This tool does not support V3 elements. Please use the elementor-v3-mcp tools instead for element type: ${elementType}`
|
|
4923
|
+
);
|
|
4924
|
+
}
|
|
4318
4925
|
const elementRawSettings = element.settings;
|
|
4319
|
-
const propSchema = (0,
|
|
4926
|
+
const propSchema = (0, import_editor_elements16.getWidgetsCache)()?.[elementType]?.atomic_props_schema;
|
|
4320
4927
|
if (!elementRawSettings || !propSchema) {
|
|
4321
4928
|
throw new Error(`No settings or prop schema found for element ID: ${elementId}`);
|
|
4322
4929
|
}
|
|
@@ -4325,7 +4932,7 @@ var initGetElementConfigTool = (reg) => {
|
|
|
4325
4932
|
import_editor_props8.Schema.configurableKeys(propSchema).forEach((key) => {
|
|
4326
4933
|
propValues[key] = structuredClone(elementRawSettings.get(key));
|
|
4327
4934
|
});
|
|
4328
|
-
const elementStyles = (0,
|
|
4935
|
+
const elementStyles = (0, import_editor_elements16.getElementStyles)(elementId) || {};
|
|
4329
4936
|
const localStyle = Object.values(elementStyles).find((style) => style.label === "local");
|
|
4330
4937
|
if (localStyle) {
|
|
4331
4938
|
const defaultVariant = localStyle.variants.find(
|
|
@@ -4368,7 +4975,11 @@ var initCanvasMcp = (reg) => {
|
|
|
4368
4975
|
`
|
|
4369
4976
|
);
|
|
4370
4977
|
initWidgetsSchemaResource(reg);
|
|
4978
|
+
initAvailableWidgetsResource(reg);
|
|
4371
4979
|
initDocumentStructureResource(reg);
|
|
4980
|
+
initSelectedElementResource(reg);
|
|
4981
|
+
initEditorStateResource(reg);
|
|
4982
|
+
initGeneralContextResource(reg);
|
|
4372
4983
|
initBuildCompositionsTool(reg);
|
|
4373
4984
|
initGetElementConfigTool(reg);
|
|
4374
4985
|
initConfigureElementTool(reg);
|
|
@@ -4488,16 +5099,16 @@ Note: The "size" property controls image resolution/loading, not visual size. Se
|
|
|
4488
5099
|
`;
|
|
4489
5100
|
|
|
4490
5101
|
// src/prevent-link-in-link-commands.ts
|
|
4491
|
-
var
|
|
5102
|
+
var import_editor_elements17 = require("@elementor/editor-elements");
|
|
4492
5103
|
var import_editor_notifications3 = require("@elementor/editor-notifications");
|
|
4493
|
-
var
|
|
5104
|
+
var import_editor_v1_adapters19 = require("@elementor/editor-v1-adapters");
|
|
4494
5105
|
var import_i18n4 = require("@wordpress/i18n");
|
|
4495
5106
|
function initLinkInLinkPrevention() {
|
|
4496
|
-
(0,
|
|
5107
|
+
(0, import_editor_v1_adapters19.blockCommand)({
|
|
4497
5108
|
command: "document/elements/paste",
|
|
4498
5109
|
condition: blockLinkInLinkPaste
|
|
4499
5110
|
});
|
|
4500
|
-
(0,
|
|
5111
|
+
(0, import_editor_v1_adapters19.blockCommand)({
|
|
4501
5112
|
command: "document/elements/move",
|
|
4502
5113
|
condition: blockLinkInLinkMove
|
|
4503
5114
|
});
|
|
@@ -4559,24 +5170,24 @@ function shouldBlock(sourceElements, targetElements) {
|
|
|
4559
5170
|
return false;
|
|
4560
5171
|
}
|
|
4561
5172
|
const isSourceContainsAnAnchor = sourceElements.some((src) => {
|
|
4562
|
-
return src?.id ? (0,
|
|
5173
|
+
return src?.id ? (0, import_editor_elements17.isElementAnchored)(src.id) || !!(0, import_editor_elements17.getAnchoredDescendantId)(src.id) : false;
|
|
4563
5174
|
});
|
|
4564
5175
|
if (!isSourceContainsAnAnchor) {
|
|
4565
5176
|
return false;
|
|
4566
5177
|
}
|
|
4567
5178
|
const isTargetContainsAnAnchor = targetElements.some((target) => {
|
|
4568
|
-
return target?.id ? (0,
|
|
5179
|
+
return target?.id ? (0, import_editor_elements17.isElementAnchored)(target.id) || !!(0, import_editor_elements17.getAnchoredAncestorId)(target.id) : false;
|
|
4569
5180
|
});
|
|
4570
5181
|
return isTargetContainsAnAnchor;
|
|
4571
5182
|
}
|
|
4572
5183
|
|
|
4573
5184
|
// src/style-commands/paste-style.ts
|
|
4574
|
-
var
|
|
5185
|
+
var import_editor_elements20 = require("@elementor/editor-elements");
|
|
4575
5186
|
var import_editor_props10 = require("@elementor/editor-props");
|
|
4576
|
-
var
|
|
5187
|
+
var import_editor_v1_adapters21 = require("@elementor/editor-v1-adapters");
|
|
4577
5188
|
|
|
4578
5189
|
// src/utils/command-utils.ts
|
|
4579
|
-
var
|
|
5190
|
+
var import_editor_elements18 = require("@elementor/editor-elements");
|
|
4580
5191
|
var import_editor_props9 = require("@elementor/editor-props");
|
|
4581
5192
|
var import_i18n5 = require("@wordpress/i18n");
|
|
4582
5193
|
function hasAtomicWidgets(args) {
|
|
@@ -4601,7 +5212,7 @@ function getClassesProp(container) {
|
|
|
4601
5212
|
}
|
|
4602
5213
|
function getContainerSchema(container) {
|
|
4603
5214
|
const type = container?.model.get("widgetType") || container?.model.get("elType");
|
|
4604
|
-
const widgetsCache = (0,
|
|
5215
|
+
const widgetsCache = (0, import_editor_elements18.getWidgetsCache)();
|
|
4605
5216
|
const elementType = widgetsCache?.[type];
|
|
4606
5217
|
return elementType?.atomic_props_schema ?? null;
|
|
4607
5218
|
}
|
|
@@ -4614,15 +5225,15 @@ function getClipboardElements(storageKey = "clipboard") {
|
|
|
4614
5225
|
}
|
|
4615
5226
|
}
|
|
4616
5227
|
function getTitleForContainers(containers) {
|
|
4617
|
-
return containers.length > 1 ? (0, import_i18n5.__)("Elements", "elementor") : (0,
|
|
5228
|
+
return containers.length > 1 ? (0, import_i18n5.__)("Elements", "elementor") : (0, import_editor_elements18.getElementLabel)(containers[0].id);
|
|
4618
5229
|
}
|
|
4619
5230
|
|
|
4620
5231
|
// src/style-commands/undoable-actions/paste-element-style.ts
|
|
4621
|
-
var
|
|
5232
|
+
var import_editor_elements19 = require("@elementor/editor-elements");
|
|
4622
5233
|
var import_editor_styles_repository4 = require("@elementor/editor-styles-repository");
|
|
4623
|
-
var
|
|
5234
|
+
var import_editor_v1_adapters20 = require("@elementor/editor-v1-adapters");
|
|
4624
5235
|
var import_i18n6 = require("@wordpress/i18n");
|
|
4625
|
-
var undoablePasteElementStyle = () => (0,
|
|
5236
|
+
var undoablePasteElementStyle = () => (0, import_editor_v1_adapters20.undoable)(
|
|
4626
5237
|
{
|
|
4627
5238
|
do: ({ containers, newStyle }) => {
|
|
4628
5239
|
return containers.map((container) => {
|
|
@@ -4631,7 +5242,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters16.undoable)(
|
|
|
4631
5242
|
if (!classesProp) {
|
|
4632
5243
|
return null;
|
|
4633
5244
|
}
|
|
4634
|
-
const originalStyles = (0,
|
|
5245
|
+
const originalStyles = (0, import_editor_elements19.getElementStyles)(container.id);
|
|
4635
5246
|
const [styleId, styleDef] = Object.entries(originalStyles ?? {})[0] ?? [];
|
|
4636
5247
|
const originalStyle = Object.keys(styleDef ?? {}).length ? styleDef : null;
|
|
4637
5248
|
const revertData = {
|
|
@@ -4640,7 +5251,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters16.undoable)(
|
|
|
4640
5251
|
};
|
|
4641
5252
|
if (styleId) {
|
|
4642
5253
|
newStyle.variants.forEach(({ meta, props, custom_css: customCss }) => {
|
|
4643
|
-
(0,
|
|
5254
|
+
(0, import_editor_elements19.updateElementStyle)({
|
|
4644
5255
|
elementId,
|
|
4645
5256
|
styleId,
|
|
4646
5257
|
meta,
|
|
@@ -4651,7 +5262,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters16.undoable)(
|
|
|
4651
5262
|
} else {
|
|
4652
5263
|
const [firstVariant] = newStyle.variants;
|
|
4653
5264
|
const additionalVariants = newStyle.variants.slice(1);
|
|
4654
|
-
revertData.styleId = (0,
|
|
5265
|
+
revertData.styleId = (0, import_editor_elements19.createElementStyle)({
|
|
4655
5266
|
elementId,
|
|
4656
5267
|
classesProp,
|
|
4657
5268
|
label: import_editor_styles_repository4.ELEMENTS_STYLES_RESERVED_LABEL,
|
|
@@ -4669,7 +5280,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters16.undoable)(
|
|
|
4669
5280
|
return;
|
|
4670
5281
|
}
|
|
4671
5282
|
if (!revertData.originalStyle) {
|
|
4672
|
-
(0,
|
|
5283
|
+
(0, import_editor_elements19.deleteElementStyle)(container.id, revertData.styleId);
|
|
4673
5284
|
return;
|
|
4674
5285
|
}
|
|
4675
5286
|
const classesProp = getClassesProp(container);
|
|
@@ -4678,7 +5289,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters16.undoable)(
|
|
|
4678
5289
|
}
|
|
4679
5290
|
const [firstVariant] = revertData.originalStyle.variants;
|
|
4680
5291
|
const additionalVariants = revertData.originalStyle.variants.slice(1);
|
|
4681
|
-
(0,
|
|
5292
|
+
(0, import_editor_elements19.createElementStyle)({
|
|
4682
5293
|
elementId: container.id,
|
|
4683
5294
|
classesProp,
|
|
4684
5295
|
label: import_editor_styles_repository4.ELEMENTS_STYLES_RESERVED_LABEL,
|
|
@@ -4698,12 +5309,12 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters16.undoable)(
|
|
|
4698
5309
|
// src/style-commands/paste-style.ts
|
|
4699
5310
|
function initPasteStyleCommand() {
|
|
4700
5311
|
const pasteElementStyleCommand = undoablePasteElementStyle();
|
|
4701
|
-
(0,
|
|
5312
|
+
(0, import_editor_v1_adapters21.blockCommand)({
|
|
4702
5313
|
command: "document/elements/paste-style",
|
|
4703
5314
|
condition: hasAtomicWidgets
|
|
4704
5315
|
});
|
|
4705
|
-
(0,
|
|
4706
|
-
(0,
|
|
5316
|
+
(0, import_editor_v1_adapters21.__privateListenTo)(
|
|
5317
|
+
(0, import_editor_v1_adapters21.commandStartEvent)("document/elements/paste-style"),
|
|
4707
5318
|
(e) => pasteStyles(e.args, pasteElementStyleCommand)
|
|
4708
5319
|
);
|
|
4709
5320
|
}
|
|
@@ -4715,7 +5326,7 @@ function pasteStyles(args, pasteLocalStyle) {
|
|
|
4715
5326
|
}
|
|
4716
5327
|
const clipboardElements = getClipboardElements(storageKey);
|
|
4717
5328
|
const [clipboardElement] = clipboardElements ?? [];
|
|
4718
|
-
const clipboardContainer = (0,
|
|
5329
|
+
const clipboardContainer = (0, import_editor_elements20.getContainer)(clipboardElement.id);
|
|
4719
5330
|
if (!clipboardElement || !clipboardContainer || !isAtomicWidget(clipboardContainer)) {
|
|
4720
5331
|
return;
|
|
4721
5332
|
}
|
|
@@ -4734,7 +5345,7 @@ function getClassesWithoutLocalStyle(clipboardContainer, style) {
|
|
|
4734
5345
|
if (!classesProp) {
|
|
4735
5346
|
return [];
|
|
4736
5347
|
}
|
|
4737
|
-
const classesSetting = (0,
|
|
5348
|
+
const classesSetting = (0, import_editor_elements20.getElementSetting)(clipboardContainer.id, classesProp);
|
|
4738
5349
|
return classesSetting?.value.filter((styleId) => styleId !== style?.id) ?? [];
|
|
4739
5350
|
}
|
|
4740
5351
|
function pasteClasses(containers, classes) {
|
|
@@ -4743,10 +5354,10 @@ function pasteClasses(containers, classes) {
|
|
|
4743
5354
|
if (!classesProp) {
|
|
4744
5355
|
return;
|
|
4745
5356
|
}
|
|
4746
|
-
const classesSetting = (0,
|
|
5357
|
+
const classesSetting = (0, import_editor_elements20.getElementSetting)(container.id, classesProp);
|
|
4747
5358
|
const currentClasses = import_editor_props10.classesPropTypeUtil.extract(classesSetting) ?? [];
|
|
4748
5359
|
const newClasses = import_editor_props10.classesPropTypeUtil.create(Array.from(/* @__PURE__ */ new Set([...classes, ...currentClasses])));
|
|
4749
|
-
(0,
|
|
5360
|
+
(0, import_editor_elements20.updateElementSettings)({
|
|
4750
5361
|
id: container.id,
|
|
4751
5362
|
props: { [classesProp]: newClasses }
|
|
4752
5363
|
});
|
|
@@ -4754,21 +5365,21 @@ function pasteClasses(containers, classes) {
|
|
|
4754
5365
|
}
|
|
4755
5366
|
|
|
4756
5367
|
// src/style-commands/reset-style.ts
|
|
4757
|
-
var
|
|
5368
|
+
var import_editor_v1_adapters23 = require("@elementor/editor-v1-adapters");
|
|
4758
5369
|
|
|
4759
5370
|
// src/style-commands/undoable-actions/reset-element-style.ts
|
|
4760
|
-
var
|
|
5371
|
+
var import_editor_elements21 = require("@elementor/editor-elements");
|
|
4761
5372
|
var import_editor_styles_repository5 = require("@elementor/editor-styles-repository");
|
|
4762
|
-
var
|
|
5373
|
+
var import_editor_v1_adapters22 = require("@elementor/editor-v1-adapters");
|
|
4763
5374
|
var import_i18n7 = require("@wordpress/i18n");
|
|
4764
|
-
var undoableResetElementStyle = () => (0,
|
|
5375
|
+
var undoableResetElementStyle = () => (0, import_editor_v1_adapters22.undoable)(
|
|
4765
5376
|
{
|
|
4766
5377
|
do: ({ containers }) => {
|
|
4767
5378
|
return containers.map((container) => {
|
|
4768
5379
|
const elementId = container.model.get("id");
|
|
4769
|
-
const containerStyles = (0,
|
|
5380
|
+
const containerStyles = (0, import_editor_elements21.getElementStyles)(elementId);
|
|
4770
5381
|
Object.keys(containerStyles ?? {}).forEach(
|
|
4771
|
-
(styleId) => (0,
|
|
5382
|
+
(styleId) => (0, import_editor_elements21.deleteElementStyle)(elementId, styleId)
|
|
4772
5383
|
);
|
|
4773
5384
|
return containerStyles;
|
|
4774
5385
|
});
|
|
@@ -4784,7 +5395,7 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters18.undoable)(
|
|
|
4784
5395
|
Object.entries(containerStyles ?? {}).forEach(([styleId, style]) => {
|
|
4785
5396
|
const [firstVariant] = style.variants;
|
|
4786
5397
|
const additionalVariants = style.variants.slice(1);
|
|
4787
|
-
(0,
|
|
5398
|
+
(0, import_editor_elements21.createElementStyle)({
|
|
4788
5399
|
elementId,
|
|
4789
5400
|
classesProp,
|
|
4790
5401
|
styleId,
|
|
@@ -4805,12 +5416,12 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters18.undoable)(
|
|
|
4805
5416
|
// src/style-commands/reset-style.ts
|
|
4806
5417
|
function initResetStyleCommand() {
|
|
4807
5418
|
const resetElementStyles = undoableResetElementStyle();
|
|
4808
|
-
(0,
|
|
5419
|
+
(0, import_editor_v1_adapters23.blockCommand)({
|
|
4809
5420
|
command: "document/elements/reset-style",
|
|
4810
5421
|
condition: hasAtomicWidgets
|
|
4811
5422
|
});
|
|
4812
|
-
(0,
|
|
4813
|
-
(0,
|
|
5423
|
+
(0, import_editor_v1_adapters23.__privateListenTo)(
|
|
5424
|
+
(0, import_editor_v1_adapters23.commandStartEvent)("document/elements/reset-style"),
|
|
4814
5425
|
(e) => resetStyles(e.args, resetElementStyles)
|
|
4815
5426
|
);
|
|
4816
5427
|
}
|
|
@@ -4907,10 +5518,34 @@ var getLegacyPanelElementView = ({ settings, ...rest }) => {
|
|
|
4907
5518
|
});
|
|
4908
5519
|
return { model: elementModel };
|
|
4909
5520
|
};
|
|
5521
|
+
|
|
5522
|
+
// src/sync/global-styles-imported-event.ts
|
|
5523
|
+
var GLOBAL_STYLES_IMPORTED_EVENT = "elementor/global-styles/imported";
|
|
5524
|
+
|
|
5525
|
+
// src/utils/after-render.ts
|
|
5526
|
+
var import_editor_elements22 = require("@elementor/editor-elements");
|
|
5527
|
+
function doAfterRender(elementIds, callback) {
|
|
5528
|
+
const pending = elementIds.map((elementId) => {
|
|
5529
|
+
const view = (0, import_editor_elements22.getContainer)(elementId)?.view;
|
|
5530
|
+
if (!view || !hasDoAfterRender(view)) {
|
|
5531
|
+
return void 0;
|
|
5532
|
+
}
|
|
5533
|
+
return new Promise((resolve) => view._doAfterRender(resolve));
|
|
5534
|
+
}).filter(Boolean);
|
|
5535
|
+
if (pending.length > 0) {
|
|
5536
|
+
Promise.all(pending).then(() => callback(elementIds));
|
|
5537
|
+
} else {
|
|
5538
|
+
callback(elementIds);
|
|
5539
|
+
}
|
|
5540
|
+
}
|
|
5541
|
+
function hasDoAfterRender(view) {
|
|
5542
|
+
return typeof view?._doAfterRender === "function";
|
|
5543
|
+
}
|
|
4910
5544
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4911
5545
|
0 && (module.exports = {
|
|
4912
5546
|
BREAKPOINTS_SCHEMA_URI,
|
|
4913
5547
|
DOCUMENT_STRUCTURE_URI,
|
|
5548
|
+
GLOBAL_STYLES_IMPORTED_EVENT,
|
|
4914
5549
|
STYLE_SCHEMA_URI,
|
|
4915
5550
|
UnknownStyleStateError,
|
|
4916
5551
|
UnknownStyleTypeError,
|
|
@@ -4922,6 +5557,7 @@ var getLegacyPanelElementView = ({ settings, ...rest }) => {
|
|
|
4922
5557
|
createTemplatedElementView,
|
|
4923
5558
|
createTransformer,
|
|
4924
5559
|
createTransformersRegistry,
|
|
5560
|
+
doAfterRender,
|
|
4925
5561
|
endDragElementFromPanel,
|
|
4926
5562
|
init,
|
|
4927
5563
|
isAtomicWidget,
|