Skip to content

Commit 65e383c

Browse files
committed
nav.js: refresh CM after theme switch
1 parent 43683fe commit 65e383c

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

assets/nav.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,11 @@
243243
}
244244
if (window.editor && window.editor.setOption)
245245
window.editor.setOption('theme', on ? 'cppmode-dark' : 'cppmode');
246-
// Switch static CodeMirror blocks theme // Tell sketch iframes about dark mode
246+
// Switch static CodeMirror blocks theme
247+
document.querySelectorAll('.CodeMirror').forEach(el => {
248+
if (el.CodeMirror) { el.CodeMirror.setOption('theme', on ? 'cppmode-dark' : 'cppmode'); el.CodeMirror.refresh(); }
249+
});
250+
// Tell sketch iframes about dark mode
247251
document.querySelectorAll('iframe').forEach(fr => {
248252
try { fr.contentWindow.postMessage(on ? 'dark' : 'light', '*'); } catch(e) {}
249253
});

0 commit comments

Comments
 (0)