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",