From 651e4bc4c137a36aa777b3f5be608e07d81f18a7 Mon Sep 17 00:00:00 2001 From: Nicolas Echezarreta Date: Tue, 24 Oct 2023 11:59:05 -0300 Subject: [PATCH] add: basic shortcuts --- packages/@dcl/inspector/package-lock.json | 20 ++++++++++++++++--- packages/@dcl/inspector/package.json | 3 ++- .../src/components/Toolbar/Toolbar.tsx | 5 +++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/packages/@dcl/inspector/package-lock.json b/packages/@dcl/inspector/package-lock.json index 2aa483595..0ad151857 100644 --- a/packages/@dcl/inspector/package-lock.json +++ b/packages/@dcl/inspector/package-lock.json @@ -8,7 +8,8 @@ "name": "@dcl/inspector", "version": "0.1.0", "dependencies": { - "@dcl/asset-packs": "^1.2.5" + "@dcl/asset-packs": "^1.2.5", + "react-hotkeys-hook": "^4.4.1" }, "devDependencies": { "@babylonjs/core": "^6.18.0", @@ -6072,7 +6073,6 @@ }, "node_modules/react-dom": { "version": "18.2.0", - "dev": true, "license": "MIT", "dependencies": { "loose-envify": "^1.1.0", @@ -6087,6 +6087,15 @@ "dev": true, "license": "MIT" }, + "node_modules/react-hotkeys-hook": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/react-hotkeys-hook/-/react-hotkeys-hook-4.4.1.tgz", + "integrity": "sha512-sClBMBioFEgFGYLTWWRKvhxcCx1DRznd+wkFHwQZspnRBkHTgruKIHptlK/U/2DPX8BhHoRGzpMVWUXMmdZlmw==", + "peerDependencies": { + "react": ">=16.8.1", + "react-dom": ">=16.8.1" + } + }, "node_modules/react-icons": { "version": "4.8.0", "dev": true, @@ -11996,7 +12005,6 @@ }, "react-dom": { "version": "18.2.0", - "dev": true, "requires": { "loose-envify": "^1.1.0", "scheduler": "^0.23.0" @@ -12006,6 +12014,12 @@ "version": "3.2.0", "dev": true }, + "react-hotkeys-hook": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/react-hotkeys-hook/-/react-hotkeys-hook-4.4.1.tgz", + "integrity": "sha512-sClBMBioFEgFGYLTWWRKvhxcCx1DRznd+wkFHwQZspnRBkHTgruKIHptlK/U/2DPX8BhHoRGzpMVWUXMmdZlmw==", + "requires": {} + }, "react-icons": { "version": "4.8.0", "dev": true, diff --git a/packages/@dcl/inspector/package.json b/packages/@dcl/inspector/package.json index 8df52d6ff..a143a01ac 100644 --- a/packages/@dcl/inspector/package.json +++ b/packages/@dcl/inspector/package.json @@ -2,7 +2,8 @@ "name": "@dcl/inspector", "version": "0.1.0", "dependencies": { - "@dcl/asset-packs": "^1.2.5" + "@dcl/asset-packs": "^1.2.5", + "react-hotkeys-hook": "^4.4.1" }, "devDependencies": { "@babylonjs/core": "^6.18.0", diff --git a/packages/@dcl/inspector/src/components/Toolbar/Toolbar.tsx b/packages/@dcl/inspector/src/components/Toolbar/Toolbar.tsx index 6268d5350..9a82be1c4 100644 --- a/packages/@dcl/inspector/src/components/Toolbar/Toolbar.tsx +++ b/packages/@dcl/inspector/src/components/Toolbar/Toolbar.tsx @@ -1,6 +1,7 @@ import { useCallback } from 'react' import { BiUndo, BiRedo, BiSave, BiBadgeCheck } from 'react-icons/bi' import { RiListSettingsLine } from 'react-icons/ri' +import { useHotkeys } from 'react-hotkeys-hook' import { withSdk } from '../../hoc/withSdk' import { Gizmos } from './Gizmos' @@ -29,6 +30,10 @@ const Toolbar = withSdk(({ sdk }) => { const handleUndo = useCallback(() => dispatch(undo()), []) const handleRedo = useCallback(() => dispatch(redo()), []) + useHotkeys('mod+s', handleSaveClick, { preventDefault: true }, []) + useHotkeys('mod+z', handleUndo, { preventDefault: true }, []) + useHotkeys('mod+y', handleRedo, { preventDefault: true }, []) + return (