fix: support resizing multiple bound text containers (#4824)
This commit is contained in:
parent
e0ca689759
commit
f224e4d596
@ -1,4 +1,4 @@
|
|||||||
import { SHIFT_LOCKING_ANGLE } from "../constants";
|
import { BOUND_TEXT_PADDING, SHIFT_LOCKING_ANGLE } from "../constants";
|
||||||
import { rescalePoints } from "../points";
|
import { rescalePoints } from "../points";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -141,7 +141,6 @@ export const transformElements = (
|
|||||||
pointerX,
|
pointerX,
|
||||||
pointerY,
|
pointerY,
|
||||||
);
|
);
|
||||||
handleBindTextResize(selectedElements, transformHandleType);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -674,7 +673,25 @@ const resizeMultipleElements = (
|
|||||||
}
|
}
|
||||||
const width = element.width * scale;
|
const width = element.width * scale;
|
||||||
const height = element.height * scale;
|
const height = element.height * scale;
|
||||||
|
const boundTextElement = getBoundTextElement(element);
|
||||||
let font: { fontSize?: number; baseline?: number } = {};
|
let font: { fontSize?: number; baseline?: number } = {};
|
||||||
|
|
||||||
|
if (boundTextElement) {
|
||||||
|
const nextFont = measureFontSizeFromWH(
|
||||||
|
boundTextElement,
|
||||||
|
width - BOUND_TEXT_PADDING * 2,
|
||||||
|
height - BOUND_TEXT_PADDING * 2,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (nextFont === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
font = {
|
||||||
|
fontSize: nextFont.size,
|
||||||
|
baseline: nextFont.baseline,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (isTextElement(element)) {
|
if (isTextElement(element)) {
|
||||||
const nextFont = measureFontSizeFromWH(element, width, height);
|
const nextFont = measureFontSizeFromWH(element, width, height);
|
||||||
if (nextFont === null) {
|
if (nextFont === null) {
|
||||||
@ -718,6 +735,15 @@ const resizeMultipleElements = (
|
|||||||
if (updates) {
|
if (updates) {
|
||||||
elements.forEach((element, index) => {
|
elements.forEach((element, index) => {
|
||||||
mutateElement(element, updates[index]);
|
mutateElement(element, updates[index]);
|
||||||
|
const boundTextElement = getBoundTextElement(element);
|
||||||
|
|
||||||
|
if (boundTextElement) {
|
||||||
|
mutateElement(boundTextElement, {
|
||||||
|
fontSize: updates[index].fontSize,
|
||||||
|
baseline: updates[index].baseline,
|
||||||
|
});
|
||||||
|
handleBindTextResize([element], transformHandleType);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user