@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.js +153 -130
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +153 -130
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -11
- package/src/mcp/index.ts +65 -4
- package/src/mcp/resources/interactions-schema-resource.ts +6 -39
- package/src/mcp/tools/manage-element-interaction-tool.ts +44 -111
- package/src/mcp/tools/schema.ts +73 -0
- package/src/utils/prop-value-utils.ts +11 -11
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,
|
|
@@ -1393,53 +1393,73 @@ var import_editor_mcp = require("@elementor/editor-mcp");
|
|
|
1393
1393
|
var MAX_INTERACTIONS_PER_ELEMENT = 5;
|
|
1394
1394
|
|
|
1395
1395
|
// src/mcp/resources/interactions-schema-resource.ts
|
|
1396
|
-
var
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
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
|
+
)
|
|
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")
|
|
1428
1443
|
};
|
|
1444
|
+
|
|
1445
|
+
// src/mcp/resources/interactions-schema-resource.ts
|
|
1446
|
+
var INTERACTIONS_SCHEMA_URI = "elementor://interactions/schema";
|
|
1429
1447
|
var initInteractionsSchemaResource = (reg) => {
|
|
1430
1448
|
const { resource } = reg;
|
|
1449
|
+
const schema = (0, import_utils.isProActive)() ? { ...baseSchema, ...proSchema } : baseSchema;
|
|
1431
1450
|
resource(
|
|
1432
1451
|
"interactions-schema",
|
|
1433
1452
|
INTERACTIONS_SCHEMA_URI,
|
|
1434
1453
|
{
|
|
1435
|
-
description: "Schema describing all available options for element interactions
|
|
1454
|
+
description: "Schema describing all available options for element interactions."
|
|
1436
1455
|
},
|
|
1437
1456
|
async () => {
|
|
1438
1457
|
return {
|
|
1439
1458
|
contents: [
|
|
1440
1459
|
{
|
|
1441
1460
|
uri: INTERACTIONS_SCHEMA_URI,
|
|
1442
|
-
|
|
1461
|
+
mimeType: "application/json",
|
|
1462
|
+
text: JSON.stringify(schema)
|
|
1443
1463
|
}
|
|
1444
1464
|
]
|
|
1445
1465
|
};
|
|
@@ -1449,85 +1469,49 @@ var initInteractionsSchemaResource = (reg) => {
|
|
|
1449
1469
|
|
|
1450
1470
|
// src/mcp/tools/manage-element-interaction-tool.ts
|
|
1451
1471
|
var import_editor_elements5 = require("@elementor/editor-elements");
|
|
1452
|
-
var
|
|
1472
|
+
var import_schema3 = require("@elementor/schema");
|
|
1473
|
+
var import_utils2 = require("@elementor/utils");
|
|
1453
1474
|
var EMPTY_INTERACTIONS = {
|
|
1454
1475
|
version: 1,
|
|
1455
1476
|
items: []
|
|
1456
1477
|
};
|
|
1457
1478
|
var initManageElementInteractionTool = (reg) => {
|
|
1458
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
|
+
};
|
|
1459
1487
|
addTool({
|
|
1460
1488
|
name: "manage-element-interaction",
|
|
1461
|
-
description: `
|
|
1462
|
-
|
|
1463
|
-
Actions:
|
|
1464
|
-
- get: Read the current interactions on the element.
|
|
1465
|
-
- add: Add a new interaction (max ${MAX_INTERACTIONS_PER_ELEMENT} per element).
|
|
1466
|
-
- update: Update an existing interaction by its interactionId.
|
|
1467
|
-
- delete: Remove a specific interaction by its interactionId.
|
|
1468
|
-
- clear: Remove all interactions from the element.
|
|
1469
|
-
|
|
1470
|
-
For add/update, provide: trigger, effect, effectType, direction (empty string for non-slide effects), duration, delay, easing.
|
|
1471
|
-
Use excludedBreakpoints to disable the animation on specific responsive breakpoints (e.g. ["mobile", "tablet"]).`,
|
|
1472
|
-
schema: {
|
|
1473
|
-
elementId: import_schema.z.string().describe("The ID of the element to read or modify interactions on"),
|
|
1474
|
-
action: import_schema.z.enum(["get", "add", "update", "delete", "clear"]).describe('Operation to perform. Use "get" first to inspect existing interactions.'),
|
|
1475
|
-
interactionId: import_schema.z.string().optional().describe('Interaction ID \u2014 required for update and delete. Obtain from a prior "get" call.'),
|
|
1476
|
-
trigger: import_schema.z.enum(["load", "scrollIn"]).optional().describe("Event that triggers the animation"),
|
|
1477
|
-
effect: import_schema.z.enum(["fade", "slide", "scale"]).optional().describe("Animation effect type"),
|
|
1478
|
-
effectType: import_schema.z.enum(["in", "out"]).optional().describe("Whether the animation plays in or out"),
|
|
1479
|
-
direction: import_schema.z.enum(["top", "bottom", "left", "right", ""]).optional().describe("Direction for slide effect. Use empty string for fade/scale."),
|
|
1480
|
-
duration: import_schema.z.number().min(0).max(1e4).optional().describe("Animation duration in milliseconds"),
|
|
1481
|
-
delay: import_schema.z.number().min(0).max(1e4).optional().describe("Animation delay in milliseconds"),
|
|
1482
|
-
easing: import_schema.z.string().optional().describe("Easing function. See interactions schema for options."),
|
|
1483
|
-
excludedBreakpoints: import_schema.z.array(import_schema.z.string()).optional().describe(
|
|
1484
|
-
'Breakpoint IDs on which this interaction is disabled (e.g. ["mobile", "tablet"]). Omit to enable on all breakpoints.'
|
|
1485
|
-
)
|
|
1486
|
-
},
|
|
1489
|
+
description: `Manage the element interaction.`,
|
|
1490
|
+
schema,
|
|
1487
1491
|
requiredResources: [
|
|
1488
1492
|
{ uri: INTERACTIONS_SCHEMA_URI, description: "Interactions schema with all available options" }
|
|
1489
1493
|
],
|
|
1490
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
|
+
},
|
|
1491
1502
|
handler: (input) => {
|
|
1492
|
-
const {
|
|
1493
|
-
elementId,
|
|
1494
|
-
action,
|
|
1495
|
-
interactionId,
|
|
1496
|
-
trigger,
|
|
1497
|
-
effect,
|
|
1498
|
-
effectType,
|
|
1499
|
-
direction,
|
|
1500
|
-
duration,
|
|
1501
|
-
delay,
|
|
1502
|
-
easing,
|
|
1503
|
-
excludedBreakpoints
|
|
1504
|
-
} = input;
|
|
1503
|
+
const { elementId, action, interactionId, ...animationData } = input;
|
|
1505
1504
|
const allInteractions = interactionsRepository.all();
|
|
1506
1505
|
const elementData = allInteractions.find((data) => data.elementId === elementId);
|
|
1507
1506
|
const currentInteractions = elementData?.interactions ?? EMPTY_INTERACTIONS;
|
|
1508
1507
|
if (action === "get") {
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
const animValue = value.animation.value;
|
|
1512
|
-
const timingValue = animValue.timing_config.value;
|
|
1513
|
-
const configValue = animValue.config.value;
|
|
1514
|
-
return {
|
|
1515
|
-
id: extractString(value.interaction_id),
|
|
1516
|
-
trigger: extractString(value.trigger),
|
|
1517
|
-
effect: extractString(animValue.effect),
|
|
1518
|
-
effectType: extractString(animValue.type),
|
|
1519
|
-
direction: extractString(animValue.direction),
|
|
1520
|
-
duration: extractSize(timingValue.duration),
|
|
1521
|
-
delay: extractSize(timingValue.delay),
|
|
1522
|
-
easing: extractString(configValue.easing),
|
|
1523
|
-
excludedBreakpoints: extractExcludedBreakpoints(value.breakpoints)
|
|
1524
|
-
};
|
|
1525
|
-
});
|
|
1526
|
-
return JSON.stringify({
|
|
1508
|
+
return {
|
|
1509
|
+
success: true,
|
|
1527
1510
|
elementId,
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1511
|
+
action,
|
|
1512
|
+
interactions: currentInteractions.items,
|
|
1513
|
+
count: currentInteractions.items.length
|
|
1514
|
+
};
|
|
1531
1515
|
}
|
|
1532
1516
|
let updatedItems = [...currentInteractions.items];
|
|
1533
1517
|
switch (action) {
|
|
@@ -1539,15 +1523,7 @@ Use excludedBreakpoints to disable the animation on specific responsive breakpoi
|
|
|
1539
1523
|
}
|
|
1540
1524
|
const newItem = createInteractionItem({
|
|
1541
1525
|
interactionId: generateTempInteractionId(),
|
|
1542
|
-
|
|
1543
|
-
effect: effect ?? DEFAULT_VALUES.effect,
|
|
1544
|
-
type: effectType ?? DEFAULT_VALUES.type,
|
|
1545
|
-
direction: direction ?? DEFAULT_VALUES.direction,
|
|
1546
|
-
duration: duration ?? DEFAULT_VALUES.duration,
|
|
1547
|
-
delay: delay ?? DEFAULT_VALUES.delay,
|
|
1548
|
-
replay: DEFAULT_VALUES.replay,
|
|
1549
|
-
easing: easing ?? DEFAULT_VALUES.easing,
|
|
1550
|
-
excludedBreakpoints
|
|
1526
|
+
...animationData
|
|
1551
1527
|
});
|
|
1552
1528
|
updatedItems = [...updatedItems, newItem];
|
|
1553
1529
|
break;
|
|
@@ -1564,23 +1540,9 @@ Use excludedBreakpoints to disable the animation on specific responsive breakpoi
|
|
|
1564
1540
|
`Interaction with ID "${interactionId}" not found on element "${elementId}".`
|
|
1565
1541
|
);
|
|
1566
1542
|
}
|
|
1567
|
-
const existingItem = updatedItems[itemIndex];
|
|
1568
|
-
const existingValue = existingItem.value;
|
|
1569
|
-
const existingAnimation = existingValue.animation.value;
|
|
1570
|
-
const existingTiming = existingAnimation.timing_config.value;
|
|
1571
|
-
const existingConfig = existingAnimation.config.value;
|
|
1572
|
-
const existingExcludedBreakpoints = extractExcludedBreakpoints(existingValue.breakpoints);
|
|
1573
1543
|
const updatedItem = createInteractionItem({
|
|
1574
1544
|
interactionId,
|
|
1575
|
-
|
|
1576
|
-
effect: effect ?? extractString(existingAnimation.effect),
|
|
1577
|
-
type: effectType ?? extractString(existingAnimation.type),
|
|
1578
|
-
direction: direction !== void 0 ? direction : extractString(existingAnimation.direction),
|
|
1579
|
-
duration: duration !== void 0 ? duration : extractSize(existingTiming.duration),
|
|
1580
|
-
delay: delay !== void 0 ? delay : extractSize(existingTiming.delay),
|
|
1581
|
-
replay: existingConfig.replay?.value ?? DEFAULT_VALUES.replay,
|
|
1582
|
-
easing: easing ?? extractString(existingConfig.easing),
|
|
1583
|
-
excludedBreakpoints: excludedBreakpoints !== void 0 ? excludedBreakpoints : existingExcludedBreakpoints
|
|
1545
|
+
...animationData
|
|
1584
1546
|
});
|
|
1585
1547
|
updatedItems = [
|
|
1586
1548
|
...updatedItems.slice(0, itemIndex),
|
|
@@ -1620,12 +1582,12 @@ Use excludedBreakpoints to disable the animation on specific responsive breakpoi
|
|
|
1620
1582
|
`Failed to update interactions for element "${elementId}": ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1621
1583
|
);
|
|
1622
1584
|
}
|
|
1623
|
-
return
|
|
1585
|
+
return {
|
|
1624
1586
|
success: true,
|
|
1625
1587
|
action,
|
|
1626
1588
|
elementId,
|
|
1627
|
-
|
|
1628
|
-
}
|
|
1589
|
+
count: updatedItems.length
|
|
1590
|
+
};
|
|
1629
1591
|
}
|
|
1630
1592
|
});
|
|
1631
1593
|
};
|
|
@@ -1633,10 +1595,71 @@ Use excludedBreakpoints to disable the animation on specific responsive breakpoi
|
|
|
1633
1595
|
// src/mcp/index.ts
|
|
1634
1596
|
var initMcpInteractions = () => {
|
|
1635
1597
|
const reg = (0, import_editor_mcp.getMCPByDomain)("interactions", {
|
|
1636
|
-
instructions:
|
|
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);
|
|
1637
1662
|
});
|
|
1638
|
-
initInteractionsSchemaResource(reg);
|
|
1639
|
-
initManageElementInteractionTool(reg);
|
|
1640
1663
|
};
|
|
1641
1664
|
|
|
1642
1665
|
// src/init.ts
|