mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-15 18:56:22 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba76df863c | ||
|
|
da0222f213 | ||
|
|
fb8a2eb2e0 | ||
|
|
cde2e27e04 |
@@ -87,7 +87,11 @@ export default class CodeEditor extends React.Component {
|
|||||||
name: 'Focus title',
|
name: 'Focus title',
|
||||||
bindKey: {win: 'Esc', mac: 'Esc'},
|
bindKey: {win: 'Esc', mac: 'Esc'},
|
||||||
exec: function (editor, e) {
|
exec: function (editor, e) {
|
||||||
remote.getCurrentWebContents().send('list-focus')
|
let currentWindow = remote.getCurrentWebContents()
|
||||||
|
if (config['switch-preview'] === 'rightclick') {
|
||||||
|
currentWindow.send('detail-preview')
|
||||||
|
}
|
||||||
|
currentWindow.send('list-focus')
|
||||||
},
|
},
|
||||||
readOnly: true
|
readOnly: true
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,6 +5,17 @@ const jetpack = require('fs-jetpack')
|
|||||||
const userDataPath = remote.app.getPath('userData')
|
const userDataPath = remote.app.getPath('userData')
|
||||||
const configFile = 'config.json'
|
const configFile = 'config.json'
|
||||||
|
|
||||||
export default function fetchConfig () {
|
const defaultConfig = {
|
||||||
return Object.assign({}, JSON.parse(jetpack.cwd(userDataPath).read(configFile, 'utf-8')))
|
'editor-font-size': '14',
|
||||||
|
'editor-font-family': 'Monaco, Consolas',
|
||||||
|
'editor-indent-type': 'space',
|
||||||
|
'editor-indent-size': '4',
|
||||||
|
'preview-font-size': '14',
|
||||||
|
'preview-font-family': 'Lato',
|
||||||
|
'switch-preview': 'blur',
|
||||||
|
'disable-direct-write': false
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function fetchConfig () {
|
||||||
|
return Object.assign({}, defaultConfig, JSON.parse(jetpack.cwd(userDataPath).read(configFile, 'utf-8')))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ export default class ArticleEditor extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switchPreviewMode (isTemporary = false) {
|
switchPreviewMode (isTemporary = false) {
|
||||||
|
if (this.props.article.mode !== 'markdown') return true
|
||||||
let cursorPosition = this.refs.editor.getCursorPosition()
|
let cursorPosition = this.refs.editor.getCursorPosition()
|
||||||
let firstVisibleRow = this.refs.editor.getFirstVisibleRow()
|
let firstVisibleRow = this.refs.editor.getFirstVisibleRow()
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|||||||
@@ -102,6 +102,10 @@ export default class ArticleDetail extends React.Component {
|
|||||||
if (isModalOpen()) return true
|
if (isModalOpen()) return true
|
||||||
if (this.refs.editor) this.refs.editor.switchEditMode()
|
if (this.refs.editor) this.refs.editor.switchEditMode()
|
||||||
}
|
}
|
||||||
|
this.previewHandler = e => {
|
||||||
|
if (isModalOpen()) return true
|
||||||
|
if (this.refs.editor) this.refs.editor.switchPreviewMode()
|
||||||
|
}
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
article: Object.assign({content: ''}, props.activeArticle),
|
article: Object.assign({content: ''}, props.activeArticle),
|
||||||
@@ -120,6 +124,7 @@ export default class ArticleDetail extends React.Component {
|
|||||||
ipc.on('detail-uncache', this.uncacheHandler)
|
ipc.on('detail-uncache', this.uncacheHandler)
|
||||||
ipc.on('detail-title', this.titleHandler)
|
ipc.on('detail-title', this.titleHandler)
|
||||||
ipc.on('detail-edit', this.editHandler)
|
ipc.on('detail-edit', this.editHandler)
|
||||||
|
ipc.on('detail-preview', this.previewHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount () {
|
componentWillUnmount () {
|
||||||
@@ -130,6 +135,7 @@ export default class ArticleDetail extends React.Component {
|
|||||||
ipc.removeListener('detail-uncache', this.uncacheHandler)
|
ipc.removeListener('detail-uncache', this.uncacheHandler)
|
||||||
ipc.removeListener('detail-title', this.titleHandler)
|
ipc.removeListener('detail-title', this.titleHandler)
|
||||||
ipc.removeListener('detail-edit', this.editHandler)
|
ipc.removeListener('detail-edit', this.editHandler)
|
||||||
|
ipc.removeListener('detail-preview', this.previewHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate (prevProps, prevState) {
|
componentDidUpdate (prevProps, prevState) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ const globalShortcut = electron.globalShortcut
|
|||||||
const jetpack = require('fs-jetpack')
|
const jetpack = require('fs-jetpack')
|
||||||
const mainWindow = require('./main-window')
|
const mainWindow = require('./main-window')
|
||||||
const nodeIpc = require('@rokt33r/node-ipc')
|
const nodeIpc = require('@rokt33r/node-ipc')
|
||||||
|
const _ = require('lodash')
|
||||||
|
|
||||||
const OSX = global.process.platform === 'darwin'
|
const OSX = global.process.platform === 'darwin'
|
||||||
|
|
||||||
@@ -73,28 +74,36 @@ function toggleMain () {
|
|||||||
// Init
|
// Init
|
||||||
global.keymap = Object.assign({}, defaultKeymap, getKeymap())
|
global.keymap = Object.assign({}, defaultKeymap, getKeymap())
|
||||||
|
|
||||||
function registerKey (name, callback, broadcast) {
|
function registerKey (name, callback) {
|
||||||
if (broadcast == null) broadcast = true
|
if (_.isString(global.keymap[name]) && global.keymap[name].trim().length > 0) {
|
||||||
|
|
||||||
try {
|
|
||||||
globalShortcut.register(global.keymap[name], callback)
|
globalShortcut.register(global.keymap[name], callback)
|
||||||
if (broadcast) {
|
|
||||||
mainWindow.webContents.send('APP_SETTING_DONE', {})
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err)
|
|
||||||
if (broadcast) {
|
|
||||||
mainWindow.webContents.send('APP_SETTING_ERROR', {
|
|
||||||
message: 'Failed to apply hotkey: Invalid format'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function registerAllKeys (broadcast) {
|
function registerAllKeys (broadcast) {
|
||||||
if (broadcast == null) broadcast = true
|
if (broadcast == null) broadcast = true
|
||||||
registerKey('toggleFinder', toggleFinder, broadcast)
|
|
||||||
registerKey('toggleMain', toggleMain, broadcast)
|
var errors = []
|
||||||
|
try {
|
||||||
|
registerKey('toggleFinder', toggleFinder)
|
||||||
|
} catch (err) {
|
||||||
|
errors.push('toggleFinder')
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
registerKey('toggleMain', toggleMain)
|
||||||
|
} catch (err) {
|
||||||
|
errors.push('toggleMain')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (broadcast) {
|
||||||
|
if (errors.length === 0) {
|
||||||
|
mainWindow.webContents.send('APP_SETTING_DONE', {})
|
||||||
|
} else {
|
||||||
|
mainWindow.webContents.send('APP_SETTING_ERROR', {
|
||||||
|
message: 'Failed to apply hotkey: ' + errors.join(' ')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
registerAllKeys(false)
|
registerAllKeys(false)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "boost",
|
"name": "boost",
|
||||||
"version": "0.5.2",
|
"version": "0.5.3",
|
||||||
"description": "Boostnote",
|
"description": "Boostnote",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user