Figma Support Forum

Copy and Paste frame from one draft to another

Hi,

I am trying the implement the functionality to my plugin to copy the frame of draft A (where the plugin is launched) and paste it into to draft B. Is it possible to do that ?

Thanks

Not really possible, plugins can’t work between files. You can store the full node JSON and then recreate the node in the new file (there is a node decoder library that can help), but that would be a pretty slow process for large nodes.

Okay thanks. But it’s possible to do it from one page to another ?

Super easy: .clone() and then page2.appendChildren(cloned)

How can I get page2 (in my case I want the node of the first page) ? I tried with:

const pageNode1 = figma.root.findOne(n => n.type === "PAGE");

But then I cannot use appendChildren on it.

appendChild docs: PageNode · Figma Developers

const pageNode = figma.root.children.find(n => n.name === "page 2 name") as PageNode

pageNode.appendChild(cloned)
1 Like

Thanks!