From 9dc930b44744ba708b7e11d61d45dc06c5f2afee Mon Sep 17 00:00:00 2001 From: David Luzar Date: Thu, 21 Jan 2021 16:21:54 +0100 Subject: [PATCH] feat: add ctrl-y to redo (#2831) --- src/actions/actionHistory.tsx | 16 ++++++++++------ src/components/HelpDialog.tsx | 11 +++++++++-- src/keys.ts | 2 ++ src/packages/excalidraw/CHANGELOG.md | 8 ++++++++ 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/actions/actionHistory.tsx b/src/actions/actionHistory.tsx index 9e3f6232..c0971c2e 100644 --- a/src/actions/actionHistory.tsx +++ b/src/actions/actionHistory.tsx @@ -6,7 +6,7 @@ import { t } from "../i18n"; import { SceneHistory, HistoryEntry } from "../history"; import { ExcalidrawElement } from "../element/types"; import { AppState } from "../types"; -import { KEYS } from "../keys"; +import { isWindows, KEYS } from "../keys"; import { getElementMap } from "../element"; import { newElementWith } from "../element/mutateElement"; import { fixBindingsAfterDeletion } from "../element/binding"; @@ -59,16 +59,16 @@ const writeData = ( return { commitToHistory }; }; -const testUndo = (shift: boolean) => (event: KeyboardEvent) => - event[KEYS.CTRL_OR_CMD] && /z/i.test(event.key) && event.shiftKey === shift; - type ActionCreator = (history: SceneHistory) => Action; export const createUndoAction: ActionCreator = (history) => ({ name: "undo", perform: (elements, appState) => writeData(elements, appState, () => history.undoOnce()), - keyTest: testUndo(false), + keyTest: (event) => + event[KEYS.CTRL_OR_CMD] && + event.key.toLowerCase() === KEYS.Z && + !event.shiftKey, PanelComponent: ({ updateData }) => ( ({ name: "redo", perform: (elements, appState) => writeData(elements, appState, () => history.redoOnce()), - keyTest: testUndo(true), + keyTest: (event) => + (event[KEYS.CTRL_OR_CMD] && + event.shiftKey && + event.key.toLowerCase() === KEYS.Z) || + (isWindows && event.ctrlKey && !event.shiftKey && event.key === KEYS.Y), PanelComponent: ({ updateData }) => ( void }) => { /> +## [Unreleased] + +## Excalidraw Library + +### Features + +- Support `Ctrl-Y` shortcut to redo on Windows [#2831](https://github.com/excalidraw/excalidraw/pull/2831). + ## 0.2.1 ## Excalidraw API