improvement: change hint for 2-point lines on resize (#2655)

This commit is contained in:
David Luzar 2020-12-22 11:00:51 +01:00 committed by GitHub
parent d7f314cda8
commit 8dfea49ec1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 11 deletions

View File

@ -38,8 +38,8 @@ const getHints = ({ appState, elements }: Hint) => {
selectedElements.length === 1 selectedElements.length === 1
) { ) {
const targetElement = selectedElements[0]; const targetElement = selectedElements[0];
if (isLinearElement(targetElement) && targetElement.points.length > 2) { if (isLinearElement(targetElement) && targetElement.points.length === 2) {
return null; return t("hints.lockAngle");
} }
return t("hints.resize"); return t("hints.resize");
} }

View File

@ -161,6 +161,7 @@
"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",
"linearElementMulti": "Click on last point or press Escape or Enter to finish", "linearElementMulti": "Click on last point or press Escape or Enter to finish",
"lockAngle": "You can constrain angle by holding SHIFT",
"resize": "You can constrain proportions by holding SHIFT while resizing,\nhold ALT to resize from the center", "resize": "You can constrain proportions by holding SHIFT while resizing,\nhold ALT to resize from the center",
"rotate": "You can constrain angles by holding SHIFT while rotating", "rotate": "You can constrain angles by holding SHIFT while rotating",
"lineEditor_info": "Double-click or press Enter to edit points", "lineEditor_info": "Double-click or press Enter to edit points",

View File

@ -39,6 +39,7 @@ Please add the latest change on the top under the correct section.
### Improvements ### Improvements
- Display proper tooltip for 2-point lines during resize, and normalize modifier key labels in hints [#2655](https://github.com/excalidraw/excalidraw/pull/2655)
- Improve error message around importing images [#2619](https://github.com/excalidraw/excalidraw/pull/2619) - Improve error message around importing images [#2619](https://github.com/excalidraw/excalidraw/pull/2619)
- Add tooltip with icon for embedding scenes [#2532](https://github.com/excalidraw/excalidraw/pull/2532) - Add tooltip with icon for embedding scenes [#2532](https://github.com/excalidraw/excalidraw/pull/2532)
- RTL support for the stats dialog [#2530](https://github.com/excalidraw/excalidraw/pull/2530) - RTL support for the stats dialog [#2530](https://github.com/excalidraw/excalidraw/pull/2530)

View File

@ -1,4 +1,4 @@
import { queryByText } from "@testing-library/react"; import { queryAllByText, queryByText } from "@testing-library/react";
import React from "react"; import React from "react";
import ReactDOM from "react-dom"; import ReactDOM from "react-dom";
import { copiedStyles } from "../actions/actionStyles"; import { copiedStyles } from "../actions/actionStyles";
@ -864,7 +864,7 @@ describe("regression tests", () => {
clientY: 1, clientY: 1,
}); });
const contextMenu = document.querySelector(".context-menu"); const contextMenu = document.querySelector(".context-menu");
fireEvent.click(queryByText(contextMenu as HTMLElement, "Delete")!); fireEvent.click(queryAllByText(contextMenu as HTMLElement, "Delete")[0]);
expect(API.getSelectedElements()).toHaveLength(0); expect(API.getSelectedElements()).toHaveLength(0);
expect(h.elements[0].isDeleted).toBe(true); expect(h.elements[0].isDeleted).toBe(true);
}); });

View File

@ -7,6 +7,7 @@ import {
import { FontFamily, FontString } from "./element/types"; import { FontFamily, FontString } from "./element/types";
import { Zoom } from "./types"; import { Zoom } from "./types";
import { unstable_batchedUpdates } from "react-dom"; import { unstable_batchedUpdates } from "react-dom";
import { isDarwin } from "./keys";
export const SVG_NS = "http://www.w3.org/2000/svg"; export const SVG_NS = "http://www.w3.org/2000/svg";
@ -179,15 +180,18 @@ export const allowFullScreen = () =>
export const exitFullScreen = () => document.exitFullscreen(); export const exitFullScreen = () => document.exitFullscreen();
export const getShortcutKey = (shortcut: string): string => { export const getShortcutKey = (shortcut: string): string => {
const isMac = /Mac|iPod|iPhone|iPad/.test(window.navigator.platform); shortcut = shortcut
if (isMac) { .replace(/\bAlt\b/i, "Alt")
return `${shortcut .replace(/\bShift\b/i, "Shift")
.replace(/\b(Enter|Return)\b/i, "Enter")
.replace(/\bDel\b/i, "Delete");
if (isDarwin) {
return shortcut
.replace(/\bCtrlOrCmd\b/i, "Cmd") .replace(/\bCtrlOrCmd\b/i, "Cmd")
.replace(/\bAlt\b/i, "Option") .replace(/\bAlt\b/i, "Option");
.replace(/\bDel\b/i, "Delete")
.replace(/\b(Enter|Return)\b/i, "Enter")}`;
} }
return `${shortcut.replace(/\bCtrlOrCmd\b/i, "Ctrl")}`; return shortcut.replace(/\bCtrlOrCmd\b/i, "Ctrl");
}; };
export const viewportCoordsToSceneCoords = ( export const viewportCoordsToSceneCoords = (