mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-02 07:53:55 +03:00
fix tinykeys ssr import
This commit is contained in:
parent
2ec56747da
commit
23069658b0
@ -1,24 +1,26 @@
|
||||
import { building } from '$app/environment';
|
||||
import tinykeys from 'tinykeys';
|
||||
import type Events from '$lib/events';
|
||||
|
||||
export default (events: ReturnType<typeof Events>) => ({
|
||||
on: (combo: string, callback: (event: KeyboardEvent) => void) => {
|
||||
if (building) return () => {};
|
||||
const comboContainsControlKeys =
|
||||
combo.includes('Meta') || combo.includes('Alt') || combo.includes('Ctrl');
|
||||
return tinykeys(window, {
|
||||
[combo]: (event) => {
|
||||
const target = event.target as HTMLElement;
|
||||
const isInput = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA';
|
||||
if (isInput && !comboContainsControlKeys) return;
|
||||
export default async (events: ReturnType<typeof Events>) =>
|
||||
building
|
||||
? { on: () => () => {} }
|
||||
: await import('tinykeys').then(({ default: tinykeys }) => ({
|
||||
on: (combo: string, callback: (event: KeyboardEvent) => void) => {
|
||||
if (building) return () => {};
|
||||
const comboContainsControlKeys =
|
||||
combo.includes('Meta') || combo.includes('Alt') || combo.includes('Ctrl');
|
||||
return tinykeys(window, {
|
||||
[combo]: (event) => {
|
||||
const target = event.target as HTMLElement;
|
||||
const isInput = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA';
|
||||
if (isInput && !comboContainsControlKeys) return;
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
events.closeCommandPalette();
|
||||
callback(event);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
events.closeCommandPalette();
|
||||
callback(event);
|
||||
}
|
||||
});
|
||||
}
|
||||
}));
|
||||
|
@ -46,6 +46,6 @@ export const load: LayoutLoad = wrapLoadWithSentry(async ({ fetch }) => {
|
||||
posthog: Posthog(),
|
||||
sentry: Sentry(),
|
||||
events,
|
||||
hotkeys: Hotkeys(events)
|
||||
hotkeys: await Hotkeys(events)
|
||||
};
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user