const types = [ "BOOLEAN_OPERATION" , "COMPONENT" , "COMPONENT_SET" , "CONNECTOR" , "DOCUMENT" , "ELLIPSE" , "FRAME" , "GROUP" , "INSTANCE" , "LINE" , "PAGE" , "POLYGON" , "RECTANGLE" , "SHAPE_WITH_TEXT" , "SLICE" , "STAMP" , "STAR" , "STICKY" , "TEXT" , "VECTOR" , ] ; figma . parameters . on ( 'input' , ( { key , query , result } ) => { switch ( key ) { case 'name' : const filter = node => node . name . toLowerCase ( ) . startsWith ( query . toLowerCase ( ) ) ; const pages = figma . root . findChildren ( node => query . length === 0 ? true : filter ( node ) ) . map ( node => ( { name : `${ node . name } (page)` , data : { name : node . name , id : node . id } } ) ) ; const nodes = query . length > 0 ? figma . currentPage . findAll ( node => filter ( node ) ) : [ ] ; const formattedNodes = nodes . map ( ( node ) => { const name = `${ node . name } [${ node . id }]` ; return ( { name , data : { name : node . name , id : node . id } } ) ; } ) ; const suggestions = [ ... pages , ... formattedNodes ] ; result . setSuggestions ( suggestions ) ; break ; default : return ; } } ) ; figma . on ( 'run' , ( { parameters } ) => { startPluginWithParameters ( parameters ! ) ; } ) ; function startPluginWithParameters ( parameters ) { const { name , id } = parameters [ 'name' ] ; const node = figma . getNodeById ( id ) ; if ( node ) { if ( node . type === "PAGE" ) { figma . currentPage = node ; } else { let currentParent = node . parent ; while ( currentParent . type !== "PAGE" ) { currentParent = currentParent . parent ; } figma . currentPage = currentParent ; figma . viewport . scrollAndZoomIntoView ( [ node ] ) ; figma . currentPage . selection = [ node as SceneNode ] ; } } else { figma . notify ( `Could not find node with name=${ name }` ) ; } figma . closePlugin ( ) ; } ;