UNPKG

svelte-command-palette

Version:

#### Increase your productivity exponentially. 🚀🚀

22 lines (21 loc) • 684 B
import { get } from 'svelte/store'; import { runAction } from '.'; import { paletteStore } from '../store/PaletteStore'; const createShortcuts = ({ actions = [] }) => { return actions.reduce((acc, curr) => { const actionHandler = (eventHandler) => { const storeProps = get(paletteStore); const { isVisible } = storeProps; if (!isVisible) { eventHandler.preventDefault(); runAction({ action: curr }); } }; const { shortcut } = curr; if (shortcut) { acc[shortcut] = actionHandler; } return acc; }, {}); }; export default createShortcuts;