fix editor theme in FF containers, fixes #1222
This commit is contained in:
parent
2d5788766a
commit
fa2dec724a
|
@ -95,13 +95,18 @@ const baseInit = (() => {
|
||||||
/** Preloads the theme so CodeMirror can use the correct metrics in its first render */
|
/** Preloads the theme so CodeMirror can use the correct metrics in its first render */
|
||||||
async function loadTheme() {
|
async function loadTheme() {
|
||||||
const theme = prefs.get('editor.theme');
|
const theme = prefs.get('editor.theme');
|
||||||
|
if (!CODEMIRROR_THEMES.includes(theme)) {
|
||||||
|
prefs.set('editor.theme', 'default');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (theme !== 'default') {
|
if (theme !== 'default') {
|
||||||
const el = $('#cm-theme');
|
const el = $('#cm-theme');
|
||||||
const el2 = await require([`/vendor/codemirror/theme/${theme}.css`]);
|
const el2 = await require([`/vendor/codemirror/theme/${theme}.css`]);
|
||||||
el2.id = el.id;
|
el2.id = el.id;
|
||||||
el.remove();
|
el.remove();
|
||||||
if (!el2.sheet) {
|
// FF containers take more time to load CSS
|
||||||
prefs.set('editor.theme', 'default');
|
for (let retry = 0; !el2.sheet && ++retry <= 10;) {
|
||||||
|
await new Promise(requestAnimationFrame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user