textStyleId of a Textnode not linked to a Textstyle

I’m trying to detect whether a Textnode is linked to a Textstyle or not.

If I do log of the textStyleId-property of a textnode with no textstyle, it return empy. In most cases that is.

Other times it returns something like S:454d67e8f1ab92e8a292c921d4add1c4a132ab75,4187:14 which is the kind of id for a textnode with a textstyle.

Is there a way to 100% know whether a textfield is not linked to a Textstyle?

I don’t quite understand what you want to achieve. In addition, you yourself described that if no style is applied to the TextNode, then the value of the textStyleId property will return an empty string, otherwise it will return the style key.

Sorry I wasn’t really clear in my message.

The problem is that in other textfields where I’m 100% certain the textfield has no Texstyle linked to it, it returns :454d67e8f1ab92e8a292c921d4add1c4a132ab75,4187:14

I don’t remember encountering this. And I can not reproduce this behavior in my file.

Could you share a link to an example file with such a TextNode?

1 Like

Think I found the issue. I had some Textnodes linked to a texstyle in a missing library, I was aware of that.

But what I think is happening is that Figma re-uses whatever styling was used in the last Textnode you’ve edited and applies that to a new Textnode you create. Including the linking to a missing Textstyle if the last Textnode was one with a texstyle in a missing library.

Hence the textStyleId on a newly created Textnode even though in Figma visually it’s not connected to a textstyle.

1 Like

Thank you for the clarification. Yes, there is this behavior with styles from missing libraries, but you can open the Inspect tab and see the style under Typography or Code sections.