1
0
mirror of https://github.com/excalidraw/excalidraw.git synced 2025-02-18 13:29:36 +01:00

feat: improve elbow arrow keyboard move (#8392)

This commit is contained in:
zsviczian 2024-08-26 15:58:54 +02:00 committed by GitHub
parent b459e5cfd2
commit afb68a6467
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -4062,7 +4062,7 @@ class App extends React.Component<AppProps, AppState> {
} }
if (isArrowKey(event.key)) { if (isArrowKey(event.key)) {
const selectedElements = this.scene.getSelectedElements({ let selectedElements = this.scene.getSelectedElements({
selectedElementIds: this.state.selectedElementIds, selectedElementIds: this.state.selectedElementIds,
includeBoundTextElement: true, includeBoundTextElement: true,
includeElementsInFrames: true, includeElementsInFrames: true,
@ -4072,17 +4072,37 @@ class App extends React.Component<AppProps, AppState> {
| ExcalidrawArrowElement | ExcalidrawArrowElement
| undefined; | undefined;
const step = elbowArrow const arrowIdsToRemove = new Set<string>();
? elbowArrow.startBinding || elbowArrow.endBinding
? 0 selectedElements
: ELEMENT_TRANSLATE_AMOUNT .filter(isElbowArrow)
: (this.getEffectiveGridSize() && .filter((arrow) => {
(event.shiftKey const startElementNotInSelection =
? ELEMENT_TRANSLATE_AMOUNT arrow.startBinding &&
: this.getEffectiveGridSize())) || !selectedElements.some(
(el) => el.id === arrow.startBinding?.elementId,
);
const endElementNotInSelection =
arrow.endBinding &&
!selectedElements.some(
(el) => el.id === arrow.endBinding?.elementId,
);
return startElementNotInSelection || endElementNotInSelection;
})
.forEach((arrow) => arrowIdsToRemove.add(arrow.id));
selectedElements = selectedElements.filter(
(el) => !arrowIdsToRemove.has(el.id),
);
const step =
(this.getEffectiveGridSize() &&
(event.shiftKey (event.shiftKey
? ELEMENT_SHIFT_TRANSLATE_AMOUNT ? ELEMENT_TRANSLATE_AMOUNT
: ELEMENT_TRANSLATE_AMOUNT); : this.getEffectiveGridSize())) ||
(event.shiftKey
? ELEMENT_SHIFT_TRANSLATE_AMOUNT
: ELEMENT_TRANSLATE_AMOUNT);
let offsetX = 0; let offsetX = 0;
let offsetY = 0; let offsetY = 0;