plugin-samples icon indicating copy to clipboard operation
plugin-samples copied to clipboard

How to obtain all textStyles in teamLibrary?

Open Dang-xiaorui opened this issue 10 months ago • 4 comments

There is a node in the current file that uses local textStyle. I want to replace it with textStyle from teamLibrary. At present, I can obtain all textStyles locally based on getLocalTextStylesSync(). So how can I obtain all textStyles and their detail information in teamLibrary?

Dang-xiaorui avatar Feb 21 '25 11:02 Dang-xiaorui

Hi @Dang-xiaorui - I don't believe this is currently possible with the Plugin API. I've shared the feedback with the team. Please feel free to share additional context about your specific use-case so that I can help provide that to the team for prioritization

akbarbmirza avatar Feb 24 '25 21:02 akbarbmirza

For typography, figma has the concept of Text Styles. I am currently developing a figma plugin that can replace the Text Styles of text nodes. For example, there is a text node that uses a local Text Style called "Small Text". I want to replace it with Text Style from teamLibrary, also known as "Small Text". Therefore, I need to retrieve all Text Styles from teamLibrary and find the Text Style named "Small Text" from it. So how can I obtain all textStyles and their detail information in teamLibrary?

Image

Dang-xiaorui avatar Feb 25 '25 11:02 Dang-xiaorui

Thanks for sharing, @Dang-xiaorui. While this info isn't available via the Plugin API, you could make a REST API call to the GET team styles endpoint along with the importStyleByKeyAsync method to get that information.

akbarbmirza avatar Feb 25 '25 22:02 akbarbmirza

Thanks for responding.But how do I get the team ID of all team libraries?

Image

Dang-xiaorui avatar Feb 26 '25 04:02 Dang-xiaorui

Hey @Dang-xiaorui - It is not possible to programmatically obtain team IDs. To obtain a team ID, navigate to the team page in the Figma file browser. The team ID is present in the URL after the word team and before your team name.

In the following example:

https://www.figma.com/files/787077228518093158/team/101536658047301531/Advocacy

101536658047301531 is the team ID

akbarbmirza avatar Mar 03 '25 21:03 akbarbmirza