@elementor/editor-canvas 4.1.0-802 → 4.1.0-804

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