figma-node-decoder icon indicating copy to clipboard operation
figma-node-decoder copied to clipboard

JSON export/import feature request

Open acomanescu opened this issue 1 year ago • 4 comments

It would be nice to have a way to export/import JSON schemas instead of generating the plugin/widget code.

Maybe this can be accomplished using the nodeToObject function for export. For import generate JSX from the exported object and then figma.createNodeFromJSXAsync. I'm not sure if figma.createNodeFromJSXAsync works in plugins or just in widgets.

Thank you for your plugin!

acomanescu avatar Jun 25 '23 22:06 acomanescu

Hi @arobert93. Thanks for getting in touch. Can you tell me what you'd like to do with the JSON schema after it's been exported? Have you tried using nodeToObject already? What is it about this that doesn't suit your needs? And just to clarify, would you like the plugin to export a JSON schema (or the JavaScript API)?

Thanks for your feedback!

gavinmcfarland avatar Jun 30 '23 22:06 gavinmcfarland

Hi @gavinmcfarland, I'm planning to store the Figma nodes is a db. I haven't tried to nodeToObject yet, but it should work. It would be nice for Figma to introduce a feature createJSXAsyncFromNode kind of function. I would like the JS API to have this to be able to build my own plugin on top of it.

acomanescu avatar Jul 01 '23 15:07 acomanescu

Thanks @arobert93. I know where you're coming from now. It's something I've thought about. I'll let you know if and when I get around to experimenting with this. My only worry is that things are changing so quickly with Figma that what I create may go out of date pretty quickly.

gavinmcfarland avatar Jul 01 '23 16:07 gavinmcfarland

@gavinmcfarland Sure, understandable. It could be a nice feature if Figma would actually expose this by default since they are using it internally to store the page information.

acomanescu avatar Jul 10 '23 13:07 acomanescu