From a6b389ca627d69d33c51e898077c6b2a22a16f61 Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Mon, 17 Jul 2023 18:18:14 +0530 Subject: [PATCH] more types --- src/data/transform.ts | 57 +++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/src/data/transform.ts b/src/data/transform.ts index 2f630ca3b1..648a4db0b1 100644 --- a/src/data/transform.ts +++ b/src/data/transform.ts @@ -129,36 +129,35 @@ export type ValidContainer = } & MarkOptional; } & ElementConstructorOpts; +export type ExcalidrawProgrammaticElement = + | Extract< + ExcalidrawElement, + | ExcalidrawSelectionElement + | ExcalidrawFreeDrawElement + | ExcalidrawFrameElement + > + | ({ + type: Extract; + x: number; + y: number; + } & Partial) + | ValidContainer + | ValidLinearElement + | ({ + type: "text"; + text: string; + x: number; + y: number; + id?: ExcalidrawTextElement["id"]; + } & Partial) + | ({ + type: Extract; + x: number; + y: number; + } & Partial); + export interface ExcalidrawProgrammaticAPI { - elements?: - | readonly ( - | Extract< - ExcalidrawElement, - | ExcalidrawSelectionElement - | ExcalidrawFreeDrawElement - | ExcalidrawFrameElement - > - | ({ - type: Extract; - x: number; - y: number; - } & Partial) - | ValidContainer - | ValidLinearElement - | ({ - type: "text"; - text: string; - x: number; - y: number; - id?: ExcalidrawTextElement["id"]; - } & Partial) - | ({ - type: Extract; - x: number; - y: number; - } & Partial) - )[] - | null; + elements?: readonly ExcalidrawProgrammaticElement[] | null; } export const ELEMENTS_SUPPORTING_PROGRAMMATIC_API = [ "rectangle",