fix: update elbow arrow on font size change #8798 (#9002)

pull/8719/merge
Alplune 6 days ago committed by GitHub
parent 49f1276ef2
commit b8da5065fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -89,6 +89,7 @@ import type {
FontFamilyValues, FontFamilyValues,
TextAlign, TextAlign,
VerticalAlign, VerticalAlign,
NonDeletedSceneElementsMap,
} from "../element/types"; } from "../element/types";
import { getLanguage, t } from "../i18n"; import { getLanguage, t } from "../i18n";
import { KEYS } from "../keys"; import { KEYS } from "../keys";
@ -115,6 +116,7 @@ import {
bindPointToSnapToElementOutline, bindPointToSnapToElementOutline,
calculateFixedPointForElbowArrowBinding, calculateFixedPointForElbowArrowBinding,
getHoveredElementForBinding, getHoveredElementForBinding,
updateBoundElements,
} from "../element/binding"; } from "../element/binding";
import { LinearElementEditor } from "../element/linearElementEditor"; import { LinearElementEditor } from "../element/linearElementEditor";
import type { LocalPoint } from "../../math"; import type { LocalPoint } from "../../math";
@ -218,33 +220,47 @@ const changeFontSize = (
) => { ) => {
const newFontSizes = new Set<number>(); const newFontSizes = new Set<number>();
return { const updatedElements = changeProperty(
elements: changeProperty( elements,
elements, appState,
appState, (oldElement) => {
(oldElement) => { if (isTextElement(oldElement)) {
if (isTextElement(oldElement)) { const newFontSize = getNewFontSize(oldElement);
const newFontSize = getNewFontSize(oldElement); newFontSizes.add(newFontSize);
newFontSizes.add(newFontSize);
let newElement: ExcalidrawTextElement = newElementWith(oldElement, {
let newElement: ExcalidrawTextElement = newElementWith(oldElement, { fontSize: newFontSize,
fontSize: newFontSize, });
}); redrawTextBoundingBox(
redrawTextBoundingBox( newElement,
newElement, app.scene.getContainerElement(oldElement),
app.scene.getContainerElement(oldElement), app.scene.getNonDeletedElementsMap(),
app.scene.getNonDeletedElementsMap(), );
);
newElement = offsetElementAfterFontResize(oldElement, newElement); newElement = offsetElementAfterFontResize(oldElement, newElement);
return newElement; return newElement;
} }
return oldElement;
},
true,
);
return oldElement; // Update arrow elements after text elements have been updated
}, const updatedElementsMap = arrayToMap(updatedElements);
true, getSelectedElements(elements, appState, {
), includeBoundTextElement: true,
}).forEach((element) => {
if (isTextElement(element)) {
updateBoundElements(
element,
updatedElementsMap as NonDeletedSceneElementsMap,
);
}
});
return {
elements: updatedElements,
appState: { appState: {
...appState, ...appState,
// update state only if we've set all select text elements to // update state only if we've set all select text elements to

Loading…
Cancel
Save