I’m just starting with Figma plugins and struggling with reading and editing Component Properties. In a very simple case, I’d like to change all property names and values to lowercase.
I don’t understand how to use editComponentProperty and can’t make sense of the documentation.
Here’s the code that I have so far:
function start() {
const doc = figma.currentPage;
const components = doc.children;
for (const component of components) {
if (component.type === 'COMPONENT' || component.type === 'COMPONENT_SET') {
const componentPropertyDefinitions = component.componentPropertyDefinitions;
for (let propertyName in componentPropertyDefinitions) {
const propertyDefinition = componentPropertyDefinitions[propertyName];
propertyName = propertyName.toLowerCase();
component.editComponentProperty(propertyName, propertyDefinition);
}
}
}
}
First argument acts as an identifier, that makes perfect sense. Second one are the updates, clear.
But why does this still throw an exception? Nothing’s changed but I still can’t write it back. (propertyName look correct to me (e.g. ‘Show Label#2:9’)