@elementor/editor-interactions 4.0.0-619 → 4.0.0-621

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.mjs CHANGED
@@ -280,13 +280,13 @@ var createInteractionItem = ({
280
280
  $$type: "interaction-item",
281
281
  value: {
282
282
  ...interactionId && { interaction_id: createString(interactionId) },
283
- trigger: createString(trigger),
283
+ trigger: createString(trigger ?? ""),
284
284
  animation: createAnimationPreset({
285
- effect,
286
- type,
285
+ effect: effect ?? "",
286
+ type: type ?? "",
287
287
  direction,
288
- duration,
289
- delay,
288
+ duration: duration ?? 0,
289
+ delay: delay ?? 0,
290
290
  replay,
291
291
  easing,
292
292
  relativeTo,
@@ -1346,53 +1346,73 @@ import { getMCPByDomain } from "@elementor/editor-mcp";
1346
1346
  var MAX_INTERACTIONS_PER_ELEMENT = 5;
1347
1347
 
1348
1348
  // src/mcp/resources/interactions-schema-resource.ts
1349
- var INTERACTIONS_SCHEMA_URI = "elementor://interactions/schema";
1350
- var schema = {
1351
- triggers: BASE_TRIGGERS.map((key) => ({
1352
- value: key,
1353
- label: TRIGGER_OPTIONS[key] ?? key
1354
- })),
1355
- effects: [
1356
- { value: "fade", label: "Fade" },
1357
- { value: "slide", label: "Slide" },
1358
- { value: "scale", label: "Scale" }
1359
- ],
1360
- effectTypes: [
1361
- { value: "in", label: "In" },
1362
- { value: "out", label: "Out" }
1363
- ],
1364
- directions: [
1365
- { value: "top", label: "Top", note: "" },
1366
- { value: "bottom", label: "Bottom", note: "" },
1367
- { value: "left", label: "Left", note: "" },
1368
- { value: "right", label: "Right", note: "" },
1369
- { value: "", label: "None", note: "Slide animation must have a direction" }
1370
- ],
1371
- easings: Object.entries(EASING_OPTIONS).map(([value, label]) => ({ value, label })),
1372
- timing: {
1373
- duration: { min: 0, max: 1e4, unit: "ms", description: "Animation duration in milliseconds" },
1374
- delay: { min: 0, max: 1e4, unit: "ms", description: "Animation delay in milliseconds" }
1375
- },
1376
- excludedBreakpoints: {
1377
- type: "string[]",
1378
- description: "List of breakpoint IDs on which this interaction is disabled. Omit to enable on all breakpoints."
1379
- },
1380
- maxInteractionsPerElement: MAX_INTERACTIONS_PER_ELEMENT
1349
+ import { isProActive } from "@elementor/utils";
1350
+
1351
+ // src/mcp/tools/schema.ts
1352
+ import { z } from "@elementor/schema";
1353
+ var baseSchema = {
1354
+ trigger: z.enum(["load", "scrollIn"]).optional().describe("Event that triggers the animation"),
1355
+ effect: z.enum(["fade", "slide", "scale"]).optional().describe("Animation effect type"),
1356
+ effectType: z.enum(["in", "out"]).optional().describe("Whether the animation plays in or out"),
1357
+ direction: z.enum(["top", "bottom", "left", "right", ""]).optional().describe("Direction for slide effect. Use empty string for fade/scale."),
1358
+ duration: z.number().min(0).max(1e4).optional().describe("Animation duration in milliseconds"),
1359
+ delay: z.number().min(0).max(1e4).optional().describe("Animation delay in milliseconds"),
1360
+ easing: z.string().optional().describe("Easing function. See interactions schema for options."),
1361
+ excludedBreakpoints: z.array(z.string()).optional().describe(
1362
+ 'Breakpoint IDs on which this interaction is disabled (e.g. ["mobile", "tablet"]). Omit to enable on all breakpoints.'
1363
+ )
1364
+ };
1365
+ var proSchema = {
1366
+ trigger: z.enum(["load", "scrollIn", "scrollOut", "scrollOn", "hover", "click"]).optional().describe("Event that triggers the animation"),
1367
+ effect: z.enum(["fade", "slide", "scale", "custom"]).optional().describe("Animation effect type"),
1368
+ customEffect: z.object({
1369
+ keyframes: z.array(
1370
+ z.object({
1371
+ stop: z.number().describe("The stop of the keyframe in percent, can be either 0 or 100"),
1372
+ value: z.object({
1373
+ opacity: z.number().min(0).max(1).describe("The opacity of the keyframe"),
1374
+ scale: z.object({
1375
+ x: z.number().min(0).max(1).describe("The x scale of the keyframe"),
1376
+ y: z.number().min(0).max(1).describe("The y scale of the keyframe")
1377
+ }).optional().describe("The scale of the keyframe"),
1378
+ rotate: z.object({
1379
+ x: z.number().min(0).max(360).describe("The x rotate of the keyframe"),
1380
+ y: z.number().min(0).max(360).describe("The y rotate of the keyframe"),
1381
+ z: z.number().min(0).max(360).describe("The z rotate of the keyframe")
1382
+ }).optional().describe("The rotate of the keyframe"),
1383
+ move: z.object({
1384
+ x: z.number().min(0).max(1).describe("The x move of the keyframe"),
1385
+ y: z.number().min(0).max(1).describe("The y move of the keyframe"),
1386
+ z: z.number().min(0).max(1).describe("The z move of the keyframe")
1387
+ }).optional().describe("The move of the keyframe"),
1388
+ skew: z.object({
1389
+ x: z.number().min(0).max(360).describe("The x skew of the keyframe"),
1390
+ y: z.number().min(0).max(360).describe("The y skew of the keyframe")
1391
+ }).optional().describe("The skew of the keyframe")
1392
+ })
1393
+ })
1394
+ ).describe("The keyframes of the custom effect")
1395
+ }).optional().describe("The custom effect to use for the animation")
1381
1396
  };
1397
+
1398
+ // src/mcp/resources/interactions-schema-resource.ts
1399
+ var INTERACTIONS_SCHEMA_URI = "elementor://interactions/schema";
1382
1400
  var initInteractionsSchemaResource = (reg) => {
1383
1401
  const { resource } = reg;
1402
+ const schema = isProActive() ? { ...baseSchema, ...proSchema } : baseSchema;
1384
1403
  resource(
1385
1404
  "interactions-schema",
1386
1405
  INTERACTIONS_SCHEMA_URI,
1387
1406
  {
1388
- description: "Schema describing all available options for element interactions (triggers, effects, easings, timing, breakpoints, etc.)."
1407
+ description: "Schema describing all available options for element interactions."
1389
1408
  },
1390
1409
  async () => {
1391
1410
  return {
1392
1411
  contents: [
1393
1412
  {
1394
1413
  uri: INTERACTIONS_SCHEMA_URI,
1395
- text: JSON.stringify(schema, null, 2)
1414
+ mimeType: "application/json",
1415
+ text: JSON.stringify(schema)
1396
1416
  }
1397
1417
  ]
1398
1418
  };
@@ -1402,85 +1422,49 @@ var initInteractionsSchemaResource = (reg) => {
1402
1422
 
1403
1423
  // src/mcp/tools/manage-element-interaction-tool.ts
1404
1424
  import { updateElementInteractions as updateElementInteractions2 } from "@elementor/editor-elements";
1405
- import { z } from "@elementor/schema";
1425
+ import { z as z2 } from "@elementor/schema";
1426
+ import { isProActive as isProActive2 } from "@elementor/utils";
1406
1427
  var EMPTY_INTERACTIONS = {
1407
1428
  version: 1,
1408
1429
  items: []
1409
1430
  };
1410
1431
  var initManageElementInteractionTool = (reg) => {
1411
1432
  const { addTool } = reg;
1433
+ const extendedSchema = isProActive2() ? { ...baseSchema, ...proSchema } : baseSchema;
1434
+ const schema = {
1435
+ elementId: z2.string().describe("The ID of the element to read or modify interactions on"),
1436
+ action: z2.enum(["get", "add", "update", "delete", "clear"]).describe('Operation to perform. Use "get" first to inspect existing interactions.'),
1437
+ interactionId: z2.string().optional().describe('Interaction ID \u2014 required for update and delete. Obtain from a prior "get" call.'),
1438
+ ...extendedSchema
1439
+ };
1412
1440
  addTool({
1413
1441
  name: "manage-element-interaction",
1414
- description: `Read or manage interactions (animations) on an element. Always call with action=get first to see existing interactions before making changes.
1415
-
1416
- Actions:
1417
- - get: Read the current interactions on the element.
1418
- - add: Add a new interaction (max ${MAX_INTERACTIONS_PER_ELEMENT} per element).
1419
- - update: Update an existing interaction by its interactionId.
1420
- - delete: Remove a specific interaction by its interactionId.
1421
- - clear: Remove all interactions from the element.
1422
-
1423
- For add/update, provide: trigger, effect, effectType, direction (empty string for non-slide effects), duration, delay, easing.
1424
- Use excludedBreakpoints to disable the animation on specific responsive breakpoints (e.g. ["mobile", "tablet"]).`,
1425
- schema: {
1426
- elementId: z.string().describe("The ID of the element to read or modify interactions on"),
1427
- action: z.enum(["get", "add", "update", "delete", "clear"]).describe('Operation to perform. Use "get" first to inspect existing interactions.'),
1428
- interactionId: z.string().optional().describe('Interaction ID \u2014 required for update and delete. Obtain from a prior "get" call.'),
1429
- trigger: z.enum(["load", "scrollIn"]).optional().describe("Event that triggers the animation"),
1430
- effect: z.enum(["fade", "slide", "scale"]).optional().describe("Animation effect type"),
1431
- effectType: z.enum(["in", "out"]).optional().describe("Whether the animation plays in or out"),
1432
- direction: z.enum(["top", "bottom", "left", "right", ""]).optional().describe("Direction for slide effect. Use empty string for fade/scale."),
1433
- duration: z.number().min(0).max(1e4).optional().describe("Animation duration in milliseconds"),
1434
- delay: z.number().min(0).max(1e4).optional().describe("Animation delay in milliseconds"),
1435
- easing: z.string().optional().describe("Easing function. See interactions schema for options."),
1436
- excludedBreakpoints: z.array(z.string()).optional().describe(
1437
- 'Breakpoint IDs on which this interaction is disabled (e.g. ["mobile", "tablet"]). Omit to enable on all breakpoints.'
1438
- )
1439
- },
1442
+ description: `Manage the element interaction.`,
1443
+ schema,
1440
1444
  requiredResources: [
1441
1445
  { uri: INTERACTIONS_SCHEMA_URI, description: "Interactions schema with all available options" }
1442
1446
  ],
1443
1447
  isDestructive: true,
1448
+ outputSchema: {
1449
+ success: z2.boolean().describe("Whether the action was successful"),
1450
+ action: z2.enum(["get", "add", "update", "delete", "clear"]).describe('Operation to perform. Use "get" first to inspect existing interactions.'),
1451
+ elementId: z2.string().optional().describe("The ID of the element to read or modify interactions on"),
1452
+ interactions: z2.array(z2.any()).optional().describe("The interactions on the element"),
1453
+ count: z2.number().optional().describe("The number of interactions on the element")
1454
+ },
1444
1455
  handler: (input) => {
1445
- const {
1446
- elementId,
1447
- action,
1448
- interactionId,
1449
- trigger,
1450
- effect,
1451
- effectType,
1452
- direction,
1453
- duration,
1454
- delay,
1455
- easing,
1456
- excludedBreakpoints
1457
- } = input;
1456
+ const { elementId, action, interactionId, ...animationData } = input;
1458
1457
  const allInteractions = interactionsRepository.all();
1459
1458
  const elementData = allInteractions.find((data) => data.elementId === elementId);
1460
1459
  const currentInteractions = elementData?.interactions ?? EMPTY_INTERACTIONS;
1461
1460
  if (action === "get") {
1462
- const summary = currentInteractions.items.map((item) => {
1463
- const { value } = item;
1464
- const animValue = value.animation.value;
1465
- const timingValue = animValue.timing_config.value;
1466
- const configValue = animValue.config.value;
1467
- return {
1468
- id: extractString(value.interaction_id),
1469
- trigger: extractString(value.trigger),
1470
- effect: extractString(animValue.effect),
1471
- effectType: extractString(animValue.type),
1472
- direction: extractString(animValue.direction),
1473
- duration: extractSize(timingValue.duration),
1474
- delay: extractSize(timingValue.delay),
1475
- easing: extractString(configValue.easing),
1476
- excludedBreakpoints: extractExcludedBreakpoints(value.breakpoints)
1477
- };
1478
- });
1479
- return JSON.stringify({
1461
+ return {
1462
+ success: true,
1480
1463
  elementId,
1481
- interactions: summary,
1482
- count: summary.length
1483
- });
1464
+ action,
1465
+ interactions: currentInteractions.items,
1466
+ count: currentInteractions.items.length
1467
+ };
1484
1468
  }
1485
1469
  let updatedItems = [...currentInteractions.items];
1486
1470
  switch (action) {
@@ -1492,15 +1476,7 @@ Use excludedBreakpoints to disable the animation on specific responsive breakpoi
1492
1476
  }
1493
1477
  const newItem = createInteractionItem({
1494
1478
  interactionId: generateTempInteractionId(),
1495
- trigger: trigger ?? DEFAULT_VALUES.trigger,
1496
- effect: effect ?? DEFAULT_VALUES.effect,
1497
- type: effectType ?? DEFAULT_VALUES.type,
1498
- direction: direction ?? DEFAULT_VALUES.direction,
1499
- duration: duration ?? DEFAULT_VALUES.duration,
1500
- delay: delay ?? DEFAULT_VALUES.delay,
1501
- replay: DEFAULT_VALUES.replay,
1502
- easing: easing ?? DEFAULT_VALUES.easing,
1503
- excludedBreakpoints
1479
+ ...animationData
1504
1480
  });
1505
1481
  updatedItems = [...updatedItems, newItem];
1506
1482
  break;
@@ -1517,23 +1493,9 @@ Use excludedBreakpoints to disable the animation on specific responsive breakpoi
1517
1493
  `Interaction with ID "${interactionId}" not found on element "${elementId}".`
1518
1494
  );
1519
1495
  }
1520
- const existingItem = updatedItems[itemIndex];
1521
- const existingValue = existingItem.value;
1522
- const existingAnimation = existingValue.animation.value;
1523
- const existingTiming = existingAnimation.timing_config.value;
1524
- const existingConfig = existingAnimation.config.value;
1525
- const existingExcludedBreakpoints = extractExcludedBreakpoints(existingValue.breakpoints);
1526
1496
  const updatedItem = createInteractionItem({
1527
1497
  interactionId,
1528
- trigger: trigger ?? extractString(existingValue.trigger),
1529
- effect: effect ?? extractString(existingAnimation.effect),
1530
- type: effectType ?? extractString(existingAnimation.type),
1531
- direction: direction !== void 0 ? direction : extractString(existingAnimation.direction),
1532
- duration: duration !== void 0 ? duration : extractSize(existingTiming.duration),
1533
- delay: delay !== void 0 ? delay : extractSize(existingTiming.delay),
1534
- replay: existingConfig.replay?.value ?? DEFAULT_VALUES.replay,
1535
- easing: easing ?? extractString(existingConfig.easing),
1536
- excludedBreakpoints: excludedBreakpoints !== void 0 ? excludedBreakpoints : existingExcludedBreakpoints
1498
+ ...animationData
1537
1499
  });
1538
1500
  updatedItems = [
1539
1501
  ...updatedItems.slice(0, itemIndex),
@@ -1573,12 +1535,12 @@ Use excludedBreakpoints to disable the animation on specific responsive breakpoi
1573
1535
  `Failed to update interactions for element "${elementId}": ${error instanceof Error ? error.message : "Unknown error"}`
1574
1536
  );
1575
1537
  }
1576
- return JSON.stringify({
1538
+ return {
1577
1539
  success: true,
1578
1540
  action,
1579
1541
  elementId,
1580
- interactionCount: updatedItems.length
1581
- });
1542
+ count: updatedItems.length
1543
+ };
1582
1544
  }
1583
1545
  });
1584
1546
  };
@@ -1586,10 +1548,71 @@ Use excludedBreakpoints to disable the animation on specific responsive breakpoi
1586
1548
  // src/mcp/index.ts
1587
1549
  var initMcpInteractions = () => {
1588
1550
  const reg = getMCPByDomain("interactions", {
1589
- instructions: "MCP server for managing element interactions and animations. Use this to add, modify, or remove animations and motion effects triggered by user events such as page load or scroll-into-view."
1551
+ instructions: `
1552
+ MCP server for managing element interactions and animations. Use this to add, modify, or remove animations and motion effects triggered by user events such as page load or scroll-into-view.
1553
+ ** IMPORTANT **
1554
+ Use the "interactions-schema" resource to get the schema of the interactions.
1555
+ Actions:
1556
+ - get: Read the current interactions on the element.
1557
+ - add: Add a new interaction (max ${MAX_INTERACTIONS_PER_ELEMENT} per element).
1558
+ - update: Update an existing interaction by its interactionId.
1559
+ - delete: Remove a specific interaction by its interactionId.
1560
+ - clear: Remove all interactions from the element.
1561
+
1562
+ For add/update, provide: trigger, effect, effectType, direction (required for slide effect), duration, delay, easing.
1563
+ Use excludedBreakpoints to disable the animation on specific responsive breakpoints (e.g. ["mobile", "tablet"]).
1564
+ Example Get Request:
1565
+ {
1566
+ "elementId": "123",
1567
+ "action": "get",
1568
+ "interactionId": "123",
1569
+ "animationData": {
1570
+ "trigger": "click",
1571
+ "effect": "fade",
1572
+ }
1573
+ }
1574
+ Example Add Request:
1575
+ {
1576
+ "elementId": "123",
1577
+ "action": "add",
1578
+ "animationData": {
1579
+ "effectType": "in",
1580
+ "direction": "top",
1581
+ "trigger": "click",
1582
+ "effect": "fade",
1583
+ "duration": 1000,
1584
+ "delay": 0,
1585
+ "easing": "easeIn",
1586
+ "excludedBreakpoints": ["mobile", "tablet"],
1587
+ }
1588
+ }
1589
+ Example Update Request:
1590
+ {
1591
+ "elementId": "123",
1592
+ "action": "update",
1593
+ "interactionId": "123",
1594
+ "animationData": {
1595
+ "trigger": "click",
1596
+ "effect": "fade",
1597
+ }
1598
+ }
1599
+ Example Delete Request:
1600
+ {
1601
+ "elementId": "123",
1602
+ "action": "delete",
1603
+ "interactionId": "123",
1604
+ }
1605
+ Example Clear Request:
1606
+ {
1607
+ "elementId": "123",
1608
+ "action": "clear",
1609
+ }
1610
+ `
1611
+ });
1612
+ reg.waitForReady().then(() => {
1613
+ initInteractionsSchemaResource(reg);
1614
+ initManageElementInteractionTool(reg);
1590
1615
  });
1591
- initInteractionsSchemaResource(reg);
1592
- initManageElementInteractionTool(reg);
1593
1616
  };
1594
1617
 
1595
1618
  // src/init.ts