Skip to main content

Drag svg from Figma plugin and drop to Figma file.


Like they did https://www.figma.com/community/plugin/884531262241804656/Drag-%26-Drop


I’m wanna develop this type of feature in my plugin.

Is this a question? 🤔


sorry yeah


Can you explain further? This depends heavily on the plugin that you’re using.


Please look back at my question again. And actually, Figma not allowing to create SVG Instance directly.


I got this error “‘postMessage’ on ‘Window’: SVGSVGElement object could not be cloned.”

in my plugin.


Use the “Drop” event in code.js.

Check out the following official examples:




I’m not sure why but when I try to use figma.on(‘drop’,…) it’s throwing errors


I don’t see any errors here. But you probably need to update plugin typings.

GitHub

I had update plugin typings but still


Since you are using Typescript, you need to respect its syntax and also return false:


figma.on('drop', (event: DropEvent) => {
// Your code
return false
})

Also add a condition for line 9 (on which you supposedly have an error) as in the example I gave you a link to:

github.com

Thank you so much for your help. It’s working now. But one typescript error still showing


if (node.appendChild) {
node.appendChild(newNode);
}

Showing this “Property ‘appendChild’ does not exist on type 'DocumentNode | PageNode | SliceNode | FrameNode… etc”



This condition is just written in order to bypass the error you indicated.


Okay thank you


Reply