fix: Linear to elbow conversion crash (#9556)
* Fix linear to elbow conversion * Add invariant check * Add dev invariant fix * Add arrowhead
This commit is contained in:
parent
27522110df
commit
91d36e9b81
@ -974,6 +974,25 @@ export const updateElbowArrowPoints = (
|
|||||||
),
|
),
|
||||||
"Elbow arrow segments must be either horizontal or vertical",
|
"Elbow arrow segments must be either horizontal or vertical",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
invariant(
|
||||||
|
updates.fixedSegments?.find(
|
||||||
|
(segment) =>
|
||||||
|
segment.index === 1 &&
|
||||||
|
pointsEqual(segment.start, (updates.points ?? arrow.points)[0]),
|
||||||
|
) == null &&
|
||||||
|
updates.fixedSegments?.find(
|
||||||
|
(segment) =>
|
||||||
|
segment.index === (updates.points ?? arrow.points).length - 1 &&
|
||||||
|
pointsEqual(
|
||||||
|
segment.end,
|
||||||
|
(updates.points ?? arrow.points)[
|
||||||
|
(updates.points ?? arrow.points).length - 1
|
||||||
|
],
|
||||||
|
),
|
||||||
|
) == null,
|
||||||
|
"The first and last segments cannot be fixed",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const fixedSegments = updates.fixedSegments ?? arrow.fixedSegments ?? [];
|
const fixedSegments = updates.fixedSegments ?? arrow.fixedSegments ?? [];
|
||||||
|
@ -564,7 +564,7 @@ export const convertElementTypes = (
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const fixedSegments: FixedSegment[] = [];
|
const fixedSegments: FixedSegment[] = [];
|
||||||
for (let i = 0; i < nextPoints.length - 1; i++) {
|
for (let i = 1; i < nextPoints.length - 2; i++) {
|
||||||
fixedSegments.push({
|
fixedSegments.push({
|
||||||
start: nextPoints[i],
|
start: nextPoints[i],
|
||||||
end: nextPoints[i + 1],
|
end: nextPoints[i + 1],
|
||||||
@ -581,6 +581,7 @@ export const convertElementTypes = (
|
|||||||
);
|
);
|
||||||
mutateElement(element, app.scene.getNonDeletedElementsMap(), {
|
mutateElement(element, app.scene.getNonDeletedElementsMap(), {
|
||||||
...updates,
|
...updates,
|
||||||
|
endArrowhead: "arrow",
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// if we're converting to non-elbow linear element, check if
|
// if we're converting to non-elbow linear element, check if
|
||||||
|
Loading…
x
Reference in New Issue
Block a user