-
Notifications
You must be signed in to change notification settings - Fork 1
/
figma.d.ts
792 lines (641 loc) · 22.9 KB
/
figma.d.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
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
// Figma Plugin API version 1, update 10
declare global {
// Global variable with Figma's plugin API.
const figma: PluginAPI
const __html__: string
interface PluginAPI {
readonly apiVersion: "1.0.0"
readonly command: string
readonly viewport: ViewportAPI
closePlugin(message?: string): void
notify(message: string, options?: NotificationOptions): NotificationHandler
showUI(html: string, options?: ShowUIOptions): void
readonly ui: UIAPI
readonly clientStorage: ClientStorageAPI
getNodeById(id: string): BaseNode | null
getStyleById(id: string): BaseStyle | null
readonly root: DocumentNode
currentPage: PageNode
on(type: "selectionchange" | "currentpagechange" | "close", callback: () => void): void
once(type: "selectionchange" | "currentpagechange" | "close", callback: () => void): void
off(type: "selectionchange" | "currentpagechange" | "close", callback: () => void): void
readonly mixed: unique symbol
createRectangle(): RectangleNode
createLine(): LineNode
createEllipse(): EllipseNode
createPolygon(): PolygonNode
createStar(): StarNode
createVector(): VectorNode
createText(): TextNode
createFrame(): FrameNode
createComponent(): ComponentNode
createPage(): PageNode
createSlice(): SliceNode
/**
* [DEPRECATED]: This API often fails to create a valid boolean operation. Use figma.union, figma.subtract, figma.intersect and figma.exclude instead.
*/
createBooleanOperation(): BooleanOperationNode
createPaintStyle(): PaintStyle
createTextStyle(): TextStyle
createEffectStyle(): EffectStyle
createGridStyle(): GridStyle
// The styles are returned in the same order as displayed in the UI. Only
// local styles are returned. Never styles from team library.
getLocalPaintStyles(): PaintStyle[]
getLocalTextStyles(): TextStyle[]
getLocalEffectStyles(): EffectStyle[]
getLocalGridStyles(): GridStyle[]
importComponentByKeyAsync(key: string): Promise<ComponentNode>
importStyleByKeyAsync(key: string): Promise<BaseStyle>
listAvailableFontsAsync(): Promise<Font[]>
loadFontAsync(fontName: FontName): Promise<void>
readonly hasMissingFont: boolean
createNodeFromSvg(svg: string): FrameNode
createImage(data: Uint8Array): Image
getImageByHash(hash: string): Image
group(nodes: ReadonlyArray<BaseNode>, parent: BaseNode & ChildrenMixin, index?: number): GroupNode
flatten(nodes: ReadonlyArray<BaseNode>, parent?: BaseNode & ChildrenMixin, index?: number): VectorNode
union(nodes: ReadonlyArray<BaseNode>, parent: BaseNode & ChildrenMixin, index?: number): BooleanOperationNode
subtract(nodes: ReadonlyArray<BaseNode>, parent: BaseNode & ChildrenMixin, index?: number): BooleanOperationNode
intersect(nodes: ReadonlyArray<BaseNode>, parent: BaseNode & ChildrenMixin, index?: number): BooleanOperationNode
exclude(nodes: ReadonlyArray<BaseNode>, parent: BaseNode & ChildrenMixin, index?: number): BooleanOperationNode
}
interface ClientStorageAPI {
getAsync(key: string): Promise<any | undefined>
setAsync(key: string, value: any): Promise<void>
}
interface NotificationOptions {
timeout?: number,
}
interface NotificationHandler {
cancel: () => void,
}
interface ShowUIOptions {
visible?: boolean,
width?: number,
height?: number,
}
interface UIPostMessageOptions {
origin?: string,
}
interface OnMessageProperties {
origin: string,
}
type MessageEventHandler = (pluginMessage: any, props: OnMessageProperties) => void
interface UIAPI {
show(): void
hide(): void
resize(width: number, height: number): void
close(): void
postMessage(pluginMessage: any, options?: UIPostMessageOptions): void
onmessage: MessageEventHandler | undefined
on(type: "message", callback: MessageEventHandler): void
once(type: "message", callback: MessageEventHandler): void
off(type: "message", callback: MessageEventHandler): void
}
interface ViewportAPI {
center: { x: number, y: number }
zoom: number
scrollAndZoomIntoView(nodes: ReadonlyArray<BaseNode>): void
}
////////////////////////////////////////////////////////////////////////////////
// Datatypes
type Transform = [
[number, number, number],
[number, number, number]
]
interface Vector {
readonly x: number
readonly y: number
}
interface RGB {
readonly r: number
readonly g: number
readonly b: number
}
interface RGBA {
readonly r: number
readonly g: number
readonly b: number
readonly a: number
}
interface FontName {
readonly family: string
readonly style: string
}
type TextCase = "ORIGINAL" | "UPPER" | "LOWER" | "TITLE"
type TextDecoration = "NONE" | "UNDERLINE" | "STRIKETHROUGH"
interface ArcData {
readonly startingAngle: number
readonly endingAngle: number
readonly innerRadius: number
}
interface ShadowEffect {
readonly type: "DROP_SHADOW" | "INNER_SHADOW"
readonly color: RGBA
readonly offset: Vector
readonly radius: number
readonly visible: boolean
readonly blendMode: BlendMode
}
interface BlurEffect {
readonly type: "LAYER_BLUR" | "BACKGROUND_BLUR"
readonly radius: number
readonly visible: boolean
}
type Effect = ShadowEffect | BlurEffect
type ConstraintType = "MIN" | "CENTER" | "MAX" | "STRETCH" | "SCALE"
interface Constraints {
readonly horizontal: ConstraintType
readonly vertical: ConstraintType
}
interface ColorStop {
readonly position: number
readonly color: RGBA
}
interface ImageFilters {
readonly exposure?: number
readonly contrast?: number
readonly saturation?: number
readonly temperature?: number
readonly tint?: number
readonly highlights?: number
readonly shadows?: number
}
interface SolidPaint {
readonly type: "SOLID"
readonly color: RGB
readonly visible?: boolean
readonly opacity?: number
readonly blendMode?: BlendMode
}
interface GradientPaint {
readonly type: "GRADIENT_LINEAR" | "GRADIENT_RADIAL" | "GRADIENT_ANGULAR" | "GRADIENT_DIAMOND"
readonly gradientTransform: Transform
readonly gradientStops: ReadonlyArray<ColorStop>
readonly visible?: boolean
readonly opacity?: number
readonly blendMode?: BlendMode
}
interface ImagePaint {
readonly type: "IMAGE"
readonly scaleMode: "FILL" | "FIT" | "CROP" | "TILE"
readonly imageHash: string | null
readonly imageTransform?: Transform // setting for "CROP"
readonly scalingFactor?: number // setting for "TILE"
readonly filters?: ImageFilters
readonly visible?: boolean
readonly opacity?: number
readonly blendMode?: BlendMode
}
type Paint = SolidPaint | GradientPaint | ImagePaint
interface Guide {
readonly axis: "X" | "Y"
readonly offset: number
}
interface RowsColsLayoutGrid {
readonly pattern: "ROWS" | "COLUMNS"
readonly alignment: "MIN" | "MAX" | "STRETCH" | "CENTER"
readonly gutterSize: number
readonly count: number // Infinity when "Auto" is set in the UI
readonly sectionSize?: number // Not set for alignment: "STRETCH"
readonly offset?: number // Not set for alignment: "CENTER"
readonly visible?: boolean
readonly color?: RGBA
}
interface GridLayoutGrid {
readonly pattern: "GRID"
readonly sectionSize: number
readonly visible?: boolean
readonly color?: RGBA
}
type LayoutGrid = RowsColsLayoutGrid | GridLayoutGrid
interface ExportSettingsConstraints {
readonly type: "SCALE" | "WIDTH" | "HEIGHT"
readonly value: number
}
interface ExportSettingsImage {
readonly format: "JPG" | "PNG"
readonly contentsOnly?: boolean // defaults to true
readonly suffix?: string
readonly constraint?: ExportSettingsConstraints
}
interface ExportSettingsSVG {
readonly format: "SVG"
readonly contentsOnly?: boolean // defaults to true
readonly suffix?: string
readonly svgOutlineText?: boolean // defaults to true
readonly svgIdAttribute?: boolean // defaults to false
readonly svgSimplifyStroke?: boolean // defaults to true
}
interface ExportSettingsPDF {
readonly format: "PDF"
readonly contentsOnly?: boolean // defaults to true
readonly suffix?: string
}
type ExportSettings = ExportSettingsImage | ExportSettingsSVG | ExportSettingsPDF
type WindingRule = "NONZERO" | "EVENODD"
interface VectorVertex {
readonly x: number
readonly y: number
readonly strokeCap?: StrokeCap
readonly strokeJoin?: StrokeJoin
readonly cornerRadius?: number
readonly handleMirroring?: HandleMirroring
}
interface VectorSegment {
readonly start: number
readonly end: number
readonly tangentStart?: Vector // Defaults to { x: 0, y: 0 }
readonly tangentEnd?: Vector // Defaults to { x: 0, y: 0 }
}
interface VectorRegion {
readonly windingRule: WindingRule
readonly loops: ReadonlyArray<ReadonlyArray<number>>
}
interface VectorNetwork {
readonly vertices: ReadonlyArray<VectorVertex>
readonly segments: ReadonlyArray<VectorSegment>
readonly regions?: ReadonlyArray<VectorRegion> // Defaults to []
}
interface VectorPath {
readonly windingRule: WindingRule | "NONE"
readonly data: string
}
type VectorPaths = ReadonlyArray<VectorPath>
interface LetterSpacing {
readonly value: number
readonly unit: "PIXELS" | "PERCENT"
}
type LineHeight = {
readonly value: number
readonly unit: "PIXELS" | "PERCENT"
} | {
readonly unit: "AUTO"
}
type BlendMode =
"PASS_THROUGH" |
"NORMAL" |
"DARKEN" |
"MULTIPLY" |
"LINEAR_BURN" |
"COLOR_BURN" |
"LIGHTEN" |
"SCREEN" |
"LINEAR_DODGE" |
"COLOR_DODGE" |
"OVERLAY" |
"SOFT_LIGHT" |
"HARD_LIGHT" |
"DIFFERENCE" |
"EXCLUSION" |
"HUE" |
"SATURATION" |
"COLOR" |
"LUMINOSITY"
interface Font {
fontName: FontName
}
type Reaction = { action: Action, trigger: Trigger }
type Action =
{ readonly type: "BACK" | "CLOSE" } |
{ readonly type: "URL", url: string } |
{ readonly type: "NODE",
readonly destinationId: string | null,
readonly navigation: Navigation,
readonly transition: Transition | null,
readonly preserveScrollPosition: boolean,
// Only present if navigation == "OVERLAY" and the destination uses
// overlay position type "RELATIVE"
readonly overlayRelativePosition?: Vector,
}
interface SimpleTransition {
readonly type: "DISSOLVE" | "SMART_ANIMATE"
readonly easing: Easing
readonly duration: number
}
interface DirectionalTransition {
readonly type: "MOVE_IN" | "MOVE_OUT" | "PUSH" | "SLIDE_IN" | "SLIDE_OUT"
readonly direction: "LEFT" | "RIGHT" | "TOP" | "BOTTOM"
readonly matchLayers: boolean
readonly easing: Easing
readonly duration: number
}
export type Transition = SimpleTransition | DirectionalTransition
type Trigger =
{ readonly type: "ON_CLICK" | "ON_HOVER" | "ON_PRESS" | "ON_DRAG" } |
{ readonly type: "AFTER_TIMEOUT", readonly timeout: number } |
{ readonly type: "MOUSE_ENTER" | "MOUSE_LEAVE" | "MOUSE_UP" | "MOUSE_DOWN",
readonly delay: number,
}
type Navigation = "NAVIGATE" | "SWAP" | "OVERLAY"
interface Easing {
readonly type: "EASE_IN" | "EASE_OUT" | "EASE_IN_AND_OUT" | "LINEAR"
}
type OverflowDirection = "NONE" | "HORIZONTAL" | "VERTICAL" | "BOTH"
type OverlayPositionType = "CENTER" | "TOP_LEFT" | "TOP_CENTER" | "TOP_RIGHT" | "BOTTOM_LEFT" | "BOTTOM_CENTER" | "BOTTOM_RIGHT" | "MANUAL"
type OverlayBackground =
{ readonly type: "NONE" } |
{ readonly type: "SOLID_COLOR", readonly color: RGBA }
type OverlayBackgroundInteraction = "NONE" | "CLOSE_ON_CLICK_OUTSIDE"
////////////////////////////////////////////////////////////////////////////////
// Mixins
interface BaseNodeMixin {
readonly id: string
readonly parent: (BaseNode & ChildrenMixin) | null
name: string // Note: setting this also sets \`autoRename\` to false on TextNodes
readonly removed: boolean
toString(): string
remove(): void
getPluginData(key: string): string
setPluginData(key: string, value: string): void
// Namespace is a string that must be at least 3 alphanumeric characters, and should
// be a name related to your plugin. Other plugins will be able to read this data.
getSharedPluginData(namespace: string, key: string): string
setSharedPluginData(namespace: string, key: string, value: string): void
}
interface SceneNodeMixin {
visible: boolean
locked: boolean
}
interface ChildrenMixin {
readonly children: ReadonlyArray<SceneNode>
appendChild(child: SceneNode): void
insertChild(index: number, child: SceneNode): void
findAll(callback?: (node: SceneNode) => boolean): SceneNode[]
findOne(callback: (node: SceneNode) => boolean): SceneNode | null
}
interface ConstraintMixin {
constraints: Constraints
}
interface LayoutMixin {
readonly absoluteTransform: Transform
relativeTransform: Transform
x: number
y: number
rotation: number // In degrees
readonly width: number
readonly height: number
layoutAlign: "MIN" | "CENTER" | "MAX" // applicable only inside auto-layout frames
resize(width: number, height: number): void
resizeWithoutConstraints(width: number, height: number): void
}
interface BlendMixin {
opacity: number
blendMode: BlendMode
isMask: boolean
effects: ReadonlyArray<Effect>
effectStyleId: string
}
interface ContainerMixin {
backgrounds: ReadonlyArray<Paint> // DEPRECATED: use 'fills' instead
layoutGrids: ReadonlyArray<LayoutGrid>
clipsContent: boolean
guides: ReadonlyArray<Guide>
gridStyleId: string
backgroundStyleId: string // DEPRECATED: use 'fillStyleId' instead
}
type StrokeCap = "NONE" | "ROUND" | "SQUARE" | "ARROW_LINES" | "ARROW_EQUILATERAL"
type StrokeJoin = "MITER" | "BEVEL" | "ROUND"
type HandleMirroring = "NONE" | "ANGLE" | "ANGLE_AND_LENGTH"
interface GeometryMixin {
fills: ReadonlyArray<Paint> | PluginAPI['mixed']
strokes: ReadonlyArray<Paint>
strokeWeight: number
strokeAlign: "CENTER" | "INSIDE" | "OUTSIDE"
strokeCap: StrokeCap | PluginAPI['mixed']
strokeJoin: StrokeJoin | PluginAPI['mixed']
dashPattern: ReadonlyArray<number>
fillStyleId: string | PluginAPI['mixed']
strokeStyleId: string
}
interface CornerMixin {
cornerRadius: number | PluginAPI['mixed']
cornerSmoothing: number
}
interface RectangleCornerMixin {
topLeftRadius: number
topRightRadius: number
bottomLeftRadius: number
bottomRightRadius: number
}
interface ExportMixin {
exportSettings: ReadonlyArray<ExportSettings>
exportAsync(settings?: ExportSettings): Promise<Uint8Array> // Defaults to PNG format
}
interface ReactionMixin {
readonly reactions: ReadonlyArray<Reaction>
}
interface DefaultShapeMixin extends
BaseNodeMixin, SceneNodeMixin, ReactionMixin,
BlendMixin, GeometryMixin, LayoutMixin, ExportMixin {
}
interface DefaultFrameMixin extends
BaseNodeMixin, SceneNodeMixin, ReactionMixin,
ChildrenMixin, ContainerMixin,
GeometryMixin, CornerMixin, RectangleCornerMixin,
BlendMixin, ConstraintMixin, LayoutMixin, ExportMixin {
layoutMode: "NONE" | "HORIZONTAL" | "VERTICAL"
counterAxisSizingMode: "FIXED" | "AUTO" // applicable only if layoutMode != "NONE"
horizontalPadding: number // applicable only if layoutMode != "NONE"
verticalPadding: number // applicable only if layoutMode != "NONE"
itemSpacing: number // applicable only if layoutMode != "NONE"
overflowDirection: OverflowDirection
numberOfFixedChildren: number
readonly overlayPositionType: OverlayPositionType
readonly overlayBackground: OverlayBackground
readonly overlayBackgroundInteraction: OverlayBackgroundInteraction
}
////////////////////////////////////////////////////////////////////////////////
// Nodes
interface DocumentNode extends BaseNodeMixin {
readonly type: "DOCUMENT"
readonly children: ReadonlyArray<PageNode>
appendChild(child: PageNode): void
insertChild(index: number, child: PageNode): void
findAll(callback?: (node: (PageNode | SceneNode)) => boolean): Array<PageNode | SceneNode>
findOne(callback: (node: (PageNode | SceneNode)) => boolean): PageNode | SceneNode | null
}
interface PageNode extends BaseNodeMixin, ChildrenMixin, ExportMixin {
readonly type: "PAGE"
clone(): PageNode
guides: ReadonlyArray<Guide>
selection: ReadonlyArray<SceneNode>
backgrounds: ReadonlyArray<Paint>
readonly prototypeStartNode: FrameNode | GroupNode | ComponentNode | InstanceNode | null
}
interface FrameNode extends DefaultFrameMixin {
readonly type: "FRAME"
clone(): FrameNode
}
interface GroupNode extends BaseNodeMixin, SceneNodeMixin, ReactionMixin, ChildrenMixin, ContainerMixin, BlendMixin, LayoutMixin, ExportMixin {
readonly type: "GROUP"
clone(): GroupNode
}
interface SliceNode extends BaseNodeMixin, SceneNodeMixin, LayoutMixin, ExportMixin {
readonly type: "SLICE"
clone(): SliceNode
}
interface RectangleNode extends DefaultShapeMixin, ConstraintMixin, CornerMixin, RectangleCornerMixin {
readonly type: "RECTANGLE"
clone(): RectangleNode
}
interface LineNode extends DefaultShapeMixin, ConstraintMixin {
readonly type: "LINE"
clone(): LineNode
}
interface EllipseNode extends DefaultShapeMixin, ConstraintMixin, CornerMixin {
readonly type: "ELLIPSE"
clone(): EllipseNode
arcData: ArcData
}
interface PolygonNode extends DefaultShapeMixin, ConstraintMixin, CornerMixin {
readonly type: "POLYGON"
clone(): PolygonNode
pointCount: number
}
interface StarNode extends DefaultShapeMixin, ConstraintMixin, CornerMixin {
readonly type: "STAR"
clone(): StarNode
pointCount: number
innerRadius: number
}
interface VectorNode extends DefaultShapeMixin, ConstraintMixin, CornerMixin {
readonly type: "VECTOR"
clone(): VectorNode
vectorNetwork: VectorNetwork
vectorPaths: VectorPaths
handleMirroring: HandleMirroring | PluginAPI['mixed']
}
interface TextNode extends DefaultShapeMixin, ConstraintMixin {
readonly type: "TEXT"
clone(): TextNode
characters: string
readonly hasMissingFont: boolean
textAlignHorizontal: "LEFT" | "CENTER" | "RIGHT" | "JUSTIFIED"
textAlignVertical: "TOP" | "CENTER" | "BOTTOM"
textAutoResize: "NONE" | "WIDTH_AND_HEIGHT" | "HEIGHT"
paragraphIndent: number
paragraphSpacing: number
autoRename: boolean
textStyleId: string | PluginAPI['mixed']
fontSize: number | PluginAPI['mixed']
fontName: FontName | PluginAPI['mixed']
textCase: TextCase | PluginAPI['mixed']
textDecoration: TextDecoration | PluginAPI['mixed']
letterSpacing: LetterSpacing | PluginAPI['mixed']
lineHeight: LineHeight | PluginAPI['mixed']
getRangeFontSize(start: number, end: number): number | PluginAPI['mixed']
setRangeFontSize(start: number, end: number, value: number): void
getRangeFontName(start: number, end: number): FontName | PluginAPI['mixed']
setRangeFontName(start: number, end: number, value: FontName): void
getRangeTextCase(start: number, end: number): TextCase | PluginAPI['mixed']
setRangeTextCase(start: number, end: number, value: TextCase): void
getRangeTextDecoration(start: number, end: number): TextDecoration | PluginAPI['mixed']
setRangeTextDecoration(start: number, end: number, value: TextDecoration): void
getRangeLetterSpacing(start: number, end: number): LetterSpacing | PluginAPI['mixed']
setRangeLetterSpacing(start: number, end: number, value: LetterSpacing): void
getRangeLineHeight(start: number, end: number): LineHeight | PluginAPI['mixed']
setRangeLineHeight(start: number, end: number, value: LineHeight): void
getRangeFills(start: number, end: number): Paint[] | PluginAPI['mixed']
setRangeFills(start: number, end: number, value: Paint[]): void
getRangeTextStyleId(start: number, end: number): string | PluginAPI['mixed']
setRangeTextStyleId(start: number, end: number, value: string): void
getRangeFillStyleId(start: number, end: number): string | PluginAPI['mixed']
setRangeFillStyleId(start: number, end: number, value: string): void
}
interface ComponentNode extends DefaultFrameMixin {
readonly type: "COMPONENT"
clone(): ComponentNode
createInstance(): InstanceNode
description: string
readonly remote: boolean
readonly key: string // The key to use with "importComponentByKeyAsync"
}
interface InstanceNode extends DefaultFrameMixin {
readonly type: "INSTANCE"
clone(): InstanceNode
masterComponent: ComponentNode
}
interface BooleanOperationNode extends DefaultShapeMixin, ChildrenMixin, CornerMixin {
readonly type: "BOOLEAN_OPERATION"
clone(): BooleanOperationNode
booleanOperation: "UNION" | "INTERSECT" | "SUBTRACT" | "EXCLUDE"
}
type BaseNode =
DocumentNode |
PageNode |
SceneNode
type SceneNode =
SliceNode |
FrameNode |
GroupNode |
ComponentNode |
InstanceNode |
BooleanOperationNode |
VectorNode |
StarNode |
LineNode |
EllipseNode |
PolygonNode |
RectangleNode |
TextNode
type NodeType =
"DOCUMENT" |
"PAGE" |
"SLICE" |
"FRAME" |
"GROUP" |
"COMPONENT" |
"INSTANCE" |
"BOOLEAN_OPERATION" |
"VECTOR" |
"STAR" |
"LINE" |
"ELLIPSE" |
"POLYGON" |
"RECTANGLE" |
"TEXT"
////////////////////////////////////////////////////////////////////////////////
// Styles
type StyleType = "PAINT" | "TEXT" | "EFFECT" | "GRID"
interface BaseStyle {
readonly id: string
readonly type: StyleType
name: string
description: string
remote: boolean
readonly key: string // The key to use with "importStyleByKeyAsync"
remove(): void
}
interface PaintStyle extends BaseStyle {
type: "PAINT"
paints: ReadonlyArray<Paint>
}
interface TextStyle extends BaseStyle {
type: "TEXT"
fontSize: number
textDecoration: TextDecoration
fontName: FontName
letterSpacing: LetterSpacing
lineHeight: LineHeight
paragraphIndent: number
paragraphSpacing: number
textCase: TextCase
}
interface EffectStyle extends BaseStyle {
type: "EFFECT"
effects: ReadonlyArray<Effect>
}
interface GridStyle extends BaseStyle {
type: "GRID"
layoutGrids: ReadonlyArray<LayoutGrid>
}
////////////////////////////////////////////////////////////////////////////////
// Other
interface Image {
readonly hash: string
getBytesAsync(): Promise<Uint8Array>
}
} // declare global
export {}