fix: resize sometimes throwing on missing null-checks (#6013)
This commit is contained in:
parent
95d669390f
commit
539505affd
@ -162,11 +162,12 @@ const rotateSingleElement = (
|
|||||||
|
|
||||||
mutateElement(element, { angle });
|
mutateElement(element, { angle });
|
||||||
if (boundTextElementId) {
|
if (boundTextElementId) {
|
||||||
const textElement = Scene.getScene(element)!.getElement(
|
const textElement =
|
||||||
|
Scene.getScene(element)?.getElement<ExcalidrawTextElementWithContainer>(
|
||||||
boundTextElementId,
|
boundTextElementId,
|
||||||
) as ExcalidrawTextElementWithContainer;
|
);
|
||||||
|
|
||||||
if (!isArrowElement(element)) {
|
if (textElement && !isArrowElement(element)) {
|
||||||
mutateElement(textElement, { angle });
|
mutateElement(textElement, { angle });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -201,9 +202,11 @@ const measureFontSizeFromWH = (
|
|||||||
|
|
||||||
const hasContainer = isBoundToContainer(element);
|
const hasContainer = isBoundToContainer(element);
|
||||||
if (hasContainer) {
|
if (hasContainer) {
|
||||||
const container = getContainerElement(element)!;
|
const container = getContainerElement(element);
|
||||||
|
if (container) {
|
||||||
width = getMaxContainerWidth(container);
|
width = getMaxContainerWidth(container);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
const nextFontSize = element.fontSize * (nextWidth / width);
|
const nextFontSize = element.fontSize * (nextWidth / width);
|
||||||
if (nextFontSize < MIN_FONT_SIZE) {
|
if (nextFontSize < MIN_FONT_SIZE) {
|
||||||
return null;
|
return null;
|
||||||
@ -211,7 +214,7 @@ const measureFontSizeFromWH = (
|
|||||||
const metrics = measureText(
|
const metrics = measureText(
|
||||||
element.text,
|
element.text,
|
||||||
getFontString({ fontSize: nextFontSize, fontFamily: element.fontFamily }),
|
getFontString({ fontSize: nextFontSize, fontFamily: element.fontFamily }),
|
||||||
hasContainer ? width : null,
|
element.containerId ? width : null,
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
size: nextFontSize,
|
size: nextFontSize,
|
||||||
@ -765,10 +768,11 @@ const rotateMultipleElements = (
|
|||||||
});
|
});
|
||||||
const boundTextElementId = getBoundTextElementId(element);
|
const boundTextElementId = getBoundTextElementId(element);
|
||||||
if (boundTextElementId) {
|
if (boundTextElementId) {
|
||||||
const textElement = Scene.getScene(element)!.getElement(
|
const textElement =
|
||||||
|
Scene.getScene(element)?.getElement<ExcalidrawTextElementWithContainer>(
|
||||||
boundTextElementId,
|
boundTextElementId,
|
||||||
) as ExcalidrawTextElementWithContainer;
|
);
|
||||||
if (!isArrowElement(element)) {
|
if (textElement && !isArrowElement(element)) {
|
||||||
mutateElement(textElement, {
|
mutateElement(textElement, {
|
||||||
x: textElement.x + (rotatedCX - cx),
|
x: textElement.x + (rotatedCX - cx),
|
||||||
y: textElement.y + (rotatedCY - cy),
|
y: textElement.y + (rotatedCY - cy),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user