-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinsert_component_id.js
37 lines (32 loc) · 1.01 KB
/
insert_component_id.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
let selectedFrames = figma.currentPage.selection
let masterComponents = []
// Select all master components
selectedFrames.forEach(selectedFrame=>{
// For selected Frame
if(selectedFrame.type=="FRAME"){
let frameComponents = selectedFrame.findAll(n=>n.type==="COMPONENT")
if(frameComponents.length>0){
masterComponents=masterComponents.concat(frameComponents)
}
}
// For selected Component
if(selectedFrame.type=="COMPONENT"){
masterComponents = masterComponents.concat(selectedFrame)
}
})
// Working with component description
masterComponents.forEach(component => {
let componentDescription = component.description
// Add Component ID
addComponentID(component)
figma.notify("Component Description is updated")
})
function addComponentID(component){
// Check if we don't have component ID already
if(component.description.search("Design: ")==-1){
// Add Component description
component.description=component.description.concat("\nDesign: "+component.id)
}
}