CodeEditor: Save with Ctrl+S via onKeyDown instead of addCommand (#68955)

Change addCommand to onKeyDown
pull/68786/head
Tobias Skarhed 2 years ago committed by GitHub
parent f22d1d14a0
commit 25b89babac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      packages/grafana-ui/src/components/Monaco/CodeEditor.tsx

@ -99,7 +99,14 @@ class UnthemedCodeEditor extends PureComponent<Props> {
this.getEditorValue = () => editor.getValue();
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, this.onSave);
// Save when pressing Ctrl+S or Cmd+S
editor.onKeyDown((e: monacoType.IKeyboardEvent) => {
if (e.keyCode === monaco.KeyCode.KeyS && (e.ctrlKey || e.metaKey)) {
e.preventDefault();
this.onSave();
}
});
const languagePromise = this.loadCustomLanguage();
if (onEditorDidMount) {

Loading…
Cancel
Save