@elementor/editor-elements 3.35.0-326 → 3.35.0-327

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