simplify theme preloader
This commit is contained in:
parent
a6f63d096e
commit
1e1ff73612
|
@ -72,7 +72,6 @@
|
||||||
<script src="edit/codemirror-default.js"></script>
|
<script src="edit/codemirror-default.js"></script>
|
||||||
|
|
||||||
<link rel="stylesheet" href="/edit/codemirror-default.css">
|
<link rel="stylesheet" href="/edit/codemirror-default.css">
|
||||||
<link id="cm-theme" rel="stylesheet">
|
|
||||||
|
|
||||||
<template data-id="appliesTo">
|
<template data-id="appliesTo">
|
||||||
<li>
|
<li>
|
||||||
|
|
14
edit/edit.js
14
edit/edit.js
|
@ -92,14 +92,12 @@ function preinit() {
|
||||||
});
|
});
|
||||||
|
|
||||||
// preload the theme so that CodeMirror can calculate its metrics in DOMContentLoaded->setupLivePrefs()
|
// preload the theme so that CodeMirror can calculate its metrics in DOMContentLoaded->setupLivePrefs()
|
||||||
new MutationObserver((mutations, observer) => {
|
document.head.appendChild(
|
||||||
const themeElement = $('#cm-theme');
|
$create('link#cm-theme', {
|
||||||
if (themeElement) {
|
rel: 'stylesheet',
|
||||||
themeElement.href = prefs.get('editor.theme') === 'default' ? ''
|
href: prefs.get('editor.theme') === 'default' ? '' :
|
||||||
: 'vendor/codemirror/theme/' + prefs.get('editor.theme') + '.css';
|
'vendor/codemirror/theme/' + prefs.get('editor.theme') + '.css'
|
||||||
observer.disconnect();
|
}));
|
||||||
}
|
|
||||||
}).observe(document, {subtree: true, childList: true});
|
|
||||||
|
|
||||||
if (chrome.windows) {
|
if (chrome.windows) {
|
||||||
queryTabs({currentWindow: true}).then(tabs => {
|
queryTabs({currentWindow: true}).then(tabs => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user