mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: bound text coordinates not being updated
This commit is contained in:
parent
f4d21c26f5
commit
c8fa32780c
1 changed files with 18 additions and 6 deletions
|
@ -51,6 +51,7 @@ import {
|
||||||
measureText,
|
measureText,
|
||||||
getMaxContainerHeight,
|
getMaxContainerHeight,
|
||||||
} from "./textElement";
|
} from "./textElement";
|
||||||
|
import { LinearElementEditor } from "./linearElementEditor";
|
||||||
|
|
||||||
export const normalizeAngle = (angle: number): number => {
|
export const normalizeAngle = (angle: number): number => {
|
||||||
if (angle < 0) {
|
if (angle < 0) {
|
||||||
|
@ -634,12 +635,23 @@ export const resizeMultipleElements = (
|
||||||
|
|
||||||
// getCommonBoundingBox() uses getBoundTextElement() which returns null for
|
// getCommonBoundingBox() uses getBoundTextElement() which returns null for
|
||||||
// original elements from pointerDownState, so we have to find and add these
|
// original elements from pointerDownState, so we have to find and add these
|
||||||
// bound text elements manually
|
// bound text elements manually. Additionally, the coordinates of bound text
|
||||||
const boundTextElements = targetElements
|
// elements aren't always up to date.
|
||||||
.map(({ orig }) => getBoundTextElementId(orig))
|
const boundTextElements = targetElements.reduce((acc, { orig }) => {
|
||||||
.filter((id): id is string => typeof id === "string")
|
if (!isLinearElement(orig)) {
|
||||||
.map((id) => pointerDownState.originalElements.get(id) ?? null)
|
return acc;
|
||||||
.filter(isBoundToContainer);
|
}
|
||||||
|
const textId = getBoundTextElementId(orig);
|
||||||
|
if (!textId) {
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
const text = pointerDownState.originalElements.get(textId) ?? null;
|
||||||
|
if (!isBoundToContainer(text)) {
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
const xy = LinearElementEditor.getBoundTextElementPosition(orig, text);
|
||||||
|
return [...acc, { ...text, ...xy }];
|
||||||
|
}, [] as ExcalidrawTextElementWithContainer[]);
|
||||||
|
|
||||||
const { minX, minY, maxX, maxY, midX, midY } = getCommonBoundingBox(
|
const { minX, minY, maxX, maxY, midX, midY } = getCommonBoundingBox(
|
||||||
targetElements.map(({ orig }) => orig).concat(boundTextElements),
|
targetElements.map(({ orig }) => orig).concat(boundTextElements),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue