mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: compute container height from bound text correctly (#6273)
* fix: compute container height from bound text correctly * fix specs * Add tests
This commit is contained in:
parent
9659254fd6
commit
0e95e2b386
3 changed files with 78 additions and 4 deletions
|
@ -182,3 +182,73 @@ describe("paste text as a single element", () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Paste bound text container", () => {
|
||||
const container = {
|
||||
type: "ellipse",
|
||||
id: "container-id",
|
||||
x: 554.984375,
|
||||
y: 196.0234375,
|
||||
width: 166,
|
||||
height: 187.01953125,
|
||||
roundness: { type: 2 },
|
||||
boundElements: [{ type: "text", id: "text-id" }],
|
||||
};
|
||||
const textElement = {
|
||||
type: "text",
|
||||
id: "text-id",
|
||||
x: 560.51171875,
|
||||
y: 202.033203125,
|
||||
width: 154,
|
||||
height: 175,
|
||||
fontSize: 20,
|
||||
fontFamily: 1,
|
||||
text: "Excalidraw is a\nvirtual \nopensource \nwhiteboard for \nsketching \nhand-drawn like\ndiagrams",
|
||||
baseline: 168,
|
||||
textAlign: "center",
|
||||
verticalAlign: "middle",
|
||||
containerId: container.id,
|
||||
originalText:
|
||||
"Excalidraw is a virtual opensource whiteboard for sketching hand-drawn like diagrams",
|
||||
};
|
||||
|
||||
it("should fix ellipse bounding box", async () => {
|
||||
const data = JSON.stringify({
|
||||
type: "excalidraw/clipboard",
|
||||
elements: [container, textElement],
|
||||
});
|
||||
setClipboardText(data);
|
||||
pasteWithCtrlCmdShiftV();
|
||||
|
||||
await waitFor(async () => {
|
||||
await sleep(1);
|
||||
expect(h.elements.length).toEqual(2);
|
||||
const container = h.elements[0];
|
||||
expect(container.height).toBe(354);
|
||||
expect(container.width).toBe(166);
|
||||
});
|
||||
});
|
||||
|
||||
it("should fix diamond bounding box", async () => {
|
||||
const data = JSON.stringify({
|
||||
type: "excalidraw/clipboard",
|
||||
elements: [
|
||||
{
|
||||
...container,
|
||||
type: "diamond",
|
||||
},
|
||||
textElement,
|
||||
],
|
||||
});
|
||||
setClipboardText(data);
|
||||
pasteWithCtrlCmdShiftV();
|
||||
|
||||
await waitFor(async () => {
|
||||
await sleep(1);
|
||||
expect(h.elements.length).toEqual(2);
|
||||
const container = h.elements[0];
|
||||
expect(container.height).toBe(740);
|
||||
expect(container.width).toBe(166);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue