feat: keyboard shortcuts for primary actions (#2030)

This commit is contained in:
Mo
2022-11-18 09:01:48 -06:00
committed by GitHub
parent 0309912f98
commit f49ba6bd4d
67 changed files with 1296 additions and 555 deletions

View File

@@ -1,7 +1,9 @@
import { WebApplication } from '@/Application/Application'
import { InternalEventBus, SNNote } from '@standardnotes/snjs'
import { OPEN_NOTE_HISTORY_COMMAND } from '@standardnotes/ui-services'
import { action, makeObservable, observable } from 'mobx'
import { AbstractViewController } from '../Abstract/AbstractViewController'
import { NotesControllerInterface } from '../NotesController/NotesControllerInterface'
export class HistoryModalController extends AbstractViewController {
note?: SNNote = undefined
@@ -11,13 +13,23 @@ export class HistoryModalController extends AbstractViewController {
this.note = undefined
}
constructor(application: WebApplication, eventBus: InternalEventBus) {
constructor(application: WebApplication, eventBus: InternalEventBus, notesController: NotesControllerInterface) {
super(application, eventBus)
makeObservable(this, {
note: observable,
setNote: action,
})
this.disposers.push(
application.keyboardService.addCommandHandler({
command: OPEN_NOTE_HISTORY_COMMAND,
onKeyDown: () => {
this.openModal(notesController.firstSelectedNote)
return true
},
}),
)
}
setNote = (note: SNNote | undefined) => {