1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

fix solarized dark/light code block thema bug

solarized dark/light shares the same css in CodeMirror.
You can see more detail info in commit 5b17808569
We need to treat solarized as a special case in code block also.
This commit is contained in:
yosmoc
2017-11-04 01:01:50 +01:00
parent 7d97784a58
commit 0bf7e8b705

View File

@@ -258,7 +258,7 @@ export default class MarkdownPreview extends React.Component {
theme = consts.THEMES.some((_theme) => _theme === theme) && theme !== 'default' theme = consts.THEMES.some((_theme) => _theme === theme) && theme !== 'default'
? theme ? theme
: 'elegant' : 'elegant'
this.getWindow().document.getElementById('codeTheme').href = `${appPath}/node_modules/codemirror/theme/${theme}.css` this.getWindow().document.getElementById('codeTheme').href = `${appPath}/node_modules/codemirror/theme/${theme.split(' ')[0]}.css`
} }
rewriteIframe () { rewriteIframe () {
@@ -330,7 +330,12 @@ export default class MarkdownPreview extends React.Component {
} }
el.parentNode.appendChild(copyIcon) el.parentNode.appendChild(copyIcon)
el.innerHTML = '' el.innerHTML = ''
el.parentNode.className += ` cm-s-${codeBlockTheme} CodeMirror` if (codeBlockTheme.indexOf('solarized') === 0) {
const [refThema, color] = codeBlockTheme.split(' ')
el.parentNode.className += ` cm-s-${refThema} cm-s-${color} CodeMirror`
} else {
el.parentNode.className += ` cm-s-${codeBlockTheme} CodeMirror`
}
CodeMirror.runMode(content, syntax.mime, el, { CodeMirror.runMode(content, syntax.mime, el, {
tabSize: indentSize tabSize: indentSize
}) })