Toggle minimap with "M" key

This commit is contained in:
tk338g
2021-02-08 00:56:30 +01:00
parent 4e3bf7e8d2
commit cf35caaf23
7 changed files with 27 additions and 3 deletions
+19
View File
@@ -7,6 +7,7 @@ import { register } from "./register";
import { allowFullScreen, exitFullScreen, isFullScreen } from "../utils";
import { CODES, KEYS } from "../keys";
import { HelpIcon } from "../components/HelpIcon";
import { MiniMap } from "../components/MiniMap";
export const actionToggleCanvasMenu = register({
name: "toggleCanvasMenu",
@@ -84,3 +85,21 @@ export const actionShortcuts = register({
),
keyTest: (event) => event.key === KEYS.QUESTION_MARK,
});
export const actionMinimap = register({
name: "toggleMinimap",
perform: (_elements, appState) => {
return {
appState: {
...appState,
isMinimapEnabled: !appState.isMinimapEnabled,
},
commitToHistory: false,
};
},
PanelComponent: ({ appState, elements }) =>
appState.isMinimapEnabled ? (
<MiniMap appState={appState} elements={getNonDeletedElements(elements)} />
) : null,
keyTest: (event) => event.key === KEYS.M,
});