File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed
Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change 11<script lang =" ts" >
22 import { paletteStore } from ' ../store/PaletteStore' ;
33 import { onDestroy , onMount , afterUpdate } from ' svelte' ;
4- import tinyKeys , { parseKeybinding } from ' tinykeys' ;
4+ // import tinyKeys, { parseKeybinding } from 'tinykeys';
55 import Portal from ' ./Portal.svelte' ;
66 import ResultPanel from ' ./ResultPanel.svelte' ;
77 import KeyboardButton from ' ./KeyboardButton.svelte' ;
2727
2828 const storeMethods = createStoreMethods ();
2929 const actionMap = createActionMap (commands );
30+ let formattedEscKey = ' '
3031 const { togglePalette, closePalette : closeCommandPalette } = storeMethods ;
3132
3233 const updateStore = () => {
106107 }
107108 };
108109
109- onMount (() => {
110+ onMount (async () => {
111+ const tinyKeys = await import (' tinykeys' )
112+ const {default : tiny, parseKeybinding} = tinyKeys
113+ formattedEscKey = parseKeybinding (' Esc' ).flat ().join (' ' );
110114 const shortcuts = createShortcuts ({
111115 actions: commands
112116 });
113- unsubscribeKbdListener = tinyKeys (window , {
117+ unsubscribeKbdListener = tiny (window , {
114118 ... shortcuts ,
115119 ' $mod+k' : togglePalette ,
116120 Escape: closePalette ,
158162 wrapperElement ?.removeEventListener ?.(' click' , handleOutsideClick );
159163 });
160164
161- const formattedEscKey = parseKeybinding ( ' Esc ' ). flat (). join ( ' ' );
165+
162166 </script >
163167
164168<Portal target =" body" >
Original file line number Diff line number Diff line change 11<script lang =" ts" >
22 import { paletteStore } from ' ../store/PaletteStore' ;
3- import { afterUpdate } from ' svelte' ;
3+ import { afterUpdate , onMount } from ' svelte' ;
44 import { runAction } from ' ../utils' ;
55 import KeyboardButton from ' ./KeyboardButton.svelte' ;
6- import * as tinykeys from ' tinykeys' ;
76 import type { action } from ' $lib/types' ;
87
98 export let action: action ;
3130 });
3231 };
3332
34- if (action .shortcut ) {
35- const parsedShortcut = tinykeys .parseKeybinding (action .shortcut );
33+ onMount (async () => {
34+ const tinyKeys = await import (' tinykeys' );
35+ const {parseKeybinding} = tinyKeys
36+ if (action .shortcut ) {
37+ const parsedShortcut = parseKeybinding (action .shortcut );
3638 formattedShortcut = parsedShortcut .flat ().filter ((s ) => s .length > 0 );
3739 }
40+ })
41+
42+
3843
3944 const onMouseEnter = () => {
4045 isActive = true ;
You can’t perform that action at this time.
0 commit comments