1
- const types = [
2
- "BOOLEAN_OPERATION" ,
3
- "COMPONENT" ,
4
- "COMPONENT_SET" ,
5
- "CONNECTOR" ,
6
- "DOCUMENT" ,
7
- "ELLIPSE" ,
8
- "FRAME" ,
9
- "GROUP" ,
10
- "INSTANCE" ,
11
- "LINE" ,
12
- "PAGE" ,
13
- "POLYGON" ,
14
- "RECTANGLE" ,
15
- "SHAPE_WITH_TEXT" ,
16
- "SLICE" ,
17
- "STAMP" ,
18
- "STAR" ,
19
- "STICKY" ,
20
- "TEXT" ,
21
- "VECTOR" ,
22
- ] ;
1
+ /* eslint-disable no-case-declarations */
23
2
24
3
// The 'input' event listens for text change in the Quick Actions box after a plugin is 'Tabbed' into.
25
4
figma . parameters . on ( 'input' , ( { key, query, result } ) => {
@@ -50,25 +29,25 @@ figma.parameters.on('input', ({ key, query, result }) => {
50
29
51
30
// When the user presses Enter after inputting all parameters, the 'run' event is fired.
52
31
figma . on ( 'run' , ( { parameters } ) => {
53
- startPluginWithParameters ( parameters ! ) ;
32
+ startPluginWithParameters ( parameters ) ;
54
33
} ) ;
55
34
56
35
// Start the plugin with parameters
57
- function startPluginWithParameters ( parameters ) {
36
+ async function startPluginWithParameters ( parameters ) {
58
37
const { name, id } = parameters [ 'name' ] ;
59
- const node = figma . getNodeById ( id ) ;
38
+ const node = await figma . getNodeByIdAsync ( id ) ;
60
39
if ( node ) {
61
40
// Node found, so we need to go to that node
62
41
if ( node . type === "PAGE" ) {
63
- figma . currentPage = node ;
42
+ await figma . setCurrentPageAsync ( node ) ;
64
43
} else {
65
44
// Figure out if the node is on the right page,
66
45
// otherwise, we need to switch to that page before zooming into the view
67
46
let currentParent = node . parent ;
68
47
while ( currentParent . type !== "PAGE" ) {
69
48
currentParent = currentParent . parent ;
70
49
}
71
- figma . currentPage = currentParent ;
50
+ await figma . setCurrentPageAsync ( currentParent ) ;
72
51
figma . viewport . scrollAndZoomIntoView ( [ node ] ) ;
73
52
figma . currentPage . selection = [ node as SceneNode ] ;
74
53
}
@@ -78,4 +57,3 @@ function startPluginWithParameters(parameters) {
78
57
}
79
58
figma . closePlugin ( ) ;
80
59
}
81
- ;
0 commit comments