From fb29638d00bea8d60a1d60dcc286474c30a5fa23 Mon Sep 17 00:00:00 2001 From: tophf Date: Mon, 11 Dec 2017 08:32:27 +0300 Subject: [PATCH] defocus codemirror on Esc --- edit/codemirror-default.js | 1 + edit/codemirror-editing-hooks.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/edit/codemirror-default.js b/edit/codemirror-default.js index 3a619cc3..02fdc676 100644 --- a/edit/codemirror-default.js +++ b/edit/codemirror-default.js @@ -27,6 +27,7 @@ keyMap: prefs.get('editor.keyMap'), extraKeys: Object.assign(CodeMirror.defaults.extraKeys || {}, { // independent of current keyMap + 'Esc': 'defocusEditor', 'Alt-Enter': 'toggleStyle', 'Alt-PageDown': 'nextEditor', 'Alt-PageUp': 'prevEditor' diff --git a/edit/codemirror-editing-hooks.js b/edit/codemirror-editing-hooks.js index d8af16d0..996a8a92 100644 --- a/edit/codemirror-editing-hooks.js +++ b/edit/codemirror-editing-hooks.js @@ -13,6 +13,7 @@ onDOMscriptReady('/codemirror.js').then(() => { save, toggleStyle, jumpToLine, + defocusEditor, nextEditor, prevEditor, find, findNext, findPrev, replace, replaceAll, }; @@ -155,6 +156,10 @@ onDOMscriptReady('/codemirror.js').then(() => { return this.display.wrapper.parentNode; } + function defocusEditor(cm) { + cm.display.input.blur(); + } + function nextEditor(cm) { return nextPrevEditor(cm, 1); }