I created a plugin that allows me to create pages, rename them, and pull in components for things like the cover. A few days ago it suddenly stopped working and now I get an error “Error: in remove: Removing this node is not allowed”. Its pretty much stopping right at the originalPage.remove() section but not sure why it would cause an error now.
const page = figma.createPage();
page.name = "Cover";
page.backgrounds = s{ type: 'SOLID', color : {r: 0, g: 0, b: 0}}];
const originalPage = figma.currentPage;
figma.currentPage= page;
originalPage.remove();
async function importNode() {
let importComponent = await figma.importComponentByKeyAsync("b917533f747dd140e0922675938169c95e3f4456");
let importComponent2 = await figma.importComponentByKeyAsync("e44e6e490be70ccc67b34702d4af234c765a020e");
importComponent.createInstance();
figma.currentPage = page2;
importComponentOntoPage(page2, importComponent2);
figma.currentPage = page3;
importComponentOntoPage(page3, importComponent2);
figma.currentPage = page4;
importComponentOntoPage(page4, importComponent2);
figma.currentPage = page5;
importComponentOntoPage(page5, importComponent2);
figma.currentPage = page;
figma.viewport.scrollAndZoomIntoView(iimportComponent])
figma.closePlugin();
}
function importComponentOntoPage(page, component) {
const instance = component.createInstance();
// Set the position of the component instance
instance.x = 0; // Adjust as needed
instance.y = 0; // Adjust as needed
const frame = figma.createFrame();
frame.name = page.name;
instance.constraints = {
horizontal: "STRETCH",
vertical: "STRETCH"
};
frame.appendChild(instance);
page.appendChild(frame);
frame.resize(instance.width, instance.height);
figma.viewport.scrollAndZoomIntoView(iframe]);
}
importNode();
const page2 = figma.createPage();
page2.name = "↳ Designs";
page2.backgrounds = r{ type: 'SOLID', color : {r: 0.13333334028720856, g: 0.13333334028720856, b: 0.13333334028720856}}];
const page3 = figma.createPage();
page3.name = "↳ 🧰 Components";
page3.backgrounds = b{ type: 'SOLID', color : {r: 0.13333334028720856, g: 0.13333334028720856, b: 0.13333334028720856}}];
const page4 = figma.createPage();
page4.name = "↳ ️ Sandbox";
page4.backgrounds =
{ type: 'SOLID', color : {r: 0.13333334028720856, g: 0.13333334028720856, b: 0.13333334028720856}}];
const page5 = figma.createPage();
page5.name = "↳ ️ Archive";
page5.backgrounds = ;{ type: 'SOLID', color : {r: 0.13333334028720856, g: 0.13333334028720856, b: 0.13333334028720856}}];