create-figma-plugin icon indicating copy to clipboard operation
create-figma-plugin copied to clipboard

Add 'pluginId' argument to emit function for non-null origin iframes

Open LukeFinch opened this issue 2 years ago • 1 comments

When using the event handlers in an iframe that points to another domain, you're required to specify the plugin id (or wildcard with '*')

Could the emit function accept an optional argument to specify the pluginId? window.parent.postMessage( { pluginMessage: [name, ...args], pluginId: '*', }, '*' )

https://www.figma.com/plugin-docs/creating-ui/#non-null-origin-iframes

LukeFinch avatar Jun 08 '22 13:06 LukeFinch

I think this has to be set globally.

// ui.ts
emit.configure({ nonNullOrigin: true })

It is also useful for some messages to be shared between plugins I suppose, where flexibility like this would be useful. I'd explicitly specify the pluginid for security reasons still.

yagudaev avatar Jan 19 '23 07:01 yagudaev