-
Notifications
You must be signed in to change notification settings - Fork 2
/
code.ts
663 lines (602 loc) · 24.6 KB
/
code.ts
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
/*
Component Cloner by Kate Miller (github: katekaho)
Allows users to create a clone of component instances under a new master component
Usage: Select the existing component instances of a master component you would like to clone.
Then hit clone to create a new master component with the instances you selected attached to it
*/
figma.showUI(__html__);
let updateUIIntervalId = setInterval(() => {
updateUI(figma.currentPage.selection);
}, 500);
// Run on input from ui.html
figma.ui.onmessage = (message) => {
switch(message.type) {
case 'cancel':
figma.closePlugin();
break;
case 'clone':
clearInterval(updateUIIntervalId);
cloneNodes(figma.currentPage.selection);
break;
}
}
/*-----------------------------------------------------------------------------
HELPER FUNCTIONS
-----------------------------------------------------------------------------*/
function updateUI(currentPageSelection) {
let errorMsg = verifyUserInput(currentPageSelection);
if (typeof errorMsg !== 'undefined') {
figma.ui.postMessage({type: 'inputError', message: errorMsg});
} else {
let componentFound = false;
let component;
let instances = [];
for (const node of currentPageSelection) {
let props = {name: node.name, id: node.id};
if (node.type === 'COMPONENT') {
componentFound = true;
component = props;
} else {
instances.push(props);
}
}
if (!componentFound) {
let master = currentPageSelection[0].masterComponent;
component = {name: master.name, id: master.id};
}
figma.ui.postMessage({type: 'noErrors', component, instances})
}
}
// Verify that child instances and/or the parent of the instances are selected
function verifyUserInput(currentPageSelection: PageNode['selection']) {
let originalComponent: ComponentNode;
let originalComponentFound: Boolean = false;
let originalComponentInSelection: Boolean = false;
if (currentPageSelection.length < 1) {
return ' ';
}
// Find the master component, if it has been selected
for (const currentNode of currentPageSelection) {
if (currentNode.type == 'COMPONENT') {
if (originalComponentFound) {
return 'Selected more than one master component';
}
originalComponentFound = true;
originalComponentInSelection = true;
originalComponent = currentNode;
if (currentPageSelection.length == 1) {
return;
}
}
}
// Verify user selection of component instances under same master
for (const currentNode of currentPageSelection) {
// If master component, skip this iteration
if (originalComponentInSelection && currentNode.type == 'COMPONENT') {
continue;
}
// Ensure that the each node is of type instance, exit if not
if (currentNode.type != 'INSTANCE') {
if(originalComponentInSelection) {
return 'Selected items are not all instances of the selected master component'
} else {
return 'Selected items are not all instances of a master component'
}
}
// Ensure that each selected element has the same master
if (originalComponent == null) {
// Sets the master component on the first loop
if (!originalComponentFound) {
originalComponent = currentNode.masterComponent;
originalComponentFound = true;
} else {
return 'Unable to find a master component, please modify your selection';
}
} else {
// Check that nodes have the same master
if (originalComponent !== currentNode.masterComponent) {
return 'Selected items are instances of different master components';
}
}
}
}
function cloneNodeBasedOnType(copy: BaseNode, original: BaseNode) {
switch (original.type) {
case 'SLICE':
copySliceNode(copy, original);
break;
case 'FRAME':
case 'GROUP':
copyFrameNode(copy, original);
break;
case 'INSTANCE':
copyInstanceNode(copy, original);
break;
case 'BOOLEAN_OPERATION':
copyBooleanOperationNode(copy, original);
break;
case 'VECTOR':
copyVectorNode(copy, original);
break;
case 'STAR':
copyStarNode(copy, original);
break;
case 'LINE':
copyLineNode(copy, original);
break;
case 'ELLIPSE':
copyEllipseNode(copy, original);
break;
case 'POLYGON':
copyPolygonNode(copy, original);
break;
case 'RECTANGLE':
copyRectangleNode(copy, original);
break;
case 'TEXT':
copyTextNode(copy, original);
break;
default:
console.error('Some other node type, need to add functionality');
}
}
function cloneNodes(currentPageSelection) {
let newMasterComponent: ComponentNode;
let newInstanceNodes = [];
let masterAssigned = false;
let clonedNodeXYOffset = 40; // Determines how far the nodes move from the original (x and y)
for (const node of currentPageSelection) {
// If haven't found the master component yet, assign it and clone
if (!masterAssigned) {
if (node.type == 'COMPONENT') { // If master component is first selected, clone it
newMasterComponent = node.clone();
} else { // Clone the first instance it finds
newMasterComponent = node.masterComponent.clone();
}
newMasterComponent['x'] = newMasterComponent['x'] + clonedNodeXYOffset;
newMasterComponent['y'] = newMasterComponent['y'] + clonedNodeXYOffset;
masterAssigned = true;
}
if (node.type == 'INSTANCE') {
// Make a new instance of the original node where the copied data will lay
let originalInstanceNode: InstanceNode = node; // Suppress some type errors
let instanceNodeCopy: InstanceNode = originalInstanceNode.clone();
// Set the master of the new instance to the newly created one
instanceNodeCopy.masterComponent = newMasterComponent;
// Copies all the original data of the node into the new one
cloneNodeBasedOnType(instanceNodeCopy, originalInstanceNode);
instanceNodeCopy['x'] = instanceNodeCopy['x'] + clonedNodeXYOffset;
instanceNodeCopy['y'] = instanceNodeCopy['y'] + clonedNodeXYOffset;
// Add it to our array so we can select it by default later
newInstanceNodes.push(instanceNodeCopy);
}
}
// Automatically selects the newly created master and child nodes
// FUTURE: Move the master near the child nodes by default
figma.currentPage.selection = [newMasterComponent, ...newInstanceNodes];
// Display message of completion
figma.ui.postMessage({type: 'complete'});
// Set viewport to cloned nodes
figma.viewport.scrollAndZoomIntoView(figma.currentPage.selection);
// Close plugin after 1 second
setTimeout(() => figma.closePlugin(), 900);
}
/*-----------------------------------------------------------------------------
END OF HELPER FUNCTIONS
-----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------
NODE COPYING FUNCTIONS
-------------------------------------------------------------------------------
The following are helper functions that copy different Node types needed for
this plugin from the original instances
Commented out fields means they can't be copied since they are instances
-----------------------------------------------------------------------------*/
function copyFrameNode(copy, original) {
// copy['absoluteTransform'] = original['absoluteTransform'];
// copy['backgroundStyleId'] = original['backgroundStyleId'];
// copy['backgrounds'] = original['backgrounds'];
copy['blendMode'] = original['blendMode'];
// copy['constrainProportions'] = original['constrainProportions'];
copy['effectStyleId'] = original['effectStyleId'];
copy['effects'] = original['effects'];
// copy['expanded'] = original['expanded'];
copy['exportSettings'] = original['exportSettings'];
// copy['isMask'] = original['isMask'];
// copy['layoutAlign'] = original['layoutAlign'];
copy['locked'] = original['locked'];
copy['name'] = original['name'];
copy['opacity'] = original['opacity'];
// copy['parent'] = original['parent'];
// copy['reactions'] = original['reactions'];
// copy['relativeTransform'] = original['relativeTransform'];
// copy['removed'] = original['removed'];
// copy['rotation'] = original['rotation'];
copy['visible'] = original['visible'];
// copy['width'] = original['width'];
// copy['x'] = original['x'];
// copy['y'] = original['y'];
// Copy each child
let currentChild = 0;
original['children'].forEach(childNode => {
cloneNodeBasedOnType(copy['children'][currentChild++], childNode);
});
}
function copyVectorNode(copy, original) {
// copy['absoluteTransform'] = original['absoluteTransform'];
copy['blendMode'] = original['blendMode'];
// copy['constraints'] = original['constraints'];
if (original['cornerRadius'] !== figma.mixed) {
copy['cornerRadius'] = original['cornerRadius'];
}
copy['cornerSmoothing'] = original['cornerSmoothing'];
copy['dashPattern'] = original['dashPattern'];
copy['effectStyleId'] = original['effectStyleId'];
copy['effects'] = original['effects'];
copy['exportSettings'] = original['exportSettings'];
copy['fillStyleId'] = original['fillStyleId'];
copy['fills'] = original['fills'];
// copy['handleMirroring'] = original['handleMirroring'];
// copy['height'] = original['height'];
// copy['isMask'] = original['isMask'];
copy['locked'] = original['locked'];
copy['name'] = original['name'];
copy['opacity'] = original['opacity'];
// copy['relativeTransform'] = original['relativeTransform'];
// copy['removed'] = original['removed'];
// copy['rotation'] = original['rotation'];
copy['strokeAlign'] = original['strokeAlign'];
// If any fields are mixed, don't copy for now
if (original['strokeCap'] !== figma.mixed) {
copy['strokeCap'] = original['strokeCap'];
}
if (original['strokeJoin'] !== figma.mixed) {
copy['strokeJoin'] = original['strokeJoin'];
}
copy['strokeStyleId'] = original['strokeStyleId'];
copy['strokeWeight'] = original['strokeWeight'];
copy['strokes'] = original['strokes'];
// copy['type'] = original['type'];
// copy['vectorNetwork'] = original['vectorNetwork'];
copy['visible'] = original['visible'];
// copy['width'] = original['width'];
// copy['x'] = original['x'];
// copy['y'] = original['y'];
}
function copyBooleanOperationNode(copy, original) {
// copy['absoluteTransform'] = original['absoluteTransform'];
copy['backgrounds'] = original['backgrounds'];
copy['blendMode'] = original['blendMode'];
copy['booleanOperation'] = original['booleanOperation'];
// copy['constraints'] = original['constraints'];
// copy['cornerRadius'] = original['cornerRadius'];
// copy['cornerSmoothing'] = original['cornerSmoothing'];
copy['dashPattern'] = original['dashPattern'];
copy['effectStyleId'] = original['effectStyleId'];
copy['effects'] = original['effects'];
copy['exportSettings'] = original['exportSettings'];
copy['fillStyleId'] = original['fillStyleId'];
copy['fills'] = original['fills'];
// copy['height'] = original['height'];
// copy['isMask'] = original['isMask'];
copy['locked'] = original['locked'];
copy['name'] = original['name'];
copy['opacity'] = original['opacity'];
// copy['relativeTransform'] = original['relativeTransform'];
// copy['removed'] = original['removed'];
// copy['rotation'] = original['rotation'];
copy['strokeAlign'] = original['strokeAlign'];
copy['strokeCap'] = original['strokeCap'];
copy['strokeJoin'] = original['strokeJoin'];
copy['strokeStyleId'] = original['strokeStyleId'];
copy['strokeWeight'] = original['strokeWeight'];
copy['strokes'] = original['strokes'];
// copy['type'] = original['type'];
copy['visible'] = original['visible'];
// copy['width'] = original['width'];
// copy['x'] = original['x'];
// copy['y'] = original['y'];
// Copy each child
let currentChild = 0;
original['children'].forEach(childNode => {
cloneNodeBasedOnType(copy['children'][currentChild++], childNode);
});
return;
}
function copyStarNode(copy, original) {
// copy['absoluteTransform'] = original['absoluteTransform'];
copy['blendMode'] = original['blendMode'];
// copy['constraints'] = original['constraints'];
copy['cornerRadius'] = original['cornerRadius'];
copy['cornerSmoothing'] = original['cornerSmoothing'];
copy['dashPattern'] = original['dashPattern'];
copy['effectStyleId'] = original['effectStyleId'];
copy['effects'] = original['effects'];
copy['exportSettings'] = original['exportSettings'];
copy['fillStyleId'] = original['fillStyleId'];
copy['fills'] = original['fills'];
// copy['height'] = original['height'];
// copy['innerRadius'] = original['innerRadius'];
// copy['isMask'] = original['isMask'];
copy['locked'] = original['locked'];
copy['name'] = original['name'];
copy['opacity'] = original['opacity'];
// copy['pointCount'] = original['pointCount'];
// copy['relativeTransform'] = original['relativeTransform'];
// copy['removed'] = original['removed'];
// copy['rotation'] = original['rotation'];
copy['strokeAlign'] = original['strokeAlign'];
copy['strokeCap'] = original['strokeCap'];
copy['strokeJoin'] = original['strokeJoin'];
copy['strokeStyleId'] = original['strokeStyleId'];
copy['strokeWeight'] = original['strokeWeight'];
copy['strokes'] = original['strokes'];
// copy['type'] = original['type'];
copy['visible'] = original['visible'];
// copy['width'] = original['width'];
// copy['x'] = original['x'];
// copy['y'] = original['y'];
}
function copyLineNode(copy, original) {
// copy['absoluteTransform'] = original['absoluteTransform'];
copy['blendMode'] = original['blendMode'];
// copy['constraints'] = original['constraints'];
copy['dashPattern'] = original['dashPattern'];
copy['effectStyleId'] = original['effectStyleId'];
copy['effects'] = original['effects'];
copy['exportSettings'] = original['exportSettings'];
copy['fillStyleId'] = original['fillStyleId'];
copy['fills'] = original['fills'];
// copy['height'] = original['height'];
// copy['isMask'] = original['isMask'];
copy['locked'] = original['locked'];
copy['name'] = original['name'];
copy['opacity'] = original['opacity'];
// copy['relativeTransform'] = original['relativeTransform'];
// copy['removed'] = original['removed'];
// copy['rotation'] = original['rotation'];
copy['strokeAlign'] = original['strokeAlign'];
copy['strokeCap'] = original['strokeCap'];
copy['strokeJoin'] = original['strokeJoin'];
copy['strokeStyleId'] = original['strokeStyleId'];
copy['strokeWeight'] = original['strokeWeight'];
copy['strokes'] = original['strokes'];
// copy['type'] = original['type'];
copy['visible'] = original['visible'];
// copy['width'] = original['width'];
// copy['x'] = original['x'];
// copy['y'] = original['y'];
}
function copyEllipseNode(copy, original) {
// copy['absoluteTransform'] = original['absoluteTransform'];
// copy['arcData'] = original['arcData'];
copy['blendMode'] = original['blendMode'];
// copy['constraints'] = original['constraints'];
// copy['cornerRadius'] = original['cornerRadius'];
// copy['cornerSmoothing'] = original['cornerSmoothing'];
copy['dashPattern'] = original['dashPattern'];
copy['effectStyleId'] = original['effectStyleId'];
copy['effects'] = original['effects'];
copy['exportSettings'] = original['exportSettings'];
copy['fillStyleId'] = original['fillStyleId'];
copy['fills'] = original['fills'];
// copy['height'] = original['height'];
// copy['isMask'] = original['isMask'];
copy['locked'] = original['locked'];
copy['name'] = original['name'];
copy['opacity'] = original['opacity'];
// copy['relativeTransform'] = original['relativeTransform'];
// copy['removed'] = original['removed'];
// copy['rotation'] = original['rotation'];
copy['strokeAlign'] = original['strokeAlign'];
copy['strokeCap'] = original['strokeCap'];
copy['strokeJoin'] = original['strokeJoin'];
copy['strokeStyleId'] = original['strokeStyleId'];
copy['strokeWeight'] = original['strokeWeight'];
copy['strokes'] = original['strokes'];
// copy['type'] = original['type'];
copy['visible'] = original['visible'];
// copy['width'] = original['width'];
// copy['x'] = original['x'];
// copy['y'] = original['y'];
}
function copyPolygonNode(copy, original) {
// copy['absoluteTransform'] = original['absoluteTransform'];
copy['blendMode'] = original['blendMode'];
// copy['constraints'] = original['constraints'];
// copy['cornerRadius'] = original['cornerRadius'];
// copy['cornerSmoothing'] = original['cornerSmoothing'];
copy['dashPattern'] = original['dashPattern'];
copy['effectStyleId'] = original['effectStyleId'];
copy['effects'] = original['effects'];
copy['exportSettings'] = original['exportSettings'];
copy['fillStyleId'] = original['fillStyleId'];
copy['fills'] = original['fills'];
// copy['height'] = original['height'];
// copy['isMask'] = original['isMask'];
copy['locked'] = original['locked'];
copy['name'] = original['name'];
copy['opacity'] = original['opacity'];
// copy['relativeTransform'] = original['relativeTransform'];
// copy['removed'] = original['removed'];
// copy['rotation'] = original['rotation'];
copy['strokeAlign'] = original['strokeAlign'];
copy['strokeCap'] = original['strokeCap'];
copy['strokeJoin'] = original['strokeJoin'];
copy['strokeStyleId'] = original['strokeStyleId'];
copy['strokeWeight'] = original['strokeWeight'];
copy['strokes'] = original['strokes'];
// copy['type'] = original['type'];
copy['visible'] = original['visible'];
// copy['width'] = original['width'];
// copy['x'] = original['x'];
// copy['y'] = original['y'];
}
function copyRectangleNode(copy, original) {
// copy['absoluteTransform'] = original['absoluteTransform'];
// copy['backgrounds'] = original['backgrounds'];
copy['blendMode'] = original['blendMode'];
// copy['bottomLeftRadius'] = original['bottomLeftRadius'];
// copy['bottomRightRadius'] = original['bottomRightRadius'];
// copy['constraints'] = original['constraints'];
if (original['cornerRadius'] !== figma.mixed) {
copy['cornerRadius'] = original['cornerRadius'];
}
if(original['cornerSmoothing'] !== figma.mixed){
copy['cornerSmoothing'] = original['cornerSmoothing'];
}
copy['dashPattern'] = original['dashPattern'];
copy['effectStyleId'] = original['effectStyleId'];
copy['effects'] = original['effects'];
copy['exportSettings'] = original['exportSettings'];
copy['fillStyleId'] = original['fillStyleId'];
copy['fills'] = original['fills'];
// copy['height'] = original['height'];
// copy['isMask'] = original['isMask'];
copy['locked'] = original['locked'];
copy['name'] = original['name'];
copy['opacity'] = original['opacity'];
// copy['relativeTransform'] = original['relativeTransform'];
// copy['removed'] = original['removed'];
// copy['rotation'] = original['rotation'];
copy['strokeAlign'] = original['strokeAlign'];
copy['strokeCap'] = original['strokeCap'];
copy['strokeJoin'] = original['strokeJoin'];
copy['strokeStyleId'] = original['strokeStyleId'];
copy['strokeWeight'] = original['strokeWeight'];
copy['strokes'] = original['strokes'];
// copy['type'] = original['type'];
copy['visible'] = original['visible'];
// copy['width'] = original['width'];
// copy['x'] = original['x'];
// copy['y'] = original['y'];
return;
}
function copyTextNode(copy, original) {
// Doesn't support Advanced Type Features, Numbers
// Load original and new font then modify once complete
if(original['fontName'] !== figma.mixed) {
Promise.all([figma.loadFontAsync(copy['fontName']), figma.loadFontAsync(original['fontName'])])
.then(() => {
copy['characters'] = original['characters'];
if (original['fontName'] !== figma.mixed) {
copy['fontName'] = original['fontName'];
}
if (original['fontSize'] !== figma.mixed) {
copy['fontSize'] = original['fontSize'];
}
if (original['letterSpacing'] !== figma.mixed) {
copy['letterSpacing'] = original['letterSpacing'];
}
if (original['lineHeight'] !== figma.mixed) {
copy['lineHeight'] = original['lineHeight'];
}
copy['paragraphIndent'] = original['paragraphIndent'];
copy['paragraphSpacing'] = original['paragraphSpacing'];
copy['textAlignHorizontal'] = original['textAlignHorizontal'];
copy['textAlignVertical'] = original['textAlignVertical'];
copy['textAutoResize'] = original['textAutoResize'];
if (original['textCase'] !== figma.mixed) {
copy['textCase'] = original['textCase'];
}
if (original['textDecoration'] !== figma.mixed) {
copy['textDecoration'] = original['textDecoration'];
}
if (original['textStyleId'] !== figma.mixed) {
copy['textStyleId'] = original['textStyleId'];
}
}).catch((err) => {
console.error("Clone plugin error: function copyTextNode() error: promise failed");
console.error(err)
});
}
// copy['absoluteTransform'] = original['absoluteTransform'];
copy['autoRename'] = original['autoRename'];
copy['blendMode'] = original['blendMode'];
// copy['constraints'] = original['constraints'];
copy['dashPattern'] = original['dashPattern'];
copy['effectStyleId'] = original['effectStyleId'];
copy['effects'] = original['effects'];
copy['exportSettings'] = original['exportSettings'];
if (original['fillStyleId'] !== figma.mixed) {
copy['fillStyleId'] = original['fillStyleId'];
}
if (original['fills'] !== figma.mixed) {
copy['fills'] = original['fills'];
}
// copy['height'] = original['height'];
// copy['isMask'] = original['isMask'];
copy['locked'] = original['locked'];
copy['name'] = original['name'];
copy['opacity'] = original['opacity'];
// copy['parent'] = original['parent'];
// copy['relativeTransform'] = original['relativeTransform'];
// copy['removed'] = original['removed'];
// copy['rotation'] = original['rotation'];
copy['strokeAlign'] = original['strokeAlign'];
copy['strokeCap'] = original['strokeCap'];
copy['strokeJoin'] = original['strokeJoin'];
copy['strokeStyleId'] = original['strokeStyleId'];
copy['strokeWeight'] = original['strokeWeight'];
copy['strokes'] = original['strokes'];
// copy['type'] = original['type'];
copy['visible'] = original['visible'];
// copy['width'] = original['width'];
// copy['x'] = original['x'];
// copy['y'] = original['y'];
return;
}
function copySliceNode(copy, original) {
// copy['absoluteTransform'] = original['absoluteTransform'];
// copy['constraints'] = original['constraints'];
copy['exportSettings'] = original['exportSettings'];
// copy['height'] = original['height'];
copy['locked'] = original['locked'];
copy['name'] = original['name'];
// copy['relativeTransform'] = original['relativeTransform'];
// copy['removed'] = original['removed'];
// copy['rotation'] = original['rotation'];
copy['visible'] = original['visible'];
// copy['width'] = original['width'];
// copy['x'] = original['x'];
// copy['y'] = original['y'];
return;
}
function copyInstanceNode(copy, original) {
// copy['absoluteTransform'] = original['absoluteTransform'];
copy['backgroundStyleId'] = original['backgroundStyleId'];
copy['backgrounds'] = original['backgrounds'];
copy['blendMode'] = original['blendMode'];
// copy['bottomLeftRadius'] = original['bottomLeftRadius'];
// copy['bottomRightRadius'] = original['bottomRightRadius'];
copy['blendMode'] = original['blendMode'];
copy['clipsContent'] = original['clipsContent'];
copy['effectStyleId'] = original['effectStyleId'];
copy['effects'] = original['effects'];
copy['exportSettings'] = original['exportSettings'];
copy['gridStyleId'] = original['gridStyleId'];
copy['guides'] = original['guides'];
// copy['height'] = original['height'];
// copy['isMask'] = original['isMask'];
copy['layoutGrids'] = original['layoutGrids'];
copy['locked'] = original['locked'];
copy['name'] = original['name'];
copy['opacity'] = original['opacity'];
// copy['parent'] = original['parent'];
// copy['relativeTransform'] = original['relativeTransform']; // This varies by base or child
// copy['removed'] = original['removed'];
// copy['rotation'] = original['rotation'];
// copy['type'] = original['type'];
copy['visible'] = original['visible'];
// copy['width'] = original['width'];
// copy['x'] = original['x'];
// copy['y'] = original['y'];
// Copy each child
let currentChild = 0;
original['children'].forEach(childNode => {
cloneNodeBasedOnType(copy['children'][currentChild++], childNode);
});
return;
}
/*-----------------------------------------------------------------------------
END OF NODE COPYING FUNCTIONS
-----------------------------------------------------------------------------*/