mirror of
https://github.com/stackblitz/bolt.new
synced 2024-11-27 22:42:21 +00:00
40 lines
744 B
TypeScript
40 lines
744 B
TypeScript
import { map } from 'nanostores';
|
|
import { workbenchStore } from './workbench';
|
|
|
|
export interface Shortcut {
|
|
key: string;
|
|
ctrlKey?: boolean;
|
|
shiftKey?: boolean;
|
|
altKey?: boolean;
|
|
metaKey?: boolean;
|
|
ctrlOrMetaKey?: boolean;
|
|
action: () => void;
|
|
}
|
|
|
|
export interface Shortcuts {
|
|
toggleTerminal: Shortcut;
|
|
}
|
|
|
|
export interface Settings {
|
|
shortcuts: Shortcuts;
|
|
}
|
|
|
|
export const shortcutsStore = map<Shortcuts>({
|
|
toggleTerminal: {
|
|
key: 'j',
|
|
ctrlOrMetaKey: true,
|
|
action: () => workbenchStore.toggleTerminal(),
|
|
},
|
|
});
|
|
|
|
export const settingsStore = map<Settings>({
|
|
shortcuts: shortcutsStore.get(),
|
|
});
|
|
|
|
shortcutsStore.subscribe((shortcuts) => {
|
|
settingsStore.set({
|
|
...settingsStore.get(),
|
|
shortcuts,
|
|
});
|
|
});
|