Currently, this is my code in code.ts file:
figma.ui.onmessage = msg => {
if (msg.type === 'option-selected') {
let toSelect = []
for (const node of figma.currentPage.selection) {
if (node.type === "TEXT") {
toSelect.push(node)
}
}
}
code in .tsx file:
<p onClick={() => parent.postMessage({ pluginMessage: { type: 'option-selected', option } }, '*')}>
{hit.content}
</p>
However, this is not the behaviour I want now (to use msg.type === ‘option-selected’). I want to instantly have access to the nodes that have been selected and work with them accordingly.
How can I do this and in which file(.tsx or code.ts)?