@elementor/editor-elements 3.33.0-231 → 3.33.0-233

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -369,4 +369,6 @@ declare const updateElementInteractions: ({ elementId, interactions, }: {
369
369
 
370
370
  declare const useElementInteractions: (elementId: ElementID) => string;
371
371
 
372
- export { type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementModel, type ElementType, type LinkInLinkRestriction, type MoveElementParams, type MoveElementsParams, type MovedElement, type MovedElementsResult, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementModelProps, type V1ElementSettingsProps, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, generateElementId, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getElementEditorSettings, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementType, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, removeElements, replaceElement, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useElementInteractions, useElementSetting, useElementSettings, useParentElement, useSelectedElement };
372
+ declare function initMcp(): void;
373
+
374
+ export { type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementModel, type ElementType, type LinkInLinkRestriction, type MoveElementParams, type MoveElementsParams, type MovedElement, type MovedElementsResult, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementModelProps, type V1ElementSettingsProps, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, generateElementId, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getElementEditorSettings, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementType, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, initMcp as initElementsMcp, isElementAnchored, moveElement, moveElements, removeElements, replaceElement, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useElementInteractions, useElementSetting, useElementSettings, useParentElement, useSelectedElement };
package/dist/index.d.ts CHANGED
@@ -369,4 +369,6 @@ declare const updateElementInteractions: ({ elementId, interactions, }: {
369
369
 
370
370
  declare const useElementInteractions: (elementId: ElementID) => string;
371
371
 
372
- export { type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementModel, type ElementType, type LinkInLinkRestriction, type MoveElementParams, type MoveElementsParams, type MovedElement, type MovedElementsResult, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementModelProps, type V1ElementSettingsProps, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, generateElementId, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getElementEditorSettings, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementType, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, removeElements, replaceElement, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useElementInteractions, useElementSetting, useElementSettings, useParentElement, useSelectedElement };
372
+ declare function initMcp(): void;
373
+
374
+ export { type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementModel, type ElementType, type LinkInLinkRestriction, type MoveElementParams, type MoveElementsParams, type MovedElement, type MovedElementsResult, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementModelProps, type V1ElementSettingsProps, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, generateElementId, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getElementEditorSettings, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementType, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, initMcp as initElementsMcp, isElementAnchored, moveElement, moveElements, removeElements, replaceElement, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useElementInteractions, useElementSetting, useElementSettings, useParentElement, useSelectedElement };
package/dist/index.js CHANGED
@@ -46,6 +46,7 @@ __export(index_exports, {
46
46
  getLinkInLinkRestriction: () => getLinkInLinkRestriction,
47
47
  getSelectedElements: () => getSelectedElements,
48
48
  getWidgetsCache: () => getWidgetsCache,
49
+ initElementsMcp: () => initMcp,
49
50
  isElementAnchored: () => isElementAnchored,
50
51
  moveElement: () => moveElement,
51
52
  moveElements: () => moveElements,
@@ -1048,6 +1049,613 @@ var useElementInteractions = (elementId) => {
1048
1049
  );
1049
1050
  return interactions;
1050
1051
  };
1052
+
1053
+ // src/mcp/index.ts
1054
+ var import_editor_mcp2 = require("@elementor/editor-mcp");
1055
+
1056
+ // src/mcp/elements-tool.ts
1057
+ var import_editor_mcp = require("@elementor/editor-mcp");
1058
+ var import_schema = require("@elementor/schema");
1059
+
1060
+ // src/mcp/handlers/create-element.ts
1061
+ function handleCreateElement({
1062
+ elementType,
1063
+ containerId,
1064
+ props = {},
1065
+ styles
1066
+ }) {
1067
+ let container = containerId === "document" ? getCurrentDocumentContainer() : getContainer(containerId);
1068
+ if (!container) {
1069
+ if (containerId === "document") {
1070
+ throw new Error("Document container not found. Please ensure the editor is initialized.");
1071
+ }
1072
+ throw new Error(`Container with ID "${containerId}" not found`);
1073
+ }
1074
+ const containerElType = container.model.get("elType");
1075
+ const isDocument = container.id === "document" || containerElType === "document";
1076
+ if (isDocument) {
1077
+ const containerModel = {
1078
+ elType: "e-div-block"
1079
+ };
1080
+ const createdContainer = createElement({
1081
+ containerId: container.id,
1082
+ model: containerModel,
1083
+ options: { useHistory: true }
1084
+ });
1085
+ createElementStyle({
1086
+ elementId: createdContainer.id,
1087
+ classesProp: "classes",
1088
+ label: "local",
1089
+ meta: { breakpoint: "desktop", state: null },
1090
+ props: {
1091
+ display: { $$type: "string", value: "flex" },
1092
+ "flex-direction": { $$type: "string", value: "row" },
1093
+ "flex-wrap": { $$type: "string", value: "wrap" }
1094
+ }
1095
+ });
1096
+ container = getContainer(createdContainer.id);
1097
+ if (!container) {
1098
+ throw new Error("Failed to create container for widget. Cannot create widgets directly in the document.");
1099
+ }
1100
+ }
1101
+ const actualContainerId = container.id;
1102
+ const elementTypeData = getElementType(elementType);
1103
+ if (!elementTypeData) {
1104
+ throw new Error(`Element type "${elementType}" not found or is not atomic`);
1105
+ }
1106
+ const model = {
1107
+ widgetType: elementType,
1108
+ elType: "widget",
1109
+ settings: props
1110
+ };
1111
+ const createdElement = createElement({
1112
+ containerId: actualContainerId,
1113
+ model,
1114
+ options: { useHistory: true }
1115
+ });
1116
+ if (styles) {
1117
+ createElementStyle({
1118
+ elementId: createdElement.id,
1119
+ classesProp: "classes",
1120
+ label: "local",
1121
+ meta: { breakpoint: "desktop", state: null },
1122
+ props: styles
1123
+ });
1124
+ }
1125
+ return {
1126
+ elementId: createdElement.id,
1127
+ type: elementType
1128
+ };
1129
+ }
1130
+
1131
+ // src/mcp/handlers/common-style-utils.ts
1132
+ var VALID_BREAKPOINTS = [
1133
+ "widescreen",
1134
+ "desktop",
1135
+ "laptop",
1136
+ "tablet_extra",
1137
+ "tablet",
1138
+ "mobile_extra",
1139
+ "mobile"
1140
+ ];
1141
+ function resolveBreakpointId(breakpoint) {
1142
+ if (breakpoint === null) {
1143
+ return null;
1144
+ }
1145
+ if (VALID_BREAKPOINTS.includes(breakpoint)) {
1146
+ return breakpoint;
1147
+ }
1148
+ return "desktop";
1149
+ }
1150
+
1151
+ // src/mcp/handlers/create-style.ts
1152
+ function handleCreateStyle({
1153
+ elementId,
1154
+ styleId,
1155
+ classesProp = "classes",
1156
+ label = "local",
1157
+ styles,
1158
+ breakpoint = "desktop",
1159
+ state = null,
1160
+ customCss = null
1161
+ }) {
1162
+ const resolvedBreakpoint = resolveBreakpointId(breakpoint);
1163
+ const resolvedState = state === null || state === void 0 ? null : state;
1164
+ const createdStyleId = createElementStyle({
1165
+ styleId,
1166
+ elementId,
1167
+ classesProp,
1168
+ label,
1169
+ meta: { breakpoint: resolvedBreakpoint, state: resolvedState },
1170
+ props: styles,
1171
+ custom_css: customCss
1172
+ });
1173
+ return { styleId: createdStyleId };
1174
+ }
1175
+
1176
+ // src/mcp/handlers/delete-element.ts
1177
+ function handleDeleteElement(elementId) {
1178
+ const container = getContainer(elementId);
1179
+ if (!container) {
1180
+ throw new Error(`Element with ID "${elementId}" not found`);
1181
+ }
1182
+ deleteElement({
1183
+ elementId,
1184
+ options: { useHistory: true }
1185
+ });
1186
+ return { success: true };
1187
+ }
1188
+
1189
+ // src/mcp/handlers/delete-style.ts
1190
+ function handleDeleteStyle({ elementId, styleId }) {
1191
+ const elementStyles = getElementStyles(elementId);
1192
+ if (!elementStyles) {
1193
+ throw new Error(`Element with ID "${elementId}" has no styles.`);
1194
+ }
1195
+ const resolvedStyleId = styleId || Object.keys(elementStyles)[0];
1196
+ if (!resolvedStyleId) {
1197
+ throw new Error(`Element with ID "${elementId}" has no styles to delete.`);
1198
+ }
1199
+ deleteElementStyle(elementId, resolvedStyleId);
1200
+ return { success: true };
1201
+ }
1202
+
1203
+ // src/mcp/handlers/deselect-element.ts
1204
+ var import_editor_v1_adapters20 = require("@elementor/editor-v1-adapters");
1205
+ function handleDeselectElement(elementId) {
1206
+ const container = getContainer(elementId);
1207
+ if (!container) {
1208
+ throw new Error(`Element with ID "${elementId}" not found`);
1209
+ }
1210
+ (0, import_editor_v1_adapters20.__privateRunCommand)("document/elements/deselect", { container });
1211
+ return { success: true };
1212
+ }
1213
+ function handleDeselectAllElements() {
1214
+ (0, import_editor_v1_adapters20.__privateRunCommand)("document/elements/deselect-all", {});
1215
+ return { success: true };
1216
+ }
1217
+
1218
+ // src/mcp/handlers/duplicate-element.ts
1219
+ function handleDuplicateElement(elementId) {
1220
+ const container = getContainer(elementId);
1221
+ if (!container) {
1222
+ throw new Error(`Element with ID "${elementId}" not found`);
1223
+ }
1224
+ const duplicatedElement = duplicateElement({
1225
+ elementId,
1226
+ options: { useHistory: true }
1227
+ });
1228
+ const type = duplicatedElement.model.get("widgetType") || duplicatedElement.model.get("elType") || "";
1229
+ return {
1230
+ elementId: duplicatedElement.id,
1231
+ type
1232
+ };
1233
+ }
1234
+
1235
+ // src/mcp/handlers/get-element-props.ts
1236
+ function handleGetElementProps(elementId) {
1237
+ const container = getContainer(elementId);
1238
+ if (!container) {
1239
+ throw new Error(`Element with ID "${elementId}" not found`);
1240
+ }
1241
+ const type = container.model.get("widgetType") || container.model.get("elType");
1242
+ if (!type) {
1243
+ throw new Error(`Element with ID "${elementId}" has no type`);
1244
+ }
1245
+ const elementType = getElementType(type);
1246
+ if (!elementType) {
1247
+ throw new Error(`Element type "${type}" is not atomic`);
1248
+ }
1249
+ const propsSchema = elementType.propsSchema;
1250
+ const propKeys = Object.keys(propsSchema);
1251
+ return getElementSettings(elementId, propKeys);
1252
+ }
1253
+
1254
+ // src/mcp/handlers/get-element-schema.ts
1255
+ var import_editor_styles3 = require("@elementor/editor-styles");
1256
+ function handleGetElementSchema(elementType) {
1257
+ const elementTypeData = getElementType(elementType);
1258
+ if (!elementTypeData) {
1259
+ throw new Error(`Element type "${elementType}" not found or is not atomic`);
1260
+ }
1261
+ return { ...elementTypeData, stylesSchema: (0, import_editor_styles3.getStylesSchema)() };
1262
+ }
1263
+
1264
+ // src/mcp/handlers/get-selected.ts
1265
+ function handleGetSelected() {
1266
+ return getSelectedElements();
1267
+ }
1268
+
1269
+ // src/mcp/handlers/get-styles.ts
1270
+ function handleGetStyles(elementId) {
1271
+ const styles = getElementStyles(elementId);
1272
+ if (!styles) {
1273
+ return null;
1274
+ }
1275
+ return Object.fromEntries(
1276
+ Object.entries(styles).map(([id, style]) => [
1277
+ id,
1278
+ {
1279
+ id: style.id,
1280
+ label: style.label,
1281
+ type: style.type,
1282
+ variants: style.variants.map((variant) => ({
1283
+ meta: variant.meta,
1284
+ props: variant.props,
1285
+ custom_css: variant.custom_css
1286
+ }))
1287
+ }
1288
+ ])
1289
+ );
1290
+ }
1291
+
1292
+ // src/mcp/handlers/list-available-types.ts
1293
+ function handleListAvailableTypes() {
1294
+ const widgetsCache = getWidgetsCache();
1295
+ if (!widgetsCache) {
1296
+ return [];
1297
+ }
1298
+ const availableTypes = [];
1299
+ Object.entries(widgetsCache).forEach(([type, config]) => {
1300
+ if (config?.atomic_controls && config?.atomic_props_schema) {
1301
+ availableTypes.push({
1302
+ type,
1303
+ title: config.title || type
1304
+ });
1305
+ }
1306
+ });
1307
+ return availableTypes;
1308
+ }
1309
+
1310
+ // src/mcp/handlers/move-element.ts
1311
+ function handleMoveElement({
1312
+ elementId,
1313
+ targetContainerId
1314
+ }) {
1315
+ const container = getContainer(elementId);
1316
+ if (!container) {
1317
+ throw new Error(`Element with ID "${elementId}" not found`);
1318
+ }
1319
+ const targetContainer = getContainer(targetContainerId);
1320
+ if (!targetContainer) {
1321
+ throw new Error(`Target container with ID "${targetContainerId}" not found`);
1322
+ }
1323
+ moveElement({
1324
+ elementId,
1325
+ targetContainerId,
1326
+ options: { useHistory: true }
1327
+ });
1328
+ return { success: true };
1329
+ }
1330
+
1331
+ // src/mcp/handlers/select-element.ts
1332
+ function handleSelectElement(elementId) {
1333
+ const container = getContainer(elementId);
1334
+ if (!container) {
1335
+ throw new Error(`Element with ID "${elementId}" not found`);
1336
+ }
1337
+ selectElement(elementId);
1338
+ return { success: true };
1339
+ }
1340
+ function handleSelectMultipleElements(elementIds) {
1341
+ elementIds.forEach((elementId) => {
1342
+ const container = getContainer(elementId);
1343
+ if (container) {
1344
+ selectElement(elementId);
1345
+ }
1346
+ });
1347
+ return { success: true };
1348
+ }
1349
+
1350
+ // src/mcp/handlers/update-props.ts
1351
+ function handleUpdateProps({ elementId, props }) {
1352
+ const container = getContainer(elementId);
1353
+ if (!container) {
1354
+ throw new Error(`Element with ID "${elementId}" not found`);
1355
+ }
1356
+ updateElementSettings({
1357
+ id: elementId,
1358
+ props,
1359
+ withHistory: true
1360
+ });
1361
+ return { success: true };
1362
+ }
1363
+
1364
+ // src/mcp/handlers/update-styles.ts
1365
+ function handleUpdateStyles({
1366
+ elementId,
1367
+ styleId,
1368
+ styles,
1369
+ breakpoint = "desktop",
1370
+ state = null
1371
+ }) {
1372
+ const resolvedBreakpoint = resolveBreakpointId(breakpoint);
1373
+ const resolvedState = state === null || state === void 0 ? null : state;
1374
+ const elementStyles = getElementStyles(elementId);
1375
+ if (!elementStyles) {
1376
+ throw new Error(`Element with ID "${elementId}" has no styles. Create a style first.`);
1377
+ }
1378
+ const resolvedStyleId = styleId || Object.keys(elementStyles)[0];
1379
+ if (!resolvedStyleId) {
1380
+ throw new Error(`Element with ID "${elementId}" has no styles. Create a style first.`);
1381
+ }
1382
+ updateElementStyle({
1383
+ elementId,
1384
+ styleId: resolvedStyleId,
1385
+ meta: { breakpoint: resolvedBreakpoint, state: resolvedState },
1386
+ props: styles
1387
+ });
1388
+ return { success: true };
1389
+ }
1390
+
1391
+ // src/mcp/elements-tool.ts
1392
+ var actionEnum = import_schema.z.enum([
1393
+ "get-element-schema",
1394
+ "get-element-props",
1395
+ "create-element",
1396
+ "update-props",
1397
+ "create-style",
1398
+ "get-styles",
1399
+ "update-styles",
1400
+ "delete-style",
1401
+ "delete",
1402
+ "duplicate",
1403
+ "move",
1404
+ "select",
1405
+ "deselect",
1406
+ "deselect-all",
1407
+ "get-selected",
1408
+ "list-available-types"
1409
+ ]);
1410
+ var schema = {
1411
+ action: actionEnum.describe("The element operation to perform."),
1412
+ elementId: import_schema.z.string().optional().describe("The ID of the target element"),
1413
+ elementIds: import_schema.z.array(import_schema.z.string()).optional().describe("Array of element IDs for multi-element operations"),
1414
+ elementType: import_schema.z.string().optional().describe(
1415
+ "The type of element to create. Must be an atomic element type (required for create-element and get-element-schema actions)"
1416
+ ),
1417
+ props: import_schema.z.record(import_schema.z.any()).optional().describe("Props object for creating or updating an element. Must match the element type's propsSchema."),
1418
+ containerId: import_schema.z.string().optional().describe(
1419
+ 'Parent container ID for element creation or move operations. Use "document" if parent is the document root.'
1420
+ ),
1421
+ targetContainerId: import_schema.z.string().optional().describe("Target container ID for move operations"),
1422
+ styles: import_schema.z.record(import_schema.z.any()).optional().describe(
1423
+ "Styles object for creating or updating element styles. Must match the element type's stylesSchema."
1424
+ ),
1425
+ styleId: import_schema.z.string().optional().describe(
1426
+ "Style definition ID for style operations. If not provided, the first available style will be used (for update/delete)."
1427
+ ),
1428
+ breakpoint: import_schema.z.string().optional().describe('Breakpoint for style operations (e.g., "desktop", "tablet", "mobile"). Defaults to "desktop".'),
1429
+ state: import_schema.z.string().optional().describe('State for style operations (e.g., "hover", "active", or null). Defaults to null.'),
1430
+ classesProp: import_schema.z.string().optional().describe('Classes property name for create-style action. Defaults to "classes".'),
1431
+ label: import_schema.z.string().optional().describe('Label for create-style action. Defaults to "local".'),
1432
+ custom_css: import_schema.z.object({ raw: import_schema.z.string() }).optional().describe("Custom CSS object with raw CSS string for create-style action.")
1433
+ };
1434
+ function routeAction(params) {
1435
+ try {
1436
+ switch (params.action) {
1437
+ case "get-element-schema":
1438
+ if (!params.elementType) {
1439
+ throw new Error("elementType is required for get-element-schema action");
1440
+ }
1441
+ return handleGetElementSchema(params.elementType);
1442
+ case "get-element-props":
1443
+ if (!params.elementId) {
1444
+ throw new Error("elementId is required for get-element-props action");
1445
+ }
1446
+ return handleGetElementProps(params.elementId);
1447
+ case "create-element":
1448
+ if (!params.elementType) {
1449
+ throw new Error("elementType is required for create-element action");
1450
+ }
1451
+ if (!params.containerId) {
1452
+ throw new Error("containerId is required for create-element action");
1453
+ }
1454
+ return handleCreateElement({
1455
+ elementType: params.elementType,
1456
+ containerId: params.containerId,
1457
+ props: params.props,
1458
+ styles: params.styles
1459
+ });
1460
+ case "update-props":
1461
+ if (!params.elementId) {
1462
+ throw new Error("elementId is required for update-props action");
1463
+ }
1464
+ if (!params.props) {
1465
+ throw new Error("props is required for update-props action");
1466
+ }
1467
+ return handleUpdateProps({
1468
+ elementId: params.elementId,
1469
+ props: params.props
1470
+ });
1471
+ case "create-style":
1472
+ if (!params.elementId) {
1473
+ throw new Error("elementId is required for create-style action");
1474
+ }
1475
+ if (!params.styles) {
1476
+ throw new Error("styles is required for create-style action");
1477
+ }
1478
+ return handleCreateStyle({
1479
+ elementId: params.elementId,
1480
+ styleId: params.styleId,
1481
+ classesProp: params.classesProp,
1482
+ label: params.label,
1483
+ styles: params.styles,
1484
+ breakpoint: params.breakpoint,
1485
+ state: params.state,
1486
+ customCss: params.custom_css
1487
+ });
1488
+ case "get-styles":
1489
+ if (!params.elementId) {
1490
+ throw new Error("elementId is required for get-styles action");
1491
+ }
1492
+ return handleGetStyles(params.elementId);
1493
+ case "update-styles":
1494
+ if (!params.elementId) {
1495
+ throw new Error("elementId is required for update-styles action");
1496
+ }
1497
+ if (!params.styles) {
1498
+ throw new Error("styles is required for update-styles action");
1499
+ }
1500
+ return handleUpdateStyles({
1501
+ elementId: params.elementId,
1502
+ styleId: params.styleId,
1503
+ styles: params.styles,
1504
+ breakpoint: params.breakpoint,
1505
+ state: params.state
1506
+ });
1507
+ case "delete-style":
1508
+ if (!params.elementId) {
1509
+ throw new Error("elementId is required for delete-style action");
1510
+ }
1511
+ return handleDeleteStyle({
1512
+ elementId: params.elementId,
1513
+ styleId: params.styleId
1514
+ });
1515
+ case "delete":
1516
+ if (!params.elementId) {
1517
+ throw new Error("elementId is required for delete action");
1518
+ }
1519
+ return handleDeleteElement(params.elementId);
1520
+ case "duplicate":
1521
+ if (!params.elementId) {
1522
+ throw new Error("elementId is required for duplicate action");
1523
+ }
1524
+ return handleDuplicateElement(params.elementId);
1525
+ case "move":
1526
+ if (!params.elementId) {
1527
+ throw new Error("elementId is required for move action");
1528
+ }
1529
+ if (!params.targetContainerId) {
1530
+ throw new Error("targetContainerId is required for move action");
1531
+ }
1532
+ return handleMoveElement({
1533
+ elementId: params.elementId,
1534
+ targetContainerId: params.targetContainerId
1535
+ });
1536
+ case "select":
1537
+ if (params.elementIds && params.elementIds.length > 0) {
1538
+ return handleSelectMultipleElements(params.elementIds);
1539
+ }
1540
+ if (!params.elementId) {
1541
+ throw new Error("elementId or elementIds is required for select action");
1542
+ }
1543
+ return handleSelectElement(params.elementId);
1544
+ case "deselect":
1545
+ if (!params.elementId) {
1546
+ throw new Error("elementId is required for deselect action");
1547
+ }
1548
+ return handleDeselectElement(params.elementId);
1549
+ case "deselect-all":
1550
+ return handleDeselectAllElements();
1551
+ case "get-selected":
1552
+ return handleGetSelected();
1553
+ case "list-available-types":
1554
+ return handleListAvailableTypes();
1555
+ default:
1556
+ throw new Error(`Unknown action: ${params.action}`);
1557
+ }
1558
+ } catch (error) {
1559
+ const errorMessage = error instanceof Error ? error.message : String(error);
1560
+ throw new Error(`Failed to execute action "${params.action}": ${errorMessage}`);
1561
+ }
1562
+ }
1563
+ function initElementsTool() {
1564
+ (0, import_editor_mcp.getMCPByDomain)("elements").addTool({
1565
+ name: "elements",
1566
+ schema,
1567
+ description: `This tool manages individual Elementor atomic elements (v4).
1568
+
1569
+ **When to use this tool:**
1570
+
1571
+ Use this tool to create, update, delete, duplicate, move, and select individual atomic elements, as well as retrieve their schemas and current props.
1572
+
1573
+ **Available actions:**
1574
+
1575
+ - \`list-available-types\`: List all available atomic element types.
1576
+ - \`get-element-schema\`: Get the propsSchema and controls for an element type. Required before creating elements of a new type.
1577
+ - \`get-element-props\`: Get the current prop values for an existing element.
1578
+ - \`create-element\`: Create a new atomic element with specified props and styles (Important to match props and styles by the schema, use get-element-schema to get the schema first).
1579
+ - \`update-props\`: Update props for an existing element.
1580
+ - \`create-style\`: Create a new style definition for an element.
1581
+ - \`get-styles\`: Get all style definitions for an element.
1582
+ - \`update-styles\`: Update styles for an existing element's style variant.
1583
+ - \`delete-style\`: Delete a style definition from an element.
1584
+ - \`delete\`: Delete an element.
1585
+ - \`duplicate\`: Duplicate an existing element.
1586
+ - \`move\`: Move an element to a different container.
1587
+ - \`select\`: Select one or more elements.
1588
+ - \`deselect\`: Deselect a specific element.
1589
+ - \`deselect-all\`: Deselect all selected elements.
1590
+ - \`get-selected\`: Get currently selected elements.
1591
+
1592
+ **Constraints:**
1593
+
1594
+ - Before creating an element of a certain type for the first time, you MUST call \`get-element-schema\` to retrieve its schema.
1595
+ - You can only update props for existing elements.
1596
+ - All props must match the element type's propsSchema keys.
1597
+ - Element types must be atomic (have atomic_controls and atomic_props_schema).
1598
+ - Container IDs must exist and be valid before create/move operations.
1599
+
1600
+ ** Must do with every operation **
1601
+ As of the user can ask in multiple ways the creation of the element, you need to first get the list of available types with "list-available-types" action.
1602
+ After getting it, convert to the most relevant type that the user requested and if this is not clear, request for user input.
1603
+ After finding out the proper type, get the schema for it with "get-element-schema" action.
1604
+
1605
+ ** Styles and Settings propUtils **
1606
+ Getting the schema is important as it introduces the propUtils for the styles and settings.
1607
+ You can use the propUtils to create, update, delete, and get the values of the styles and settings.
1608
+ Settings exists in the result of the get-element-schema action -> propsSchema.
1609
+ Styles exists in the result of the get-element-schema action -> stylesSchema.
1610
+
1611
+ **Examples:**
1612
+
1613
+ Get schema for heading element:
1614
+ \`\`\`json
1615
+ { "action": "get-element-schema", "elementType": "e-heading" }
1616
+ \`\`\`
1617
+
1618
+ Create a heading element:
1619
+ \`\`\`json
1620
+ { "action": "create-element", "elementType": "e-heading", "containerId": "document", "props": { "title": { $$type: "string", "value": "Hello World" } } }
1621
+ \`\`\`
1622
+
1623
+ Update element props:
1624
+ \`\`\`json
1625
+ { "action": "update-props", "elementId": "abc123", "props": { "title": "Updated Title" } }
1626
+ \`\`\`
1627
+
1628
+ Create element style:
1629
+ \`\`\`json
1630
+ { "action": "create-style", "elementId": "abc123", "styles": { "padding": "20px", "margin": "10px" } }
1631
+ \`\`\`
1632
+
1633
+ Get element styles:
1634
+ \`\`\`json
1635
+ { "action": "get-styles", "elementId": "abc123" }
1636
+ \`\`\`
1637
+
1638
+ Update element styles:
1639
+ \`\`\`json
1640
+ { "action": "update-styles", "elementId": "abc123", "styles": { "padding": "20px", "margin": "10px" } }
1641
+ \`\`\`
1642
+
1643
+ Delete element style:
1644
+ \`\`\`json
1645
+ { "action": "delete-style", "elementId": "abc123", "styleId": "style-id-123" }
1646
+ \`\`\``,
1647
+ handler: async (params) => {
1648
+ return routeAction(params);
1649
+ }
1650
+ });
1651
+ }
1652
+
1653
+ // src/mcp/index.ts
1654
+ function initMcp() {
1655
+ const { setMCPDescription } = (0, import_editor_mcp2.getMCPByDomain)("elements");
1656
+ setMCPDescription("Tools for managing atomic elements in Elementor v4 editor");
1657
+ initElementsTool();
1658
+ }
1051
1659
  // Annotate the CommonJS export names for ESM import in node:
1052
1660
  0 && (module.exports = {
1053
1661
  ELEMENT_STYLE_CHANGE_EVENT,
@@ -1076,6 +1684,7 @@ var useElementInteractions = (elementId) => {
1076
1684
  getLinkInLinkRestriction,
1077
1685
  getSelectedElements,
1078
1686
  getWidgetsCache,
1687
+ initElementsMcp,
1079
1688
  isElementAnchored,
1080
1689
  moveElement,
1081
1690
  moveElements,