Skip to content

Commit 473d910

Browse files
committed
fix: enable in monaco editor
1 parent 20d31c4 commit 473d910

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

src/containers/AsideNavigation/AsideNavigation.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,28 @@ export function AsideNavigation(props: AsideNavigationProps) {
120120

121121
return <HelpCenterContent view="single" footerItems={footerItemsWithHandlers} />;
122122
};
123-
124123
React.useEffect(() => {
124+
// Register hotkey for keyboard shortcuts
125125
hotkeys(SHORTCUTS_HOTKEY, (event) => {
126126
event.preventDefault();
127127
setVisiblePanel(Panel.Hotkeys);
128128
});
129+
130+
// Add listener for custom event from Monaco editor
131+
const handleOpenKeyboardShortcutsPanel = () => {
132+
setVisiblePanel(Panel.Hotkeys);
133+
};
134+
135+
window.addEventListener('openKeyboardShortcutsPanel', handleOpenKeyboardShortcutsPanel);
136+
129137
return () => {
130138
hotkeys.unbind(SHORTCUTS_HOTKEY);
139+
window.removeEventListener(
140+
'openKeyboardShortcutsPanel',
141+
handleOpenKeyboardShortcutsPanel,
142+
);
131143
};
132-
});
144+
}, []);
133145

134146
return (
135147
<React.Fragment>

src/containers/AsideNavigation/constants.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {isMac} from './utils';
22

3-
export const SHORTCUTS_HOTKEY = 'Shift+K';
3+
export const SHORTCUTS_HOTKEY = isMac() ? 'cmd+K' : 'ctrl+K';
44

55
// Hotkeys configuration for the keyboard shortcuts panel
66
export const HOTKEYS = [

src/containers/Tenant/Query/QueryEditor/YqlEditor.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ export function YqlEditor({
8888
monacoGhostInstance?.unregister();
8989
};
9090
}, [isCodeAssistEnabled, monacoGhostConfig, monacoGhostInstance, prepareUserQueriesCache]);
91-
9291
const editorDidMount = (editor: Monaco.editor.IStandaloneCodeEditor, monaco: typeof Monaco) => {
9392
window.ydbEditor = editor;
9493
const keybindings = getKeyBindings(monaco);
@@ -102,6 +101,17 @@ export function YqlEditor({
102101
}
103102
});
104103

104+
editor.addAction({
105+
id: 'openKeyboardShortcutsPanel',
106+
label: 'Open Keyboard Shortcuts Panel',
107+
keybindings: [keybindings.shortcutsHotkey],
108+
run: () => {
109+
// Dispatch an event that can be caught by the AsideNavigation component
110+
const event = new CustomEvent('openKeyboardShortcutsPanel');
111+
window.dispatchEvent(event);
112+
},
113+
});
114+
105115
if (window.api.codeAssist) {
106116
setMonacoGhostInstance(createMonacoGhostInstance(editor));
107117
}

src/containers/Tenant/Query/QueryEditor/keybindings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ export function getKeyBindings(monaco: typeof Monaco) {
1313
selectNextQuery: ctrlKey | KeyCode.DownArrow,
1414
saveQuery: ctrlKey | KeyCode.KeyS,
1515
saveSelectedQuery: ctrlKey | KeyMod.Shift | KeyCode.KeyS,
16+
shortcutsHotkey: ctrlKey | KeyCode.KeyK,
1617
};
1718
}

0 commit comments

Comments
 (0)