diff --git a/package-lock.json b/package-lock.json index f3f790ce..18db2334 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "azure-iot-explorer", - "version": "0.15.11", + "version": "0.15.12", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 2de0cba5..d36c8b8c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "azure-iot-explorer", - "version": "0.15.11", + "version": "0.15.12", "description": "This project welcomes contributions and suggestions. Most contributions require you to agree to a\r Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us\r the rights to use your contribution. For details, visit https://cla.microsoft.com.", "main": "host/electron.js", "build": { diff --git a/src/app/shared/components/monacoEditor.tsx b/src/app/shared/components/monacoEditor.tsx index 056b2ef6..e61573d1 100644 --- a/src/app/shared/components/monacoEditor.tsx +++ b/src/app/shared/components/monacoEditor.tsx @@ -92,6 +92,23 @@ export const MonacoEditorComponent: React.FC = ({ editorDidMount={(editor): void => { editorRef.current = editor; placeholderContentWidget(editor, placeholder || ''); + + editor.addCommand( + monaco.KeyMod.Alt | monaco.KeyCode.KeyM, + () => { + + /* In Electron, to fully remove focus from the Monaco Editor. + we will need to shift focus to another DOM element or window. + It is due to Electron's integration with Chromium and the way focus is managed between the webview and the main process. + We will create a dummy input, move the focus to it, and then clean it up. */ + const dummyInput = document.createElement("input"); + dummyInput.style.position = "absolute"; + dummyInput.style.opacity = "0"; + document.body.appendChild(dummyInput); + dummyInput.focus(); + setTimeout(() => document.body.removeChild(dummyInput), 0); + } + ); }} value={content} language={language || 'json'}