@elementor/editor-canvas 4.3.0-991 → 4.3.0-993
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 +251 -409
- package/dist/index.mjs +122 -282
- package/package.json +20 -20
- package/src/mcp/resources/__tests__/available-widgets-resource.test.ts +76 -0
- package/src/mcp/resources/__tests__/widgets-schema-resource.test.ts +79 -76
- package/src/mcp/resources/available-widgets-resource.ts +31 -40
- package/src/mcp/resources/widgets-schema-resource.ts +35 -150
- package/src/mcp/resources/build-llm-guidance.ts +0 -110
package/dist/index.js
CHANGED
|
@@ -71,176 +71,37 @@ module.exports = __toCommonJS(index_exports);
|
|
|
71
71
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
72
72
|
|
|
73
73
|
// src/mcp/resources/widgets-schema-resource.ts
|
|
74
|
-
var import_editor_elements2 = require("@elementor/editor-elements");
|
|
75
74
|
var import_editor_mcp = require("@elementor/editor-mcp");
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
// src/mcp/utils/element-data-util.ts
|
|
79
|
-
var import_editor_elements = require("@elementor/editor-elements");
|
|
80
|
-
function hasV3Controls(controls) {
|
|
81
|
-
return typeof controls === "object" && controls !== null && Object.keys(controls).length > 0;
|
|
82
|
-
}
|
|
83
|
-
function isWidgetAvailableForLLM(config) {
|
|
84
|
-
if (!config) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
if (config.meta?.llm_support === false) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
if (config.title === "Component") {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
if (config.atomic_props_schema) {
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
return hasV3Controls(config.controls);
|
|
97
|
-
}
|
|
98
|
-
function getWidgetVersion(config) {
|
|
99
|
-
return config?.atomic_props_schema ? "v4" : "v3";
|
|
100
|
-
}
|
|
101
|
-
function getAvailableWidgets() {
|
|
102
|
-
const cache = (0, import_editor_elements.getWidgetsCache)() ?? {};
|
|
103
|
-
return Object.keys(cache).filter((widgetType) => isWidgetAvailableForLLM(cache[widgetType])).sort().map((widgetType) => {
|
|
104
|
-
const config = cache[widgetType];
|
|
105
|
-
const description = typeof config?.meta?.description === "string" ? config.meta.description : void 0;
|
|
106
|
-
return {
|
|
107
|
-
type: widgetType,
|
|
108
|
-
version: getWidgetVersion(config),
|
|
109
|
-
...description && { description }
|
|
110
|
-
};
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// src/composition-builder/utils/required-default-child-tags.ts
|
|
115
|
-
function getRequiredDefaultChildTemplates(elementConfig) {
|
|
116
|
-
const defaultChildren = elementConfig?.default_children;
|
|
117
|
-
if (!Array.isArray(defaultChildren)) {
|
|
118
|
-
return [];
|
|
119
|
-
}
|
|
120
|
-
return defaultChildren.filter((child) => child?.meta?.required ?? false);
|
|
121
|
-
}
|
|
122
|
-
function getRequiredDefaultChildTypes(elementConfig) {
|
|
123
|
-
return getRequiredDefaultChildTemplates(elementConfig).map((child) => child.widgetType ?? child.elType ?? "").filter((type) => Boolean(type));
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// src/mcp/resources/build-llm-guidance.ts
|
|
127
|
-
var DEFAULT_STYLES_INSTRUCTION = "These are the default styles applied to the widget. Override only when necessary.";
|
|
128
|
-
var DEFAULT_SETTINGS_INSTRUCTION = "These are the default settings applied to the widget. Omit them from elementConfig unless the user explicitly asks to change them.";
|
|
129
|
-
var BASE_SETTING_PROP_HINT = "Has a widget default \u2014 omit unless user explicitly requests a change. See llm_guidance.default_settings.";
|
|
130
|
-
function mergeInstructions(existing, additional) {
|
|
131
|
-
if (typeof existing === "string" && existing.length > 0) {
|
|
132
|
-
return `${existing} ${additional}`;
|
|
133
|
-
}
|
|
134
|
-
return additional;
|
|
135
|
-
}
|
|
136
|
-
function enrichPropertiesWithBaseSettingsHints(properties, baseSettingsKeys) {
|
|
137
|
-
if (!baseSettingsKeys.length) {
|
|
138
|
-
return properties;
|
|
139
|
-
}
|
|
140
|
-
const enriched = { ...properties };
|
|
141
|
-
for (const key of baseSettingsKeys) {
|
|
142
|
-
const propSchema = enriched[key];
|
|
143
|
-
if (!propSchema) {
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
enriched[key] = {
|
|
147
|
-
...propSchema,
|
|
148
|
-
description: propSchema.description ? `${propSchema.description} ${BASE_SETTING_PROP_HINT}` : BASE_SETTING_PROP_HINT
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
return enriched;
|
|
152
|
-
}
|
|
153
|
-
function buildLlmGuidance(widgetData, widgetType, allWidgets) {
|
|
154
|
-
const defaultStyles = {};
|
|
155
|
-
const baseStyleSchema = widgetData?.base_styles;
|
|
156
|
-
if (baseStyleSchema) {
|
|
157
|
-
Object.values(baseStyleSchema).forEach((stylePropType) => {
|
|
158
|
-
stylePropType.variants.forEach((variant) => {
|
|
159
|
-
Object.assign(defaultStyles, variant.props);
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
const baseSettings = widgetData?.base_settings ?? {};
|
|
164
|
-
const hasDefaultStyles = Object.keys(defaultStyles).length > 0;
|
|
165
|
-
const hasDefaultSettings = Object.keys(baseSettings).length > 0;
|
|
166
|
-
const llmGuidance = {
|
|
167
|
-
can_have_children: !!widgetData?.meta?.is_container
|
|
168
|
-
};
|
|
169
|
-
if (hasDefaultStyles) {
|
|
170
|
-
llmGuidance.instructions = DEFAULT_STYLES_INSTRUCTION;
|
|
171
|
-
llmGuidance.default_styles = defaultStyles;
|
|
172
|
-
}
|
|
173
|
-
if (hasDefaultSettings) {
|
|
174
|
-
llmGuidance.instructions = mergeInstructions(llmGuidance.instructions, DEFAULT_SETTINGS_INSTRUCTION);
|
|
175
|
-
llmGuidance.default_settings = baseSettings;
|
|
176
|
-
}
|
|
177
|
-
const allowedChildTypes = widgetData.allowed_child_types;
|
|
178
|
-
const allowedParents = Object.entries(allWidgets).filter(([, parentConfig]) => parentConfig.allowed_child_types?.includes(widgetType)).map(([parentType]) => parentType);
|
|
179
|
-
if (allowedChildTypes?.length || allowedParents.length) {
|
|
180
|
-
llmGuidance.nesting = {
|
|
181
|
-
...allowedChildTypes?.length ? { allowed_child_types: allowedChildTypes } : {},
|
|
182
|
-
...allowedParents.length ? { allowed_parents: allowedParents } : {}
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
const requiredDirectChildTags = getRequiredDefaultChildTypes(widgetData);
|
|
186
|
-
if (requiredDirectChildTags.length) {
|
|
187
|
-
llmGuidance.required_direct_children = requiredDirectChildTags;
|
|
188
|
-
}
|
|
189
|
-
return llmGuidance;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// src/mcp/resources/widgets-schema-resource.ts
|
|
193
|
-
var V3_LAYOUT_CONTROL_TYPES = /* @__PURE__ */ new Set(["section", "tab", "tabs"]);
|
|
194
|
-
function extractV3ControlsMetadata(controls) {
|
|
195
|
-
if (!hasV3Controls(controls)) {
|
|
196
|
-
return {};
|
|
197
|
-
}
|
|
198
|
-
const result = {};
|
|
199
|
-
for (const [controlKey, raw] of Object.entries(controls)) {
|
|
200
|
-
if (!raw || typeof raw !== "object") {
|
|
201
|
-
continue;
|
|
202
|
-
}
|
|
203
|
-
const control = raw;
|
|
204
|
-
const controlType = typeof control.type === "string" ? control.type : void 0;
|
|
205
|
-
if (controlType && V3_LAYOUT_CONTROL_TYPES.has(controlType)) {
|
|
206
|
-
continue;
|
|
207
|
-
}
|
|
208
|
-
const entry = {};
|
|
209
|
-
if (Object.prototype.hasOwnProperty.call(control, "default")) {
|
|
210
|
-
entry.default = control.default;
|
|
211
|
-
}
|
|
212
|
-
if (controlType) {
|
|
213
|
-
entry.type = controlType;
|
|
214
|
-
}
|
|
215
|
-
if (Object.prototype.hasOwnProperty.call(control, "options") && control.options !== void 0) {
|
|
216
|
-
const options = control.options;
|
|
217
|
-
if (options && typeof options === "object" && !Array.isArray(options)) {
|
|
218
|
-
entry.options = Object.keys(options);
|
|
219
|
-
} else {
|
|
220
|
-
entry.options = options;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
result[controlKey] = entry;
|
|
224
|
-
}
|
|
225
|
-
return result;
|
|
226
|
-
}
|
|
75
|
+
var import_http_client = require("@elementor/http-client");
|
|
227
76
|
var CANVAS_SERVER_NAME = "editor-canvas";
|
|
228
77
|
var WIDGET_SCHEMA_URI = "elementor://widgets/schema/{widgetType}";
|
|
229
78
|
var WIDGET_SCHEMA_FULL_URI = `${CANVAS_SERVER_NAME}_${WIDGET_SCHEMA_URI}`;
|
|
230
79
|
var BEST_PRACTICES_URI = "elementor://style/best-practices";
|
|
231
80
|
var BEST_PRACTICES_FULL_URI = `${CANVAS_SERVER_NAME}_${BEST_PRACTICES_URI}`;
|
|
81
|
+
var MCP_PROXY_URL = "elementor/v1/mcp-proxy";
|
|
82
|
+
var listWidgetTypes = async () => {
|
|
83
|
+
const { data } = await (0, import_http_client.httpService)().post(MCP_PROXY_URL, {
|
|
84
|
+
tool: "list-widgets",
|
|
85
|
+
input: {}
|
|
86
|
+
});
|
|
87
|
+
return (data.data ?? []).map((widget) => widget.type);
|
|
88
|
+
};
|
|
89
|
+
var fetchWidgetSchema = async (widgetType) => {
|
|
90
|
+
const { data } = await (0, import_http_client.httpService)().post(MCP_PROXY_URL, {
|
|
91
|
+
tool: "get-widget-schema",
|
|
92
|
+
input: { widget_type: widgetType }
|
|
93
|
+
});
|
|
94
|
+
return data.data ?? {};
|
|
95
|
+
};
|
|
232
96
|
var initWidgetsSchemaResource = (reg) => {
|
|
233
97
|
const { resource } = reg;
|
|
234
98
|
resource(
|
|
235
99
|
"widget-schema-by-type",
|
|
236
100
|
new import_editor_mcp.ResourceTemplate(WIDGET_SCHEMA_URI, {
|
|
237
|
-
list: () => {
|
|
238
|
-
const
|
|
239
|
-
const availableWidgets = Object.keys(cache).filter(
|
|
240
|
-
(widgetType) => isWidgetAvailableForLLM(cache[widgetType])
|
|
241
|
-
);
|
|
101
|
+
list: async () => {
|
|
102
|
+
const widgetTypes = await listWidgetTypes();
|
|
242
103
|
return {
|
|
243
|
-
resources:
|
|
104
|
+
resources: widgetTypes.map((widgetType) => ({
|
|
244
105
|
uri: `elementor://widgets/schema/${widgetType}`,
|
|
245
106
|
name: "Widget schema for " + widgetType
|
|
246
107
|
}))
|
|
@@ -252,52 +113,16 @@ var initWidgetsSchemaResource = (reg) => {
|
|
|
252
113
|
},
|
|
253
114
|
async (uri, variables) => {
|
|
254
115
|
const widgetType = typeof variables.widgetType === "string" ? variables.widgetType : variables.widgetType?.[0];
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
throw new Error(`No prop schema found for element type: ${widgetType}`);
|
|
258
|
-
}
|
|
259
|
-
const propSchema = widgetData.atomic_props_schema;
|
|
260
|
-
if (!propSchema) {
|
|
261
|
-
if (!hasV3Controls(widgetData.controls)) {
|
|
262
|
-
throw new Error(`No prop schema found for element type: ${widgetType}`);
|
|
263
|
-
}
|
|
264
|
-
const controlMetadata = extractV3ControlsMetadata(widgetData.controls);
|
|
265
|
-
return {
|
|
266
|
-
contents: [
|
|
267
|
-
{
|
|
268
|
-
uri: uri.toString(),
|
|
269
|
-
mimeType: "application/json",
|
|
270
|
-
text: JSON.stringify({
|
|
271
|
-
widget_version: "v3",
|
|
272
|
-
message: "This widget exists in the editor but has no atomic props schema (V4). Use control_metadata as non-authoritative hints from legacy controls.",
|
|
273
|
-
fields_note: "All settings are optional; there is no JSON schema for this widget type.",
|
|
274
|
-
properties: controlMetadata
|
|
275
|
-
})
|
|
276
|
-
}
|
|
277
|
-
]
|
|
278
|
-
};
|
|
116
|
+
if (!widgetType) {
|
|
117
|
+
throw new Error("No widget type provided.");
|
|
279
118
|
}
|
|
280
|
-
const
|
|
281
|
-
const asJson = enrichPropertiesWithBaseSettingsHints(
|
|
282
|
-
Object.fromEntries(
|
|
283
|
-
Object.entries(propSchema).filter(([key, propType]) => import_editor_props.Schema.isPropKeyConfigurable(key, propType)).map(([key, propType]) => [key, import_editor_props.Schema.propTypeToJsonSchema(propType)])
|
|
284
|
-
),
|
|
285
|
-
baseSettingsKeys
|
|
286
|
-
);
|
|
287
|
-
const description = typeof widgetData?.meta?.description === "string" ? widgetData.meta.description : void 0;
|
|
288
|
-
const allWidgets = (0, import_editor_elements2.getWidgetsCache)() || {};
|
|
289
|
-
const llmGuidance = buildLlmGuidance(widgetData, widgetType, allWidgets);
|
|
119
|
+
const schema2 = await fetchWidgetSchema(widgetType);
|
|
290
120
|
return {
|
|
291
121
|
contents: [
|
|
292
122
|
{
|
|
293
123
|
uri: uri.toString(),
|
|
294
124
|
mimeType: "application/json",
|
|
295
|
-
text: JSON.stringify(
|
|
296
|
-
type: "object",
|
|
297
|
-
properties: asJson,
|
|
298
|
-
description,
|
|
299
|
-
llm_guidance: llmGuidance
|
|
300
|
-
})
|
|
125
|
+
text: JSON.stringify(schema2)
|
|
301
126
|
}
|
|
302
127
|
]
|
|
303
128
|
};
|
|
@@ -352,11 +177,11 @@ var initBreakpointsResource = (reg) => {
|
|
|
352
177
|
};
|
|
353
178
|
|
|
354
179
|
// src/mcp/utils/convert-css-to-atomic.ts
|
|
355
|
-
var
|
|
180
|
+
var import_http_client2 = require("@elementor/http-client");
|
|
356
181
|
var CSS_TO_ATOMIC_URL = "elementor/v1/css-to-atomic";
|
|
357
182
|
var SINGLE_BLOCK_KEY = "default";
|
|
358
183
|
var convertBlocks = async (blocks) => {
|
|
359
|
-
const { data } = await (0,
|
|
184
|
+
const { data } = await (0, import_http_client2.httpService)().post(
|
|
360
185
|
CSS_TO_ATOMIC_URL,
|
|
361
186
|
{ blocks }
|
|
362
187
|
);
|
|
@@ -416,7 +241,7 @@ var renameClass = (oldClassName, newClassName) => {
|
|
|
416
241
|
|
|
417
242
|
// src/components/elements-overlays.tsx
|
|
418
243
|
var React7 = __toESM(require("react"));
|
|
419
|
-
var
|
|
244
|
+
var import_editor_elements3 = require("@elementor/editor-elements");
|
|
420
245
|
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
421
246
|
|
|
422
247
|
// src/components/grid-outline/grid-empty-cell-positioner.tsx
|
|
@@ -487,7 +312,7 @@ function useMutationsListener({ element, onChange }) {
|
|
|
487
312
|
|
|
488
313
|
// src/hooks/use-grid-tracks.ts
|
|
489
314
|
var import_react4 = require("react");
|
|
490
|
-
var
|
|
315
|
+
var import_editor_elements = require("@elementor/editor-elements");
|
|
491
316
|
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
492
317
|
|
|
493
318
|
// src/utils/grid-outline-utils.ts
|
|
@@ -633,7 +458,7 @@ var DEVICE_MODE_CHANGE_EVENT = "elementor/device-mode/change";
|
|
|
633
458
|
function useGridTracks(element, rect) {
|
|
634
459
|
const [tracks, setTracks] = (0, import_react4.useState)(EMPTY);
|
|
635
460
|
const trigger = (0, import_editor_v1_adapters2.__privateUseListenTo)(
|
|
636
|
-
[(0, import_editor_v1_adapters2.windowEvent)(
|
|
461
|
+
[(0, import_editor_v1_adapters2.windowEvent)(import_editor_elements.ELEMENT_STYLE_CHANGE_EVENT), (0, import_editor_v1_adapters2.windowEvent)(DEVICE_MODE_CHANGE_EVENT)],
|
|
637
462
|
() => ({})
|
|
638
463
|
);
|
|
639
464
|
const childrenTrigger = useGridChildren(element);
|
|
@@ -850,7 +675,7 @@ var GridEmptyCellPositioner = ({ element }) => {
|
|
|
850
675
|
|
|
851
676
|
// src/components/grid-outline/grid-outline-overlay.tsx
|
|
852
677
|
var React6 = __toESM(require("react"));
|
|
853
|
-
var
|
|
678
|
+
var import_editor_elements2 = require("@elementor/editor-elements");
|
|
854
679
|
var import_ui2 = require("@elementor/ui");
|
|
855
680
|
var import_react11 = require("@floating-ui/react");
|
|
856
681
|
|
|
@@ -1139,7 +964,7 @@ function GridOutline({ element, tracks, width, height }) {
|
|
|
1139
964
|
|
|
1140
965
|
// src/components/grid-outline/grid-outline-overlay.tsx
|
|
1141
966
|
var GridOutlineOverlay = ({ element, id, isSelected }) => {
|
|
1142
|
-
const settings = (0,
|
|
967
|
+
const settings = (0, import_editor_elements2.useElementEditorSettings)(id);
|
|
1143
968
|
const enabled = settings?.grid_outline;
|
|
1144
969
|
const rect = useElementRect(element);
|
|
1145
970
|
const tracks = useGridTracks(element, rect);
|
|
@@ -1182,7 +1007,7 @@ var overlayRegistry = [
|
|
|
1182
1007
|
}
|
|
1183
1008
|
];
|
|
1184
1009
|
function ElementsOverlays() {
|
|
1185
|
-
const selected = (0,
|
|
1010
|
+
const selected = (0, import_editor_elements3.useSelectedElement)();
|
|
1186
1011
|
const elements = useElementsDom();
|
|
1187
1012
|
const currentEditMode = (0, import_editor_v1_adapters3.useEditMode)();
|
|
1188
1013
|
const isEditMode = currentEditMode === "edit";
|
|
@@ -1212,7 +1037,7 @@ function useElementsDom() {
|
|
|
1212
1037
|
return (0, import_editor_v1_adapters3.__privateUseListenTo)(
|
|
1213
1038
|
[(0, import_editor_v1_adapters3.windowEvent)("elementor/editor/element-rendered"), (0, import_editor_v1_adapters3.windowEvent)("elementor/editor/element-destroyed")],
|
|
1214
1039
|
() => {
|
|
1215
|
-
return (0,
|
|
1040
|
+
return (0, import_editor_elements3.getElements)().filter((el) => isV4Element(el.view?.el?.dataset)).map((element) => ({
|
|
1216
1041
|
id: element.id,
|
|
1217
1042
|
domElement: element.view?.getDomElement?.()?.get?.(0),
|
|
1218
1043
|
isGlobal: element.model.get("isGlobal") ?? false,
|
|
@@ -1466,7 +1291,7 @@ var import_editor_styles = require("@elementor/editor-styles");
|
|
|
1466
1291
|
var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
|
|
1467
1292
|
|
|
1468
1293
|
// src/renderers/create-props-resolver.ts
|
|
1469
|
-
var
|
|
1294
|
+
var import_editor_props = require("@elementor/editor-props");
|
|
1470
1295
|
|
|
1471
1296
|
// src/renderers/multi-props.ts
|
|
1472
1297
|
var isMultiProps = (propValue) => {
|
|
@@ -1504,7 +1329,7 @@ function createPropsResolver({ transformers, schema: initialSchema, onPropResolv
|
|
|
1504
1329
|
if (value === null || value === void 0) {
|
|
1505
1330
|
return null;
|
|
1506
1331
|
}
|
|
1507
|
-
if (!(0,
|
|
1332
|
+
if (!(0, import_editor_props.isTransformable)(value)) {
|
|
1508
1333
|
return value;
|
|
1509
1334
|
}
|
|
1510
1335
|
if (depth > TRANSFORM_DEPTH_LIMIT) {
|
|
@@ -1562,13 +1387,13 @@ function createPropsResolver({ transformers, schema: initialSchema, onPropResolv
|
|
|
1562
1387
|
}
|
|
1563
1388
|
|
|
1564
1389
|
// src/renderers/enqueue-font-from-style-prop.ts
|
|
1565
|
-
var
|
|
1390
|
+
var import_editor_props2 = require("@elementor/editor-props");
|
|
1566
1391
|
var maybeEnqueueFontFromStyleProp = (propType, propValue, enqueue) => {
|
|
1567
|
-
if (!(0,
|
|
1392
|
+
if (!(0, import_editor_props2.isTransformable)(propValue) || propValue.disabled) {
|
|
1568
1393
|
return;
|
|
1569
1394
|
}
|
|
1570
1395
|
const typeKey = propType.kind === "union" ? propValue.$$type : propType.key;
|
|
1571
|
-
const propTypeUtil = (0,
|
|
1396
|
+
const propTypeUtil = (0, import_editor_props2.getPropSchemaFromCache)(typeKey);
|
|
1572
1397
|
if (!propTypeUtil || !("getEnqueueFontFamily" in propTypeUtil) || typeof propTypeUtil.getEnqueueFontFamily !== "function") {
|
|
1573
1398
|
return;
|
|
1574
1399
|
}
|
|
@@ -1964,7 +1789,7 @@ var import_editor_v1_adapters11 = require("@elementor/editor-v1-adapters");
|
|
|
1964
1789
|
var import_i18n = require("@wordpress/i18n");
|
|
1965
1790
|
|
|
1966
1791
|
// src/form-structure/utils.ts
|
|
1967
|
-
var
|
|
1792
|
+
var import_editor_elements4 = require("@elementor/editor-elements");
|
|
1968
1793
|
var FORM_ELEMENT_TYPE = "e-form";
|
|
1969
1794
|
var FORM_FIELD_ELEMENT_TYPES = /* @__PURE__ */ new Set([
|
|
1970
1795
|
"e-form-input",
|
|
@@ -1994,10 +1819,10 @@ function isWithinForm(element) {
|
|
|
1994
1819
|
return isElementWithinFormSelector(element);
|
|
1995
1820
|
}
|
|
1996
1821
|
function hasElementType(element, type) {
|
|
1997
|
-
return (0,
|
|
1822
|
+
return (0, import_editor_elements4.getAllDescendants)(element).some((item) => getElementType(item) === type);
|
|
1998
1823
|
}
|
|
1999
1824
|
function hasElementTypes(element, types) {
|
|
2000
|
-
return (0,
|
|
1825
|
+
return (0, import_editor_elements4.getAllDescendants)(element).some((item) => {
|
|
2001
1826
|
const itemType = getElementType(item);
|
|
2002
1827
|
return itemType ? types.has(itemType) : false;
|
|
2003
1828
|
});
|
|
@@ -2778,7 +2603,7 @@ function initStyleTransformers() {
|
|
|
2778
2603
|
}
|
|
2779
2604
|
|
|
2780
2605
|
// src/legacy/init-legacy-views.ts
|
|
2781
|
-
var
|
|
2606
|
+
var import_editor_elements8 = require("@elementor/editor-elements");
|
|
2782
2607
|
var import_editor_v1_adapters14 = require("@elementor/editor-v1-adapters");
|
|
2783
2608
|
|
|
2784
2609
|
// src/renderers/create-dom-renderer.ts
|
|
@@ -2907,25 +2732,25 @@ function createElementViewClassDeclaration() {
|
|
|
2907
2732
|
}
|
|
2908
2733
|
|
|
2909
2734
|
// src/legacy/create-nested-templated-element-type.ts
|
|
2910
|
-
var
|
|
2735
|
+
var import_editor_elements6 = require("@elementor/editor-elements");
|
|
2911
2736
|
|
|
2912
2737
|
// src/legacy/create-pending-element.ts
|
|
2913
|
-
var
|
|
2738
|
+
var import_editor_elements5 = require("@elementor/editor-elements");
|
|
2914
2739
|
function createPendingElement(wrapperView, data, options = {}) {
|
|
2915
2740
|
const parentContainer = wrapperView.getContainer();
|
|
2916
2741
|
const model = { ...data };
|
|
2917
2742
|
if (!model.id) {
|
|
2918
|
-
model.id = (0,
|
|
2743
|
+
model.id = (0, import_editor_elements5.generateElementId)();
|
|
2919
2744
|
}
|
|
2920
2745
|
if (!model.elements) {
|
|
2921
2746
|
model.elements = [];
|
|
2922
2747
|
}
|
|
2923
|
-
const added = (0,
|
|
2748
|
+
const added = (0, import_editor_elements5.addModelToParent)(parentContainer.id, model, options);
|
|
2924
2749
|
if (!added) {
|
|
2925
2750
|
return void 0;
|
|
2926
2751
|
}
|
|
2927
2752
|
const childId = model.id;
|
|
2928
|
-
const childModel = (0,
|
|
2753
|
+
const childModel = (0, import_editor_elements5.findModelInDocument)(childId);
|
|
2929
2754
|
if (!childModel) {
|
|
2930
2755
|
return void 0;
|
|
2931
2756
|
}
|
|
@@ -2936,7 +2761,7 @@ function createPendingElement(wrapperView, data, options = {}) {
|
|
|
2936
2761
|
model: childModel,
|
|
2937
2762
|
view: void 0,
|
|
2938
2763
|
lookup() {
|
|
2939
|
-
return (0,
|
|
2764
|
+
return (0, import_editor_elements5.getContainer)(childId) ?? pendingContainer;
|
|
2940
2765
|
}
|
|
2941
2766
|
};
|
|
2942
2767
|
wrapperView.once("render", () => {
|
|
@@ -2949,7 +2774,7 @@ function createPendingElement(wrapperView, data, options = {}) {
|
|
|
2949
2774
|
}
|
|
2950
2775
|
function selectChildWhenWrapperRenders(wrapperView, childId) {
|
|
2951
2776
|
wrapperView.once("render", () => {
|
|
2952
|
-
const childContainer = (0,
|
|
2777
|
+
const childContainer = (0, import_editor_elements5.getContainer)(childId);
|
|
2953
2778
|
if (childContainer?.model?.trigger) {
|
|
2954
2779
|
childContainer.model.trigger("request:edit");
|
|
2955
2780
|
return;
|
|
@@ -3216,7 +3041,7 @@ function createNestedTemplatedElementView({
|
|
|
3216
3041
|
this._initAlpine();
|
|
3217
3042
|
});
|
|
3218
3043
|
this.model.trigger("render:complete");
|
|
3219
|
-
window.dispatchEvent(new CustomEvent(
|
|
3044
|
+
window.dispatchEvent(new CustomEvent(import_editor_elements6.ELEMENT_STYLE_CHANGE_EVENT));
|
|
3220
3045
|
},
|
|
3221
3046
|
async _renderTemplate() {
|
|
3222
3047
|
const model = this.model;
|
|
@@ -3464,8 +3289,8 @@ var import_client = require("react-dom/client");
|
|
|
3464
3289
|
|
|
3465
3290
|
// src/legacy/replacements/inline-editing/inline-editing-elements.tsx
|
|
3466
3291
|
var React11 = __toESM(require("react"));
|
|
3467
|
-
var
|
|
3468
|
-
var
|
|
3292
|
+
var import_editor_elements7 = require("@elementor/editor-elements");
|
|
3293
|
+
var import_editor_props4 = require("@elementor/editor-props");
|
|
3469
3294
|
var import_editor_v1_adapters13 = require("@elementor/editor-v1-adapters");
|
|
3470
3295
|
var import_i18n3 = require("@wordpress/i18n");
|
|
3471
3296
|
|
|
@@ -3742,11 +3567,11 @@ var InlineEditingToolbar = ({ anchor, editor, id }) => {
|
|
|
3742
3567
|
};
|
|
3743
3568
|
|
|
3744
3569
|
// src/legacy/replacements/inline-editing/inline-editing-eligibility.ts
|
|
3745
|
-
var
|
|
3570
|
+
var import_editor_props3 = require("@elementor/editor-props");
|
|
3746
3571
|
var hasKey = (propType) => {
|
|
3747
3572
|
return "key" in propType;
|
|
3748
3573
|
};
|
|
3749
|
-
var TEXT_PROP_TYPE_KEYS = /* @__PURE__ */ new Set([
|
|
3574
|
+
var TEXT_PROP_TYPE_KEYS = /* @__PURE__ */ new Set([import_editor_props3.htmlV3PropTypeUtil.key, import_editor_props3.stringPropTypeUtil.key]);
|
|
3750
3575
|
var isCoreTextPropTypeKey = (key) => {
|
|
3751
3576
|
return TEXT_PROP_TYPE_KEYS.has(key);
|
|
3752
3577
|
};
|
|
@@ -3766,7 +3591,7 @@ var isInlineEditingAllowed = ({ rawValue, propTypeFromSchema }) => {
|
|
|
3766
3591
|
if (rawValue === null || rawValue === void 0) {
|
|
3767
3592
|
return isAllowedBySchema(propTypeFromSchema);
|
|
3768
3593
|
}
|
|
3769
|
-
return
|
|
3594
|
+
return import_editor_props3.htmlV3PropTypeUtil.isValid(rawValue) || import_editor_props3.stringPropTypeUtil.isValid(rawValue);
|
|
3770
3595
|
};
|
|
3771
3596
|
|
|
3772
3597
|
// src/legacy/replacements/inline-editing/inline-editing-elements.tsx
|
|
@@ -3840,7 +3665,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3840
3665
|
return INLINE_EDITING_PROPERTY_PER_TYPE[this.type] ?? "";
|
|
3841
3666
|
}
|
|
3842
3667
|
getInlineEditablePropType() {
|
|
3843
|
-
const propSchema = (0,
|
|
3668
|
+
const propSchema = (0, import_editor_elements7.getElementType)(this.type)?.propsSchema;
|
|
3844
3669
|
const propertyName = this.getInlineEditablePropertyName();
|
|
3845
3670
|
return propSchema?.[propertyName] ?? null;
|
|
3846
3671
|
}
|
|
@@ -3851,15 +3676,15 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3851
3676
|
}
|
|
3852
3677
|
getExtractedContentValue() {
|
|
3853
3678
|
const propValue = this.getInlineEditablePropValue();
|
|
3854
|
-
const extracted =
|
|
3855
|
-
return
|
|
3679
|
+
const extracted = import_editor_props4.htmlV3PropTypeUtil.extract(propValue);
|
|
3680
|
+
return import_editor_props4.stringPropTypeUtil.extract(extracted?.content ?? null) ?? "";
|
|
3856
3681
|
}
|
|
3857
3682
|
setContentValue(value) {
|
|
3858
3683
|
const settingKey = this.getInlineEditablePropertyName();
|
|
3859
3684
|
const html = value || "";
|
|
3860
|
-
const parsed = (0,
|
|
3861
|
-
const valueToSave =
|
|
3862
|
-
content: parsed.content ?
|
|
3685
|
+
const parsed = (0, import_editor_props4.parseHtmlChildren)(html);
|
|
3686
|
+
const valueToSave = import_editor_props4.htmlV3PropTypeUtil.create({
|
|
3687
|
+
content: parsed.content ? import_editor_props4.stringPropTypeUtil.create(parsed.content) : null,
|
|
3863
3688
|
children: parsed.children
|
|
3864
3689
|
});
|
|
3865
3690
|
(0, import_editor_v1_adapters13.undoable)(
|
|
@@ -3874,7 +3699,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3874
3699
|
}
|
|
3875
3700
|
},
|
|
3876
3701
|
{
|
|
3877
|
-
title: (0,
|
|
3702
|
+
title: (0, import_editor_elements7.getElementLabel)(this.id),
|
|
3878
3703
|
// translators: %s is the name of the property that was edited.
|
|
3879
3704
|
subtitle: (0, import_i18n3.__)("%s edited", "elementor").replace(
|
|
3880
3705
|
"%s",
|
|
@@ -3890,7 +3715,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3890
3715
|
return null;
|
|
3891
3716
|
}
|
|
3892
3717
|
if (propType.kind === "union") {
|
|
3893
|
-
const textKeys = [
|
|
3718
|
+
const textKeys = [import_editor_props4.htmlV3PropTypeUtil.key, import_editor_props4.stringPropTypeUtil.key];
|
|
3894
3719
|
for (const key of textKeys) {
|
|
3895
3720
|
if (propType.prop_types[key]) {
|
|
3896
3721
|
return key;
|
|
@@ -3907,7 +3732,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3907
3732
|
(0, import_editor_v1_adapters13.__privateRunCommandSync)(
|
|
3908
3733
|
"document/elements/set-settings",
|
|
3909
3734
|
{
|
|
3910
|
-
container: (0,
|
|
3735
|
+
container: (0, import_editor_elements7.getContainer)(this.id),
|
|
3911
3736
|
settings: {
|
|
3912
3737
|
[key]: value
|
|
3913
3738
|
}
|
|
@@ -3919,10 +3744,10 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3919
3744
|
getExpectedTag() {
|
|
3920
3745
|
const tagPropType = this.getTagPropType();
|
|
3921
3746
|
const tagSettingKey = "tag";
|
|
3922
|
-
return
|
|
3747
|
+
return import_editor_props4.stringPropTypeUtil.extract(this.getSetting(tagSettingKey) ?? null) ?? import_editor_props4.stringPropTypeUtil.extract(tagPropType?.default ?? null) ?? null;
|
|
3923
3748
|
}
|
|
3924
3749
|
getTagPropType() {
|
|
3925
|
-
const propsSchema = (0,
|
|
3750
|
+
const propsSchema = (0, import_editor_elements7.getElementType)(this.type)?.propsSchema;
|
|
3926
3751
|
if (!propsSchema?.tag) {
|
|
3927
3752
|
return null;
|
|
3928
3753
|
}
|
|
@@ -4085,7 +3910,7 @@ function registerElementType(type, elementTypeGenerator) {
|
|
|
4085
3910
|
}
|
|
4086
3911
|
function initLegacyViews() {
|
|
4087
3912
|
(0, import_editor_v1_adapters14.__privateListenTo)((0, import_editor_v1_adapters14.v1ReadyEvent)(), () => {
|
|
4088
|
-
const widgetsCache = (0,
|
|
3913
|
+
const widgetsCache = (0, import_editor_elements8.getWidgetsCache)() ?? {};
|
|
4089
3914
|
const renderer = createDomRenderer();
|
|
4090
3915
|
registerProPromotionTypes(widgetsCache);
|
|
4091
3916
|
Object.keys(widgetsCache).forEach((type) => {
|
|
@@ -4094,7 +3919,7 @@ function initLegacyViews() {
|
|
|
4094
3919
|
});
|
|
4095
3920
|
}
|
|
4096
3921
|
function registerElementInLegacyManager(type, renderer) {
|
|
4097
|
-
const element = ((0,
|
|
3922
|
+
const element = ((0, import_editor_elements8.getWidgetsCache)() ?? {})[type];
|
|
4098
3923
|
if (!element?.atomic) {
|
|
4099
3924
|
return;
|
|
4100
3925
|
}
|
|
@@ -4146,7 +3971,7 @@ function createNestedTemplatedType(type, renderer, element) {
|
|
|
4146
3971
|
}
|
|
4147
3972
|
|
|
4148
3973
|
// src/legacy/tabs-model-extensions.ts
|
|
4149
|
-
var
|
|
3974
|
+
var import_editor_props5 = require("@elementor/editor-props");
|
|
4150
3975
|
var tabModelExtensions = {
|
|
4151
3976
|
modifyDefaultChildren(elements) {
|
|
4152
3977
|
if (!Array.isArray(elements) || elements.length === 0) {
|
|
@@ -4162,8 +3987,8 @@ var tabModelExtensions = {
|
|
|
4162
3987
|
...paragraphElement,
|
|
4163
3988
|
settings: {
|
|
4164
3989
|
...paragraphElement.settings,
|
|
4165
|
-
paragraph:
|
|
4166
|
-
content:
|
|
3990
|
+
paragraph: import_editor_props5.htmlV3PropTypeUtil.create({
|
|
3991
|
+
content: import_editor_props5.stringPropTypeUtil.create(`Tab ${position}`),
|
|
4167
3992
|
children: []
|
|
4168
3993
|
})
|
|
4169
3994
|
}
|
|
@@ -4176,43 +4001,41 @@ function initTabsModelExtensions() {
|
|
|
4176
4001
|
}
|
|
4177
4002
|
|
|
4178
4003
|
// src/mcp/canvas-mcp.ts
|
|
4179
|
-
var
|
|
4004
|
+
var import_editor_props9 = require("@elementor/editor-props");
|
|
4180
4005
|
|
|
4181
4006
|
// src/mcp/resources/available-widgets-resource.ts
|
|
4182
|
-
var
|
|
4007
|
+
var import_http_client3 = require("@elementor/http-client");
|
|
4008
|
+
var MCP_PROXY_URL2 = "elementor/v1/mcp-proxy";
|
|
4183
4009
|
var AVAILABLE_WIDGETS_URI = "elementor://context/available-widgets";
|
|
4184
4010
|
var AVAILABLE_WIDGETS_URI_V4 = "elementor://context/available-widgets/v4";
|
|
4185
|
-
var
|
|
4186
|
-
const {
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
...buildContents(AVAILABLE_WIDGETS_URI)
|
|
4203
|
-
});
|
|
4204
|
-
sendResourceUpdated({
|
|
4205
|
-
uri: AVAILABLE_WIDGETS_URI_V4,
|
|
4206
|
-
...buildContents(AVAILABLE_WIDGETS_URI_V4, (w) => w.version === "v4")
|
|
4207
|
-
});
|
|
4011
|
+
var fetchWidgets = async (version) => {
|
|
4012
|
+
const { data } = await (0, import_http_client3.httpService)().post(MCP_PROXY_URL2, {
|
|
4013
|
+
tool: "list-widgets",
|
|
4014
|
+
input: version ? { version } : {}
|
|
4015
|
+
});
|
|
4016
|
+
return data.data ?? [];
|
|
4017
|
+
};
|
|
4018
|
+
var buildContents = async (uri, version) => {
|
|
4019
|
+
const widgets = await fetchWidgets(version);
|
|
4020
|
+
return {
|
|
4021
|
+
contents: [
|
|
4022
|
+
{
|
|
4023
|
+
uri,
|
|
4024
|
+
mimeType: "application/json",
|
|
4025
|
+
text: JSON.stringify(widgets, null, 2)
|
|
4026
|
+
}
|
|
4027
|
+
]
|
|
4208
4028
|
};
|
|
4029
|
+
};
|
|
4030
|
+
var initAvailableWidgetsResource = (reg) => {
|
|
4031
|
+
const { resource } = reg;
|
|
4209
4032
|
resource(
|
|
4210
4033
|
"available-widgets-v4",
|
|
4211
4034
|
AVAILABLE_WIDGETS_URI_V4,
|
|
4212
4035
|
{
|
|
4213
4036
|
description: "All registered v4 version widgets"
|
|
4214
4037
|
},
|
|
4215
|
-
async () => buildContents(AVAILABLE_WIDGETS_URI_V4,
|
|
4038
|
+
async () => buildContents(AVAILABLE_WIDGETS_URI_V4, "v4")
|
|
4216
4039
|
);
|
|
4217
4040
|
resource(
|
|
4218
4041
|
"available-widgets",
|
|
@@ -4222,22 +4045,11 @@ var initAvailableWidgetsResource = (reg) => {
|
|
|
4222
4045
|
},
|
|
4223
4046
|
async () => buildContents(AVAILABLE_WIDGETS_URI)
|
|
4224
4047
|
);
|
|
4225
|
-
const eventName = (0, import_editor_v1_adapters15.v1ReadyEvent)().name;
|
|
4226
|
-
const onV1Ready = () => {
|
|
4227
|
-
const widgets = getAvailableWidgets();
|
|
4228
|
-
if (widgets.length === 0) {
|
|
4229
|
-
return;
|
|
4230
|
-
}
|
|
4231
|
-
window.removeEventListener(eventName, onV1Ready);
|
|
4232
|
-
notifyResourcesUpdated();
|
|
4233
|
-
};
|
|
4234
|
-
window.addEventListener(eventName, onV1Ready);
|
|
4235
|
-
onV1Ready();
|
|
4236
4048
|
};
|
|
4237
4049
|
|
|
4238
4050
|
// src/mcp/resources/best-practices-resource.ts
|
|
4239
|
-
var
|
|
4240
|
-
var
|
|
4051
|
+
var import_http_client4 = require("@elementor/http-client");
|
|
4052
|
+
var MCP_PROXY_URL3 = "elementor/v1/mcp-proxy";
|
|
4241
4053
|
var BEST_PRACTICES_URI2 = "elementor://style/best-practices";
|
|
4242
4054
|
var initBestPracticesResource = (reg) => {
|
|
4243
4055
|
const { resource } = reg;
|
|
@@ -4249,7 +4061,7 @@ var initBestPracticesResource = (reg) => {
|
|
|
4249
4061
|
mimeType: "text/markdown"
|
|
4250
4062
|
},
|
|
4251
4063
|
async (uri) => {
|
|
4252
|
-
const { data } = await (0,
|
|
4064
|
+
const { data } = await (0, import_http_client4.httpService)().get(MCP_PROXY_URL3, {
|
|
4253
4065
|
params: { uri: uri.href }
|
|
4254
4066
|
});
|
|
4255
4067
|
return {
|
|
@@ -4266,8 +4078,8 @@ var initBestPracticesResource = (reg) => {
|
|
|
4266
4078
|
};
|
|
4267
4079
|
|
|
4268
4080
|
// src/mcp/resources/document-structure-resource.ts
|
|
4269
|
-
var
|
|
4270
|
-
var
|
|
4081
|
+
var import_editor_elements9 = require("@elementor/editor-elements");
|
|
4082
|
+
var import_editor_v1_adapters15 = require("@elementor/editor-v1-adapters");
|
|
4271
4083
|
var DOCUMENT_STRUCTURE_URI = "elementor://document/structure";
|
|
4272
4084
|
var initDocumentStructureResource = (reg) => {
|
|
4273
4085
|
const { resource, sendResourceUpdated } = reg;
|
|
@@ -4280,15 +4092,15 @@ var initDocumentStructureResource = (reg) => {
|
|
|
4280
4092
|
sendResourceUpdated({ uri: DOCUMENT_STRUCTURE_URI });
|
|
4281
4093
|
}
|
|
4282
4094
|
};
|
|
4283
|
-
(0,
|
|
4095
|
+
(0, import_editor_v1_adapters15.__privateListenTo)(
|
|
4284
4096
|
[
|
|
4285
|
-
(0,
|
|
4286
|
-
(0,
|
|
4287
|
-
(0,
|
|
4288
|
-
(0,
|
|
4289
|
-
(0,
|
|
4290
|
-
(0,
|
|
4291
|
-
(0,
|
|
4097
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("document/elements/create"),
|
|
4098
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("document/elements/delete"),
|
|
4099
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("document/elements/move"),
|
|
4100
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("document/elements/copy"),
|
|
4101
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("document/elements/paste"),
|
|
4102
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("editor/documents/attach-preview"),
|
|
4103
|
+
(0, import_editor_v1_adapters15.commandEndEvent)("editor/documents/switch")
|
|
4292
4104
|
],
|
|
4293
4105
|
updateDocumentStructure
|
|
4294
4106
|
);
|
|
@@ -4331,7 +4143,7 @@ function resolveElementVersion(element) {
|
|
|
4331
4143
|
return "v4";
|
|
4332
4144
|
}
|
|
4333
4145
|
const widgetType = element.model?.attributes?.widgetType;
|
|
4334
|
-
if (widgetType && (0,
|
|
4146
|
+
if (widgetType && (0, import_editor_elements9.getWidgetsCache)()?.[widgetType]?.atomic_props_schema) {
|
|
4335
4147
|
return "v4";
|
|
4336
4148
|
}
|
|
4337
4149
|
return "v3";
|
|
@@ -4358,11 +4170,11 @@ function extractElementData(element) {
|
|
|
4358
4170
|
}
|
|
4359
4171
|
|
|
4360
4172
|
// src/mcp/resources/dynamic-tags-resource.ts
|
|
4361
|
-
var
|
|
4173
|
+
var import_http_client5 = require("@elementor/http-client");
|
|
4362
4174
|
var DYNAMIC_TAGS_URI = "elementor://dynamic-tags";
|
|
4363
|
-
var
|
|
4175
|
+
var MCP_PROXY_URL4 = "elementor/v1/mcp-proxy";
|
|
4364
4176
|
var fetchDynamicTags = async () => {
|
|
4365
|
-
const { data } = await (0,
|
|
4177
|
+
const { data } = await (0, import_http_client5.httpService)().post(MCP_PROXY_URL4, {
|
|
4366
4178
|
tool: "list-dynamic-tags",
|
|
4367
4179
|
input: {}
|
|
4368
4180
|
});
|
|
@@ -4393,7 +4205,7 @@ var initDynamicTagsResource = (reg) => {
|
|
|
4393
4205
|
};
|
|
4394
4206
|
|
|
4395
4207
|
// src/mcp/resources/editor-state-resource.ts
|
|
4396
|
-
var
|
|
4208
|
+
var import_editor_v1_adapters16 = require("@elementor/editor-v1-adapters");
|
|
4397
4209
|
var CURRENTLY_VIEWED_SCREEN = "The user is currently viewing the Elementor editor";
|
|
4398
4210
|
var PAGE_CONTENT_CHARACTER_LIMIT = 500;
|
|
4399
4211
|
var PREVIEW_TEXT_NODE_MIN_LENGTH = 2;
|
|
@@ -4414,8 +4226,8 @@ var initEditorStateResource = (reg) => {
|
|
|
4414
4226
|
lastSerializedState = serialized;
|
|
4415
4227
|
sendResourceUpdated({ uri: EDITOR_STATE_URI });
|
|
4416
4228
|
};
|
|
4417
|
-
(0,
|
|
4418
|
-
[(0,
|
|
4229
|
+
(0, import_editor_v1_adapters16.__privateListenTo)(
|
|
4230
|
+
[(0, import_editor_v1_adapters16.commandEndEvent)("editor/documents/switch"), (0, import_editor_v1_adapters16.commandEndEvent)("editor/documents/attach-preview")],
|
|
4419
4231
|
notifyIfChanged
|
|
4420
4232
|
);
|
|
4421
4233
|
lastSerializedState = JSON.stringify(buildState());
|
|
@@ -4489,7 +4301,7 @@ function getPageTitle() {
|
|
|
4489
4301
|
}
|
|
4490
4302
|
|
|
4491
4303
|
// src/mcp/resources/general-context-resource.ts
|
|
4492
|
-
var
|
|
4304
|
+
var import_editor_v1_adapters17 = require("@elementor/editor-v1-adapters");
|
|
4493
4305
|
var GENERAL_CONTEXT_URI = "elementor://context/general";
|
|
4494
4306
|
var initGeneralContextResource = (reg) => {
|
|
4495
4307
|
const { resource, sendResourceUpdated } = reg;
|
|
@@ -4550,11 +4362,11 @@ var initGeneralContextResource = (reg) => {
|
|
|
4550
4362
|
};
|
|
4551
4363
|
}
|
|
4552
4364
|
);
|
|
4553
|
-
(0,
|
|
4365
|
+
(0, import_editor_v1_adapters17.__privateListenTo)(
|
|
4554
4366
|
[
|
|
4555
|
-
(0,
|
|
4556
|
-
(0,
|
|
4557
|
-
(0,
|
|
4367
|
+
(0, import_editor_v1_adapters17.commandEndEvent)("editor/documents/switch"),
|
|
4368
|
+
(0, import_editor_v1_adapters17.commandEndEvent)("editor/documents/attach-preview"),
|
|
4369
|
+
(0, import_editor_v1_adapters17.commandEndEvent)("document/elements/settings")
|
|
4558
4370
|
],
|
|
4559
4371
|
pushUpdateIfChanged
|
|
4560
4372
|
);
|
|
@@ -4562,8 +4374,8 @@ var initGeneralContextResource = (reg) => {
|
|
|
4562
4374
|
};
|
|
4563
4375
|
|
|
4564
4376
|
// src/mcp/resources/selected-element-resource.ts
|
|
4565
|
-
var
|
|
4566
|
-
var
|
|
4377
|
+
var import_editor_elements10 = require("@elementor/editor-elements");
|
|
4378
|
+
var import_editor_v1_adapters18 = require("@elementor/editor-v1-adapters");
|
|
4567
4379
|
var SELECTED_ELEMENT_URI = "elementor://context/selected-element";
|
|
4568
4380
|
var initSelectedElementResource = (reg) => {
|
|
4569
4381
|
const { resource, sendResourceUpdated } = reg;
|
|
@@ -4594,11 +4406,11 @@ var initSelectedElementResource = (reg) => {
|
|
|
4594
4406
|
}
|
|
4595
4407
|
publishIfChanged(readSelectionFromEditor());
|
|
4596
4408
|
};
|
|
4597
|
-
(0,
|
|
4409
|
+
(0, import_editor_v1_adapters18.__privateListenTo)(
|
|
4598
4410
|
[
|
|
4599
|
-
(0,
|
|
4600
|
-
(0,
|
|
4601
|
-
(0,
|
|
4411
|
+
(0, import_editor_v1_adapters18.commandEndEvent)("document/elements/select"),
|
|
4412
|
+
(0, import_editor_v1_adapters18.commandEndEvent)("document/elements/deselect-all"),
|
|
4413
|
+
(0, import_editor_v1_adapters18.commandEndEvent)("document/elements/settings")
|
|
4602
4414
|
],
|
|
4603
4415
|
onCommand
|
|
4604
4416
|
);
|
|
@@ -4633,11 +4445,11 @@ function createEmptySelectedElementPayload() {
|
|
|
4633
4445
|
};
|
|
4634
4446
|
}
|
|
4635
4447
|
function readSelectionFromEditor() {
|
|
4636
|
-
const elements = (0,
|
|
4448
|
+
const elements = (0, import_editor_elements10.getSelectedElements)();
|
|
4637
4449
|
if (elements.length !== 1) {
|
|
4638
4450
|
return createEmptySelectedElementPayload();
|
|
4639
4451
|
}
|
|
4640
|
-
const container = (0,
|
|
4452
|
+
const container = (0, import_editor_elements10.getContainer)(elements[0].id);
|
|
4641
4453
|
return buildPayloadFromContainer(container);
|
|
4642
4454
|
}
|
|
4643
4455
|
function buildPayloadFromContainer(container) {
|
|
@@ -4660,7 +4472,7 @@ function resolveElementVersion2(container, widgetType) {
|
|
|
4660
4472
|
if (container.model?.config?.atomic) {
|
|
4661
4473
|
return "v4";
|
|
4662
4474
|
}
|
|
4663
|
-
if (widgetType && (0,
|
|
4475
|
+
if (widgetType && (0, import_editor_elements10.getWidgetsCache)()?.[widgetType]?.atomic_props_schema) {
|
|
4664
4476
|
return "v4";
|
|
4665
4477
|
}
|
|
4666
4478
|
return "v3";
|
|
@@ -4670,7 +4482,7 @@ function getElementProperties(container, widgetType) {
|
|
|
4670
4482
|
if (!settings || typeof settings !== "object") {
|
|
4671
4483
|
return null;
|
|
4672
4484
|
}
|
|
4673
|
-
const widgetConfig = widgetType ? (0,
|
|
4485
|
+
const widgetConfig = widgetType ? (0, import_editor_elements10.getWidgetsCache)()?.[widgetType] : null;
|
|
4674
4486
|
const controls = widgetConfig?.controls;
|
|
4675
4487
|
const filtered = {};
|
|
4676
4488
|
for (const [key, value] of Object.entries(settings)) {
|
|
@@ -4709,17 +4521,17 @@ function getElementDisplayName(container) {
|
|
|
4709
4521
|
|
|
4710
4522
|
// src/mcp/tools/build-composition/tool.ts
|
|
4711
4523
|
var import_editor_documents3 = require("@elementor/editor-documents");
|
|
4712
|
-
var
|
|
4524
|
+
var import_editor_elements15 = require("@elementor/editor-elements");
|
|
4713
4525
|
var import_editor_mcp3 = require("@elementor/editor-mcp");
|
|
4714
4526
|
|
|
4715
4527
|
// src/composition-builder/composition-builder.ts
|
|
4716
|
-
var
|
|
4528
|
+
var import_editor_elements13 = require("@elementor/editor-elements");
|
|
4717
4529
|
|
|
4718
4530
|
// src/mcp/utils/do-update-element-property.ts
|
|
4719
|
-
var
|
|
4720
|
-
var
|
|
4531
|
+
var import_editor_elements12 = require("@elementor/editor-elements");
|
|
4532
|
+
var import_editor_props6 = require("@elementor/editor-props");
|
|
4721
4533
|
var import_editor_styles4 = require("@elementor/editor-styles");
|
|
4722
|
-
var
|
|
4534
|
+
var import_editor_v1_adapters20 = require("@elementor/editor-v1-adapters");
|
|
4723
4535
|
|
|
4724
4536
|
// src/mcp/utils/merge-custom-css.ts
|
|
4725
4537
|
var CUSTOM_CSS_SEPARATOR = "\n";
|
|
@@ -4736,7 +4548,7 @@ var readStoredCustomCssText = (raw) => {
|
|
|
4736
4548
|
};
|
|
4737
4549
|
|
|
4738
4550
|
// src/mcp/utils/resolve-canonical-prop-name.ts
|
|
4739
|
-
var
|
|
4551
|
+
var import_editor_elements11 = require("@elementor/editor-elements");
|
|
4740
4552
|
function buildAliasToCanonicalMap(schema2) {
|
|
4741
4553
|
const aliasToCanonical = {};
|
|
4742
4554
|
for (const [canonical, propType] of Object.entries(schema2)) {
|
|
@@ -4753,14 +4565,14 @@ function buildAliasToCanonicalMap(schema2) {
|
|
|
4753
4565
|
return aliasToCanonical;
|
|
4754
4566
|
}
|
|
4755
4567
|
function resolveCanonicalPropName(elementType, propertyName) {
|
|
4756
|
-
const schema2 = (0,
|
|
4568
|
+
const schema2 = (0, import_editor_elements11.getWidgetsCache)()?.[elementType]?.atomic_props_schema;
|
|
4757
4569
|
if (!schema2 || schema2[propertyName]) {
|
|
4758
4570
|
return propertyName;
|
|
4759
4571
|
}
|
|
4760
4572
|
return buildAliasToCanonicalMap(schema2)[propertyName] ?? propertyName;
|
|
4761
4573
|
}
|
|
4762
4574
|
function resolveCanonicalPropKeys(elementType, props) {
|
|
4763
|
-
const schema2 = (0,
|
|
4575
|
+
const schema2 = (0, import_editor_elements11.getWidgetsCache)()?.[elementType]?.atomic_props_schema;
|
|
4764
4576
|
if (!schema2) {
|
|
4765
4577
|
return { ...props };
|
|
4766
4578
|
}
|
|
@@ -4788,11 +4600,11 @@ function resolveCanonicalPropKeys(elementType, props) {
|
|
|
4788
4600
|
}
|
|
4789
4601
|
|
|
4790
4602
|
// src/mcp/utils/resolve-dynamic-tag.ts
|
|
4791
|
-
var
|
|
4603
|
+
var import_editor_v1_adapters19 = require("@elementor/editor-v1-adapters");
|
|
4792
4604
|
var DYNAMIC_PROP_TYPE_KEY = "dynamic";
|
|
4793
4605
|
var OMITTED_DYNAMIC_SETTING_KEYS = ["fallback"];
|
|
4794
4606
|
var getAtomicDynamicTags = () => {
|
|
4795
|
-
const config = (0,
|
|
4607
|
+
const config = (0, import_editor_v1_adapters19.getElementorConfig)();
|
|
4796
4608
|
return config.atomicDynamicTags?.tags ?? {};
|
|
4797
4609
|
};
|
|
4798
4610
|
var getDynamicTagNamesByCategories = (categories) => {
|
|
@@ -4856,7 +4668,7 @@ var LOCAL_STYLE_META = {
|
|
|
4856
4668
|
};
|
|
4857
4669
|
function resolvePropValue(value, forceKey) {
|
|
4858
4670
|
const Utils = window.elementorV2.editorVariables.Utils;
|
|
4859
|
-
return
|
|
4671
|
+
return import_editor_props6.Schema.adjustLlmPropValueSchema(value, {
|
|
4860
4672
|
forceKey,
|
|
4861
4673
|
transformers: {
|
|
4862
4674
|
...Utils.globalVariablesLLMResolvers,
|
|
@@ -4868,7 +4680,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
4868
4680
|
const { elementId, propertyValue, elementType, customCssWriteMode = "replace" } = params;
|
|
4869
4681
|
const propertyName = params.propertyName === "_styles" ? params.propertyName : resolveCanonicalPropName(elementType, params.propertyName);
|
|
4870
4682
|
if (propertyName === "_styles") {
|
|
4871
|
-
const elementStyles = (0,
|
|
4683
|
+
const elementStyles = (0, import_editor_elements12.getElementStyles)(elementId) || {};
|
|
4872
4684
|
const propertyMapValue = propertyValue;
|
|
4873
4685
|
const styleSchema = (0, import_editor_styles4.getStylesSchema)();
|
|
4874
4686
|
const transformedStyleValues = Object.fromEntries(
|
|
@@ -4915,7 +4727,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
4915
4727
|
}
|
|
4916
4728
|
if (propertyRawSchema.kind === "plain") {
|
|
4917
4729
|
if (typeof propertyMapValue[stylePropName] !== "object") {
|
|
4918
|
-
const propUtil = (0,
|
|
4730
|
+
const propUtil = (0, import_editor_props6.getPropSchemaFromCache)(propertyRawSchema.key);
|
|
4919
4731
|
if (propUtil) {
|
|
4920
4732
|
const plainValue = propUtil.create(propertyMapValue[stylePropName]);
|
|
4921
4733
|
propertyMapValue[stylePropName] = plainValue;
|
|
@@ -4925,7 +4737,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
4925
4737
|
});
|
|
4926
4738
|
delete transformedStyleValues.custom_css;
|
|
4927
4739
|
if (!localStyle) {
|
|
4928
|
-
(0,
|
|
4740
|
+
(0, import_editor_elements12.createElementStyle)({
|
|
4929
4741
|
elementId,
|
|
4930
4742
|
...typeof customCss !== "undefined" ? { custom_css: customCss } : {},
|
|
4931
4743
|
classesProp: "classes",
|
|
@@ -4939,7 +4751,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
4939
4751
|
}
|
|
4940
4752
|
});
|
|
4941
4753
|
} else {
|
|
4942
|
-
(0,
|
|
4754
|
+
(0, import_editor_elements12.updateElementStyle)({
|
|
4943
4755
|
elementId,
|
|
4944
4756
|
styleId: localStyle.id,
|
|
4945
4757
|
meta: {
|
|
@@ -4954,7 +4766,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
4954
4766
|
}
|
|
4955
4767
|
return;
|
|
4956
4768
|
}
|
|
4957
|
-
const elementPropSchema = (0,
|
|
4769
|
+
const elementPropSchema = (0, import_editor_elements12.getWidgetsCache)()?.[elementType]?.atomic_props_schema;
|
|
4958
4770
|
if (!elementPropSchema) {
|
|
4959
4771
|
throw new Error(`No prop schema found for element type: ${elementType}`);
|
|
4960
4772
|
}
|
|
@@ -4968,7 +4780,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
4968
4780
|
}
|
|
4969
4781
|
const propKey = elementPropSchema[propertyName].key;
|
|
4970
4782
|
const value = resolvePropValue(propertyValue, propKey);
|
|
4971
|
-
const { valid, jsonSchema } =
|
|
4783
|
+
const { valid, jsonSchema } = import_editor_props6.Schema.validatePropValue(elementPropSchema[propertyName], propertyValue);
|
|
4972
4784
|
if (!valid) {
|
|
4973
4785
|
throw new Error(
|
|
4974
4786
|
`Invalid PropValue for elementId: ${elementId}. PropKey: ${propKey}, PropValue: ${JSON.stringify(
|
|
@@ -4977,16 +4789,25 @@ var doUpdateElementProperty = (params) => {
|
|
|
4977
4789
|
Expected Schema: ${jsonSchema}`
|
|
4978
4790
|
);
|
|
4979
4791
|
}
|
|
4980
|
-
(0,
|
|
4792
|
+
(0, import_editor_elements12.updateElementSettings)({
|
|
4981
4793
|
id: elementId,
|
|
4982
4794
|
props: {
|
|
4983
4795
|
[propertyName]: value
|
|
4984
4796
|
},
|
|
4985
4797
|
withHistory: false
|
|
4986
4798
|
});
|
|
4987
|
-
(0,
|
|
4799
|
+
(0, import_editor_v1_adapters20.__privateRunCommandSync)("document/save/set-is-modified", { status: true }, { internal: true });
|
|
4988
4800
|
};
|
|
4989
4801
|
|
|
4802
|
+
// src/composition-builder/utils/required-default-child-tags.ts
|
|
4803
|
+
function getRequiredDefaultChildTemplates(elementConfig) {
|
|
4804
|
+
const defaultChildren = elementConfig?.default_children;
|
|
4805
|
+
if (!Array.isArray(defaultChildren)) {
|
|
4806
|
+
return [];
|
|
4807
|
+
}
|
|
4808
|
+
return defaultChildren.filter((child) => child?.meta?.required ?? false);
|
|
4809
|
+
}
|
|
4810
|
+
|
|
4990
4811
|
// src/composition-builder/utils/required-children-enforcer.ts
|
|
4991
4812
|
var REQUIRED_CHILD_SCHEMA_HINT = "Use the widget schema resource; under llm_guidance.required_direct_children for V4 widgets.";
|
|
4992
4813
|
var RequiredChildrenEnforcer = class {
|
|
@@ -5035,11 +4856,11 @@ var CompositionBuilder = class _CompositionBuilder {
|
|
|
5035
4856
|
elementCustomCSS = {};
|
|
5036
4857
|
rootContainers = [];
|
|
5037
4858
|
api = {
|
|
5038
|
-
createElement:
|
|
5039
|
-
deleteElement:
|
|
5040
|
-
getWidgetsCache:
|
|
5041
|
-
generateElementId:
|
|
5042
|
-
getContainer:
|
|
4859
|
+
createElement: import_editor_elements13.createElement,
|
|
4860
|
+
deleteElement: import_editor_elements13.deleteElement,
|
|
4861
|
+
getWidgetsCache: import_editor_elements13.getWidgetsCache,
|
|
4862
|
+
generateElementId: import_editor_elements13.generateElementId,
|
|
4863
|
+
getContainer: import_editor_elements13.getContainer,
|
|
5043
4864
|
doUpdateElementProperty
|
|
5044
4865
|
};
|
|
5045
4866
|
xml;
|
|
@@ -5290,6 +5111,27 @@ var trackCanvasEvent = (data) => {
|
|
|
5290
5111
|
(0, import_events.trackEvent)(data);
|
|
5291
5112
|
};
|
|
5292
5113
|
|
|
5114
|
+
// src/mcp/utils/element-data-util.ts
|
|
5115
|
+
var import_editor_elements14 = require("@elementor/editor-elements");
|
|
5116
|
+
function hasV3Controls(controls) {
|
|
5117
|
+
return typeof controls === "object" && controls !== null && Object.keys(controls).length > 0;
|
|
5118
|
+
}
|
|
5119
|
+
function isWidgetAvailableForLLM(config) {
|
|
5120
|
+
if (!config) {
|
|
5121
|
+
return false;
|
|
5122
|
+
}
|
|
5123
|
+
if (config.meta?.llm_support === false) {
|
|
5124
|
+
return false;
|
|
5125
|
+
}
|
|
5126
|
+
if (config.title === "Component") {
|
|
5127
|
+
return false;
|
|
5128
|
+
}
|
|
5129
|
+
if (config.atomic_props_schema) {
|
|
5130
|
+
return true;
|
|
5131
|
+
}
|
|
5132
|
+
return hasV3Controls(config.controls);
|
|
5133
|
+
}
|
|
5134
|
+
|
|
5293
5135
|
// src/mcp/utils/get-composition-target-container.ts
|
|
5294
5136
|
var import_editor_documents2 = require("@elementor/editor-documents");
|
|
5295
5137
|
function getCompositionTargetContainer(documentContainer, documentType) {
|
|
@@ -5572,19 +5414,19 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
5572
5414
|
const { xmlStructure, elementConfig, stylesConfig } = adaptLeafRootParams({
|
|
5573
5415
|
...rawParams,
|
|
5574
5416
|
stylesConfig: convertedStyles,
|
|
5575
|
-
widgetsCache: (0,
|
|
5417
|
+
widgetsCache: (0, import_editor_elements15.getWidgetsCache)() ?? {}
|
|
5576
5418
|
});
|
|
5577
5419
|
let generatedXML = "";
|
|
5578
5420
|
const errors = [];
|
|
5579
5421
|
const rootContainers = [];
|
|
5580
|
-
const documentContainer = (0,
|
|
5422
|
+
const documentContainer = (0, import_editor_elements15.getContainer)("document");
|
|
5581
5423
|
const currentDocument = (0, import_editor_documents3.getCurrentDocument)();
|
|
5582
5424
|
const targetContainer = getCompositionTargetContainer(documentContainer, currentDocument?.type.value);
|
|
5583
5425
|
try {
|
|
5584
5426
|
const compositionBuilder = CompositionBuilder.fromXMLString(xmlStructure, {
|
|
5585
|
-
createElement:
|
|
5586
|
-
deleteElement:
|
|
5587
|
-
getWidgetsCache:
|
|
5427
|
+
createElement: import_editor_elements15.createElement,
|
|
5428
|
+
deleteElement: import_editor_elements15.deleteElement,
|
|
5429
|
+
getWidgetsCache: import_editor_elements15.getWidgetsCache
|
|
5588
5430
|
});
|
|
5589
5431
|
compositionBuilder.setElementConfig(elementConfig);
|
|
5590
5432
|
compositionBuilder.setStylesConfig(stylesConfig);
|
|
@@ -5616,7 +5458,7 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
5616
5458
|
}
|
|
5617
5459
|
if (errors.length) {
|
|
5618
5460
|
rootContainers.forEach((rootContainer) => {
|
|
5619
|
-
(0,
|
|
5461
|
+
(0, import_editor_elements15.deleteElement)({
|
|
5620
5462
|
container: rootContainer,
|
|
5621
5463
|
options: { useHistory: false }
|
|
5622
5464
|
});
|
|
@@ -5685,7 +5527,7 @@ function assertCompositionXmlUsesV4WidgetsOnly(xmlStructure) {
|
|
|
5685
5527
|
if (doc.querySelector("parsererror")) {
|
|
5686
5528
|
throw new Error("Failed to parse XML string: " + doc);
|
|
5687
5529
|
}
|
|
5688
|
-
const widgetsCache = (0,
|
|
5530
|
+
const widgetsCache = (0, import_editor_elements15.getWidgetsCache)() ?? {};
|
|
5689
5531
|
for (const node of doc.querySelectorAll("*")) {
|
|
5690
5532
|
const type = node.tagName;
|
|
5691
5533
|
const widgetData = widgetsCache[type];
|
|
@@ -5724,9 +5566,9 @@ function onElementAdded(element) {
|
|
|
5724
5566
|
}
|
|
5725
5567
|
|
|
5726
5568
|
// src/mcp/tools/configure-element/tool.ts
|
|
5727
|
-
var
|
|
5569
|
+
var import_editor_elements16 = require("@elementor/editor-elements");
|
|
5728
5570
|
var import_editor_mcp5 = require("@elementor/editor-mcp");
|
|
5729
|
-
var
|
|
5571
|
+
var import_editor_props7 = require("@elementor/editor-props");
|
|
5730
5572
|
|
|
5731
5573
|
// src/mcp/tools/configure-element/prompt.ts
|
|
5732
5574
|
var import_editor_mcp4 = require("@elementor/editor-mcp");
|
|
@@ -5893,13 +5735,13 @@ var initConfigureElementTool = (reg) => {
|
|
|
5893
5735
|
{ description: "Dynamic tags catalog", uri: DYNAMIC_TAGS_URI }
|
|
5894
5736
|
],
|
|
5895
5737
|
handler: async ({ elementId, propertiesToChange, elementType, style }) => {
|
|
5896
|
-
const widgetData = (0,
|
|
5738
|
+
const widgetData = (0, import_editor_elements16.getWidgetsCache)()?.[elementType];
|
|
5897
5739
|
if (!widgetData) {
|
|
5898
5740
|
throw new Error(
|
|
5899
5741
|
`Unknown element type: ${elementType}. Check the available-widgets resource for valid types.`
|
|
5900
5742
|
);
|
|
5901
5743
|
}
|
|
5902
|
-
const container = (0,
|
|
5744
|
+
const container = (0, import_editor_elements16.getContainer)(elementId);
|
|
5903
5745
|
if (!container) {
|
|
5904
5746
|
throw new Error(`Element with id ${elementId} not found`);
|
|
5905
5747
|
}
|
|
@@ -5915,7 +5757,7 @@ var initConfigureElementTool = (reg) => {
|
|
|
5915
5757
|
const propertiesToUpdate = resolveCanonicalPropKeys(elementType, propertiesToChange);
|
|
5916
5758
|
const toUpdate = Object.entries(propertiesToUpdate);
|
|
5917
5759
|
for (const [propertyName, propertyValue] of toUpdate) {
|
|
5918
|
-
if (!
|
|
5760
|
+
if (!import_editor_props7.Schema.isPropKeyConfigurable(propertyName)) {
|
|
5919
5761
|
throw new Error(`Not allowed to update ${propertyName}`);
|
|
5920
5762
|
}
|
|
5921
5763
|
try {
|
|
@@ -5992,9 +5834,9 @@ Provide styling as raw CSS via the "style" parameter (a flat map of CSS property
|
|
|
5992
5834
|
|
|
5993
5835
|
// src/mcp/tools/create-element/tool.ts
|
|
5994
5836
|
var import_editor_documents4 = require("@elementor/editor-documents");
|
|
5995
|
-
var
|
|
5837
|
+
var import_http_client6 = require("@elementor/http-client");
|
|
5996
5838
|
var import_schema5 = require("@elementor/schema");
|
|
5997
|
-
var
|
|
5839
|
+
var MCP_PROXY_URL5 = "elementor/v1/mcp-proxy";
|
|
5998
5840
|
var initCreateElementTool = (reg) => {
|
|
5999
5841
|
const { addTool } = reg;
|
|
6000
5842
|
addTool({
|
|
@@ -6014,7 +5856,7 @@ var initCreateElementTool = (reg) => {
|
|
|
6014
5856
|
if (!document2?.id) {
|
|
6015
5857
|
throw new Error("No active document found.");
|
|
6016
5858
|
}
|
|
6017
|
-
const { data } = await (0,
|
|
5859
|
+
const { data } = await (0, import_http_client6.httpService)().post(MCP_PROXY_URL5, {
|
|
6018
5860
|
tool: "create-element",
|
|
6019
5861
|
input: {
|
|
6020
5862
|
parent_id: parentId ?? "document",
|
|
@@ -6032,8 +5874,8 @@ var initCreateElementTool = (reg) => {
|
|
|
6032
5874
|
};
|
|
6033
5875
|
|
|
6034
5876
|
// src/mcp/tools/get-element-config/tool.ts
|
|
6035
|
-
var
|
|
6036
|
-
var
|
|
5877
|
+
var import_editor_elements17 = require("@elementor/editor-elements");
|
|
5878
|
+
var import_editor_props8 = require("@elementor/editor-props");
|
|
6037
5879
|
var import_schema6 = require("@elementor/schema");
|
|
6038
5880
|
var schema = {
|
|
6039
5881
|
elementId: import_schema6.z.string()
|
|
@@ -6067,12 +5909,12 @@ var initGetElementConfigTool = (reg) => {
|
|
|
6067
5909
|
schema,
|
|
6068
5910
|
outputSchema: outputSchema3,
|
|
6069
5911
|
handler: async ({ elementId }) => {
|
|
6070
|
-
const element = (0,
|
|
5912
|
+
const element = (0, import_editor_elements17.getContainer)(elementId);
|
|
6071
5913
|
if (!element) {
|
|
6072
5914
|
throw new Error(`Element with ID ${elementId} not found.`);
|
|
6073
5915
|
}
|
|
6074
5916
|
const elementType = element.model.get("widgetType") || element.model.get("elType") || "";
|
|
6075
|
-
const widgetData = (0,
|
|
5917
|
+
const widgetData = (0, import_editor_elements17.getWidgetsCache)()?.[elementType];
|
|
6076
5918
|
if (!widgetData) {
|
|
6077
5919
|
throw new Error(
|
|
6078
5920
|
`Unknown element type: ${elementType}. Check the available-widgets resource for valid types.`
|
|
@@ -6084,16 +5926,16 @@ var initGetElementConfigTool = (reg) => {
|
|
|
6084
5926
|
);
|
|
6085
5927
|
}
|
|
6086
5928
|
const elementRawSettings = element.settings;
|
|
6087
|
-
const propSchema = (0,
|
|
5929
|
+
const propSchema = (0, import_editor_elements17.getWidgetsCache)()?.[elementType]?.atomic_props_schema;
|
|
6088
5930
|
if (!elementRawSettings || !propSchema) {
|
|
6089
5931
|
throw new Error(`No settings or prop schema found for element ID: ${elementId}`);
|
|
6090
5932
|
}
|
|
6091
5933
|
const propValues = {};
|
|
6092
5934
|
const stylePropValues = {};
|
|
6093
|
-
|
|
5935
|
+
import_editor_props8.Schema.configurableKeys(propSchema).forEach((key) => {
|
|
6094
5936
|
propValues[key] = structuredClone(elementRawSettings.get(key));
|
|
6095
5937
|
});
|
|
6096
|
-
const elementStyles = (0,
|
|
5938
|
+
const elementStyles = (0, import_editor_elements17.getElementStyles)(elementId) || {};
|
|
6097
5939
|
const localStyle = Object.values(elementStyles).find((style) => style.label === "local");
|
|
6098
5940
|
if (localStyle) {
|
|
6099
5941
|
const defaultVariant = localStyle.variants.find(
|
|
@@ -6126,7 +5968,7 @@ var initGetElementConfigTool = (reg) => {
|
|
|
6126
5968
|
|
|
6127
5969
|
// src/mcp/canvas-mcp.ts
|
|
6128
5970
|
var initCanvasMcp = (reg) => {
|
|
6129
|
-
|
|
5971
|
+
import_editor_props9.Schema.setDynamicTagNamesResolver(getDynamicTagNamesByCategories);
|
|
6130
5972
|
initWidgetsSchemaResource(reg);
|
|
6131
5973
|
initAvailableWidgetsResource(reg);
|
|
6132
5974
|
initDocumentStructureResource(reg);
|
|
@@ -6251,16 +6093,16 @@ Note: The "size" property controls image resolution/loading, not visual size. Se
|
|
|
6251
6093
|
`;
|
|
6252
6094
|
|
|
6253
6095
|
// src/prevent-link-in-link-commands.ts
|
|
6254
|
-
var
|
|
6096
|
+
var import_editor_elements18 = require("@elementor/editor-elements");
|
|
6255
6097
|
var import_editor_notifications3 = require("@elementor/editor-notifications");
|
|
6256
|
-
var
|
|
6098
|
+
var import_editor_v1_adapters21 = require("@elementor/editor-v1-adapters");
|
|
6257
6099
|
var import_i18n4 = require("@wordpress/i18n");
|
|
6258
6100
|
function initLinkInLinkPrevention() {
|
|
6259
|
-
(0,
|
|
6101
|
+
(0, import_editor_v1_adapters21.blockCommand)({
|
|
6260
6102
|
command: "document/elements/paste",
|
|
6261
6103
|
condition: blockLinkInLinkPaste
|
|
6262
6104
|
});
|
|
6263
|
-
(0,
|
|
6105
|
+
(0, import_editor_v1_adapters21.blockCommand)({
|
|
6264
6106
|
command: "document/elements/move",
|
|
6265
6107
|
condition: blockLinkInLinkMove
|
|
6266
6108
|
});
|
|
@@ -6322,25 +6164,25 @@ function shouldBlock(sourceElements, targetElements) {
|
|
|
6322
6164
|
return false;
|
|
6323
6165
|
}
|
|
6324
6166
|
const isSourceContainsAnAnchor = sourceElements.some((src) => {
|
|
6325
|
-
return src?.id ? (0,
|
|
6167
|
+
return src?.id ? (0, import_editor_elements18.isElementAnchored)(src.id) || !!(0, import_editor_elements18.getAnchoredDescendantId)(src.id) : false;
|
|
6326
6168
|
});
|
|
6327
6169
|
if (!isSourceContainsAnAnchor) {
|
|
6328
6170
|
return false;
|
|
6329
6171
|
}
|
|
6330
6172
|
const isTargetContainsAnAnchor = targetElements.some((target) => {
|
|
6331
|
-
return target?.id ? (0,
|
|
6173
|
+
return target?.id ? (0, import_editor_elements18.isElementAnchored)(target.id) || !!(0, import_editor_elements18.getAnchoredAncestorId)(target.id) : false;
|
|
6332
6174
|
});
|
|
6333
6175
|
return isTargetContainsAnAnchor;
|
|
6334
6176
|
}
|
|
6335
6177
|
|
|
6336
6178
|
// src/style-commands/paste-style.ts
|
|
6337
|
-
var
|
|
6338
|
-
var
|
|
6339
|
-
var
|
|
6179
|
+
var import_editor_elements21 = require("@elementor/editor-elements");
|
|
6180
|
+
var import_editor_props11 = require("@elementor/editor-props");
|
|
6181
|
+
var import_editor_v1_adapters23 = require("@elementor/editor-v1-adapters");
|
|
6340
6182
|
|
|
6341
6183
|
// src/utils/command-utils.ts
|
|
6342
|
-
var
|
|
6343
|
-
var
|
|
6184
|
+
var import_editor_elements19 = require("@elementor/editor-elements");
|
|
6185
|
+
var import_editor_props10 = require("@elementor/editor-props");
|
|
6344
6186
|
var import_i18n5 = require("@wordpress/i18n");
|
|
6345
6187
|
function hasAtomicWidgets(args) {
|
|
6346
6188
|
const { containers = [args.container] } = args;
|
|
@@ -6358,13 +6200,13 @@ function getClassesProp(container) {
|
|
|
6358
6200
|
return null;
|
|
6359
6201
|
}
|
|
6360
6202
|
const [propKey] = Object.entries(propsSchema).find(
|
|
6361
|
-
([, propType]) => propType.kind === "plain" && propType.key ===
|
|
6203
|
+
([, propType]) => propType.kind === "plain" && propType.key === import_editor_props10.CLASSES_PROP_KEY
|
|
6362
6204
|
) ?? [];
|
|
6363
6205
|
return propKey ?? null;
|
|
6364
6206
|
}
|
|
6365
6207
|
function getContainerSchema(container) {
|
|
6366
6208
|
const type = container?.model.get("widgetType") || container?.model.get("elType");
|
|
6367
|
-
const widgetsCache = (0,
|
|
6209
|
+
const widgetsCache = (0, import_editor_elements19.getWidgetsCache)();
|
|
6368
6210
|
const elementType = widgetsCache?.[type];
|
|
6369
6211
|
return elementType?.atomic_props_schema ?? null;
|
|
6370
6212
|
}
|
|
@@ -6377,15 +6219,15 @@ function getClipboardElements(storageKey = "clipboard") {
|
|
|
6377
6219
|
}
|
|
6378
6220
|
}
|
|
6379
6221
|
function getTitleForContainers(containers) {
|
|
6380
|
-
return containers.length > 1 ? (0, import_i18n5.__)("Elements", "elementor") : (0,
|
|
6222
|
+
return containers.length > 1 ? (0, import_i18n5.__)("Elements", "elementor") : (0, import_editor_elements19.getElementLabel)(containers[0].id);
|
|
6381
6223
|
}
|
|
6382
6224
|
|
|
6383
6225
|
// src/style-commands/undoable-actions/paste-element-style.ts
|
|
6384
|
-
var
|
|
6226
|
+
var import_editor_elements20 = require("@elementor/editor-elements");
|
|
6385
6227
|
var import_editor_styles_repository4 = require("@elementor/editor-styles-repository");
|
|
6386
|
-
var
|
|
6228
|
+
var import_editor_v1_adapters22 = require("@elementor/editor-v1-adapters");
|
|
6387
6229
|
var import_i18n6 = require("@wordpress/i18n");
|
|
6388
|
-
var undoablePasteElementStyle = () => (0,
|
|
6230
|
+
var undoablePasteElementStyle = () => (0, import_editor_v1_adapters22.undoable)(
|
|
6389
6231
|
{
|
|
6390
6232
|
do: ({ containers, newStyle }) => {
|
|
6391
6233
|
return containers.map((container) => {
|
|
@@ -6394,7 +6236,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters23.undoable)(
|
|
|
6394
6236
|
if (!classesProp) {
|
|
6395
6237
|
return null;
|
|
6396
6238
|
}
|
|
6397
|
-
const originalStyles = (0,
|
|
6239
|
+
const originalStyles = (0, import_editor_elements20.getElementStyles)(container.id);
|
|
6398
6240
|
const [styleId, styleDef] = Object.entries(originalStyles ?? {})[0] ?? [];
|
|
6399
6241
|
const originalStyle = Object.keys(styleDef ?? {}).length ? styleDef : null;
|
|
6400
6242
|
const revertData = {
|
|
@@ -6403,7 +6245,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters23.undoable)(
|
|
|
6403
6245
|
};
|
|
6404
6246
|
if (styleId) {
|
|
6405
6247
|
newStyle.variants.forEach(({ meta, props, custom_css: customCss }) => {
|
|
6406
|
-
(0,
|
|
6248
|
+
(0, import_editor_elements20.updateElementStyle)({
|
|
6407
6249
|
elementId,
|
|
6408
6250
|
styleId,
|
|
6409
6251
|
meta,
|
|
@@ -6414,7 +6256,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters23.undoable)(
|
|
|
6414
6256
|
} else {
|
|
6415
6257
|
const [firstVariant] = newStyle.variants;
|
|
6416
6258
|
const additionalVariants = newStyle.variants.slice(1);
|
|
6417
|
-
revertData.styleId = (0,
|
|
6259
|
+
revertData.styleId = (0, import_editor_elements20.createElementStyle)({
|
|
6418
6260
|
elementId,
|
|
6419
6261
|
classesProp,
|
|
6420
6262
|
label: import_editor_styles_repository4.ELEMENTS_STYLES_RESERVED_LABEL,
|
|
@@ -6432,7 +6274,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters23.undoable)(
|
|
|
6432
6274
|
return;
|
|
6433
6275
|
}
|
|
6434
6276
|
if (!revertData.originalStyle) {
|
|
6435
|
-
(0,
|
|
6277
|
+
(0, import_editor_elements20.deleteElementStyle)(container.id, revertData.styleId);
|
|
6436
6278
|
return;
|
|
6437
6279
|
}
|
|
6438
6280
|
const classesProp = getClassesProp(container);
|
|
@@ -6441,7 +6283,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters23.undoable)(
|
|
|
6441
6283
|
}
|
|
6442
6284
|
const [firstVariant] = revertData.originalStyle.variants;
|
|
6443
6285
|
const additionalVariants = revertData.originalStyle.variants.slice(1);
|
|
6444
|
-
(0,
|
|
6286
|
+
(0, import_editor_elements20.createElementStyle)({
|
|
6445
6287
|
elementId: container.id,
|
|
6446
6288
|
classesProp,
|
|
6447
6289
|
label: import_editor_styles_repository4.ELEMENTS_STYLES_RESERVED_LABEL,
|
|
@@ -6461,12 +6303,12 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters23.undoable)(
|
|
|
6461
6303
|
// src/style-commands/paste-style.ts
|
|
6462
6304
|
function initPasteStyleCommand() {
|
|
6463
6305
|
const pasteElementStyleCommand = undoablePasteElementStyle();
|
|
6464
|
-
(0,
|
|
6306
|
+
(0, import_editor_v1_adapters23.blockCommand)({
|
|
6465
6307
|
command: "document/elements/paste-style",
|
|
6466
6308
|
condition: hasAtomicWidgets
|
|
6467
6309
|
});
|
|
6468
|
-
(0,
|
|
6469
|
-
(0,
|
|
6310
|
+
(0, import_editor_v1_adapters23.__privateListenTo)(
|
|
6311
|
+
(0, import_editor_v1_adapters23.commandStartEvent)("document/elements/paste-style"),
|
|
6470
6312
|
(e) => pasteStyles(e.args, pasteElementStyleCommand)
|
|
6471
6313
|
);
|
|
6472
6314
|
}
|
|
@@ -6478,7 +6320,7 @@ function pasteStyles(args, pasteLocalStyle) {
|
|
|
6478
6320
|
}
|
|
6479
6321
|
const clipboardElements = getClipboardElements(storageKey);
|
|
6480
6322
|
const [clipboardElement] = clipboardElements ?? [];
|
|
6481
|
-
const clipboardContainer = (0,
|
|
6323
|
+
const clipboardContainer = (0, import_editor_elements21.getContainer)(clipboardElement.id);
|
|
6482
6324
|
if (!clipboardElement || !clipboardContainer || !isAtomicWidget(clipboardContainer)) {
|
|
6483
6325
|
return;
|
|
6484
6326
|
}
|
|
@@ -6497,7 +6339,7 @@ function getClassesWithoutLocalStyle(clipboardContainer, style) {
|
|
|
6497
6339
|
if (!classesProp) {
|
|
6498
6340
|
return [];
|
|
6499
6341
|
}
|
|
6500
|
-
const classesSetting = (0,
|
|
6342
|
+
const classesSetting = (0, import_editor_elements21.getElementSetting)(clipboardContainer.id, classesProp);
|
|
6501
6343
|
return classesSetting?.value.filter((styleId) => styleId !== style?.id) ?? [];
|
|
6502
6344
|
}
|
|
6503
6345
|
function pasteClasses(containers, classes) {
|
|
@@ -6506,10 +6348,10 @@ function pasteClasses(containers, classes) {
|
|
|
6506
6348
|
if (!classesProp) {
|
|
6507
6349
|
return;
|
|
6508
6350
|
}
|
|
6509
|
-
const classesSetting = (0,
|
|
6510
|
-
const currentClasses =
|
|
6511
|
-
const newClasses =
|
|
6512
|
-
(0,
|
|
6351
|
+
const classesSetting = (0, import_editor_elements21.getElementSetting)(container.id, classesProp);
|
|
6352
|
+
const currentClasses = import_editor_props11.classesPropTypeUtil.extract(classesSetting) ?? [];
|
|
6353
|
+
const newClasses = import_editor_props11.classesPropTypeUtil.create(Array.from(/* @__PURE__ */ new Set([...classes, ...currentClasses])));
|
|
6354
|
+
(0, import_editor_elements21.updateElementSettings)({
|
|
6513
6355
|
id: container.id,
|
|
6514
6356
|
props: { [classesProp]: newClasses }
|
|
6515
6357
|
});
|
|
@@ -6517,21 +6359,21 @@ function pasteClasses(containers, classes) {
|
|
|
6517
6359
|
}
|
|
6518
6360
|
|
|
6519
6361
|
// src/style-commands/reset-style.ts
|
|
6520
|
-
var
|
|
6362
|
+
var import_editor_v1_adapters25 = require("@elementor/editor-v1-adapters");
|
|
6521
6363
|
|
|
6522
6364
|
// src/style-commands/undoable-actions/reset-element-style.ts
|
|
6523
|
-
var
|
|
6365
|
+
var import_editor_elements22 = require("@elementor/editor-elements");
|
|
6524
6366
|
var import_editor_styles_repository5 = require("@elementor/editor-styles-repository");
|
|
6525
|
-
var
|
|
6367
|
+
var import_editor_v1_adapters24 = require("@elementor/editor-v1-adapters");
|
|
6526
6368
|
var import_i18n7 = require("@wordpress/i18n");
|
|
6527
|
-
var undoableResetElementStyle = () => (0,
|
|
6369
|
+
var undoableResetElementStyle = () => (0, import_editor_v1_adapters24.undoable)(
|
|
6528
6370
|
{
|
|
6529
6371
|
do: ({ containers }) => {
|
|
6530
6372
|
return containers.map((container) => {
|
|
6531
6373
|
const elementId = container.model.get("id");
|
|
6532
|
-
const containerStyles = (0,
|
|
6374
|
+
const containerStyles = (0, import_editor_elements22.getElementStyles)(elementId);
|
|
6533
6375
|
Object.keys(containerStyles ?? {}).forEach(
|
|
6534
|
-
(styleId) => (0,
|
|
6376
|
+
(styleId) => (0, import_editor_elements22.deleteElementStyle)(elementId, styleId)
|
|
6535
6377
|
);
|
|
6536
6378
|
return containerStyles;
|
|
6537
6379
|
});
|
|
@@ -6547,7 +6389,7 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters25.undoable)(
|
|
|
6547
6389
|
Object.entries(containerStyles ?? {}).forEach(([styleId, style]) => {
|
|
6548
6390
|
const [firstVariant] = style.variants;
|
|
6549
6391
|
const additionalVariants = style.variants.slice(1);
|
|
6550
|
-
(0,
|
|
6392
|
+
(0, import_editor_elements22.createElementStyle)({
|
|
6551
6393
|
elementId,
|
|
6552
6394
|
classesProp,
|
|
6553
6395
|
styleId,
|
|
@@ -6568,12 +6410,12 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters25.undoable)(
|
|
|
6568
6410
|
// src/style-commands/reset-style.ts
|
|
6569
6411
|
function initResetStyleCommand() {
|
|
6570
6412
|
const resetElementStyles = undoableResetElementStyle();
|
|
6571
|
-
(0,
|
|
6413
|
+
(0, import_editor_v1_adapters25.blockCommand)({
|
|
6572
6414
|
command: "document/elements/reset-style",
|
|
6573
6415
|
condition: hasAtomicWidgets
|
|
6574
6416
|
});
|
|
6575
|
-
(0,
|
|
6576
|
-
(0,
|
|
6417
|
+
(0, import_editor_v1_adapters25.__privateListenTo)(
|
|
6418
|
+
(0, import_editor_v1_adapters25.commandStartEvent)("document/elements/reset-style"),
|
|
6577
6419
|
(e) => resetStyles(e.args, resetElementStyles)
|
|
6578
6420
|
);
|
|
6579
6421
|
}
|
|
@@ -6722,9 +6564,9 @@ function getRectClipPath(rect, viewport) {
|
|
|
6722
6564
|
}
|
|
6723
6565
|
|
|
6724
6566
|
// src/hooks/use-canvas-document.ts
|
|
6725
|
-
var
|
|
6567
|
+
var import_editor_v1_adapters26 = require("@elementor/editor-v1-adapters");
|
|
6726
6568
|
function useCanvasDocument() {
|
|
6727
|
-
return (0,
|
|
6569
|
+
return (0, import_editor_v1_adapters26.__privateUseListenTo)((0, import_editor_v1_adapters26.commandEndEvent)("editor/documents/attach-preview"), () => (0, import_editor_v1_adapters26.getCanvasIframeDocument)());
|
|
6728
6570
|
}
|
|
6729
6571
|
|
|
6730
6572
|
// src/hooks/use-escape-on-canvas.ts
|
|
@@ -6747,10 +6589,10 @@ function useEscapeOnCanvas(canvasDocument, onEscape) {
|
|
|
6747
6589
|
}
|
|
6748
6590
|
|
|
6749
6591
|
// src/utils/after-render.ts
|
|
6750
|
-
var
|
|
6592
|
+
var import_editor_elements23 = require("@elementor/editor-elements");
|
|
6751
6593
|
function doAfterRender(elementIds, callback) {
|
|
6752
6594
|
const pending = elementIds.map((elementId) => {
|
|
6753
|
-
const view = (0,
|
|
6595
|
+
const view = (0, import_editor_elements23.getContainer)(elementId)?.view;
|
|
6754
6596
|
if (!view || !hasDoAfterRender(view)) {
|
|
6755
6597
|
return void 0;
|
|
6756
6598
|
}
|