Skip to main content
Question

How to recognise Rich Text from a TextNode

  • January 16, 2025
  • 1 reply
  • 26 views

Pedro Alejandro Pacheco Tripi

I have a TextNode that can include Rich Text. What would be the best approach to recognise style changes such as bold text, line breaks (These come as \n in the .characters property of the node), bullet points, etc.

I’ve tried various methods, I managed to identify bold text using getStyledTextSegments
https://www.figma.com/plugin-docs/api/properties/TextNode-getstyledtextsegments/

But I didn’t find a way to detect when the TextNode has bullet points.

I basically need this because I’m converting the TextNode to HTML, so I need to be able to reliably identify every rich text property.

Thanks in advance.

This topic has been closed for replies.

1 reply

tank666
  • 4873 replies
  • January 16, 2025

Add to the StyledTextSegment array all the necessary properties whose values you want to obtain using the method you mentioned.

For example, the listOptions property is responsible for the list style.

Please refer to these documentation pages:

https://www.figma.com/plugin-docs/api/properties/TextNode-getstyledtextsegments/

https://www.figma.com/plugin-docs/api/StyledTextSegment/