fix: Bound arrow elements for distribute and wyswig updates (#10702)

* fix: update distributeElements to updateBoundElements

Co-authored-by: Anvi Kudaraya <anvikudaraya417@gmail.com>

* fix: apply updateBoundElements when bound text extends past container height

Co-authored-by: Anvi Kudaraya <anvikudaraya417@gmail.com>

---------

Co-authored-by: Anvi Kudaraya <anvikudaraya417@gmail.com>
This commit is contained in:
Christopher Tangonan
2026-01-26 09:52:13 -08:00
committed by GitHub
parent 60759d314d
commit 28691e14b1
3 changed files with 24 additions and 9 deletions
+20 -9
View File
@@ -1,10 +1,12 @@
import type { AppState } from "@excalidraw/excalidraw/types";
import { updateBoundElements } from "./binding";
import { getCommonBoundingBox } from "./bounds";
import { newElementWith } from "./mutateElement";
import { getSelectedElementsByGroup } from "./groups";
import type { Scene } from "./Scene";
import type { ElementsMap, ExcalidrawElement } from "./types";
export interface Distribution {
@@ -17,6 +19,7 @@ export const distributeElements = (
elementsMap: ElementsMap,
distribution: Distribution,
appState: Readonly<AppState>,
scene: Scene,
): ExcalidrawElement[] => {
const [start, mid, end, extent] =
distribution.axis === "x"
@@ -66,12 +69,16 @@ export const distributeElements = (
translation[distribution.axis] = pos - box[mid];
}
return group.map((element) =>
newElementWith(element, {
return group.map((element) => {
const updatedElement = scene.mutateElement(element, {
x: element.x + translation.x,
y: element.y + translation.y,
}),
);
});
updateBoundElements(element, scene, {
simultaneouslyUpdated: group,
});
return updatedElement;
});
});
}
@@ -90,11 +97,15 @@ export const distributeElements = (
pos += step;
pos += box[extent];
return group.map((element) =>
newElementWith(element, {
return group.map((element) => {
const updatedElement = scene.mutateElement(element, {
x: element.x + translation.x,
y: element.y + translation.y,
}),
);
});
updateBoundElements(element, scene, {
simultaneouslyUpdated: group,
});
return updatedElement;
});
});
};
@@ -58,6 +58,7 @@ const distributeSelectedElements = (
app.scene.getNonDeletedElementsMap(),
distribution,
appState,
app.scene,
);
const updatedElementsMap = arrayToMap(updatedElements);
@@ -14,6 +14,7 @@ import {
import {
originalContainerCache,
updateBoundElements,
updateOriginalContainerCache,
} from "@excalidraw/element";
@@ -208,6 +209,7 @@ export const textWysiwyg = ({
);
app.scene.mutateElement(container, { height: targetContainerHeight });
updateBoundElements(container, app.scene);
return;
} else if (
// autoshrink container height until original container height
@@ -221,6 +223,7 @@ export const textWysiwyg = ({
container.type,
);
app.scene.mutateElement(container, { height: targetContainerHeight });
updateBoundElements(container, app.scene);
} else {
const { x, y } = computeBoundTextPosition(
container,