From 7f7128ec09906882076a57a792eb515403f2653d Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Mon, 19 Jun 2023 13:47:28 +0530 Subject: [PATCH] fix: don't allow binding text to images (#6693) --- src/element/textElement.ts | 1 - src/element/typeChecks.test.ts | 18 +++++++++--------- src/element/typeChecks.ts | 1 - src/element/types.ts | 1 - 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/element/textElement.ts b/src/element/textElement.ts index 3956393b..76de2c88 100644 --- a/src/element/textElement.ts +++ b/src/element/textElement.ts @@ -862,7 +862,6 @@ const VALID_CONTAINER_TYPES = new Set([ "rectangle", "ellipse", "diamond", - "image", "arrow", ]); diff --git a/src/element/typeChecks.test.ts b/src/element/typeChecks.test.ts index ab04c29b..60eb9e27 100644 --- a/src/element/typeChecks.test.ts +++ b/src/element/typeChecks.test.ts @@ -30,15 +30,6 @@ describe("Test TypeChecks", () => { }), ), ).toBeTruthy(); - - expect( - hasBoundTextElement( - API.createElement({ - type: "image", - boundElements: [{ type: "text", id: "text-id" }], - }), - ), - ).toBeTruthy(); }); it("should return false for text bindable containers without bound text", () => { @@ -62,5 +53,14 @@ describe("Test TypeChecks", () => { ), ).toBeFalsy(); }); + + expect( + hasBoundTextElement( + API.createElement({ + type: "image", + boundElements: [{ type: "text", id: "text-id" }], + }), + ), + ).toBeFalsy(); }); }); diff --git a/src/element/typeChecks.ts b/src/element/typeChecks.ts index 302e9d37..d255a9a2 100644 --- a/src/element/typeChecks.ts +++ b/src/element/typeChecks.ts @@ -126,7 +126,6 @@ export const isTextBindableContainer = ( (element.type === "rectangle" || element.type === "diamond" || element.type === "ellipse" || - element.type === "image" || isArrowElement(element)) ); }; diff --git a/src/element/types.ts b/src/element/types.ts index ad461016..a8c49e1a 100644 --- a/src/element/types.ts +++ b/src/element/types.ts @@ -162,7 +162,6 @@ export type ExcalidrawTextContainer = | ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement - | ExcalidrawImageElement | ExcalidrawArrowElement; export type ExcalidrawTextElementWithContainer = {