@elementor/editor-interactions 4.0.0-619 → 4.0.0-manual
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 +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +189 -172
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +189 -172
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -11
- package/src/components/interaction-details.tsx +34 -42
- package/src/interactions-controls-registry.ts +4 -4
- 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 +29 -29
package/dist/index.d.mts
CHANGED
|
@@ -71,7 +71,7 @@ declare const ELEMENTS_INTERACTIONS_PROVIDER_KEY_PREFIX = "document-elements-int
|
|
|
71
71
|
|
|
72
72
|
declare function init(): void;
|
|
73
73
|
|
|
74
|
-
type InteractionsControlType = 'trigger' | 'effect' | 'effectType' | 'direction' | 'duration' | 'delay' | 'replay' | 'easing' | 'relativeTo' | '
|
|
74
|
+
type InteractionsControlType = 'trigger' | 'effect' | 'effectType' | 'direction' | 'duration' | 'delay' | 'replay' | 'easing' | 'relativeTo' | 'start' | 'end' | 'customEffects';
|
|
75
75
|
type InteractionsControlPropsMap = {
|
|
76
76
|
trigger: FieldProps;
|
|
77
77
|
effect: FieldProps;
|
|
@@ -83,8 +83,8 @@ type InteractionsControlPropsMap = {
|
|
|
83
83
|
replay: ReplayFieldProps;
|
|
84
84
|
easing: FieldProps;
|
|
85
85
|
relativeTo: FieldProps;
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
start: FieldProps;
|
|
87
|
+
end: FieldProps;
|
|
88
88
|
};
|
|
89
89
|
type ControlOptions<T extends InteractionsControlType> = {
|
|
90
90
|
type: T;
|
package/dist/index.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ declare const ELEMENTS_INTERACTIONS_PROVIDER_KEY_PREFIX = "document-elements-int
|
|
|
71
71
|
|
|
72
72
|
declare function init(): void;
|
|
73
73
|
|
|
74
|
-
type InteractionsControlType = 'trigger' | 'effect' | 'effectType' | 'direction' | 'duration' | 'delay' | 'replay' | 'easing' | 'relativeTo' | '
|
|
74
|
+
type InteractionsControlType = 'trigger' | 'effect' | 'effectType' | 'direction' | 'duration' | 'delay' | 'replay' | 'easing' | 'relativeTo' | 'start' | 'end' | 'customEffects';
|
|
75
75
|
type InteractionsControlPropsMap = {
|
|
76
76
|
trigger: FieldProps;
|
|
77
77
|
effect: FieldProps;
|
|
@@ -83,8 +83,8 @@ type InteractionsControlPropsMap = {
|
|
|
83
83
|
replay: ReplayFieldProps;
|
|
84
84
|
easing: FieldProps;
|
|
85
85
|
relativeTo: FieldProps;
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
start: FieldProps;
|
|
87
|
+
end: FieldProps;
|
|
88
88
|
};
|
|
89
89
|
type ControlOptions<T extends InteractionsControlType> = {
|
|
90
90
|
type: T;
|
package/dist/index.js
CHANGED
|
@@ -245,16 +245,16 @@ var createConfig = ({
|
|
|
245
245
|
replay,
|
|
246
246
|
easing = "easeIn",
|
|
247
247
|
relativeTo = "",
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
start = 85,
|
|
249
|
+
end = 15
|
|
250
250
|
}) => ({
|
|
251
251
|
$$type: "config",
|
|
252
252
|
value: {
|
|
253
253
|
replay: createBoolean(replay),
|
|
254
254
|
easing: createString(easing),
|
|
255
255
|
relativeTo: createString(relativeTo),
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
start: createSize(start, "%"),
|
|
257
|
+
end: createSize(end, "%")
|
|
258
258
|
}
|
|
259
259
|
});
|
|
260
260
|
var createSize = (value, defaultUnit, defaultValue) => {
|
|
@@ -288,8 +288,8 @@ var createAnimationPreset = ({
|
|
|
288
288
|
replay = false,
|
|
289
289
|
easing = "easeIn",
|
|
290
290
|
relativeTo,
|
|
291
|
-
|
|
292
|
-
|
|
291
|
+
start,
|
|
292
|
+
end,
|
|
293
293
|
customEffects
|
|
294
294
|
}) => ({
|
|
295
295
|
$$type: "animation-preset-props",
|
|
@@ -303,8 +303,8 @@ var createAnimationPreset = ({
|
|
|
303
303
|
replay,
|
|
304
304
|
easing,
|
|
305
305
|
relativeTo,
|
|
306
|
-
|
|
307
|
-
|
|
306
|
+
start,
|
|
307
|
+
end
|
|
308
308
|
})
|
|
309
309
|
}
|
|
310
310
|
});
|
|
@@ -319,26 +319,26 @@ var createInteractionItem = ({
|
|
|
319
319
|
replay = false,
|
|
320
320
|
easing = "easeIn",
|
|
321
321
|
relativeTo,
|
|
322
|
-
|
|
323
|
-
|
|
322
|
+
start,
|
|
323
|
+
end,
|
|
324
324
|
excludedBreakpoints,
|
|
325
325
|
customEffects
|
|
326
326
|
}) => ({
|
|
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,
|
|
340
|
-
|
|
341
|
-
|
|
340
|
+
start,
|
|
341
|
+
end,
|
|
342
342
|
customEffects
|
|
343
343
|
}),
|
|
344
344
|
...excludedBreakpoints && excludedBreakpoints.length > 0 && {
|
|
@@ -504,8 +504,8 @@ var DEFAULT_VALUES = {
|
|
|
504
504
|
replay: false,
|
|
505
505
|
easing: "easeIn",
|
|
506
506
|
relativeTo: "viewport",
|
|
507
|
-
|
|
508
|
-
|
|
507
|
+
start: 85,
|
|
508
|
+
end: 15
|
|
509
509
|
};
|
|
510
510
|
var TRIGGERS_WITHOUT_REPLAY = ["load", "scrollOn", "hover", "click"];
|
|
511
511
|
var controlVisibilityConfig = {
|
|
@@ -514,8 +514,8 @@ var controlVisibilityConfig = {
|
|
|
514
514
|
effectType: (values) => values.effect !== "custom",
|
|
515
515
|
direction: (values) => values.effect !== "custom",
|
|
516
516
|
relativeTo: (values) => values.trigger === "scrollOn",
|
|
517
|
-
|
|
518
|
-
|
|
517
|
+
start: (values) => values.trigger === "scrollOn",
|
|
518
|
+
end: (values) => values.trigger === "scrollOn",
|
|
519
519
|
duration: (values) => {
|
|
520
520
|
const isRelativeToVisible = values.trigger === "scrollOn";
|
|
521
521
|
return !isRelativeToVisible;
|
|
@@ -544,11 +544,8 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
|
|
|
544
544
|
const replay = extractBoolean(interaction.animation.value.config?.value.replay, DEFAULT_VALUES.replay);
|
|
545
545
|
const easing = extractString(interaction.animation.value.config?.value.easing, DEFAULT_VALUES.easing);
|
|
546
546
|
const relativeTo = extractString(interaction.animation.value.config?.value.relativeTo, DEFAULT_VALUES.relativeTo);
|
|
547
|
-
const
|
|
548
|
-
const
|
|
549
|
-
interaction.animation.value.config?.value.offsetBottom,
|
|
550
|
-
DEFAULT_VALUES.offsetBottom
|
|
551
|
-
);
|
|
547
|
+
const start = extractSize(interaction.animation.value.config?.value.start, DEFAULT_VALUES.start);
|
|
548
|
+
const end = extractSize(interaction.animation.value.config?.value.end, DEFAULT_VALUES.end);
|
|
552
549
|
const interactionValues = {
|
|
553
550
|
trigger,
|
|
554
551
|
effect,
|
|
@@ -559,8 +556,8 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
|
|
|
559
556
|
easing,
|
|
560
557
|
replay,
|
|
561
558
|
relativeTo,
|
|
562
|
-
|
|
563
|
-
|
|
559
|
+
start,
|
|
560
|
+
end,
|
|
564
561
|
customEffects
|
|
565
562
|
};
|
|
566
563
|
const TriggerControl = useControlComponent("trigger", true);
|
|
@@ -570,11 +567,8 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
|
|
|
570
567
|
"relativeTo",
|
|
571
568
|
controlVisibilityConfig.relativeTo(interactionValues)
|
|
572
569
|
);
|
|
573
|
-
const
|
|
574
|
-
const
|
|
575
|
-
"offsetBottom",
|
|
576
|
-
controlVisibilityConfig.offsetBottom(interactionValues)
|
|
577
|
-
);
|
|
570
|
+
const StartControl = useControlComponent("start", controlVisibilityConfig.start(interactionValues));
|
|
571
|
+
const EndControl = useControlComponent("end", controlVisibilityConfig.end(interactionValues));
|
|
578
572
|
const CustomEffectControl = useControlComponent(
|
|
579
573
|
"customEffects",
|
|
580
574
|
controlVisibilityConfig.custom(interactionValues)
|
|
@@ -607,8 +601,8 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
|
|
|
607
601
|
replay: updates.replay ?? replay,
|
|
608
602
|
easing: updates.easing ?? easing,
|
|
609
603
|
relativeTo: updates.relativeTo ?? relativeTo,
|
|
610
|
-
|
|
611
|
-
|
|
604
|
+
start: updates.start ?? start,
|
|
605
|
+
end: updates.end ?? end,
|
|
612
606
|
customEffects: updates.customEffects ?? customEffects
|
|
613
607
|
})
|
|
614
608
|
};
|
|
@@ -659,23 +653,23 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
|
|
|
659
653
|
onChange: (v) => updateInteraction({ delay: v }),
|
|
660
654
|
defaultValue: DEFAULT_VALUES.delay
|
|
661
655
|
}
|
|
662
|
-
))), controlVisibilityConfig.relativeTo(interactionValues) && RelativeToControl && /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(import_ui3.Divider, null), /* @__PURE__ */ React7.createElement(import_ui3.Grid, { container: true, spacing: 1.5 }, /* @__PURE__ */ React7.createElement(Field, { label: (0, import_i18n2.__)("
|
|
663
|
-
|
|
656
|
+
))), controlVisibilityConfig.relativeTo(interactionValues) && RelativeToControl && /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(import_ui3.Divider, null), /* @__PURE__ */ React7.createElement(import_ui3.Grid, { container: true, spacing: 1.5 }, StartControl && /* @__PURE__ */ React7.createElement(Field, { label: (0, import_i18n2.__)("Start", "elementor") }, /* @__PURE__ */ React7.createElement(
|
|
657
|
+
StartControl,
|
|
664
658
|
{
|
|
665
|
-
value:
|
|
666
|
-
onChange: (v) => updateInteraction({
|
|
659
|
+
value: parseSizeValue(start, ["%"]).size?.toString() ?? "",
|
|
660
|
+
onChange: (v) => updateInteraction({ start: v })
|
|
667
661
|
}
|
|
668
|
-
)),
|
|
669
|
-
|
|
662
|
+
)), EndControl && /* @__PURE__ */ React7.createElement(Field, { label: (0, import_i18n2.__)("End", "elementor") }, /* @__PURE__ */ React7.createElement(
|
|
663
|
+
EndControl,
|
|
670
664
|
{
|
|
671
|
-
value:
|
|
672
|
-
onChange: (v) => updateInteraction({
|
|
665
|
+
value: parseSizeValue(end, ["%"]).size?.toString() ?? "",
|
|
666
|
+
onChange: (v) => updateInteraction({ end: v })
|
|
673
667
|
}
|
|
674
|
-
)),
|
|
675
|
-
|
|
668
|
+
)), /* @__PURE__ */ React7.createElement(Field, { label: (0, import_i18n2.__)("Relative To", "elementor") }, /* @__PURE__ */ React7.createElement(
|
|
669
|
+
RelativeToControl,
|
|
676
670
|
{
|
|
677
|
-
value:
|
|
678
|
-
onChange: (v) => updateInteraction({
|
|
671
|
+
value: relativeTo,
|
|
672
|
+
onChange: (v) => updateInteraction({ relativeTo: v })
|
|
679
673
|
}
|
|
680
674
|
))), /* @__PURE__ */ React7.createElement(import_ui3.Divider, null)), EasingControl && /* @__PURE__ */ React7.createElement(import_ui3.Grid, { container: true, spacing: 1.5 }, /* @__PURE__ */ React7.createElement(Field, { label: (0, import_i18n2.__)("Easing", "elementor") }, /* @__PURE__ */ React7.createElement(
|
|
681
675
|
EasingControl,
|
|
@@ -1393,53 +1387,73 @@ var import_editor_mcp = require("@elementor/editor-mcp");
|
|
|
1393
1387
|
var MAX_INTERACTIONS_PER_ELEMENT = 5;
|
|
1394
1388
|
|
|
1395
1389
|
// src/mcp/resources/interactions-schema-resource.ts
|
|
1396
|
-
var
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
directions: [
|
|
1412
|
-
{ value: "top", label: "Top", note: "" },
|
|
1413
|
-
{ value: "bottom", label: "Bottom", note: "" },
|
|
1414
|
-
{ value: "left", label: "Left", note: "" },
|
|
1415
|
-
{ value: "right", label: "Right", note: "" },
|
|
1416
|
-
{ value: "", label: "None", note: "Slide animation must have a direction" }
|
|
1417
|
-
],
|
|
1418
|
-
easings: Object.entries(EASING_OPTIONS).map(([value, label]) => ({ value, label })),
|
|
1419
|
-
timing: {
|
|
1420
|
-
duration: { min: 0, max: 1e4, unit: "ms", description: "Animation duration in milliseconds" },
|
|
1421
|
-
delay: { min: 0, max: 1e4, unit: "ms", description: "Animation delay in milliseconds" }
|
|
1422
|
-
},
|
|
1423
|
-
excludedBreakpoints: {
|
|
1424
|
-
type: "string[]",
|
|
1425
|
-
description: "List of breakpoint IDs on which this interaction is disabled. Omit to enable on all breakpoints."
|
|
1426
|
-
},
|
|
1427
|
-
maxInteractionsPerElement: MAX_INTERACTIONS_PER_ELEMENT
|
|
1390
|
+
var import_utils = require("@elementor/utils");
|
|
1391
|
+
|
|
1392
|
+
// src/mcp/tools/schema.ts
|
|
1393
|
+
var import_schema = require("@elementor/schema");
|
|
1394
|
+
var baseSchema = {
|
|
1395
|
+
trigger: import_schema.z.enum(["load", "scrollIn"]).optional().describe("Event that triggers the animation"),
|
|
1396
|
+
effect: import_schema.z.enum(["fade", "slide", "scale"]).optional().describe("Animation effect type"),
|
|
1397
|
+
effectType: import_schema.z.enum(["in", "out"]).optional().describe("Whether the animation plays in or out"),
|
|
1398
|
+
direction: import_schema.z.enum(["top", "bottom", "left", "right", ""]).optional().describe("Direction for slide effect. Use empty string for fade/scale."),
|
|
1399
|
+
duration: import_schema.z.number().min(0).max(1e4).optional().describe("Animation duration in milliseconds"),
|
|
1400
|
+
delay: import_schema.z.number().min(0).max(1e4).optional().describe("Animation delay in milliseconds"),
|
|
1401
|
+
easing: import_schema.z.string().optional().describe("Easing function. See interactions schema for options."),
|
|
1402
|
+
excludedBreakpoints: import_schema.z.array(import_schema.z.string()).optional().describe(
|
|
1403
|
+
'Breakpoint IDs on which this interaction is disabled (e.g. ["mobile", "tablet"]). Omit to enable on all breakpoints.'
|
|
1404
|
+
)
|
|
1428
1405
|
};
|
|
1406
|
+
var proSchema = {
|
|
1407
|
+
trigger: import_schema.z.enum(["load", "scrollIn", "scrollOut", "scrollOn", "hover", "click"]).optional().describe("Event that triggers the animation"),
|
|
1408
|
+
effect: import_schema.z.enum(["fade", "slide", "scale", "custom"]).optional().describe("Animation effect type"),
|
|
1409
|
+
customEffect: import_schema.z.object({
|
|
1410
|
+
keyframes: import_schema.z.array(
|
|
1411
|
+
import_schema.z.object({
|
|
1412
|
+
stop: import_schema.z.number().describe("The stop of the keyframe in percent, can be either 0 or 100"),
|
|
1413
|
+
value: import_schema.z.object({
|
|
1414
|
+
opacity: import_schema.z.number().min(0).max(1).describe("The opacity of the keyframe"),
|
|
1415
|
+
scale: import_schema.z.object({
|
|
1416
|
+
x: import_schema.z.number().min(0).max(1).describe("The x scale of the keyframe"),
|
|
1417
|
+
y: import_schema.z.number().min(0).max(1).describe("The y scale of the keyframe")
|
|
1418
|
+
}).optional().describe("The scale of the keyframe"),
|
|
1419
|
+
rotate: import_schema.z.object({
|
|
1420
|
+
x: import_schema.z.number().min(0).max(360).describe("The x rotate of the keyframe"),
|
|
1421
|
+
y: import_schema.z.number().min(0).max(360).describe("The y rotate of the keyframe"),
|
|
1422
|
+
z: import_schema.z.number().min(0).max(360).describe("The z rotate of the keyframe")
|
|
1423
|
+
}).optional().describe("The rotate of the keyframe"),
|
|
1424
|
+
move: import_schema.z.object({
|
|
1425
|
+
x: import_schema.z.number().min(0).max(1).describe("The x move of the keyframe"),
|
|
1426
|
+
y: import_schema.z.number().min(0).max(1).describe("The y move of the keyframe"),
|
|
1427
|
+
z: import_schema.z.number().min(0).max(1).describe("The z move of the keyframe")
|
|
1428
|
+
}).optional().describe("The move of the keyframe"),
|
|
1429
|
+
skew: import_schema.z.object({
|
|
1430
|
+
x: import_schema.z.number().min(0).max(360).describe("The x skew of the keyframe"),
|
|
1431
|
+
y: import_schema.z.number().min(0).max(360).describe("The y skew of the keyframe")
|
|
1432
|
+
}).optional().describe("The skew of the keyframe")
|
|
1433
|
+
})
|
|
1434
|
+
})
|
|
1435
|
+
).describe("The keyframes of the custom effect")
|
|
1436
|
+
}).optional().describe("The custom effect to use for the animation")
|
|
1437
|
+
};
|
|
1438
|
+
|
|
1439
|
+
// src/mcp/resources/interactions-schema-resource.ts
|
|
1440
|
+
var INTERACTIONS_SCHEMA_URI = "elementor://interactions/schema";
|
|
1429
1441
|
var initInteractionsSchemaResource = (reg) => {
|
|
1430
1442
|
const { resource } = reg;
|
|
1443
|
+
const schema = (0, import_utils.isProActive)() ? { ...baseSchema, ...proSchema } : baseSchema;
|
|
1431
1444
|
resource(
|
|
1432
1445
|
"interactions-schema",
|
|
1433
1446
|
INTERACTIONS_SCHEMA_URI,
|
|
1434
1447
|
{
|
|
1435
|
-
description: "Schema describing all available options for element interactions
|
|
1448
|
+
description: "Schema describing all available options for element interactions."
|
|
1436
1449
|
},
|
|
1437
1450
|
async () => {
|
|
1438
1451
|
return {
|
|
1439
1452
|
contents: [
|
|
1440
1453
|
{
|
|
1441
1454
|
uri: INTERACTIONS_SCHEMA_URI,
|
|
1442
|
-
|
|
1455
|
+
mimeType: "application/json",
|
|
1456
|
+
text: JSON.stringify(schema)
|
|
1443
1457
|
}
|
|
1444
1458
|
]
|
|
1445
1459
|
};
|
|
@@ -1449,85 +1463,49 @@ var initInteractionsSchemaResource = (reg) => {
|
|
|
1449
1463
|
|
|
1450
1464
|
// src/mcp/tools/manage-element-interaction-tool.ts
|
|
1451
1465
|
var import_editor_elements5 = require("@elementor/editor-elements");
|
|
1452
|
-
var
|
|
1466
|
+
var import_schema3 = require("@elementor/schema");
|
|
1467
|
+
var import_utils2 = require("@elementor/utils");
|
|
1453
1468
|
var EMPTY_INTERACTIONS = {
|
|
1454
1469
|
version: 1,
|
|
1455
1470
|
items: []
|
|
1456
1471
|
};
|
|
1457
1472
|
var initManageElementInteractionTool = (reg) => {
|
|
1458
1473
|
const { addTool } = reg;
|
|
1474
|
+
const extendedSchema = (0, import_utils2.isProActive)() ? { ...baseSchema, ...proSchema } : baseSchema;
|
|
1475
|
+
const schema = {
|
|
1476
|
+
elementId: import_schema3.z.string().describe("The ID of the element to read or modify interactions on"),
|
|
1477
|
+
action: import_schema3.z.enum(["get", "add", "update", "delete", "clear"]).describe('Operation to perform. Use "get" first to inspect existing interactions.'),
|
|
1478
|
+
interactionId: import_schema3.z.string().optional().describe('Interaction ID \u2014 required for update and delete. Obtain from a prior "get" call.'),
|
|
1479
|
+
...extendedSchema
|
|
1480
|
+
};
|
|
1459
1481
|
addTool({
|
|
1460
1482
|
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
|
-
},
|
|
1483
|
+
description: `Manage the element interaction.`,
|
|
1484
|
+
schema,
|
|
1487
1485
|
requiredResources: [
|
|
1488
1486
|
{ uri: INTERACTIONS_SCHEMA_URI, description: "Interactions schema with all available options" }
|
|
1489
1487
|
],
|
|
1490
1488
|
isDestructive: true,
|
|
1489
|
+
outputSchema: {
|
|
1490
|
+
success: import_schema3.z.boolean().describe("Whether the action was successful"),
|
|
1491
|
+
action: import_schema3.z.enum(["get", "add", "update", "delete", "clear"]).describe('Operation to perform. Use "get" first to inspect existing interactions.'),
|
|
1492
|
+
elementId: import_schema3.z.string().optional().describe("The ID of the element to read or modify interactions on"),
|
|
1493
|
+
interactions: import_schema3.z.array(import_schema3.z.any()).optional().describe("The interactions on the element"),
|
|
1494
|
+
count: import_schema3.z.number().optional().describe("The number of interactions on the element")
|
|
1495
|
+
},
|
|
1491
1496
|
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;
|
|
1497
|
+
const { elementId, action, interactionId, ...animationData } = input;
|
|
1505
1498
|
const allInteractions = interactionsRepository.all();
|
|
1506
1499
|
const elementData = allInteractions.find((data) => data.elementId === elementId);
|
|
1507
1500
|
const currentInteractions = elementData?.interactions ?? EMPTY_INTERACTIONS;
|
|
1508
1501
|
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({
|
|
1502
|
+
return {
|
|
1503
|
+
success: true,
|
|
1527
1504
|
elementId,
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1505
|
+
action,
|
|
1506
|
+
interactions: currentInteractions.items,
|
|
1507
|
+
count: currentInteractions.items.length
|
|
1508
|
+
};
|
|
1531
1509
|
}
|
|
1532
1510
|
let updatedItems = [...currentInteractions.items];
|
|
1533
1511
|
switch (action) {
|
|
@@ -1539,15 +1517,7 @@ Use excludedBreakpoints to disable the animation on specific responsive breakpoi
|
|
|
1539
1517
|
}
|
|
1540
1518
|
const newItem = createInteractionItem({
|
|
1541
1519
|
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
|
|
1520
|
+
...animationData
|
|
1551
1521
|
});
|
|
1552
1522
|
updatedItems = [...updatedItems, newItem];
|
|
1553
1523
|
break;
|
|
@@ -1564,23 +1534,9 @@ Use excludedBreakpoints to disable the animation on specific responsive breakpoi
|
|
|
1564
1534
|
`Interaction with ID "${interactionId}" not found on element "${elementId}".`
|
|
1565
1535
|
);
|
|
1566
1536
|
}
|
|
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
1537
|
const updatedItem = createInteractionItem({
|
|
1574
1538
|
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
|
|
1539
|
+
...animationData
|
|
1584
1540
|
});
|
|
1585
1541
|
updatedItems = [
|
|
1586
1542
|
...updatedItems.slice(0, itemIndex),
|
|
@@ -1620,12 +1576,12 @@ Use excludedBreakpoints to disable the animation on specific responsive breakpoi
|
|
|
1620
1576
|
`Failed to update interactions for element "${elementId}": ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1621
1577
|
);
|
|
1622
1578
|
}
|
|
1623
|
-
return
|
|
1579
|
+
return {
|
|
1624
1580
|
success: true,
|
|
1625
1581
|
action,
|
|
1626
1582
|
elementId,
|
|
1627
|
-
|
|
1628
|
-
}
|
|
1583
|
+
count: updatedItems.length
|
|
1584
|
+
};
|
|
1629
1585
|
}
|
|
1630
1586
|
});
|
|
1631
1587
|
};
|
|
@@ -1633,10 +1589,71 @@ Use excludedBreakpoints to disable the animation on specific responsive breakpoi
|
|
|
1633
1589
|
// src/mcp/index.ts
|
|
1634
1590
|
var initMcpInteractions = () => {
|
|
1635
1591
|
const reg = (0, import_editor_mcp.getMCPByDomain)("interactions", {
|
|
1636
|
-
instructions:
|
|
1592
|
+
instructions: `
|
|
1593
|
+
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.
|
|
1594
|
+
** IMPORTANT **
|
|
1595
|
+
Use the "interactions-schema" resource to get the schema of the interactions.
|
|
1596
|
+
Actions:
|
|
1597
|
+
- get: Read the current interactions on the element.
|
|
1598
|
+
- add: Add a new interaction (max ${MAX_INTERACTIONS_PER_ELEMENT} per element).
|
|
1599
|
+
- update: Update an existing interaction by its interactionId.
|
|
1600
|
+
- delete: Remove a specific interaction by its interactionId.
|
|
1601
|
+
- clear: Remove all interactions from the element.
|
|
1602
|
+
|
|
1603
|
+
For add/update, provide: trigger, effect, effectType, direction (required for slide effect), duration, delay, easing.
|
|
1604
|
+
Use excludedBreakpoints to disable the animation on specific responsive breakpoints (e.g. ["mobile", "tablet"]).
|
|
1605
|
+
Example Get Request:
|
|
1606
|
+
{
|
|
1607
|
+
"elementId": "123",
|
|
1608
|
+
"action": "get",
|
|
1609
|
+
"interactionId": "123",
|
|
1610
|
+
"animationData": {
|
|
1611
|
+
"trigger": "click",
|
|
1612
|
+
"effect": "fade",
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
Example Add Request:
|
|
1616
|
+
{
|
|
1617
|
+
"elementId": "123",
|
|
1618
|
+
"action": "add",
|
|
1619
|
+
"animationData": {
|
|
1620
|
+
"effectType": "in",
|
|
1621
|
+
"direction": "top",
|
|
1622
|
+
"trigger": "click",
|
|
1623
|
+
"effect": "fade",
|
|
1624
|
+
"duration": 1000,
|
|
1625
|
+
"delay": 0,
|
|
1626
|
+
"easing": "easeIn",
|
|
1627
|
+
"excludedBreakpoints": ["mobile", "tablet"],
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
Example Update Request:
|
|
1631
|
+
{
|
|
1632
|
+
"elementId": "123",
|
|
1633
|
+
"action": "update",
|
|
1634
|
+
"interactionId": "123",
|
|
1635
|
+
"animationData": {
|
|
1636
|
+
"trigger": "click",
|
|
1637
|
+
"effect": "fade",
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
Example Delete Request:
|
|
1641
|
+
{
|
|
1642
|
+
"elementId": "123",
|
|
1643
|
+
"action": "delete",
|
|
1644
|
+
"interactionId": "123",
|
|
1645
|
+
}
|
|
1646
|
+
Example Clear Request:
|
|
1647
|
+
{
|
|
1648
|
+
"elementId": "123",
|
|
1649
|
+
"action": "clear",
|
|
1650
|
+
}
|
|
1651
|
+
`
|
|
1652
|
+
});
|
|
1653
|
+
reg.waitForReady().then(() => {
|
|
1654
|
+
initInteractionsSchemaResource(reg);
|
|
1655
|
+
initManageElementInteractionTool(reg);
|
|
1637
1656
|
});
|
|
1638
|
-
initInteractionsSchemaResource(reg);
|
|
1639
|
-
initManageElementInteractionTool(reg);
|
|
1640
1657
|
};
|
|
1641
1658
|
|
|
1642
1659
|
// src/init.ts
|