unregister CM on closing showCodeMirrorPopup

This commit is contained in:
tophf 2017-12-09 18:23:18 +03:00
parent 9c1c15465e
commit 5f1f9c4d86
2 changed files with 7 additions and 2 deletions

View File

@ -562,7 +562,7 @@ function showCodeMirrorPopup(title, html, options) {
const popup = showHelp(title, html); const popup = showHelp(title, html);
popup.classList.add('big'); popup.classList.add('big');
const cm = popup.codebox = CodeMirror($('.contents', popup), Object.assign({ let cm = popup.codebox = CodeMirror($('.contents', popup), Object.assign({
mode: 'css', mode: 'css',
lineNumbers: true, lineNumbers: true,
lineWrapping: true, lineWrapping: true,
@ -577,6 +577,10 @@ function showCodeMirrorPopup(title, html, options) {
cm.focus(); cm.focus();
cm.on('focus', () => cm.rerouteHotkeys(false)); cm.on('focus', () => cm.rerouteHotkeys(false));
cm.on('blur', () => cm.rerouteHotkeys(true)); cm.on('blur', () => cm.rerouteHotkeys(true));
window.addEventListener('closeHelp', function _() {
window.removeEventListener('closeHelp', _);
cm = popup.codebox = null;
});
return popup; return popup;
} }

View File

@ -419,7 +419,7 @@ function setupLinterPopup(config) {
}); });
$('.contents', popup).appendChild(makeFooter()); $('.contents', popup).appendChild(makeFooter());
const cm = popup.codebox; let cm = popup.codebox;
cm.focus(); cm.focus();
cm.setValue(config); cm.setValue(config);
cm.clearHistory(); cm.clearHistory();
@ -431,6 +431,7 @@ function setupLinterPopup(config) {
window.addEventListener('closeHelp', function _() { window.addEventListener('closeHelp', function _() {
window.removeEventListener('closeHelp', _); window.removeEventListener('closeHelp', _);
cm.rerouteHotkeys(true); cm.rerouteHotkeys(true);
cm = null;
}); });
loadScript([ loadScript([