Fix the highlight part of the issue
This commit is contained in:
parent
9af3177dbd
commit
6deb4fdbe6
@ -416,7 +416,7 @@ export const maybeSuggestBindingsForLinearElementAtCoords = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
const suggestedBindings = pointerCoords.reduce(
|
const suggestedBindings = pointerCoords.reduce(
|
||||||
(acc: NonDeleted<ExcalidrawBindableElement>[], coords) => {
|
(acc: Set<NonDeleted<ExcalidrawBindableElement>>, coords) => {
|
||||||
const hoveredBindableElement = getHoveredElementForBinding(
|
const hoveredBindableElement = getHoveredElementForBinding(
|
||||||
coords,
|
coords,
|
||||||
scene.getNonDeletedElements(),
|
scene.getNonDeletedElements(),
|
||||||
@ -425,6 +425,7 @@ export const maybeSuggestBindingsForLinearElementAtCoords = (
|
|||||||
isElbowArrow(linearElement),
|
isElbowArrow(linearElement),
|
||||||
isElbowArrow(linearElement),
|
isElbowArrow(linearElement),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
hoveredBindableElement != null &&
|
hoveredBindableElement != null &&
|
||||||
!isLinearElementSimpleAndAlreadyBound(
|
!isLinearElementSimpleAndAlreadyBound(
|
||||||
@ -433,14 +434,15 @@ export const maybeSuggestBindingsForLinearElementAtCoords = (
|
|||||||
hoveredBindableElement,
|
hoveredBindableElement,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
acc.push(hoveredBindableElement);
|
acc.add(hoveredBindableElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
},
|
},
|
||||||
[],
|
new Set() as Set<NonDeleted<ExcalidrawBindableElement>>,
|
||||||
);
|
);
|
||||||
|
|
||||||
return suggestedBindings;
|
return Array.from(suggestedBindings);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const maybeBindLinearElement = (
|
export const maybeBindLinearElement = (
|
||||||
@ -580,7 +582,7 @@ export const isLinearElementSimpleAndAlreadyBound = (
|
|||||||
|
|
||||||
const isLinearElementSimple = (
|
const isLinearElementSimple = (
|
||||||
linearElement: NonDeleted<ExcalidrawLinearElement>,
|
linearElement: NonDeleted<ExcalidrawLinearElement>,
|
||||||
): boolean => linearElement.points.length < 3;
|
): boolean => linearElement.points.length < 3 && !isElbowArrow(linearElement);
|
||||||
|
|
||||||
const unbindLinearElement = (
|
const unbindLinearElement = (
|
||||||
linearElement: NonDeleted<ExcalidrawLinearElement>,
|
linearElement: NonDeleted<ExcalidrawLinearElement>,
|
||||||
|
@ -371,10 +371,16 @@ export class LinearElementEditor {
|
|||||||
// suggest bindings for first and last point if selected
|
// suggest bindings for first and last point if selected
|
||||||
let suggestedBindings: ExcalidrawBindableElement[] = [];
|
let suggestedBindings: ExcalidrawBindableElement[] = [];
|
||||||
if (isBindingElement(element, false)) {
|
if (isBindingElement(element, false)) {
|
||||||
|
const firstSelectedIndex = selectedPointsIndices[0] === 0;
|
||||||
|
const lastSelectedIndex =
|
||||||
|
selectedPointsIndices[selectedPointsIndices.length - 1] ===
|
||||||
|
element.points.length - 1;
|
||||||
const coords: { x: number; y: number }[] = [];
|
const coords: { x: number; y: number }[] = [];
|
||||||
|
|
||||||
const firstSelectedIndex = selectedPointsIndices[0];
|
if (!firstSelectedIndex !== !lastSelectedIndex) {
|
||||||
if (firstSelectedIndex === 0) {
|
coords.push({ x: scenePointerX, y: scenePointerY });
|
||||||
|
} else {
|
||||||
|
if (firstSelectedIndex) {
|
||||||
coords.push(
|
coords.push(
|
||||||
tupleToCoors(
|
tupleToCoors(
|
||||||
LinearElementEditor.getPointGlobalCoordinates(
|
LinearElementEditor.getPointGlobalCoordinates(
|
||||||
@ -386,19 +392,20 @@ export class LinearElementEditor {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const lastSelectedIndex =
|
if (lastSelectedIndex) {
|
||||||
selectedPointsIndices[selectedPointsIndices.length - 1];
|
|
||||||
if (lastSelectedIndex === element.points.length - 1) {
|
|
||||||
coords.push(
|
coords.push(
|
||||||
tupleToCoors(
|
tupleToCoors(
|
||||||
LinearElementEditor.getPointGlobalCoordinates(
|
LinearElementEditor.getPointGlobalCoordinates(
|
||||||
element,
|
element,
|
||||||
element.points[lastSelectedIndex],
|
element.points[
|
||||||
|
selectedPointsIndices[selectedPointsIndices.length - 1]
|
||||||
|
],
|
||||||
elementsMap,
|
elementsMap,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (coords.length) {
|
if (coords.length) {
|
||||||
suggestedBindings = maybeSuggestBindingsForLinearElementAtCoords(
|
suggestedBindings = maybeSuggestBindingsForLinearElementAtCoords(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user