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

esc to show preview when rightclick to toggle set

This commit is contained in:
Rokt33r
2016-01-19 18:58:27 +09:00
parent fb8a2eb2e0
commit da0222f213
3 changed files with 12 additions and 1 deletions

View File

@@ -87,7 +87,11 @@ export default class CodeEditor extends React.Component {
name: 'Focus title',
bindKey: {win: 'Esc', mac: 'Esc'},
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
})

View File

@@ -65,6 +65,7 @@ export default class ArticleEditor extends React.Component {
}
switchPreviewMode (isTemporary = false) {
if (this.props.article.mode !== 'markdown') return true
let cursorPosition = this.refs.editor.getCursorPosition()
let firstVisibleRow = this.refs.editor.getFirstVisibleRow()
this.setState({

View File

@@ -102,6 +102,10 @@ export default class ArticleDetail extends React.Component {
if (isModalOpen()) return true
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 = {
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-title', this.titleHandler)
ipc.on('detail-edit', this.editHandler)
ipc.on('detail-preview', this.previewHandler)
}
componentWillUnmount () {
@@ -130,6 +135,7 @@ export default class ArticleDetail extends React.Component {
ipc.removeListener('detail-uncache', this.uncacheHandler)
ipc.removeListener('detail-title', this.titleHandler)
ipc.removeListener('detail-edit', this.editHandler)
ipc.removeListener('detail-preview', this.previewHandler)
}
componentDidUpdate (prevProps, prevState) {