|
|
|
@ -526,6 +526,44 @@ describe("textWysiwyg", () => {
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should compute the container height correctly and not throw error when height is updated while editing the text", async () => {
|
|
|
|
|
const diamond = API.createElement({
|
|
|
|
|
type: "diamond",
|
|
|
|
|
x: 10,
|
|
|
|
|
y: 20,
|
|
|
|
|
width: 90,
|
|
|
|
|
height: 75,
|
|
|
|
|
});
|
|
|
|
|
h.elements = [diamond];
|
|
|
|
|
|
|
|
|
|
expect(h.elements.length).toBe(1);
|
|
|
|
|
expect(h.elements[0].id).toBe(diamond.id);
|
|
|
|
|
|
|
|
|
|
API.setSelectedElements([diamond]);
|
|
|
|
|
Keyboard.keyPress(KEYS.ENTER);
|
|
|
|
|
|
|
|
|
|
const editor = document.querySelector(
|
|
|
|
|
".excalidraw-textEditorContainer > textarea",
|
|
|
|
|
) as HTMLTextAreaElement;
|
|
|
|
|
|
|
|
|
|
await new Promise((r) => setTimeout(r, 0));
|
|
|
|
|
const value = new Array(1000).fill("1").join("\n");
|
|
|
|
|
|
|
|
|
|
// Pasting large text to simulate height increase
|
|
|
|
|
expect(() =>
|
|
|
|
|
fireEvent.input(editor, { target: { value } }),
|
|
|
|
|
).not.toThrow();
|
|
|
|
|
|
|
|
|
|
expect(diamond.height).toBe(50020);
|
|
|
|
|
|
|
|
|
|
// Clearing text to simulate height decrease
|
|
|
|
|
expect(() =>
|
|
|
|
|
fireEvent.input(editor, { target: { value: "" } }),
|
|
|
|
|
).not.toThrow();
|
|
|
|
|
|
|
|
|
|
expect(diamond.height).toBe(70);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should bind text to container when double clicked on center of transparent container", async () => {
|
|
|
|
|
const rectangle = API.createElement({
|
|
|
|
|
type: "rectangle",
|
|
|
|
@ -1181,9 +1219,7 @@ describe("textWysiwyg", () => {
|
|
|
|
|
expect(
|
|
|
|
|
(h.elements[1] as ExcalidrawTextElementWithContainer).fontSize,
|
|
|
|
|
).toEqual(36);
|
|
|
|
|
expect(getOriginalContainerHeightFromCache(rectangle.id)).toBe(
|
|
|
|
|
96.39999999999999,
|
|
|
|
|
);
|
|
|
|
|
expect(getOriginalContainerHeightFromCache(rectangle.id)).toBe(97);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should update line height when font family updated", async () => {
|
|
|
|
|