From 484b003b34c74b33e2b5b955796c7bc0e765e570 Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Fri, 26 Jul 2019 13:04:53 +0900 Subject: [PATCH] Fix theme paths --- browser/components/MarkdownPreview.js | 10 +++++----- browser/lib/consts.js | 9 ++++----- browser/main/lib/ConfigManager.js | 4 ++-- browser/main/modals/PreferencesModal/UiTab.js | 4 ++-- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/browser/components/MarkdownPreview.js b/browser/components/MarkdownPreview.js index ef178298..ed13099f 100755 --- a/browser/components/MarkdownPreview.js +++ b/browser/components/MarkdownPreview.js @@ -325,7 +325,7 @@ export default class MarkdownPreview extends React.Component { body, this.props.storagePath ) - const files = [this.GetCodeThemeLink(codeBlockTheme), ...CSS_FILES] + const files = [this.getCodeThemeLink(codeBlockTheme), ...CSS_FILES] files.forEach(file => { if (global.process.platform === 'win32') { file = file.replace('file:///', '') @@ -637,7 +637,7 @@ export default class MarkdownPreview extends React.Component { this.getWindow().document.getElementById( 'codeTheme' - ).href = this.GetCodeThemeLink(codeBlockTheme) + ).href = this.getCodeThemeLink(codeBlockTheme) this.getWindow().document.getElementById('style').innerHTML = buildStyle( fontFamily, fontSize, @@ -650,11 +650,11 @@ export default class MarkdownPreview extends React.Component { ) } - GetCodeThemeLink (name) { + getCodeThemeLink (name) { const theme = consts.THEMES.find(theme => theme.name === name) - return theme - ? (win ? theme.path : `${appPath}/${theme.path}`) + return theme != null + ? theme.path : `${appPath}/node_modules/codemirror/theme/elegant.css` } diff --git a/browser/lib/consts.js b/browser/lib/consts.js index 3603c202..ed497376 100644 --- a/browser/lib/consts.js +++ b/browser/lib/consts.js @@ -19,7 +19,7 @@ const themes = paths return { name, - path: path.join(directory.split(/\//g).slice(-3).join('/'), file), + path: path.join(directory, file), className: `cm-s-${name}` } })) @@ -28,17 +28,16 @@ const themes = paths themes.splice(themes.findIndex(({ name }) => name === 'solarized'), 1, { name: 'solarized dark', - path: `${CODEMIRROR_THEME_PATH}/solarized.css`, + path: path.join(paths[0], 'solarized.css'), className: `cm-s-solarized cm-s-dark` }, { name: 'solarized light', - path: `${CODEMIRROR_THEME_PATH}/solarized.css`, + path: path.join(paths[0], 'solarized.css'), className: `cm-s-solarized cm-s-light` }) - themes.splice(0, 0, { name: 'default', - path: `${CODEMIRROR_THEME_PATH}/elegant.css`, + path: path.join(paths[0], 'elegant.css'), className: `cm-s-default` }) diff --git a/browser/main/lib/ConfigManager.js b/browser/main/lib/ConfigManager.js index 1ef27d5e..e13cdbc1 100644 --- a/browser/main/lib/ConfigManager.js +++ b/browser/main/lib/ConfigManager.js @@ -143,7 +143,7 @@ function get () { const theme = consts.THEMES.find(theme => theme.name === config.editor.theme) if (theme) { - editorTheme.setAttribute('href', win ? theme.path : `../${theme.path}`) + editorTheme.setAttribute('href', theme.path) } else { config.editor.theme = 'default' } @@ -191,7 +191,7 @@ function set (updates) { const newTheme = consts.THEMES.find(theme => theme.name === newConfig.editor.theme) if (newTheme) { - editorTheme.setAttribute('href', win ? newTheme.path : `../${newTheme.path}`) + editorTheme.setAttribute('href', newTheme.path) } ipcRenderer.send('config-renew', { diff --git a/browser/main/modals/PreferencesModal/UiTab.js b/browser/main/modals/PreferencesModal/UiTab.js index e26f088f..cff063ff 100644 --- a/browser/main/modals/PreferencesModal/UiTab.js +++ b/browser/main/modals/PreferencesModal/UiTab.js @@ -14,7 +14,7 @@ import { getLanguages } from 'browser/lib/Languages' import normalizeEditorFontFamily from 'browser/lib/normalizeEditorFontFamily' const OSX = global.process.platform === 'darwin' -const win = global.process.platform === 'win32' +const WIN = global.process.platform === 'win32' const electron = require('electron') const ipc = electron.ipcRenderer @@ -137,7 +137,7 @@ class UiTab extends React.Component { const theme = consts.THEMES.find(theme => theme.name === newCodemirrorTheme) if (theme) { - checkHighLight.setAttribute('href', win ? theme.path : `../${theme.path}`) + checkHighLight.setAttribute('href', theme.path) } }