123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import { AnyAction } from 'redux';
-
- import {
- DISABLE_KEYBOARD_SHORTCUTS,
- ENABLE_KEYBOARD_SHORTCUTS,
- REGISTER_KEYBOARD_SHORTCUT,
- UNREGISTER_KEYBOARD_SHORTCUT
- } from './actionTypes';
- import { IKeyboardShortcut } from './types';
-
- /**
- * Action to register a new shortcut.
- *
- * @param {IKeyboardShortcut} shortcut - The shortcut to register.
- * @returns {AnyAction}
- */
- export const registerShortcut = (shortcut: IKeyboardShortcut): AnyAction => {
- return {
- type: REGISTER_KEYBOARD_SHORTCUT,
- shortcut
- };
- };
-
- /**
- * Action to unregister a shortcut.
- *
- * @param {string} character - The character of the shortcut to unregister.
- * @param {boolean} altKey - Whether the shortcut used altKey.
- * @returns {AnyAction}
- */
- export const unregisterShortcut = (character: string, altKey = false): AnyAction => {
- return {
- alt: altKey,
- type: UNREGISTER_KEYBOARD_SHORTCUT,
- character
- };
- };
-
- /**
- * Action to enable keyboard shortcuts.
- *
- * @returns {AnyAction}
- */
- export const enableKeyboardShortcuts = (): AnyAction => {
- return {
- type: ENABLE_KEYBOARD_SHORTCUTS
- };
- };
-
-
- /**
- * Action to enable keyboard shortcuts.
- *
- * @returns {AnyAction}
- */
- export const disableKeyboardShortcuts = (): AnyAction => {
- return {
- type: DISABLE_KEYBOARD_SHORTCUTS
- };
- };
|