@@ -87,7 +87,7 @@ function cmdReorder() {
8787 } )
8888}
8989
90- function cmdTidy ( xSpacing , ySpacing ) {
90+ function cmdTidy ( xSpacing , ySpacing , wrapInstances ) {
9191 var selection = figma . currentPage . selection
9292 var parent = ( selection [ 0 ] . type == 'PAGE' ) ? figma . currentPage : selection [ 0 ] . parent
9393 var allNodes = parent . children
@@ -122,7 +122,7 @@ function cmdTidy(xSpacing, ySpacing) {
122122 var newYPos = yPos
123123
124124 // Wrap instances with a frame around
125- if ( match . type == 'INSTANCE' ) {
125+ if ( wrapInstances && match . type == 'INSTANCE' ) {
126126 var instanceParent = figma . createFrame ( )
127127 instanceParent . x = newXPos
128128 instanceParent . y = newYPos
@@ -156,11 +156,13 @@ Promise.all([
156156
157157 let SPACING = { x : 100 , y : 200 }
158158 let START_NAME = '000'
159+ let WRAP_INSTANCES = true
159160 let RENAME_STRATEGY_REPLACE = 'replace'
160161 let RENAME_STRATEGY_MERGE = 'merge'
161162 let PREFERENCES = {
162163 spacing : SPACING ,
163164 start_name : START_NAME ,
165+ wrap_instances : WRAP_INSTANCES ,
164166 rename_strategy : RENAME_STRATEGY_REPLACE
165167 }
166168
@@ -195,13 +197,13 @@ Promise.all([
195197 } else
196198 if ( cmd == 'tidy' ) {
197199 // RUNS WITHOUT UI
198- cmdTidy ( preferences . spacing . x , preferences . spacing . y )
200+ cmdTidy ( preferences . spacing . x , preferences . spacing . y , preferences . wrap_instances )
199201 figma . notify ( 'Super Tidy: Tidy' )
200202 setTimeout ( ( ) => figma . closePlugin ( ) , 100 )
201203 } else
202204 if ( cmd == 'all' ) {
203205 // RUNS WITHOUT UI
204- cmdTidy ( preferences . spacing . x , preferences . spacing . y )
206+ cmdTidy ( preferences . spacing . x , preferences . spacing . y , preferences . wrap_instances )
205207 cmdReorder ( )
206208 cmdRename ( preferences . rename_strategy , preferences . start_name )
207209 figma . notify ( 'Super Tidy' )
@@ -223,7 +225,7 @@ Promise.all([
223225 var REORDER_ENABLED = msg . options . reorder
224226 var TIDY_ENABLED = msg . options . tidy
225227
226- if ( TIDY_ENABLED ) cmdTidy ( preferences . spacing . x , preferences . spacing . y )
228+ if ( TIDY_ENABLED ) cmdTidy ( preferences . spacing . x , preferences . spacing . y , preferences . wrap_instances )
227229 if ( RENAMING_ENABLED ) cmdRename ( preferences . rename_strategy , preferences . start_name )
228230 if ( REORDER_ENABLED ) cmdReorder ( )
229231 figma . notify ( 'Super Tidy' )
0 commit comments