mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: Arrow conversion regression (#9241)
All checks were successful
Tests / test (push) Successful in 4m43s
All checks were successful
Tests / test (push) Successful in 4m43s
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
parent
21ffaf4d76
commit
30983d801a
4 changed files with 129 additions and 110 deletions
|
@ -111,6 +111,8 @@ import {
|
|||
tupleToCoors,
|
||||
} from "../utils";
|
||||
|
||||
import { updateElbowArrowPoints } from "../element/elbowArrow";
|
||||
|
||||
import { register } from "./register";
|
||||
|
||||
import type {
|
||||
|
@ -1572,7 +1574,7 @@ export const actionChangeArrowType = register({
|
|||
if (!isArrowElement(el)) {
|
||||
return el;
|
||||
}
|
||||
const newElement = newElementWith(el, {
|
||||
let newElement = newElementWith(el, {
|
||||
roundness:
|
||||
value === ARROW_TYPE.round
|
||||
? {
|
||||
|
@ -1587,6 +1589,8 @@ export const actionChangeArrowType = register({
|
|||
});
|
||||
|
||||
if (isElbowArrow(newElement)) {
|
||||
newElement.fixedSegments = null;
|
||||
|
||||
const elementsMap = app.scene.getNonDeletedElementsMap();
|
||||
|
||||
app.dismissLinearEditor();
|
||||
|
@ -1661,46 +1665,71 @@ export const actionChangeArrowType = register({
|
|||
endHoveredElement &&
|
||||
bindLinearElement(newElement, endHoveredElement, "end", elementsMap);
|
||||
|
||||
mutateElement(newElement, {
|
||||
points: [finalStartPoint, finalEndPoint].map(
|
||||
(p): LocalPoint =>
|
||||
pointFrom(p[0] - newElement.x, p[1] - newElement.y),
|
||||
),
|
||||
...(startElement && newElement.startBinding
|
||||
const startBinding =
|
||||
startElement && newElement.startBinding
|
||||
? {
|
||||
startBinding: {
|
||||
// @ts-ignore TS cannot discern check above
|
||||
...newElement.startBinding!,
|
||||
...calculateFixedPointForElbowArrowBinding(
|
||||
newElement,
|
||||
startElement,
|
||||
"start",
|
||||
elementsMap,
|
||||
),
|
||||
},
|
||||
// @ts-ignore TS cannot discern check above
|
||||
...newElement.startBinding!,
|
||||
...calculateFixedPointForElbowArrowBinding(
|
||||
newElement,
|
||||
startElement,
|
||||
"start",
|
||||
elementsMap,
|
||||
),
|
||||
}
|
||||
: {}),
|
||||
...(endElement && newElement.endBinding
|
||||
: null;
|
||||
const endBinding =
|
||||
endElement && newElement.endBinding
|
||||
? {
|
||||
endBinding: {
|
||||
// @ts-ignore TS cannot discern check above
|
||||
...newElement.endBinding,
|
||||
...calculateFixedPointForElbowArrowBinding(
|
||||
newElement,
|
||||
endElement,
|
||||
"end",
|
||||
elementsMap,
|
||||
),
|
||||
},
|
||||
// @ts-ignore TS cannot discern check above
|
||||
...newElement.endBinding,
|
||||
...calculateFixedPointForElbowArrowBinding(
|
||||
newElement,
|
||||
endElement,
|
||||
"end",
|
||||
elementsMap,
|
||||
),
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
: null;
|
||||
|
||||
newElement = {
|
||||
...newElement,
|
||||
startBinding,
|
||||
endBinding,
|
||||
...updateElbowArrowPoints(newElement, elementsMap, {
|
||||
points: [finalStartPoint, finalEndPoint].map(
|
||||
(p): LocalPoint =>
|
||||
pointFrom(p[0] - newElement.x, p[1] - newElement.y),
|
||||
),
|
||||
startBinding,
|
||||
endBinding,
|
||||
fixedSegments: null,
|
||||
}),
|
||||
};
|
||||
|
||||
LinearElementEditor.updateEditorMidPointsCache(
|
||||
newElement,
|
||||
elementsMap,
|
||||
app.state,
|
||||
);
|
||||
} else {
|
||||
const elementsMap = app.scene.getNonDeletedElementsMap();
|
||||
if (newElement.startBinding) {
|
||||
const startElement = elementsMap.get(
|
||||
newElement.startBinding.elementId,
|
||||
) as ExcalidrawBindableElement;
|
||||
if (startElement) {
|
||||
bindLinearElement(newElement, startElement, "start", elementsMap);
|
||||
}
|
||||
}
|
||||
if (newElement.endBinding) {
|
||||
const endElement = elementsMap.get(
|
||||
newElement.endBinding.elementId,
|
||||
) as ExcalidrawBindableElement;
|
||||
if (endElement) {
|
||||
bindLinearElement(newElement, endElement, "end", elementsMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return newElement;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue