Browse Source

fix: don't allow binding text to images (#6693)

pull/6696/head
Aakansha Doshi 3 years ago committed by GitHub
parent
commit
7f7128ec09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      src/element/textElement.ts
  2. 18
      src/element/typeChecks.test.ts
  3. 1
      src/element/typeChecks.ts
  4. 1
      src/element/types.ts

1
src/element/textElement.ts

@ -862,7 +862,6 @@ const VALID_CONTAINER_TYPES = new Set([ @@ -862,7 +862,6 @@ const VALID_CONTAINER_TYPES = new Set([
"rectangle",
"ellipse",
"diamond",
"image",
"arrow",
]);

18
src/element/typeChecks.test.ts

@ -30,15 +30,6 @@ describe("Test TypeChecks", () => { @@ -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", () => { @@ -62,5 +53,14 @@ describe("Test TypeChecks", () => {
),
).toBeFalsy();
});
expect(
hasBoundTextElement(
API.createElement({
type: "image",
boundElements: [{ type: "text", id: "text-id" }],
}),
),
).toBeFalsy();
});
});

1
src/element/typeChecks.ts

@ -126,7 +126,6 @@ export const isTextBindableContainer = ( @@ -126,7 +126,6 @@ export const isTextBindableContainer = (
(element.type === "rectangle" ||
element.type === "diamond" ||
element.type === "ellipse" ||
element.type === "image" ||
isArrowElement(element))
);
};

1
src/element/types.ts

@ -162,7 +162,6 @@ export type ExcalidrawTextContainer = @@ -162,7 +162,6 @@ export type ExcalidrawTextContainer =
| ExcalidrawRectangleElement
| ExcalidrawDiamondElement
| ExcalidrawEllipseElement
| ExcalidrawImageElement
| ExcalidrawArrowElement;
export type ExcalidrawTextElementWithContainer = {

Loading…
Cancel
Save