simplify toggleEditorFocus now that CM 5.35 handles Ctrl-Pause
This commit is contained in:
parent
77d44c233e
commit
6e8ff5b9ef
|
@ -30,8 +30,6 @@
|
||||||
'Alt-Enter': 'toggleStyle',
|
'Alt-Enter': 'toggleStyle',
|
||||||
'Alt-PageDown': 'nextEditor',
|
'Alt-PageDown': 'nextEditor',
|
||||||
'Alt-PageUp': 'prevEditor',
|
'Alt-PageUp': 'prevEditor',
|
||||||
// show the hotkey in keymap info popup by adding a dummy command
|
|
||||||
// TODO: implement as a normal command when CodeMirror is fixed
|
|
||||||
'Ctrl-Pause': 'toggleEditorFocus',
|
'Ctrl-Pause': 'toggleEditorFocus',
|
||||||
}),
|
}),
|
||||||
maxHighlightLength: 100e3,
|
maxHighlightLength: 100e3,
|
||||||
|
@ -44,19 +42,6 @@
|
||||||
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 = {};
|
||||||
|
|
|
@ -14,6 +14,7 @@ onDOMscriptReady('/codemirror.js').then(() => {
|
||||||
const COMMANDS = {
|
const COMMANDS = {
|
||||||
save,
|
save,
|
||||||
toggleStyle,
|
toggleStyle,
|
||||||
|
toggleEditorFocus,
|
||||||
jumpToLine,
|
jumpToLine,
|
||||||
nextEditor, prevEditor,
|
nextEditor, prevEditor,
|
||||||
};
|
};
|
||||||
|
@ -198,6 +199,15 @@ onDOMscriptReady('/codemirror.js').then(() => {
|
||||||
}, {value: cur.line + 1});
|
}, {value: cur.line + 1});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleEditorFocus(cm) {
|
||||||
|
if (!cm) return;
|
||||||
|
if (cm.hasFocus()) {
|
||||||
|
setTimeout(() => cm.display.input.blur());
|
||||||
|
} else {
|
||||||
|
cm.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function refocusMinidialog(cm) {
|
function refocusMinidialog(cm) {
|
||||||
const section = cm.getSection();
|
const section = cm.getSection();
|
||||||
if (!$('.CodeMirror-dialog', section)) {
|
if (!$('.CodeMirror-dialog', section)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user