Skip to main content
Solved

Passing Code.JS or Code.TS values/variables to UI.HTML


D_S

Hello! I’m currently working on a plugin and I’m trying to pass the Font Size value to display within my Plugin UI. I’m retrieving the value via const selection = figma.currentPage.selection["0"].fontSize; but I can’t seem to get it to display within my plugin UI. I’ve tried document.getElementById('font_field').innerText = (figma.currentPage.selection["0"].fontSize); but no luck.

My main goal is to actually just pass the value to a tensor flow script that’s working within my html doc but to also display it within the UI.

How do I communicate between the two files? : )

Thank you!!

Best answer by tank666

You must send the message using postMessage.

figma.com
View original
This topic has been closed for comments

tank666

You must send the message using postMessage.

figma.com

D_S
  • July 6, 2021

Worked like a charm, thank you!


Leonardo_Ratzlaff1

I’m using postMessage

figma.ui.postMessage({ type: 'results', updatedComponents}, '*');

but I get the following error:
Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings