figma-jsonrpc icon indicating copy to clipboard operation
figma-jsonrpc copied to clipboard

Support pluginId option in postMessage for non-null origin iframes

Open JustH opened this issue 4 years ago • 2 comments

Figma introduced the ability to run UIs from a hosted non-null origin iframe https://www.figma.com/plugin-docs/creating-ui/#non-null-origin-iframes

This requires an additional pluginId field in the body of the message, and should also allow passing a url to the second argument of post message.

Proposal would be to update sendRaw to get passed the options from creating the API, and add an option field for "pluginId" and "targetOrigin" that user can pass in.

Happy to put together a PR, but wanted to talk through implementation as well. Another option would be just to make it a boolean in options, ie nonNull: true to have the api setup using figma.pluignId to retrieve the ID, and add 'figma.com' as targetOrigin.

Let me know if you have any thoughts. Thanks!

JustH avatar Jan 18 '22 23:01 JustH

Tbh I haven't played with figma plugins in 2 years so I'm a bit out of touch (I don't even remember how this library works 😄 )

Happy to go with either of your options, I'll trust you :)

mathieudutour avatar Jan 19 '22 09:01 mathieudutour

I'm late to the party, but in case someone else stumbles upon this issue while looking for options:

I rewrote this library for hosted (non-null origin) plugins with some other configuration options. The new package is published as figma-plugin-api on npm: https://www.npmjs.com/package/figma-plugin-api

kulmajaba avatar Sep 13 '23 09:09 kulmajaba