1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-19 20:51:42 +00:00

use codemirror

This commit is contained in:
Dick Choi
2016-10-03 22:28:13 +09:00
parent 041232fbdd
commit 90b490c28b
17 changed files with 217 additions and 1079 deletions

View File

@@ -4,6 +4,8 @@ const OSX = global.process.platform === 'darwin'
const electron = require('electron')
const { ipcRenderer } = electron
let isInitialized = false
const defaultConfig = {
zoom: 1,
isSideNavFolded: false,
@@ -19,11 +21,11 @@ const defaultConfig = {
defaultNote: 'ALWAYS_ASK' // 'ALWAYS_ASK', 'SNIPPET_NOTE', 'MARKDOWN_NOTE'
},
editor: {
theme: 'xcode',
theme: 'default',
fontSize: '14',
fontFamily: 'Monaco, Consolas',
indentType: 'space',
indentSize: '4',
indentSize: '2',
switchPreview: 'BLUR' // Available value: RIGHTCLICK, BLUR
},
preview: {
@@ -64,6 +66,20 @@ function get () {
_save(config)
}
if (!isInitialized) {
isInitialized = true
let editorTheme = document.getElementById('editorTheme')
if (editorTheme == null) {
editorTheme = document.createElement('link')
editorTheme.setAttribute('id', 'editorTheme')
editorTheme.setAttribute('rel', 'stylesheet')
document.head.appendChild(editorTheme)
}
if (config.editor.theme !== 'default') {
editorTheme.setAttribute('href', '../node_modules/codemirror/theme/' + config.editor.theme + '.css')
}
}
return config
}
@@ -79,6 +95,15 @@ function set (updates) {
document.body.setAttribute('data-theme', 'default')
}
let editorTheme = document.getElementById('editorTheme')
if (editorTheme == null) {
editorTheme = document.createElement('link')
editorTheme.setAttribute('id', 'editorTheme')
editorTheme.setAttribute('rel', 'stylesheet')
document.head.appendChild(editorTheme)
}
editorTheme.setAttribute('href', '../node_modules/codemirror/theme/' + newConfig.editor.theme + '.css')
ipcRenderer.send('config-renew', {
config: get()
})

View File

@@ -21,10 +21,15 @@ function resolveStorageNotes (storage) {
return /\.cson$/.test(notePath)
})
.map(function parseCSONFile (notePath) {
let data = CSON.readFileSync(path.join(notesDirPath, notePath))
data.key = path.basename(notePath, '.cson')
data.storage = storage.key
return data
try {
let data = CSON.readFileSync(path.join(notesDirPath, notePath))
data.key = path.basename(notePath, '.cson')
data.storage = storage.key
return data
} catch (err) {
console.error(notePath)
throw err
}
})
return Promise.resolve(notes)