create-figma-plugin
create-figma-plugin copied to clipboard
Add 'pluginId' argument to emit function for non-null origin iframes
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
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.