I’m working on a Figma plugin and need to programmatically convert existing Frame or Instance nodes into Component nodes. In the Figma interface, this is straightforward - you just right-click on any element and select “Create Component” from the context menu.
However, I can’t figure out how to achieve this same functionality using the Figma API. I’ve discovered the figma.createComponent() method, but this only generates a blank Component node rather than converting an existing element.
Is there a specific API method or approach that allows me to transform an already existing Frame or Instance node into a Component node? I need to maintain all the existing properties and child elements during this conversion process.