From 6dfe4dd5825bdd815ec7ca0441ce0f032f8c8666 Mon Sep 17 00:00:00 2001 From: Jordi Sala Morales Date: Tue, 9 Apr 2024 18:44:29 +0000 Subject: [PATCH] start adding options --- src/ui/converters/createPenpotText.ts | 2 +- src/ui/lib/penpot.d.ts | 5 +-- src/ui/lib/types/baseOptions.d.ts | 6 ++++ src/ui/lib/types/textOptions.d.ts | 49 +++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 src/ui/lib/types/baseOptions.d.ts create mode 100644 src/ui/lib/types/textOptions.d.ts diff --git a/src/ui/converters/createPenpotText.ts b/src/ui/converters/createPenpotText.ts index c83e555..ea65659 100644 --- a/src/ui/converters/createPenpotText.ts +++ b/src/ui/converters/createPenpotText.ts @@ -54,7 +54,7 @@ export const createPenpotText = ( type: 'paragraph-set', children: [ { - lineHeight: node.lineHeight, + // lineHeight: node.lineHeight, fontStyle: 'normal', children: children, textTransform: translateTextTransform(node), diff --git a/src/ui/lib/penpot.d.ts b/src/ui/lib/penpot.d.ts index c60a165..23775b8 100644 --- a/src/ui/lib/penpot.d.ts +++ b/src/ui/lib/penpot.d.ts @@ -1,9 +1,10 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ +import { TextOptions } from './types/textOptions'; export interface PenpotFile { asMap(): any; export(): void; - addPage(name: string): void; + addPage(name: string, options?: object): void; closePage(): void; addArtboard(artboard: any): void; closeArtboard(): void; @@ -11,7 +12,7 @@ export interface PenpotFile { closeGroup(): void; createRect(rect: any): void; createCircle(circle: any): void; - createText(text: any): void; + createText(options: TextOptions): void; createImage(image: any): void; } diff --git a/src/ui/lib/types/baseOptions.d.ts b/src/ui/lib/types/baseOptions.d.ts new file mode 100644 index 0000000..053bb7d --- /dev/null +++ b/src/ui/lib/types/baseOptions.d.ts @@ -0,0 +1,6 @@ +export type BaseOptions = { + x: number; + y: number; + width: number; + height: number; +}; diff --git a/src/ui/lib/types/textOptions.d.ts b/src/ui/lib/types/textOptions.d.ts new file mode 100644 index 0000000..af38a96 --- /dev/null +++ b/src/ui/lib/types/textOptions.d.ts @@ -0,0 +1,49 @@ +import { BaseOptions } from './baseOptions'; + +export type TextOptions = BaseOptions & { + name: string; + rotation: number; + type: symbol; + content: { + type: 'root'; + key?: string; + children?: { + type: 'paragraph-set'; + key?: string; + children: { + type: 'paragraph'; + key?: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + fills?: any; + fontFamily?: string; + fontSize?: string; + fontStyle?: string; + fontWeight?: string; + direction?: string; + textDecoration?: string; + textTransform?: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + typographyRefId?: any; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + typographyRefFile?: any; + children: { + text: string; + key?: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + fills?: any; + fontFamily?: string; + fontSize?: string; + fontStyle?: string; + fontWeight?: string; + direction?: string; + textDecoration?: string; + textTransform?: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + typographyRefId?: any; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + typographyRefFile?: any; + }[]; + }[]; + }[]; + }; +};