interactions
, first and foremost, is a module like, e.g., scenegraph
, meaning you can “require” its contents (documented here) by using
const interactions = require('interactions');
Anywhere in your plugin’s JavaScript code.
I assume by
you refer to
// Get all interactions in the entire document (grouped by triggering node)
var allInteractions = require("interactions").allInteractions;
// Get interactions triggered by the selected node
var nodeInteractions = selection.items[0].triggeredInteractions;
// Get all interactions leading to a particular artboard
var artboard = ...
var interactionsToArtboard = artboard.incomingInteractions;
// Print out details of one particular interaction
var interaction = ...
console.log("Trigger: " + interaction.trigger.type + " -> Action: " + interaction.action.type);
(the snippet from the docs)?
If so, this is more pseudocode demonstrating how you could use the interactions module (e.g., the ...
, could be whatever you want), meaning this is not to let you copy and paste it.
I’ll try to clarify the plugin file structure a bit since I believe this might help here:
A plugin has, at the very least, one JavaScript file (main.js
) and its manifest.json
. Any functionality will have to get handled by JavaScript (except the declarations of UI Entry points in your manifest.json
), meaning also this happens in a JS file.
It is possible to have multiple JS files in your project. You could, for example, export a function in one file and import and use it in your main.js
file:
// /main.js
const myFunc = require('./another-file');
module.exports = { commands: { myFunc } };
// /another-file.js
module.exports = function(selection, root) { ... };
(cf. JavaScript support · Adobe XD Plugin Reference)
Therefore, there is no “one place,” where this can get pasted. The section you’ve linked to is part of the technical reference, meaning it is assumed, when you look at it, that you’ve read (and/or can apply) the things described in the Plugin Development 101 section of the docs. This section, among other things, includes descriptions of how to access APIs, including the interactions
APIs: Accessing APIs · Adobe XD Plugin Reference.
I want to make it clear that I mean no disrespect whatsoever with the following statement, it is just a neutral observation by me:
The fact that you’re asking the question in the way you do (including asking for a step by step process) shows (to me) that you aren’t able to apply the concepts explained in the Plugin Development 101 section, yet. Being a beginner is not a problem (everyone was, once, in each area, after all), and if you have any questions about things there that you don’t understand, please feel free to ask them, and we’ll try our best to help you.
However, you’re asking about an advanced topic that, having said the above, is, for now, outside your grasp. You currently not fully understanding the basics means that if I provide you with a step by step instruction, you probably won’t really understand what it does, meaning it might solve your immediate problem, but won’t really help you.
Please try to understand the basics first, before diving into the technical reference. When you find aspects of that that you don’t understand, please ask about them here. I’m sure you’re not the only one facing these questions, and getting answers to them in this forum will benefit you and a lot of other developers, meaning I’d be happy to answer them as the time I have allows it.
But please forgive me for not providing a step by step process, as requested. I fear this wouldn’t benefit you or anyone else and only lead to you applying solutions you don’t understand, yet, meaning you’re dependent on the forum for maintaining a plugin. I can assure you (from my own experience) that the time you spend by getting a firm understanding of the basics is well worth the time you save afterward 