From 7ab49ff5bcefc3392eab09d78492e313120ded56 Mon Sep 17 00:00:00 2001 From: Grace Date: Tue, 3 Dec 2024 09:40:16 +0000 Subject: [PATCH] Add edit in MakeCode shortcut --- src/keyboard-shortcuts.ts | 1 + src/pages/TestingModelPage.tsx | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/keyboard-shortcuts.ts b/src/keyboard-shortcuts.ts index d2ce0f006..a2ac91965 100644 --- a/src/keyboard-shortcuts.ts +++ b/src/keyboard-shortcuts.ts @@ -9,6 +9,7 @@ export const keyboardShortcuts = { renameAction: ["F2"], connect: ["ctrl+shift+c", "meta+shift+c"], disconnect: ["ctrl+shift+d", "meta+shift+d"], + editInMakeCode: ["ctrl+shift+e", "meta+shift+e"], }; export const globalShortcutConfig = { diff --git a/src/pages/TestingModelPage.tsx b/src/pages/TestingModelPage.tsx index 055605eda..727ca9389 100644 --- a/src/pages/TestingModelPage.tsx +++ b/src/pages/TestingModelPage.tsx @@ -12,9 +12,11 @@ import { VStack, } from "@chakra-ui/react"; import { useCallback, useEffect, useState } from "react"; +import { useHotkeys } from "react-hotkeys-hook"; import { RiDeleteBin2Line } from "react-icons/ri"; import { FormattedMessage, useIntl } from "react-intl"; import { useNavigate } from "react-router"; +import { useBufferedData } from "../buffered-data-hooks"; import BackArrow from "../components/BackArrow"; import DefaultPageLayout, { ProjectMenuItems, @@ -27,10 +29,10 @@ import TestingModelTable from "../components/TestingModelTable"; import { useConnectActions } from "../connect-actions-hooks"; import { useConnectionStage } from "../connection-stage-hooks"; import { useProject } from "../hooks/project-hooks"; +import { globalShortcutConfig, keyboardShortcuts } from "../keyboard-shortcuts"; import { useStore } from "../store"; import { tourElClassname } from "../tours"; import { createDataSamplesPageUrl } from "../urls"; -import { useBufferedData } from "../buffered-data-hooks"; const TestingModelPage = () => { const navigate = useNavigate(); @@ -96,6 +98,11 @@ const TestingModelPage = () => { incompatibleEditorDeviceDisclosure.onClose(); setEditorLoading(false); }, [incompatibleEditorDeviceDisclosure, openEditor]); + useHotkeys( + keyboardShortcuts.editInMakeCode, + maybeOpenEditor, + globalShortcutConfig + ); return model ? (