Last active
March 11, 2021 21:16
-
-
Save ryohey/30b16fb89ec49cee8e8313658a347e6b to your computer and use it in GitHub Desktop.
Detach and flatten all frames in Figma
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const detachAndFlatten = (pageName) => { | |
const detach = (c) => figma.union([c], c.parent) | |
const page = figma.root.children.find(c => c.name === pageName) | |
const frames = page.children.filter(c => c.type === "FRAME") | |
for (let frame of frames) { | |
for (let c of frame.children) { | |
if (c.type === "INSTANCE") { | |
c = detach(c) | |
} else { | |
// | |
} | |
figma.flatten([c]) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
detachAndFlatten("here is your page name")