Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update typings for annotations, measurements, et al #272

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading