Skip to main content
Solved

[PLUGIN API] Link TextNode characters to component property


Bogriceanu_Sorin

I am developing a little Figma plugin using the Plugin API.

I am working with a TextNode withing a Component.

The component has a TEXT proprety configured.

I am tring to link the content of the text node to the value of the component’s proprety using the API

Below is the exact UI functionality that I am aiming for.
Screenshot 2024-01-12 at 14.34.37

I haven’t found anything that would help in the Plugin API refference.

Can you guys point me in the right dirrection?

10x

Best answer by tank666

figma.com
View original

6 replies

tank666
  • 4859 replies
  • Answer
  • January 12, 2024

Bogriceanu_Sorin

I went trough all the specs for TextNode and Component event did a deep dive with the console debugger… no luck…

If I look at a node where I set this from the console, it appears as a bound variable to the “characters” key of the TextNode, but if I try to use setBoundVariable(“characters”, propID) it fails.


tank666
  • 4859 replies
  • January 12, 2024

Sorry, but what does variable binding have to do with it? You want to apply the component’s text property, right? The componentPropertyReferences property of the TextNode, to which I left a direct link in the previous post, is what you need.


Bogriceanu_Sorin

my mistake… I missread the link on the phone. It scrolled to top and missed the point.

Just tried it now. Works!

Many thnaks!!!

Sorin


Finnian_Langham

@Bogriceanu_Sorin Hey, I’m trying to achieve this same thing. Can you share your code? I’m not clear on how to create new componentPropertyReference item.


tank666
  • 4859 replies
  • October 24, 2024
TextNode.componentPropertyReferences = {characters: 'TextPropertyName#0:1'};

Reply


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