From 5b458288e7b0a955fb552b682c08ee5a0722b141 Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Fri, 26 May 2023 13:00:22 +0530 Subject: [PATCH] fix creation of regular text --- src/data/transform.ts | 2 ++ src/data/types.ts | 7 +++++-- src/packages/excalidraw/example/App.tsx | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/data/transform.ts b/src/data/transform.ts index 2d257525b4..ce0f63eb71 100644 --- a/src/data/transform.ts +++ b/src/data/transform.ts @@ -362,6 +362,8 @@ export const convertToExcalidrawElements = ( excalidrawElement = { width: metrics.width, height: metrics.height, + fontFamily, + fontSize, ...elementWithid, }; diff --git a/src/data/types.ts b/src/data/types.ts index a4c463f381..3e6599fa27 100644 --- a/src/data/types.ts +++ b/src/data/types.ts @@ -46,9 +46,10 @@ export interface ImportedDataState { source?: string; elements?: | readonly ( + | ExcalidrawElement | ({ - type: Exclude; - id?: ExcalidrawElement["id"]; + type: Exclude; + id?: ExcalidrawGenericElement["id"]; label?: { text: string; fontSize?: number; @@ -60,6 +61,8 @@ export interface ImportedDataState { | ({ type: "text"; text: string; + x: number; + y: number; id?: ExcalidrawTextElement["id"]; } & Partial) | ({ diff --git a/src/packages/excalidraw/example/App.tsx b/src/packages/excalidraw/example/App.tsx index 20c99d8e1b..decd47fef7 100644 --- a/src/packages/excalidraw/example/App.tsx +++ b/src/packages/excalidraw/example/App.tsx @@ -212,6 +212,12 @@ export default function App({ appTitle, useCustom, customArgs }: AppProps) { start: { type: "rectangle", id: "rect-1" }, end: { type: "ellipse" }, }, + { + type: "text", + x: 300, + y: 100, + text: "HELLO WORLD!", + }, ], null, ),