fix: Corner jumping & hints (#10403)

* fix: Corner jumping

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* fix: Hints

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* fix: No corner avoidance for simple arrows

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* show alt/cmd hint when creating/moving arrow point any time

---------

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
Márk Tolmács
2025-11-26 11:00:33 +00:00
committed by GitHub
co-authored by dwelle
parent c141960ada
commit 019ce4c52c
6 changed files with 34 additions and 29 deletions
+14 -11
View File
@@ -1202,23 +1202,26 @@ export const bindPointToSnapToElementOutline = (
customIntersector?: LineSegment<GlobalPoint>, customIntersector?: LineSegment<GlobalPoint>,
): GlobalPoint => { ): GlobalPoint => {
const elbowed = isElbowArrow(arrowElement); const elbowed = isElbowArrow(arrowElement);
const point = const point = LinearElementEditor.getPointAtIndexGlobalCoordinates(
customIntersector && !elbowed arrowElement,
? customIntersector[0] startOrEnd === "start" ? 0 : -1,
: LinearElementEditor.getPointAtIndexGlobalCoordinates( elementsMap,
arrowElement, );
startOrEnd === "start" ? 0 : -1,
elementsMap,
);
if (arrowElement.points.length < 2) { if (arrowElement.points.length < 2) {
// New arrow creation, so no snapping // New arrow creation, so no snapping
return point; return point;
} }
const edgePoint = isRectanguloidElement(bindableElement) const edgePoint =
? avoidRectangularCorner(arrowElement, bindableElement, elementsMap, point) isRectanguloidElement(bindableElement) && elbowed
: point; ? avoidRectangularCorner(
arrowElement,
bindableElement,
elementsMap,
point,
)
: point;
const adjacentPoint = const adjacentPoint =
customIntersector && !elbowed customIntersector && !elbowed
? customIntersector[1] ? customIntersector[1]
+14 -2
View File
@@ -62,6 +62,20 @@ const getHints = ({
shortcut: getTaggedShortcutKey("Alt"), shortcut: getTaggedShortcutKey("Alt"),
}); });
} }
const selectedElements = app.scene.getSelectedElements(appState);
// creating or dragging arrow point
if (
appState.selectedLinearElement?.isDragging &&
selectedElements[0]?.type === "arrow"
) {
return t("hints.arrowBindModifiers", {
shortcut_1: getTaggedShortcutKey("Ctrl"),
shortcut_2: getTaggedShortcutKey("Alt"),
});
}
if (activeTool.type === "arrow" || activeTool.type === "line") { if (activeTool.type === "arrow" || activeTool.type === "line") {
if (multiMode) { if (multiMode) {
return t("hints.linearElementMulti", { return t("hints.linearElementMulti", {
@@ -89,8 +103,6 @@ const getHints = ({
return t("hints.embeddable"); return t("hints.embeddable");
} }
const selectedElements = app.scene.getSelectedElements(appState);
if ( if (
isResizing && isResizing &&
lastPointerDownWith === "mouse" && lastPointerDownWith === "mouse" &&
+2 -8
View File
@@ -646,14 +646,8 @@ const LayerUI = ({
}; };
const stripIrrelevantAppStateProps = (appState: AppState): UIAppState => { const stripIrrelevantAppStateProps = (appState: AppState): UIAppState => {
const { const { startBoundElement, cursorButton, scrollX, scrollY, ...ret } =
suggestedBinding, appState;
startBoundElement,
cursorButton,
scrollX,
scrollY,
...ret
} = appState;
return ret; return ret;
}; };
+1 -1
View File
@@ -341,7 +341,7 @@
"canvasPanning": "To move canvas, hold {{shortcut_1}} or {{shortcut_2}} while dragging, or use the hand tool", "canvasPanning": "To move canvas, hold {{shortcut_1}} or {{shortcut_2}} while dragging, or use the hand tool",
"linearElement": "Click to start multiple points, drag for single line", "linearElement": "Click to start multiple points, drag for single line",
"arrowTool": "Click to start multiple points, drag for single line. Press {{shortcut}} again to change arrow type.", "arrowTool": "Click to start multiple points, drag for single line. Press {{shortcut}} again to change arrow type.",
"arrowBindModifiers": "Hold {{shortcut_1}} to bind inside, or {{shortcut_2}} to disable binding", "arrowBindModifiers": "Hold {{shortcut_1}} to disable binding, or {{shortcut_2}} to bind at a fixed point",
"freeDraw": "Click and drag, release when you're finished", "freeDraw": "Click and drag, release when you're finished",
"text": "Tip: you can also add text by double-clicking anywhere with the selection tool", "text": "Tip: you can also add text by double-clicking anywhere with the selection tool",
"embeddable": "Click-drag to create a website embed", "embeddable": "Click-drag to create a website embed",
@@ -203,7 +203,7 @@ exports[`move element > rectangles with binding arrow 7`] = `
0, 0,
], ],
[ [
79, "79.00000",
"124.16785", "124.16785",
], ],
], ],
@@ -228,7 +228,7 @@ exports[`move element > rectangles with binding arrow 7`] = `
"updated": 1, "updated": 1,
"version": 12, "version": 12,
"versionNonce": 2066753033, "versionNonce": 2066753033,
"width": 79, "width": "79.00000",
"x": 111, "x": 111,
"y": "6.14995", "y": "6.14995",
} }
+1 -5
View File
@@ -474,11 +474,7 @@ export type SearchMatch = {
export type UIAppState = Omit< export type UIAppState = Omit<
AppState, AppState,
| "suggestedBinding" "startBoundElement" | "cursorButton" | "scrollX" | "scrollY"
| "startBoundElement"
| "cursorButton"
| "scrollX"
| "scrollY"
>; >;
export type NormalizedZoomValue = number & { _brand: "normalizedZoom" }; export type NormalizedZoomValue = number & { _brand: "normalizedZoom" };