fix(element): unbind unreachable skeleton arrow ends, rebind the rest

`convertToExcalidrawElements` binds skeleton arrows to their `start`/`end`
elements while it is still creating elements, and the placement pass
(e0f198c15) then places every bound end where its binding puts it. Two
kinds of bindings made at conversion time are wrong, and placing the
arrows exposes them.

1. Ends given beyond the binding area of their element

   A layout engine (e.g. mermaid's sequence diagrams, whose messages are
   bound to the participants' headers but drawn far below them) can bind an
   end the user could never bind in the editor. Its fixedPoint lies well
   outside the element, and `normalizeFixedPoint` clamps it, so the binding
   can't hold the end where it was given.

   Reproduction: rectangles A (0,0 100x20) and B (500,0 100x20).
   - "half-far": an arrow at (100,10) with points [0,0]->[450,490], start A,
     end B, so its end is given at (550,500), far below B.
   - "beyond": an arrow at (50,40) with points [0,0]->[500,0], start A, end B,
     20px below both, so beyond binding distance.

   Failure case (HEAD):
   - "half-far": end bound to B at fixedPoint [0.5001,10]. Placing moves the
     end from the given (550,500) to (550,200).
   - "beyond": both ends bound at fixedPoint [0.5001,2]. That's a binding the
     editor can't create, and it moves the arrow onto the headers the first
     time A or B is moved.
   Expected: ends beyond the binding area are left unbound where given.
   Ends within it stay bound.

   Fix: new `isPointInBindingArea` (collision.ts) checks whether a point is
   inside an element or within binding distance of its outline.
   `isEndBoundBeyondBindingArea` (binding.ts) applies it to an arrow's bound
   end. Before placing, the pass unbinds every end beyond its element's
   binding area (`unbindBindingElement`, which also drops the arrow from
   the element's `boundElements`). An arrow with no binding left isn't
   placed and keeps its geometry as given.

   The check ignores frame clipping (`getBindingCandidates` still skips
   the clipped parts of frame children): frames are sized around their
   children only at the end of the conversion, so an element given with a
   `frameId` would be checked against a 0x0 frame, and every end bound to
   it would be beyond reach. Arrows unbound from an element are still
   framed with it, as the frame pass frames what is bound to a frame's
   children (through their `boundElements`, which no longer list them).

   An end that just falls short of its element is extended onto it instead
   (`extendBoundEndOntoElement`, binding.ts): its end segment is extended
   past the end by the segment's length, at least 100px, and if that
   reaches the element, the end is moved to where it does, off the element
   by the binding gap, and stays bound. This keeps bindings a generator
   meant to make, but drew arrows slightly too short for.

   Reproduction: rectangle B (500,0 100x20), an arrow at (150,10) with
   points [0,0]->[250,0], end B, so its end is given 100px short of B.
   Expected: end bound to B, moved to (500 - binding gap, 10).

2. Ends bound before their element is sized

   A rectangle/ellipse/diamond with a label and no width/height is created
   0x0 and sized to fit its label only when its label is bound. That happens
   in the same pass that binds arrows, in skeleton order. An arrow listed
   before the element therefore binds to a 0x0 element, and
   `calculateFixedPointForNonElbowArrowBinding` binds ends on elements
   smaller than MIN_BINDABLE_SIZE to their center. Nothing recomputes the
   binding once the element is sized, so the placement pass re-aims the end
   at the center, and the result depends on element order.

   Reproduction: an arrow at (100,50) with points [0,0]->[300,0], end bound
   to B, where B is a rectangle at (400,25) with label "B" and no size
   (sized to 20x35).

   Failure case (HEAD):
     arrow listed first: endBinding.fixedPoint [0.5001,0.5001] (center),
                         points [[0,0],[294,-7.11]] (tilted)
     B listed first:     endBinding.fixedPoint [0,0.714] (left edge),
                         points [[0,0],[294,0]] (straight)
   Expected: the same in either order, the "B listed first" result.

   Fix: the pass rebinds each end that is still bound
   (`bindBindingElement`, keeping its mode) against its element as sized.
   For elements whose size didn't change after binding, this gives the
   same binding as before.

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Mark Tolmacs committed 2026-10-23 15:10:00 +00:00
1 parent 7decbf92f8
commit 61255ad730
5 files changed
+516 -25

No files matched your search

@@ -134,7 +134,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 5,
"version": 7,
"versionNonce": Any<Number>,
"width": 371.50564585626694,
"x": 253,
@@ -196,7 +196,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 5,
"version": 7,
"versionNonce": Any<Number>,
"width": 383.0807596341628,
"x": 241.7419168232014,
@@ -357,7 +357,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing t
"endBinding": {
"elementId": "text-2",
"fixedPoint": [
-2.05,
0,
0.5001,
],
"mode": "orbit",
@@ -378,7 +378,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing t
0,
],
[
94,
293,
0,
],
],
@@ -399,11 +399,11 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing t
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 5,
"version": 7,
"versionNonce": Any<Number>,
"width": 94,
"width": 293,
"x": 261,
"y": 239.0025,
"y": 239.00250000000003,
}
`;
@@ -446,8 +446,8 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing t
"versionNonce": Any<Number>,
"verticalAlign": "middle",
"width": 130,
"x": 243,
"y": 226.5025,
"x": 342.5,
"y": 226.50250000000003,
}
`;
@@ -510,7 +510,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to shapes whe
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 5,
"version": 7,
"versionNonce": Any<Number>,
"width": 88.00000089285714,
"x": 261,
@@ -697,7 +697,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to text when
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 5,
"version": 7,
"versionNonce": Any<Number>,
"width": 88,
"x": 261,
@@ -1595,7 +1595,7 @@ exports[`Test Transform > should transform the elements correctly when linear el
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 5,
"version": 7,
"versionNonce": Any<Number>,
"width": 266.28515625,
"x": 117.26171875,
@@ -1660,7 +1660,7 @@ exports[`Test Transform > should transform the elements correctly when linear el
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 4,
"version": 6,
"versionNonce": Any<Number>,
"width": 0,
"x": 77.017,
@@ -684,6 +684,8 @@ describe("Test Transform", () => {
type: "arrow",
x: 255,
y: 239,
// reaching text-2, within its binding area
width: 305,
label: {
text: "HELLO WORLD!!",
},
@@ -785,7 +787,8 @@ describe("Test Transform", () => {
const elements = [
{
type: "arrow",
x: 255,
// reaching rect-1, within its binding area
x: 460,
y: 239,
end: {
id: "rect-1",
@@ -809,7 +812,7 @@ describe("Test Transform", () => {
const [arrow, rect] = excalidrawElements;
expect((arrow as ExcalidrawArrowElement).endBinding).toStrictEqual({
elementId: "rect-1",
fixedPoint: [-2.05, 0.5001],
fixedPoint: [0, 0.5001],
mode: "orbit",
});
expect(rect.boundElements).toStrictEqual([
@@ -1654,6 +1657,297 @@ describe("Test Transform", () => {
});
});
it("should unbind arrow ends given beyond the binding areas of the elements they're bound to", () => {
// e.g. a sequence diagram's messages, bound to their participants' headers
const elements = convertToExcalidrawElements(
[
{ type: "rectangle", id: "A", x: 0, y: 0, width: 100, height: 20 },
{ type: "rectangle", id: "B", x: 500, y: 0, width: 100, height: 20 },
{
type: "arrow",
id: "beyond",
x: 50,
// further below them than binding distance
y: 40,
points: [pointFrom<LocalPoint>(0, 0), pointFrom<LocalPoint>(500, 0)],
start: { id: "A" },
end: { id: "B" },
label: { text: "message" },
},
{
type: "arrow",
id: "half-far",
x: 100,
y: 10,
points: [
pointFrom<LocalPoint>(0, 0),
pointFrom<LocalPoint>(450, 490),
],
start: { id: "A" },
end: { id: "B" },
},
{
type: "arrow",
id: "near",
x: 50,
// within binding distance below them
y: 30,
points: [pointFrom<LocalPoint>(0, 0), pointFrom<LocalPoint>(500, 0)],
start: { id: "A" },
end: { id: "B" },
},
],
opts,
);
const elementsMap = arrayToMap(elements);
const near = elementsMap.get("near") as ExcalidrawArrowElement;
const beyond = elementsMap.get("beyond") as ExcalidrawArrowElement;
const halfFar = elementsMap.get("half-far") as ExcalidrawArrowElement;
expect(beyond).toMatchObject({
startBinding: null,
endBinding: null,
x: 50,
y: 40,
width: 500,
height: 0,
points: [
[0, 0],
[500, 0],
],
});
expect(near.startBinding?.elementId).toBe("A");
expect(near.endBinding?.elementId).toBe("B");
expect(halfFar.startBinding?.elementId).toBe("A");
expect(halfFar.endBinding).toBeNull();
expect(elementsMap.get("A")?.boundElements).toEqual([
{ id: "half-far", type: "arrow" },
{ id: "near", type: "arrow" },
]);
expect(elementsMap.get("B")?.boundElements).toEqual([
{ id: "near", type: "arrow" },
]);
// placed off A by the binding gap, its unbound end left where given
expect(halfFar.x).toBeGreaterThan(100);
const [endX, endY] = LinearElementEditor.getPointAtIndexGlobalCoordinates(
halfFar,
-1,
elementsMap,
);
expect(endX).toBeCloseTo(550);
expect(endY).toBeCloseTo(500);
});
it("should frame arrows unbound from a frame's children with them", () => {
const elements = convertToExcalidrawElements(
[
{ type: "rectangle", id: "A", x: 0, y: 0, width: 100, height: 20 },
{ type: "rectangle", id: "B", x: 500, y: 0, width: 100, height: 20 },
{
type: "arrow",
id: "arrow",
x: 50,
// further below them than binding distance
y: 60,
points: [pointFrom<LocalPoint>(0, 0), pointFrom<LocalPoint>(500, 0)],
start: { id: "A" },
end: { id: "B" },
},
{ type: "frame", children: ["A", "B"] },
],
opts,
);
const frame = elements.find((element) => element.type === "frame")!;
const arrow = elements.find(
(element) => element.id === "arrow",
) as ExcalidrawArrowElement;
expect(arrow.startBinding).toBeNull();
expect(arrow.endBinding).toBeNull();
expect(arrow.frameId).toBe(frame.id);
const [, , , maxY] = getCommonBounds([arrow]);
expect(frame.y + frame.height).toBeGreaterThanOrEqual(maxY);
});
it("should extend arrow ends falling short of the elements they're bound to onto them", () => {
const elements = convertToExcalidrawElements(
[
{ type: "rectangle", id: "A", x: 0, y: 0, width: 100, height: 20 },
{ type: "rectangle", id: "B", x: 500, y: 0, width: 100, height: 20 },
{
type: "arrow",
id: "short",
// ends 100px short of B: within its end segment's length
x: 150,
y: 10,
points: [pointFrom<LocalPoint>(0, 0), pointFrom<LocalPoint>(250, 0)],
end: { id: "B" },
},
{
type: "arrow",
id: "stub",
// starts 80px short of A: within the minimum extension
x: 180,
y: 10,
points: [pointFrom<LocalPoint>(0, 0), pointFrom<LocalPoint>(20, 0)],
start: { id: "A" },
},
{
type: "arrow",
id: "too-short",
// ends 200px short of B: beyond its end segment's length
x: 200,
y: 10,
points: [pointFrom<LocalPoint>(0, 0), pointFrom<LocalPoint>(100, 0)],
end: { id: "B" },
},
],
opts,
);
const elementsMap = arrayToMap(elements);
const short = elementsMap.get("short") as ExcalidrawArrowElement;
const stub = elementsMap.get("stub") as ExcalidrawArrowElement;
const tooShort = elementsMap.get("too-short") as ExcalidrawArrowElement;
expect(short.endBinding?.elementId).toBe("B");
const [shortEndX, shortEndY] =
LinearElementEditor.getPointAtIndexGlobalCoordinates(
short,
-1,
elementsMap,
);
expect(shortEndX).toBeCloseTo(500 - getBindingGap(elementsMap.get("B")!));
expect(shortEndY).toBeCloseTo(10);
expect(stub.startBinding?.elementId).toBe("A");
const [stubStartX, stubStartY] =
LinearElementEditor.getPointAtIndexGlobalCoordinates(
stub,
0,
elementsMap,
);
expect(stubStartX).toBeCloseTo(100 + getBindingGap(elementsMap.get("A")!));
expect(stubStartY).toBeCloseTo(10);
expect(tooShort).toMatchObject({
endBinding: null,
x: 200,
y: 10,
points: [
[0, 0],
[100, 0],
],
});
expect(elementsMap.get("A")?.boundElements).toEqual([
{ id: "stub", type: "arrow" },
]);
expect(elementsMap.get("B")?.boundElements).toEqual([
{ id: "short", type: "arrow" },
]);
});
it("should keep arrow ends bound to frame children where given, whether frameId or children is given", () => {
for (const byFrameId of [true, false]) {
const elements = convertToExcalidrawElements(
[
// not sized yet when arrow ends are checked
{
type: "frame",
id: "frame",
x: 0,
y: 0,
children: byFrameId ? [] : ["A", "B"],
},
{
type: "rectangle",
id: "A",
x: 0,
y: 0,
width: 100,
height: 20,
...(byFrameId && { frameId: "frame" }),
},
{
type: "rectangle",
id: "B",
x: 300,
y: 0,
width: 100,
height: 20,
...(byFrameId && { frameId: "frame" }),
},
{
type: "arrow",
id: "arrow",
x: 100,
y: 10,
points: [
pointFrom<LocalPoint>(0, 0),
pointFrom<LocalPoint>(200, 0),
],
start: { id: "A" },
end: { id: "B" },
},
],
opts,
);
const elementsMap = arrayToMap(elements);
const arrow = elementsMap.get("arrow") as ExcalidrawArrowElement;
expect(elementsMap.get("A")?.frameId).toBe("frame");
expect(elementsMap.get("B")?.frameId).toBe("frame");
// on the edges they're given on, facing each other
expect(arrow.startBinding).toStrictEqual({
elementId: "A",
fixedPoint: [1, 0.5001],
mode: "orbit",
});
expect(arrow.endBinding).toStrictEqual({
elementId: "B",
fixedPoint: [0, 0.5001],
mode: "orbit",
});
}
});
it("should bind arrows to elements sized to fit their labels after them as to those before them", () => {
const convert = (rectangleFirst: boolean) => {
// sized to fit its label, after the arrows listed before it are bound
const rectangle = {
type: "rectangle",
id: "B",
x: 400,
y: 25,
label: { text: "B" },
} as const;
const arrow = {
type: "arrow",
id: "arrow",
x: 100,
y: 50,
points: [pointFrom<LocalPoint>(0, 0), pointFrom<LocalPoint>(300, 0)],
end: { id: "B" },
} as const;
const elements = convertToExcalidrawElements(
rectangleFirst ? [rectangle, arrow] : [arrow, rectangle],
opts,
);
return elements.find(
(element) => element.id === "arrow",
) as ExcalidrawArrowElement;
};
const arrowFirst = convert(false);
const rectangleFirst = convert(true);
// not bound to the center of B as it was before being sized, but where
// the end was given: B's left edge
expect(arrowFirst.endBinding?.fixedPoint[0]).toBeCloseTo(0);
expect(arrowFirst.endBinding).toEqual(rectangleFirst.endBinding);
expect(arrowFirst.points).toEqual(rectangleFirst.points);
expect(arrowFirst.height).toBe(0);
});
it("should create shapes for start / end without ids where arrows in any direction start / end", () => {
const arrows = {
diagonal: [pointFrom<LocalPoint>(0, 0), pointFrom<LocalPoint>(100, 100)],
+116
View File
@@ -35,6 +35,7 @@ import {
hitElementItself,
intersectElementWithLineSegment,
isBindableElementInsideOtherBindable,
isPointInBindingArea,
isPointInElement,
} from "./collision";
import { distanceToElement } from "./distance";
@@ -1185,6 +1186,121 @@ export const bindBindingElement = (
applyBinding(arrow, hoveredElement, binding, startOrEnd, scene);
};
/**
* Whether the arrow's end is bound to an element it's beyond the binding area
* of, i.e. that it couldn't be bound to in the editor (e.g. a participant's
* header in a sequence diagram, as laid out by mermaid)
*/
export const isEndBoundBeyondBindingArea = (
arrow: ExcalidrawArrowElement,
startOrEnd: "start" | "end",
elementsMap: NonDeletedSceneElementsMap,
zoom: AppState["zoom"],
): boolean => {
const binding =
startOrEnd === "start" ? arrow.startBinding : arrow.endBinding;
const bindableElement = binding && elementsMap.get(binding.elementId);
return (
!!bindableElement &&
isBindableElement(bindableElement) &&
!isPointInBindingArea(
LinearElementEditor.getPointAtIndexGlobalCoordinates(
arrow,
startOrEnd === "start" ? 0 : -1,
elementsMap,
),
bindableElement,
elementsMap,
zoom,
)
);
};
// how far at least to extend an arrow's end segment looking for what it's
// bound to (see `extendBoundEndOntoElement`)
const MIN_BOUND_END_EXTENSION = 100;
/**
* Extends the arrow's bound end along its end segment, by the segment's length
* (at least MIN_BOUND_END_EXTENSION), and if that reaches the element it's
* bound to, moves the end there, off the element by the binding gap. This
* restores bindings given to arrows that just fall short of their elements.
*
* @returns whether the end was moved onto the element
*/
export const extendBoundEndOntoElement = (
arrow: NonDeleted<ExcalidrawArrowElement>,
startOrEnd: "start" | "end",
scene: Scene,
): boolean => {
const elementsMap = scene.getNonDeletedElementsMap();
const binding =
startOrEnd === "start" ? arrow.startBinding : arrow.endBinding;
const bindableElement = binding && elementsMap.get(binding.elementId);
if (
!bindableElement ||
!isBindableElement(bindableElement) ||
arrow.points.length < 2
) {
return false;
}
const index = startOrEnd === "start" ? 0 : arrow.points.length - 1;
const end = LinearElementEditor.getPointAtIndexGlobalCoordinates(
arrow,
index,
elementsMap,
);
const adjacent = LinearElementEditor.getPointAtIndexGlobalCoordinates(
arrow,
startOrEnd === "start" ? 1 : -2,
elementsMap,
);
const segmentLength = pointDistance(adjacent, end);
if (segmentLength < PRECISION) {
return false;
}
const extension = lineSegment(
end,
pointFromVector(
vectorScale(
vectorNormalize(vectorFromPoint(end, adjacent)),
Math.max(segmentLength, MIN_BOUND_END_EXTENSION),
),
end,
),
);
const nextEnd = intersectElementWithLineSegment(
bindableElement,
elementsMap,
extension,
getBindingGap(bindableElement),
).sort((a, b) => pointDistanceSq(a, end) - pointDistanceSq(b, end))[0];
if (!nextEnd) {
return false;
}
LinearElementEditor.movePoints(
arrow,
scene,
new Map([
[
index,
{
point: LinearElementEditor.pointFromAbsoluteCoords(
arrow,
nextEnd,
elementsMap,
),
},
],
]),
);
return true;
};
export const unbindBindingElement = (
arrow: ExcalidrawArrowElement,
startOrEnd: "start" | "end",
+27 -4
View File
@@ -320,10 +320,6 @@ const bindableElementBorderDistanceIfClose = (
return -Infinity;
}
if (isPointClippedByEnclosingFrame(element, point, elementsMap)) {
return -Infinity;
}
const isInside = isPointInElement(point, element, elementsMap);
// frames are only bindable from the outside, so arrows ending inside
// a frame can bind to its children (or stay unbound)
@@ -339,6 +335,29 @@ const bindableElementBorderDistanceIfClose = (
return distance > tolerance ? -Infinity : -distance;
};
/**
* Whether an arrow endpoint at the point could bind to the element: inside it,
* or within binding distance of its outline. Unlike `getBindingCandidates`,
* it ignores frame clipping, as frames may not be sized yet (e.g. while
* converting skeletons, where frames are sized around their children last)
*/
export const isPointInBindingArea = (
point: GlobalPoint,
element: NonDeleted<ExcalidrawBindableElement>,
elementsMap: ElementsMap,
zoom: AppState["zoom"],
) => {
const maxDistance = maxBindingDistance_simple(zoom);
return (
bindableElementBorderDistanceIfClose(
element,
point,
elementsMap,
maxDistance,
) > -maxDistance
);
};
type BindingCandidate = {
element: NonDeleted<ExcalidrawBindableElement>;
/** distance to the outline: positive inside, negative outside */
@@ -399,6 +418,10 @@ const getBindingCandidates = (
}
}
if (isPointClippedByEnclosingFrame(element, point, elementsMap)) {
continue;
}
const distance = bindableElementBorderDistanceIfClose(
element,
point,
+64 -6
View File
@@ -31,7 +31,13 @@ import {
import type { MarkOptional } from "@excalidraw/common/utility-types";
import type { Zoom } from "@excalidraw/excalidraw/types";
import { bindBindingElement, updateBoundArrow } from "./binding";
import {
bindBindingElement,
extendBoundEndOntoElement,
isEndBoundBeyondBindingArea,
unbindBindingElement,
updateBoundArrow,
} from "./binding";
import {
newArrowElement,
newElement,
@@ -49,7 +55,11 @@ import {
} from "./newElement";
import { normalizeStickyNoteStrokeColor } from "./stickyNote";
import { measureText, normalizeText } from "./textMeasurements";
import { isArrowElement, isStickyNoteElement } from "./typeChecks";
import {
isArrowElement,
isBindableElement,
isStickyNoteElement,
} from "./typeChecks";
import { syncInvalidIndices } from "./fractionalIndex";
@@ -949,9 +959,54 @@ export const convertToExcalidrawElements = (
// created to bind to since the scene was built, so resync it first
scene.replaceAllElements(elementStore.getElementsMap());
const placedElementsMap = scene.getNonDeletedElementsMap();
// arrows unbound below, by what they were bound to: they still connect it
// (e.g. they're framed with it)
const unboundArrowIds = new Map<ExcalidrawElement["id"], string[]>();
for (const arrow of scene.getNonDeletedElements()) {
if (!isArrowElement(arrow)) {
continue;
}
// users can't (re)bind an end given (e.g. by a layout engine) beyond the
// binding area of what it's bound to, so don't leave it bound there,
// unless it just falls short of it: then extend it onto it
for (const startOrEnd of ["start", "end"] as const) {
if (
isEndBoundBeyondBindingArea(
arrow,
startOrEnd,
placedElementsMap,
DEFAULT_ZOOM,
) &&
!extendBoundEndOntoElement(arrow, startOrEnd, scene)
) {
const elementId = unbindBindingElement(arrow, startOrEnd, scene);
if (elementId) {
unboundArrowIds.set(elementId, [
...(unboundArrowIds.get(elementId) ?? []),
arrow.id,
]);
}
continue;
}
// it was bound before what it's bound to was sized if that came later
// (e.g. to fit its label), so its fixed point may be off (e.g. the
// center of a 0x0 element): rebind it against the element as sized
const binding =
startOrEnd === "start" ? arrow.startBinding : arrow.endBinding;
const bindableElement =
binding && placedElementsMap.get(binding.elementId);
if (bindableElement && isBindableElement(bindableElement)) {
bindBindingElement(
arrow,
bindableElement,
binding.mode,
startOrEnd,
scene,
DEFAULT_ZOOM,
);
}
}
if (
!isArrowElement(arrow) ||
![arrow.startBinding, arrow.endBinding].some(
(binding) => binding && placedElementsMap.has(binding.elementId),
)
@@ -1029,11 +1084,14 @@ export const convertToExcalidrawElements = (
}
Object.assign(elementInFrame, { frameId: frame.id });
elementInFrame?.boundElements?.forEach((boundElement) => {
const ele = elementStore.getElement(boundElement.id);
[
...(elementInFrame.boundElements ?? []).map(({ id }) => id),
...(unboundArrowIds.get(elementInFrame.id) ?? []),
].forEach((boundElementId) => {
const ele = elementStore.getElement(boundElementId);
if (!ele) {
throw new Error(
`Bound element with id ${boundElement.id} doesn't exist`,
`Bound element with id ${boundElementId} doesn't exist`,
);
}
Object.assign(ele, { frameId: frame.id });