Closed PepperKUN closed 2 months ago
Oh, I found that I didn't need an anonymous function to execute. I made a mistake. π
Oh, I found that I didn't need an anonymous function to execute. I made a mistake. π
Glad to hear the issue is resolved π π Would you mind sharing the fixed code, so anybody facing the same confusion can take a reference? π @PepperKUN
Oh, I found that I didn't need an anonymous function to execute. I made a mistake. π
Glad to hear the issue is resolved π π Would you mind sharing the fixed code, so anybody facing the same confusion can take a reference? π @PepperKUN
Here is the final code:
async function bootstrap() {
initializeNetwork(NetworkSide.PLUGIN);
if (figma.editorType === "figma") {
figma.showUI(__html__, {
width: 400,
height: 200,
title: "Animator Figma",
});
// figma.on('selectionchange', getSelection)
} else if (figma.editorType === "figjam") {
figma.showUI(__html__, {
width: 800,
height: 650,
title: "Animator FigJam",
});
}
console.log("Bootstrapped @", Networker.Side.current.getName());
NetworkMessages.HELLO_UI.send({ text: "Hey there, UI!" });
figma.on('selectionchange', ()=>{
const selection = figma.currentPage.selection
console.log('selection', selection)
})
}
bootstrap();
Hello, I've been using your template to build my own figma plug-in, and the structure looks clear. But I have a problem with methods like "figma.on". I don't think it's clear where they should be placed in the template.
I created an anonymous function at plugin.ts to execute methods like "figma.on". It works, but it looks a little weird. Is there a more elegant way to execute functions like figma.on?