fix: cleanup redrawTextBoundingBox (#6518)
* chore: cleanup redrawTextBoundingBox * fix
This commit is contained in:
parent
1e9943323a
commit
dae81c0a2c
@ -83,35 +83,25 @@ export const redrawTextBoundingBox = (
|
|||||||
boundTextUpdates.baseline = metrics.baseline;
|
boundTextUpdates.baseline = metrics.baseline;
|
||||||
|
|
||||||
if (container) {
|
if (container) {
|
||||||
if (isArrowElement(container)) {
|
const containerDims = getContainerDims(container);
|
||||||
const centerX = textElement.x + textElement.width / 2;
|
const maxContainerHeight = getMaxContainerHeight(container);
|
||||||
const centerY = textElement.y + textElement.height / 2;
|
|
||||||
const diffWidth = metrics.width - textElement.width;
|
|
||||||
const diffHeight = metrics.height - textElement.height;
|
|
||||||
boundTextUpdates.x = centerY - (textElement.height + diffHeight) / 2;
|
|
||||||
boundTextUpdates.y = centerX - (textElement.width + diffWidth) / 2;
|
|
||||||
} else {
|
|
||||||
const containerDims = getContainerDims(container);
|
|
||||||
let maxContainerHeight = getMaxContainerHeight(container);
|
|
||||||
|
|
||||||
let nextHeight = containerDims.height;
|
let nextHeight = containerDims.height;
|
||||||
if (metrics.height > maxContainerHeight) {
|
if (metrics.height > maxContainerHeight) {
|
||||||
nextHeight = computeContainerDimensionForBoundText(
|
nextHeight = computeContainerDimensionForBoundText(
|
||||||
metrics.height,
|
metrics.height,
|
||||||
container.type,
|
container.type,
|
||||||
);
|
);
|
||||||
mutateElement(container, { height: nextHeight });
|
mutateElement(container, { height: nextHeight });
|
||||||
maxContainerHeight = getMaxContainerHeight(container);
|
updateOriginalContainerCache(container.id, nextHeight);
|
||||||
updateOriginalContainerCache(container.id, nextHeight);
|
|
||||||
}
|
|
||||||
const updatedTextElement = {
|
|
||||||
...textElement,
|
|
||||||
...boundTextUpdates,
|
|
||||||
} as ExcalidrawTextElementWithContainer;
|
|
||||||
const { x, y } = computeBoundTextPosition(container, updatedTextElement);
|
|
||||||
boundTextUpdates.x = x;
|
|
||||||
boundTextUpdates.y = y;
|
|
||||||
}
|
}
|
||||||
|
const updatedTextElement = {
|
||||||
|
...textElement,
|
||||||
|
...boundTextUpdates,
|
||||||
|
} as ExcalidrawTextElementWithContainer;
|
||||||
|
const { x, y } = computeBoundTextPosition(container, updatedTextElement);
|
||||||
|
boundTextUpdates.x = x;
|
||||||
|
boundTextUpdates.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutateElement(textElement, boundTextUpdates);
|
mutateElement(textElement, boundTextUpdates);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user