Skip to content

Commit

Permalink
update typings for annotations, measurements, et al
Browse files Browse the repository at this point in the history
  • Loading branch information
jefflee-figma committed Jan 25, 2024
1 parent b6010a1 commit 1742ac4
Showing 1 changed file with 105 additions and 8 deletions.
113 changes: 105 additions & 8 deletions plugin-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,7 @@ interface BaseFrameMixin
ExportMixin,
IndividualStrokesMixin,
AutoLayoutMixin,
AnnotationsMixin,
DevStatusMixin {
readonly detachedInfo: DetachedInfo | null
layoutGrids: ReadonlyArray<LayoutGrid>
Expand All @@ -1712,6 +1713,87 @@ interface MinimalBlendMixin {
opacity: number
blendMode: BlendMode
}
interface Annotation {
readonly label?: string
readonly properties?: ReadonlyArray<AnnotationProperty>
}
interface AnnotationProperty {
readonly type: AnnotationPropertyType
}
declare type AnnotationPropertyType =
| 'width'
| 'height'
| 'maxWidth'
| 'minWidth'
| 'maxHeight'
| 'minHeight'
| 'fills'
| 'strokes'
| 'effects'
| 'strokeWeight'
| 'cornerRadius'
| 'textStyleId'
| 'textAlignHorizontal'
| 'fontFamily'
| 'fontSize'
| 'fontWeight'
| 'lineHeight'
| 'letterSpacing'
| 'itemSpacing'
| 'padding'
| 'layoutMode'
| 'alignItems'
| 'opacity'
| 'mainComponent'
interface AnnotationsMixin {
annotations: ReadonlyArray<Annotation>
}
interface Measurement {
id: string
start: {
node: SceneNode
side: MeasurementSide
}
end: {
node: SceneNode
side: MeasurementSide
}
offset: MeasurementOffset
}
declare type MeasurementSide = 'TOP' | 'RIGHT' | 'BOTTOM' | 'LEFT'
declare type MeasurementOffset =
| {
type: 'INNER'
relative: number
}
| {
type: 'OUTER'
fixed: number
}
interface MeasurementsMixin {
getMeasurements(): Measurement[]
getMeasurementsForNode(node: SceneNode): Measurement[]
addMeasurement(
start: {
node: SceneNode
side: MeasurementSide
},
end: {
node: SceneNode
side: MeasurementSide
},
options?: {
offset?: MeasurementOffset
},
): Measurement
editMeasurement(
id: string,
newValue: {
offset: MeasurementOffset
},
): Measurement
deleteMeasurement(id: string): void
}
interface VariantMixin {
readonly variantProperties: {
[property: string]: string
Expand Down Expand Up @@ -1832,7 +1914,12 @@ interface ExplicitVariableModesMixin {
clearExplicitVariableModeForCollection(collectionId: string): void
setExplicitVariableModeForCollection(collectionId: string, modeId: string): void
}
interface PageNode extends BaseNodeMixin, ChildrenMixin, ExportMixin, ExplicitVariableModesMixin {
interface PageNode
extends BaseNodeMixin,
ChildrenMixin,
ExportMixin,
ExplicitVariableModesMixin,
MeasurementsMixin {
readonly type: 'PAGE'
clone(): PageNode
guides: ReadonlyArray<Guide>
Expand Down Expand Up @@ -1876,35 +1963,45 @@ interface RectangleNode
ConstraintMixin,
CornerMixin,
RectangleCornerMixin,
IndividualStrokesMixin {
IndividualStrokesMixin,
AnnotationsMixin {
readonly type: 'RECTANGLE'
clone(): RectangleNode
}
interface LineNode extends DefaultShapeMixin, ConstraintMixin {
interface LineNode extends DefaultShapeMixin, ConstraintMixin, AnnotationsMixin {
readonly type: 'LINE'
clone(): LineNode
}
interface EllipseNode extends DefaultShapeMixin, ConstraintMixin, CornerMixin {
interface EllipseNode extends DefaultShapeMixin, ConstraintMixin, CornerMixin, AnnotationsMixin {
readonly type: 'ELLIPSE'
clone(): EllipseNode
arcData: ArcData
}
interface PolygonNode extends DefaultShapeMixin, ConstraintMixin, CornerMixin {
interface PolygonNode extends DefaultShapeMixin, ConstraintMixin, CornerMixin, AnnotationsMixin {
readonly type: 'POLYGON'
clone(): PolygonNode
pointCount: number
}
interface StarNode extends DefaultShapeMixin, ConstraintMixin, CornerMixin {
interface StarNode extends DefaultShapeMixin, ConstraintMixin, CornerMixin, AnnotationsMixin {
readonly type: 'STAR'
clone(): StarNode
pointCount: number
innerRadius: number
}
interface VectorNode extends DefaultShapeMixin, ConstraintMixin, CornerMixin, VectorLikeMixin {
interface VectorNode
extends DefaultShapeMixin,
ConstraintMixin,
CornerMixin,
VectorLikeMixin,
AnnotationsMixin {
readonly type: 'VECTOR'
clone(): VectorNode
}
interface TextNode extends DefaultShapeMixin, ConstraintMixin, NonResizableTextMixin {
interface TextNode
extends DefaultShapeMixin,
ConstraintMixin,
NonResizableTextMixin,
AnnotationsMixin {
readonly type: 'TEXT'
clone(): TextNode
textAlignHorizontal: 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFIED'
Expand Down

0 comments on commit 1742ac4

Please sign in to comment.