From 2a246e448e302ed0eb8497be054959b659381b2e Mon Sep 17 00:00:00 2001 From: Jordi Sala Morales Date: Wed, 10 Apr 2024 11:08:55 +0000 Subject: [PATCH] add image --- src/ui/converters/createPenpotImage.ts | 1 + src/ui/lib/penpot.d.ts | 4 ++-- src/ui/lib/types/image/imageAttributes.d.ts | 14 ++++++++++++++ src/ui/lib/types/image/imageShape.d.ts | 4 ++++ 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 src/ui/lib/types/image/imageAttributes.d.ts create mode 100644 src/ui/lib/types/image/imageShape.d.ts diff --git a/src/ui/converters/createPenpotImage.ts b/src/ui/converters/createPenpotImage.ts index 35e4307..34351b8 100644 --- a/src/ui/converters/createPenpotImage.ts +++ b/src/ui/converters/createPenpotImage.ts @@ -7,6 +7,7 @@ export const createPenpotImage = ( baseY: number ) => { file.penpotFile.createImage({ + type: Symbol.for('image'), name: node.name, x: node.x + baseX, y: node.y + baseY, diff --git a/src/ui/lib/penpot.d.ts b/src/ui/lib/penpot.d.ts index f15fef2..9d3c131 100644 --- a/src/ui/lib/penpot.d.ts +++ b/src/ui/lib/penpot.d.ts @@ -1,4 +1,5 @@ import { CircleShape } from './types/circle/circleShape'; +import { ImageShape } from './types/image/imageShape'; import { RectShape } from './types/rect/rectShape'; import { TextShape } from './types/text/textShape'; @@ -17,8 +18,7 @@ export interface PenpotFile { createRect(rect: RectShape): void; createCircle(circle: CircleShape): void; createText(options: TextShape): void; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - createImage(image: any): void; + createImage(image: ImageShape): void; } export function createFile(name: string): PenpotFile; diff --git a/src/ui/lib/types/image/imageAttributes.d.ts b/src/ui/lib/types/image/imageAttributes.d.ts new file mode 100644 index 0000000..1fd9897 --- /dev/null +++ b/src/ui/lib/types/image/imageAttributes.d.ts @@ -0,0 +1,14 @@ +export type ImageAttributes = { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + id?: any; + type: symbol; + // TODO: Investigate where it comes from + dataUri?: string; + metadata: { + width: number; + height: number; + mtype?: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + id?: any; + }; +}; diff --git a/src/ui/lib/types/image/imageShape.d.ts b/src/ui/lib/types/image/imageShape.d.ts new file mode 100644 index 0000000..a99dc5c --- /dev/null +++ b/src/ui/lib/types/image/imageShape.d.ts @@ -0,0 +1,4 @@ +import { Shape } from '../shape'; +import { ImageAttributes } from './imageAttributes'; + +export type ImageShape = Shape & ImageAttributes;