Ctrl-Pause defocuses/focuses the editor
This commit is contained in:
parent
2d12bfd1f5
commit
2dfaa22c35
|
@ -1,4 +1,4 @@
|
||||||
/* global CodeMirror prefs loadScript editor */
|
/* global CodeMirror prefs loadScript editor editors */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@
|
||||||
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'
|
||||||
|
@ -41,6 +40,19 @@
|
||||||
cm.blockComment(cm.getCursor('from'), cm.getCursor('to'), {fullLines: false});
|
cm.blockComment(cm.getCursor('from'), cm.getCursor('to'), {fullLines: false});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Ctrl-Pause defocuses/focuses the editor
|
||||||
|
addEventListener('keydown', event => {
|
||||||
|
if (event.code === 'Pause' && event.ctrlKey && !event.shiftKey && !event.altKey && !event.metaKey) {
|
||||||
|
event.preventDefault();
|
||||||
|
const cm = window.editors && (editors.lastActive || editors[0]) || ($('.CodeMirror') || {}).CodeMirror;
|
||||||
|
if (cm && cm.hasFocus()) {
|
||||||
|
setTimeout(() => cm.display.input.blur());
|
||||||
|
} else if (cm) {
|
||||||
|
cm.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
// 'basic' keymap only has basic keys by design, so we skip it
|
// 'basic' keymap only has basic keys by design, so we skip it
|
||||||
|
|
||||||
const extraKeysCommands = {};
|
const extraKeysCommands = {};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user