feat: keyboard shortcuts for primary actions (#2030)
This commit is contained in:
@@ -29,7 +29,7 @@ const IndicatorWithTooltip = ({
|
||||
children: ReactNode
|
||||
animateIcon?: boolean
|
||||
}) => (
|
||||
<div className="relative">
|
||||
<div className="note-status-tooltip-container relative">
|
||||
<button
|
||||
className={classNames('peer flex h-5 w-5 items-center justify-center rounded-full', className)}
|
||||
onClick={onClick}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import { WebApplication } from '@/Application/Application'
|
||||
import { ViewControllerManager } from '@/Controllers/ViewControllerManager'
|
||||
import { NotesController } from '@/Controllers/NotesController'
|
||||
import { NotesController } from '@/Controllers/NotesController/NotesController'
|
||||
import {
|
||||
ApplicationEvent,
|
||||
ProposedSecondsToDeferUILevelSessionExpirationDuringActiveInteraction,
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
SNComponent,
|
||||
SNNote,
|
||||
} from '@standardnotes/snjs'
|
||||
import { confirmDialog, KeyboardKey, KeyboardModifier } from '@standardnotes/ui-services'
|
||||
import { confirmDialog, DELETE_NOTE_KEYBOARD_COMMAND, KeyboardKey } from '@standardnotes/ui-services'
|
||||
import { ChangeEventHandler, createRef, KeyboardEventHandler, RefObject } from 'react'
|
||||
import { SuperEditor } from './SuperEditor/SuperEditor'
|
||||
import IndicatorCircle from '../IndicatorCircle/IndicatorCircle'
|
||||
@@ -764,11 +764,10 @@ class NoteView extends AbstractComponent<NoteViewProps, State> {
|
||||
}
|
||||
|
||||
registerKeyboardShortcuts() {
|
||||
this.removeTrashKeyObserver = this.application.io.addKeyObserver({
|
||||
key: KeyboardKey.Backspace,
|
||||
this.removeTrashKeyObserver = this.application.keyboardService.addCommandHandler({
|
||||
command: DELETE_NOTE_KEYBOARD_COMMAND,
|
||||
notTags: ['INPUT', 'TEXTAREA'],
|
||||
notElementIds: [SuperEditorContentId],
|
||||
modifiers: [KeyboardModifier.Meta],
|
||||
onKeyDown: () => {
|
||||
this.deleteNote(false).catch(console.error)
|
||||
},
|
||||
@@ -877,7 +876,7 @@ class NoteView extends AbstractComponent<NoteViewProps, State> {
|
||||
/>
|
||||
</div>
|
||||
{renderHeaderOptions && (
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="note-view-options-buttons flex items-center gap-3">
|
||||
<LinkedItemsButton
|
||||
filesController={this.viewControllerManager.filesController}
|
||||
linkingController={this.viewControllerManager.linkingController}
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
PrefKey,
|
||||
WebAppEvent,
|
||||
} from '@standardnotes/snjs'
|
||||
import { KeyboardKey } from '@standardnotes/ui-services'
|
||||
import { TAB_COMMAND } from '@standardnotes/ui-services'
|
||||
import { ChangeEventHandler, forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react'
|
||||
import { NoteViewController } from '../Controller/NoteViewController'
|
||||
|
||||
@@ -181,9 +181,9 @@ export const PlainEditor = forwardRef<PlainEditorInterface, Props>(
|
||||
return
|
||||
}
|
||||
|
||||
tabObserverDisposer.current = application.io.addKeyObserver({
|
||||
tabObserverDisposer.current = application.keyboardService.addCommandHandler({
|
||||
element: editor,
|
||||
key: KeyboardKey.Tab,
|
||||
command: TAB_COMMAND,
|
||||
onKeyDown: (event) => {
|
||||
if (document.hidden || note.current.locked || event.shiftKey) {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user