diff --git a/packages/ui-services/src/Keyboard/KeyboardCommands.ts b/packages/ui-services/src/Keyboard/KeyboardCommands.ts index 0982efe90..76a10c3ac 100644 --- a/packages/ui-services/src/Keyboard/KeyboardCommands.ts +++ b/packages/ui-services/src/Keyboard/KeyboardCommands.ts @@ -28,3 +28,4 @@ export const SUPER_SHOW_MARKDOWN_PREVIEW = createKeyboardCommand('SUPER_SHOW_MAR export const SUPER_EXPORT_JSON = createKeyboardCommand('SUPER_EXPORT_JSON') export const SUPER_EXPORT_MARKDOWN = createKeyboardCommand('SUPER_EXPORT_MARKDOWN') export const SUPER_EXPORT_HTML = createKeyboardCommand('SUPER_EXPORT_HTML') +export const OPEN_PREFERENCES_COMMAND = createKeyboardCommand('OPEN_PREFERENCES_COMMAND') diff --git a/packages/ui-services/src/Keyboard/getKeyboardShortcuts.ts b/packages/ui-services/src/Keyboard/getKeyboardShortcuts.ts index 6fe9e4eae..1ec92cda1 100644 --- a/packages/ui-services/src/Keyboard/getKeyboardShortcuts.ts +++ b/packages/ui-services/src/Keyboard/getKeyboardShortcuts.ts @@ -22,6 +22,7 @@ import { STAR_NOTE_COMMAND, PIN_NOTE_COMMAND, SUPER_SHOW_MARKDOWN_PREVIEW, + OPEN_PREFERENCES_COMMAND, } from './KeyboardCommands' import { KeyboardKey } from './KeyboardKey' import { KeyboardModifier } from './KeyboardModifier' @@ -139,5 +140,11 @@ export function getKeyboardShortcuts(platform: Platform, _environment: Environme modifiers: [primaryModifier, KeyboardModifier.Shift], preventDefault: true, }, + { + command: OPEN_PREFERENCES_COMMAND, + key: ',', + modifiers: [primaryModifier], + preventDefault: true, + }, ] } diff --git a/packages/web/src/javascripts/Components/Preferences/PreferencesViewWrapper.tsx b/packages/web/src/javascripts/Components/Preferences/PreferencesViewWrapper.tsx index 8a13b78cd..370067eb2 100644 --- a/packages/web/src/javascripts/Components/Preferences/PreferencesViewWrapper.tsx +++ b/packages/web/src/javascripts/Components/Preferences/PreferencesViewWrapper.tsx @@ -1,12 +1,23 @@ -import { FunctionComponent } from 'react' +import { FunctionComponent, useEffect } from 'react' import { observer } from 'mobx-react-lite' import PreferencesView from './PreferencesView' import { PreferencesViewWrapperProps } from './PreferencesViewWrapperProps' +import { useCommandService } from '../CommandProvider' +import { OPEN_PREFERENCES_COMMAND } from '@standardnotes/ui-services' const PreferencesViewWrapper: FunctionComponent = ({ viewControllerManager, application, }) => { + const commandService = useCommandService() + + useEffect(() => { + return commandService.addCommandHandler({ + command: OPEN_PREFERENCES_COMMAND, + onKeyDown: () => viewControllerManager.preferencesController.openPreferences(), + }) + }, [commandService, viewControllerManager]) + if (!viewControllerManager.preferencesController?.isOpen) { return null }