mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-17 14:30:32 +02:00
fix: Locked elbow arrow creation
This commit is contained in:
@@ -397,9 +397,11 @@ export class LinearElementEditor {
|
|||||||
): Pick<AppState, "suggestedBinding" | "selectedLinearElement"> | null {
|
): Pick<AppState, "suggestedBinding" | "selectedLinearElement"> | null {
|
||||||
const elementsMap = app.scene.getNonDeletedElementsMap();
|
const elementsMap = app.scene.getNonDeletedElementsMap();
|
||||||
const elements = app.scene.getNonDeletedElements();
|
const elements = app.scene.getNonDeletedElements();
|
||||||
const { elbowed, elementId, initialState, selectedPointsIndices } =
|
const { elbowed, elementId, initialState } = linearElementEditor;
|
||||||
linearElementEditor;
|
const selectedPointsIndices = Array.from(
|
||||||
const { lastClickedPoint } = initialState;
|
linearElementEditor.selectedPointsIndices ?? [],
|
||||||
|
);
|
||||||
|
let { lastClickedPoint } = initialState;
|
||||||
const element = LinearElementEditor.getElement(elementId, elementsMap);
|
const element = LinearElementEditor.getElement(elementId, elementsMap);
|
||||||
|
|
||||||
invariant(element, "Element being dragged must exist in the scene");
|
invariant(element, "Element being dragged must exist in the scene");
|
||||||
@@ -411,6 +413,18 @@ export class LinearElementEditor {
|
|||||||
"There must be selected points in order to drag them",
|
"There must be selected points in order to drag them",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (elbowed) {
|
||||||
|
selectedPointsIndices.some((pointIdx, idx) => {
|
||||||
|
if (pointIdx > 0 && pointIdx !== element.points.length - 1) {
|
||||||
|
selectedPointsIndices[idx] = element.points.length - 1;
|
||||||
|
lastClickedPoint = element.points.length - 1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
invariant(
|
invariant(
|
||||||
lastClickedPoint > -1 &&
|
lastClickedPoint > -1 &&
|
||||||
selectedPointsIndices.includes(lastClickedPoint) &&
|
selectedPointsIndices.includes(lastClickedPoint) &&
|
||||||
@@ -422,16 +436,6 @@ export class LinearElementEditor {
|
|||||||
}) lastClickedPoint(${lastClickedPoint})`,
|
}) lastClickedPoint(${lastClickedPoint})`,
|
||||||
);
|
);
|
||||||
|
|
||||||
invariant(
|
|
||||||
!elbowed ||
|
|
||||||
selectedPointsIndices?.filter(
|
|
||||||
(idx) => idx !== 0 && idx !== element.points.length - 1,
|
|
||||||
).length === 0,
|
|
||||||
`Only start and end points can be selected for elbow arrows: ${JSON.stringify(
|
|
||||||
selectedPointsIndices,
|
|
||||||
)} end point ${element.points.length - 1}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
// point that's being dragged (out of all selected points)
|
// point that's being dragged (out of all selected points)
|
||||||
const draggingPoint = element.points[lastClickedPoint];
|
const draggingPoint = element.points[lastClickedPoint];
|
||||||
// The adjacent point to the one dragged point
|
// The adjacent point to the one dragged point
|
||||||
|
Reference in New Issue
Block a user