Replace codemirror theme indent hardcoding
This commit is contained in:
parent
a3dbc627d1
commit
f4d1f36ce1
|
@ -537,7 +537,7 @@ onDOMscriptReady('/codemirror.js').then(() => {
|
||||||
'xq-dark',
|
'xq-dark',
|
||||||
'xq-light',
|
'xq-light',
|
||||||
'yeti',
|
'yeti',
|
||||||
'zenburn'
|
'zenburn',
|
||||||
/* populate-theme-end */
|
/* populate-theme-end */
|
||||||
];
|
];
|
||||||
localStorage.codeMirrorThemes = themes.join(' ');
|
localStorage.codeMirrorThemes = themes.join(' ');
|
||||||
|
|
|
@ -15,11 +15,13 @@ async function getThemes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceThemes(content, themes) {
|
function replaceThemes(content, themes) {
|
||||||
const list = JSON.stringify(themes, null, 8).replace(/"/g, '\'');
|
const lineFeed = content.includes('\r\n') ? '\r\n' : '\n';
|
||||||
return content.replace(
|
return content.replace(
|
||||||
/\/\*\s*populate-theme-start\s*\*\/[\s\S]+\/\*\s*populate-theme-end\s*\*\//,
|
/(\x20+)(\/\*\s*populate-theme-start\s*\*\/)[\s\S]+?(\/\*\s*populate-theme-end\s*\*\/)/,
|
||||||
// strip off square brackets & first 8 spaces
|
(_, indent, intro, outro) =>
|
||||||
`/* populate-theme-start */\n${list.substring(2, list.length - 2)}\n /* populate-theme-end */`
|
indent + intro + lineFeed +
|
||||||
|
themes.map(_ => `${indent}'${_}',`).join(lineFeed) + lineFeed +
|
||||||
|
indent + outro
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user