@elementor/editor-interactions 4.0.0-609 → 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.d.mts CHANGED
@@ -12,10 +12,6 @@ declare const InteractionsTab: ({ elementId }: {
12
12
  elementId: string;
13
13
  }) => React.JSX.Element;
14
14
 
15
- type AnimationOption = {
16
- value: string;
17
- label: string;
18
- };
19
15
  type InteractionConstants = {
20
16
  defaultDuration: number;
21
17
  defaultDelay: number;
@@ -25,7 +21,6 @@ type InteractionConstants = {
25
21
  };
26
22
  type InteractionsConfig = {
27
23
  constants: InteractionConstants;
28
- animationOptions: AnimationOption[];
29
24
  };
30
25
  type FieldProps<T = string> = {
31
26
  value: T;
package/dist/index.d.ts CHANGED
@@ -12,10 +12,6 @@ declare const InteractionsTab: ({ elementId }: {
12
12
  elementId: string;
13
13
  }) => React.JSX.Element;
14
14
 
15
- type AnimationOption = {
16
- value: string;
17
- label: string;
18
- };
19
15
  type InteractionConstants = {
20
16
  defaultDuration: number;
21
17
  defaultDelay: number;
@@ -25,7 +21,6 @@ type InteractionConstants = {
25
21
  };
26
22
  type InteractionsConfig = {
27
23
  constants: InteractionConstants;
28
- animationOptions: AnimationOption[];
29
24
  };
30
25
  type FieldProps<T = string> = {
31
26
  value: T;
package/dist/index.js CHANGED
@@ -327,13 +327,13 @@ var createInteractionItem = ({
327
327
  $$type: "interaction-item",
328
328
  value: {
329
329
  ...interactionId && { interaction_id: createString(interactionId) },
330
- trigger: createString(trigger),
330
+ trigger: createString(trigger ?? ""),
331
331
  animation: createAnimationPreset({
332
- effect,
333
- type,
332
+ effect: effect ?? "",
333
+ type: type ?? "",
334
334
  direction,
335
- duration,
336
- delay,
335
+ duration: duration ?? 0,
336
+ delay: delay ?? 0,
337
337
  replay,
338
338
  easing,
339
339
  relativeTo,
@@ -936,8 +936,7 @@ var DEFAULT_CONFIG = {
936
936
  slideDistance: 100,
937
937
  scaleStart: 0.5,
938
938
  easing: "linear"
939
- },
940
- animationOptions: []
939
+ }
941
940
  };
942
941
  function getInteractionsConfig() {
943
942
  return window.ElementorInteractionsConfig || DEFAULT_CONFIG;
@@ -1394,53 +1393,73 @@ var import_editor_mcp = require("@elementor/editor-mcp");
1394
1393
  var MAX_INTERACTIONS_PER_ELEMENT = 5;
1395
1394
 
1396
1395
  // src/mcp/resources/interactions-schema-resource.ts
1397
- var INTERACTIONS_SCHEMA_URI = "elementor://interactions/schema";
1398
- var schema = {
1399
- triggers: BASE_TRIGGERS.map((key) => ({
1400
- value: key,
1401
- label: TRIGGER_OPTIONS[key] ?? key
1402
- })),
1403
- effects: [
1404
- { value: "fade", label: "Fade" },
1405
- { value: "slide", label: "Slide" },
1406
- { value: "scale", label: "Scale" }
1407
- ],
1408
- effectTypes: [
1409
- { value: "in", label: "In" },
1410
- { value: "out", label: "Out" }
1411
- ],
1412
- directions: [
1413
- { value: "top", label: "Top", note: "" },
1414
- { value: "bottom", label: "Bottom", note: "" },
1415
- { value: "left", label: "Left", note: "" },
1416
- { value: "right", label: "Right", note: "" },
1417
- { value: "", label: "None", note: "Slide animation must have a direction" }
1418
- ],
1419
- easings: Object.entries(EASING_OPTIONS).map(([value, label]) => ({ value, label })),
1420
- timing: {
1421
- duration: { min: 0, max: 1e4, unit: "ms", description: "Animation duration in milliseconds" },
1422
- delay: { min: 0, max: 1e4, unit: "ms", description: "Animation delay in milliseconds" }
1423
- },
1424
- excludedBreakpoints: {
1425
- type: "string[]",
1426
- description: "List of breakpoint IDs on which this interaction is disabled. Omit to enable on all breakpoints."
1427
- },
1428
- maxInteractionsPerElement: MAX_INTERACTIONS_PER_ELEMENT
1396
+ var import_utils = require("@elementor/utils");
1397
+
1398
+ // src/mcp/tools/schema.ts
1399
+ var import_schema = require("@elementor/schema");
1400
+ var baseSchema = {
1401
+ trigger: import_schema.z.enum(["load", "scrollIn"]).optional().describe("Event that triggers the animation"),
1402
+ effect: import_schema.z.enum(["fade", "slide", "scale"]).optional().describe("Animation effect type"),
1403
+ effectType: import_schema.z.enum(["in", "out"]).optional().describe("Whether the animation plays in or out"),
1404
+ direction: import_schema.z.enum(["top", "bottom", "left", "right", ""]).optional().describe("Direction for slide effect. Use empty string for fade/scale."),
1405
+ duration: import_schema.z.number().min(0).max(1e4).optional().describe("Animation duration in milliseconds"),
1406
+ delay: import_schema.z.number().min(0).max(1e4).optional().describe("Animation delay in milliseconds"),
1407
+ easing: import_schema.z.string().optional().describe("Easing function. See interactions schema for options."),
1408
+ excludedBreakpoints: import_schema.z.array(import_schema.z.string()).optional().describe(
1409
+ 'Breakpoint IDs on which this interaction is disabled (e.g. ["mobile", "tablet"]). Omit to enable on all breakpoints.'
1410
+ )
1429
1411
  };
1412
+ var proSchema = {
1413
+ trigger: import_schema.z.enum(["load", "scrollIn", "scrollOut", "scrollOn", "hover", "click"]).optional().describe("Event that triggers the animation"),
1414
+ effect: import_schema.z.enum(["fade", "slide", "scale", "custom"]).optional().describe("Animation effect type"),
1415
+ customEffect: import_schema.z.object({
1416
+ keyframes: import_schema.z.array(
1417
+ import_schema.z.object({
1418
+ stop: import_schema.z.number().describe("The stop of the keyframe in percent, can be either 0 or 100"),
1419
+ value: import_schema.z.object({
1420
+ opacity: import_schema.z.number().min(0).max(1).describe("The opacity of the keyframe"),
1421
+ scale: import_schema.z.object({
1422
+ x: import_schema.z.number().min(0).max(1).describe("The x scale of the keyframe"),
1423
+ y: import_schema.z.number().min(0).max(1).describe("The y scale of the keyframe")
1424
+ }).optional().describe("The scale of the keyframe"),
1425
+ rotate: import_schema.z.object({
1426
+ x: import_schema.z.number().min(0).max(360).describe("The x rotate of the keyframe"),
1427
+ y: import_schema.z.number().min(0).max(360).describe("The y rotate of the keyframe"),
1428
+ z: import_schema.z.number().min(0).max(360).describe("The z rotate of the keyframe")
1429
+ }).optional().describe("The rotate of the keyframe"),
1430
+ move: import_schema.z.object({
1431
+ x: import_schema.z.number().min(0).max(1).describe("The x move of the keyframe"),
1432
+ y: import_schema.z.number().min(0).max(1).describe("The y move of the keyframe"),
1433
+ z: import_schema.z.number().min(0).max(1).describe("The z move of the keyframe")
1434
+ }).optional().describe("The move of the keyframe"),
1435
+ skew: import_schema.z.object({
1436
+ x: import_schema.z.number().min(0).max(360).describe("The x skew of the keyframe"),
1437
+ y: import_schema.z.number().min(0).max(360).describe("The y skew of the keyframe")
1438
+ }).optional().describe("The skew of the keyframe")
1439
+ })
1440
+ })
1441
+ ).describe("The keyframes of the custom effect")
1442
+ }).optional().describe("The custom effect to use for the animation")
1443
+ };
1444
+
1445
+ // src/mcp/resources/interactions-schema-resource.ts
1446
+ var INTERACTIONS_SCHEMA_URI = "elementor://interactions/schema";
1430
1447
  var initInteractionsSchemaResource = (reg) => {
1431
1448
  const { resource } = reg;
1449
+ const schema = (0, import_utils.isProActive)() ? { ...baseSchema, ...proSchema } : baseSchema;
1432
1450
  resource(
1433
1451
  "interactions-schema",
1434
1452
  INTERACTIONS_SCHEMA_URI,
1435
1453
  {
1436
- description: "Schema describing all available options for element interactions (triggers, effects, easings, timing, breakpoints, etc.)."
1454
+ description: "Schema describing all available options for element interactions."
1437
1455
  },
1438
1456
  async () => {
1439
1457
  return {
1440
1458
  contents: [
1441
1459
  {
1442
1460
  uri: INTERACTIONS_SCHEMA_URI,
1443
- text: JSON.stringify(schema, null, 2)
1461
+ mimeType: "application/json",
1462
+ text: JSON.stringify(schema)
1444
1463
  }
1445
1464
  ]
1446
1465
  };
@@ -1450,85 +1469,49 @@ var initInteractionsSchemaResource = (reg) => {
1450
1469
 
1451
1470
  // src/mcp/tools/manage-element-interaction-tool.ts
1452
1471
  var import_editor_elements5 = require("@elementor/editor-elements");
1453
- var import_schema = require("@elementor/schema");
1472
+ var import_schema3 = require("@elementor/schema");
1473
+ var import_utils2 = require("@elementor/utils");
1454
1474
  var EMPTY_INTERACTIONS = {
1455
1475
  version: 1,
1456
1476
  items: []
1457
1477
  };
1458
1478
  var initManageElementInteractionTool = (reg) => {
1459
1479
  const { addTool } = reg;
1480
+ const extendedSchema = (0, import_utils2.isProActive)() ? { ...baseSchema, ...proSchema } : baseSchema;
1481
+ const schema = {
1482
+ elementId: import_schema3.z.string().describe("The ID of the element to read or modify interactions on"),
1483
+ action: import_schema3.z.enum(["get", "add", "update", "delete", "clear"]).describe('Operation to perform. Use "get" first to inspect existing interactions.'),
1484
+ interactionId: import_schema3.z.string().optional().describe('Interaction ID \u2014 required for update and delete. Obtain from a prior "get" call.'),
1485
+ ...extendedSchema
1486
+ };
1460
1487
  addTool({
1461
1488
  name: "manage-element-interaction",
1462
- description: `Read or manage interactions (animations) on an element. Always call with action=get first to see existing interactions before making changes.
1463
-
1464
- Actions:
1465
- - get: Read the current interactions on the element.
1466
- - add: Add a new interaction (max ${MAX_INTERACTIONS_PER_ELEMENT} per element).
1467
- - update: Update an existing interaction by its interactionId.
1468
- - delete: Remove a specific interaction by its interactionId.
1469
- - clear: Remove all interactions from the element.
1470
-
1471
- For add/update, provide: trigger, effect, effectType, direction (empty string for non-slide effects), duration, delay, easing.
1472
- Use excludedBreakpoints to disable the animation on specific responsive breakpoints (e.g. ["mobile", "tablet"]).`,
1473
- schema: {
1474
- elementId: import_schema.z.string().describe("The ID of the element to read or modify interactions on"),
1475
- action: import_schema.z.enum(["get", "add", "update", "delete", "clear"]).describe('Operation to perform. Use "get" first to inspect existing interactions.'),
1476
- interactionId: import_schema.z.string().optional().describe('Interaction ID \u2014 required for update and delete. Obtain from a prior "get" call.'),
1477
- trigger: import_schema.z.enum(["load", "scrollIn"]).optional().describe("Event that triggers the animation"),
1478
- effect: import_schema.z.enum(["fade", "slide", "scale"]).optional().describe("Animation effect type"),
1479
- effectType: import_schema.z.enum(["in", "out"]).optional().describe("Whether the animation plays in or out"),
1480
- direction: import_schema.z.enum(["top", "bottom", "left", "right", ""]).optional().describe("Direction for slide effect. Use empty string for fade/scale."),
1481
- duration: import_schema.z.number().min(0).max(1e4).optional().describe("Animation duration in milliseconds"),
1482
- delay: import_schema.z.number().min(0).max(1e4).optional().describe("Animation delay in milliseconds"),
1483
- easing: import_schema.z.string().optional().describe("Easing function. See interactions schema for options."),
1484
- excludedBreakpoints: import_schema.z.array(import_schema.z.string()).optional().describe(
1485
- 'Breakpoint IDs on which this interaction is disabled (e.g. ["mobile", "tablet"]). Omit to enable on all breakpoints.'
1486
- )
1487
- },
1489
+ description: `Manage the element interaction.`,
1490
+ schema,
1488
1491
  requiredResources: [
1489
1492
  { uri: INTERACTIONS_SCHEMA_URI, description: "Interactions schema with all available options" }
1490
1493
  ],
1491
1494
  isDestructive: true,
1495
+ outputSchema: {
1496
+ success: import_schema3.z.boolean().describe("Whether the action was successful"),
1497
+ action: import_schema3.z.enum(["get", "add", "update", "delete", "clear"]).describe('Operation to perform. Use "get" first to inspect existing interactions.'),
1498
+ elementId: import_schema3.z.string().optional().describe("The ID of the element to read or modify interactions on"),
1499
+ interactions: import_schema3.z.array(import_schema3.z.any()).optional().describe("The interactions on the element"),
1500
+ count: import_schema3.z.number().optional().describe("The number of interactions on the element")
1501
+ },
1492
1502
  handler: (input) => {
1493
- const {
1494
- elementId,
1495
- action,
1496
- interactionId,
1497
- trigger,
1498
- effect,
1499
- effectType,
1500
- direction,
1501
- duration,
1502
- delay,
1503
- easing,
1504
- excludedBreakpoints
1505
- } = input;
1503
+ const { elementId, action, interactionId, ...animationData } = input;
1506
1504
  const allInteractions = interactionsRepository.all();
1507
1505
  const elementData = allInteractions.find((data) => data.elementId === elementId);
1508
1506
  const currentInteractions = elementData?.interactions ?? EMPTY_INTERACTIONS;
1509
1507
  if (action === "get") {
1510
- const summary = currentInteractions.items.map((item) => {
1511
- const { value } = item;
1512
- const animValue = value.animation.value;
1513
- const timingValue = animValue.timing_config.value;
1514
- const configValue = animValue.config.value;
1515
- return {
1516
- id: extractString(value.interaction_id),
1517
- trigger: extractString(value.trigger),
1518
- effect: extractString(animValue.effect),
1519
- effectType: extractString(animValue.type),
1520
- direction: extractString(animValue.direction),
1521
- duration: extractSize(timingValue.duration),
1522
- delay: extractSize(timingValue.delay),
1523
- easing: extractString(configValue.easing),
1524
- excludedBreakpoints: extractExcludedBreakpoints(value.breakpoints)
1525
- };
1526
- });
1527
- return JSON.stringify({
1508
+ return {
1509
+ success: true,
1528
1510
  elementId,
1529
- interactions: summary,
1530
- count: summary.length
1531
- });
1511
+ action,
1512
+ interactions: currentInteractions.items,
1513
+ count: currentInteractions.items.length
1514
+ };
1532
1515
  }
1533
1516
  let updatedItems = [...currentInteractions.items];
1534
1517
  switch (action) {
@@ -1540,15 +1523,7 @@ Use excludedBreakpoints to disable the animation on specific responsive breakpoi
1540
1523
  }
1541
1524
  const newItem = createInteractionItem({
1542
1525
  interactionId: generateTempInteractionId(),
1543
- trigger: trigger ?? DEFAULT_VALUES.trigger,
1544
- effect: effect ?? DEFAULT_VALUES.effect,
1545
- type: effectType ?? DEFAULT_VALUES.type,
1546
- direction: direction ?? DEFAULT_VALUES.direction,
1547
- duration: duration ?? DEFAULT_VALUES.duration,
1548
- delay: delay ?? DEFAULT_VALUES.delay,
1549
- replay: DEFAULT_VALUES.replay,
1550
- easing: easing ?? DEFAULT_VALUES.easing,
1551
- excludedBreakpoints
1526
+ ...animationData
1552
1527
  });
1553
1528
  updatedItems = [...updatedItems, newItem];
1554
1529
  break;
@@ -1565,23 +1540,9 @@ Use excludedBreakpoints to disable the animation on specific responsive breakpoi
1565
1540
  `Interaction with ID "${interactionId}" not found on element "${elementId}".`
1566
1541
  );
1567
1542
  }
1568
- const existingItem = updatedItems[itemIndex];
1569
- const existingValue = existingItem.value;
1570
- const existingAnimation = existingValue.animation.value;
1571
- const existingTiming = existingAnimation.timing_config.value;
1572
- const existingConfig = existingAnimation.config.value;
1573
- const existingExcludedBreakpoints = extractExcludedBreakpoints(existingValue.breakpoints);
1574
1543
  const updatedItem = createInteractionItem({
1575
1544
  interactionId,
1576
- trigger: trigger ?? extractString(existingValue.trigger),
1577
- effect: effect ?? extractString(existingAnimation.effect),
1578
- type: effectType ?? extractString(existingAnimation.type),
1579
- direction: direction !== void 0 ? direction : extractString(existingAnimation.direction),
1580
- duration: duration !== void 0 ? duration : extractSize(existingTiming.duration),
1581
- delay: delay !== void 0 ? delay : extractSize(existingTiming.delay),
1582
- replay: existingConfig.replay?.value ?? DEFAULT_VALUES.replay,
1583
- easing: easing ?? extractString(existingConfig.easing),
1584
- excludedBreakpoints: excludedBreakpoints !== void 0 ? excludedBreakpoints : existingExcludedBreakpoints
1545
+ ...animationData
1585
1546
  });
1586
1547
  updatedItems = [
1587
1548
  ...updatedItems.slice(0, itemIndex),
@@ -1621,12 +1582,12 @@ Use excludedBreakpoints to disable the animation on specific responsive breakpoi
1621
1582
  `Failed to update interactions for element "${elementId}": ${error instanceof Error ? error.message : "Unknown error"}`
1622
1583
  );
1623
1584
  }
1624
- return JSON.stringify({
1585
+ return {
1625
1586
  success: true,
1626
1587
  action,
1627
1588
  elementId,
1628
- interactionCount: updatedItems.length
1629
- });
1589
+ count: updatedItems.length
1590
+ };
1630
1591
  }
1631
1592
  });
1632
1593
  };
@@ -1634,10 +1595,71 @@ Use excludedBreakpoints to disable the animation on specific responsive breakpoi
1634
1595
  // src/mcp/index.ts
1635
1596
  var initMcpInteractions = () => {
1636
1597
  const reg = (0, import_editor_mcp.getMCPByDomain)("interactions", {
1637
- 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."
1598
+ instructions: `
1599
+ 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.
1600
+ ** IMPORTANT **
1601
+ Use the "interactions-schema" resource to get the schema of the interactions.
1602
+ Actions:
1603
+ - get: Read the current interactions on the element.
1604
+ - add: Add a new interaction (max ${MAX_INTERACTIONS_PER_ELEMENT} per element).
1605
+ - update: Update an existing interaction by its interactionId.
1606
+ - delete: Remove a specific interaction by its interactionId.
1607
+ - clear: Remove all interactions from the element.
1608
+
1609
+ For add/update, provide: trigger, effect, effectType, direction (required for slide effect), duration, delay, easing.
1610
+ Use excludedBreakpoints to disable the animation on specific responsive breakpoints (e.g. ["mobile", "tablet"]).
1611
+ Example Get Request:
1612
+ {
1613
+ "elementId": "123",
1614
+ "action": "get",
1615
+ "interactionId": "123",
1616
+ "animationData": {
1617
+ "trigger": "click",
1618
+ "effect": "fade",
1619
+ }
1620
+ }
1621
+ Example Add Request:
1622
+ {
1623
+ "elementId": "123",
1624
+ "action": "add",
1625
+ "animationData": {
1626
+ "effectType": "in",
1627
+ "direction": "top",
1628
+ "trigger": "click",
1629
+ "effect": "fade",
1630
+ "duration": 1000,
1631
+ "delay": 0,
1632
+ "easing": "easeIn",
1633
+ "excludedBreakpoints": ["mobile", "tablet"],
1634
+ }
1635
+ }
1636
+ Example Update Request:
1637
+ {
1638
+ "elementId": "123",
1639
+ "action": "update",
1640
+ "interactionId": "123",
1641
+ "animationData": {
1642
+ "trigger": "click",
1643
+ "effect": "fade",
1644
+ }
1645
+ }
1646
+ Example Delete Request:
1647
+ {
1648
+ "elementId": "123",
1649
+ "action": "delete",
1650
+ "interactionId": "123",
1651
+ }
1652
+ Example Clear Request:
1653
+ {
1654
+ "elementId": "123",
1655
+ "action": "clear",
1656
+ }
1657
+ `
1658
+ });
1659
+ reg.waitForReady().then(() => {
1660
+ initInteractionsSchemaResource(reg);
1661
+ initManageElementInteractionTool(reg);
1638
1662
  });
1639
- initInteractionsSchemaResource(reg);
1640
- initManageElementInteractionTool(reg);
1641
1663
  };
1642
1664
 
1643
1665
  // src/init.ts