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

Change addCommand to onKeyDown
This commit is contained in:
Tobias Skarhed 2023-05-25 10:49:23 +02:00 committed by GitHub
parent f22d1d14a0
commit 25b89babac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {