defocus codemirror on Esc

This commit is contained in:
tophf 2017-12-11 08:32:27 +03:00
parent 60a5fb96be
commit fb29638d00
2 changed files with 6 additions and 0 deletions

View File

@ -27,6 +27,7 @@
keyMap: prefs.get('editor.keyMap'), keyMap: prefs.get('editor.keyMap'),
extraKeys: Object.assign(CodeMirror.defaults.extraKeys || {}, { extraKeys: Object.assign(CodeMirror.defaults.extraKeys || {}, {
// independent of current keyMap // independent of current keyMap
'Esc': 'defocusEditor',
'Alt-Enter': 'toggleStyle', 'Alt-Enter': 'toggleStyle',
'Alt-PageDown': 'nextEditor', 'Alt-PageDown': 'nextEditor',
'Alt-PageUp': 'prevEditor' 'Alt-PageUp': 'prevEditor'

View File

@ -13,6 +13,7 @@ onDOMscriptReady('/codemirror.js').then(() => {
save, save,
toggleStyle, toggleStyle,
jumpToLine, jumpToLine,
defocusEditor,
nextEditor, prevEditor, nextEditor, prevEditor,
find, findNext, findPrev, replace, replaceAll, find, findNext, findPrev, replace, replaceAll,
}; };
@ -155,6 +156,10 @@ onDOMscriptReady('/codemirror.js').then(() => {
return this.display.wrapper.parentNode; return this.display.wrapper.parentNode;
} }
function defocusEditor(cm) {
cm.display.input.blur();
}
function nextEditor(cm) { function nextEditor(cm) {
return nextPrevEditor(cm, 1); return nextPrevEditor(cm, 1);
} }