Virtual whiteboard for sketching hand-drawn like diagrams
improvement: change hint for 2-point lines on resize (#2655)
David Luzar8dfea49ec109
diff --git a/src/components/HintViewer.tsx b/src/components/HintViewer.tsxindex 6e9be975fe..0b9ab568eb 100644--- a/src/components/HintViewer.tsx+++ b/src/components/HintViewer.tsx@@ -38,8 +38,8 @@ const getHints = ({ appState, elements }: Hint) => {selectedElements.length === 1) {const targetElement = selectedElements[0];- if (isLinearElement(targetElement) && targetElement.points.length > 2) {- return null;+ if (isLinearElement(targetElement) && targetElement.points.length === 2) {+ return t("hints.lockAngle");}return t("hints.resize");}diff --git a/src/locales/en.json b/src/locales/en.jsonindex 7bf46fe212..6f16fc9860 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -161,6 +161,7 @@"freeDraw": "Click and drag, release when you're finished","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",+ "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","rotate": "You can constrain angles by holding SHIFT while rotating","lineEditor_info": "Double-click or press Enter to edit points",diff --git a/src/packages/excalidraw/CHANGELOG.md b/src/packages/excalidraw/CHANGELOG.mdindex 62ace97fa6..ab26fdf347 100644--- a/src/packages/excalidraw/CHANGELOG.md+++ b/src/packages/excalidraw/CHANGELOG.md@@ -39,6 +39,7 @@ Please add the latest change on the top under the correct section.### 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)- 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)diff --git a/src/tests/regressionTests.test.tsx b/src/tests/regressionTests.test.tsxindex c3a6c3894d..1a2aaa6a8b 100644--- a/src/tests/regressionTests.test.tsx+++ b/src/tests/regressionTests.test.tsx@@ -1,4 +1,4 @@-import { queryByText } from "@testing-library/react";+import { queryAllByText, queryByText } from "@testing-library/react";import React from "react";import ReactDOM from "react-dom";import { copiedStyles } from "../actions/actionStyles";@@ -864,7 +864,7 @@ describe("regression tests", () => {clientY: 1,});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(h.elements[0].isDeleted).toBe(true);});diff --git a/src/utils.ts b/src/utils.tsindex 821ece5706..e1c276d45c 100644--- a/src/utils.ts+++ b/src/utils.ts@@ -7,6 +7,7 @@ import {import { FontFamily, FontString } from "./element/types";import { Zoom } from "./types";import { unstable_batchedUpdates } from "react-dom";+import { isDarwin } from "./keys";export const SVG_NS = "http://www.w3.org/2000/svg";@@ -179,15 +180,18 @@ export const allowFullScreen = () =>export const exitFullScreen = () => document.exitFullscreen();export const getShortcutKey = (shortcut: string): string => {- const isMac = /Mac|iPod|iPhone|iPad/.test(window.navigator.platform);- if (isMac) {- return `${shortcut+ shortcut = shortcut+ .replace(/\bAlt\b/i, "Alt")+ .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(/\bAlt\b/i, "Option")- .replace(/\bDel\b/i, "Delete")- .replace(/\b(Enter|Return)\b/i, "Enter")}`;+ .replace(/\bAlt\b/i, "Option");}- return `${shortcut.replace(/\bCtrlOrCmd\b/i, "Ctrl")}`;+ return shortcut.replace(/\bCtrlOrCmd\b/i, "Ctrl");};export const viewportCoordsToSceneCoords = (