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

Merge pull request #753 from asmsuechan/work-shortcuts-in-right-click

Change to work ctrl-e and ctrl-w in RIGHTCLICK
This commit is contained in:
SuenagaRyota
2017-08-05 12:05:22 +09:00
committed by GitHub

View File

@@ -81,7 +81,6 @@ class MarkdownEditor extends React.Component {
if (newStatus === 'CODE') { if (newStatus === 'CODE') {
this.refs.code.focus() this.refs.code.focus()
} else { } else {
this.refs.code.blur()
this.refs.preview.focus() this.refs.preview.focus()
} }
eventEmitter.emit('topbar:togglelockbutton', this.state.status) eventEmitter.emit('topbar:togglelockbutton', this.state.status)
@@ -164,15 +163,18 @@ class MarkdownEditor extends React.Component {
} }
handleKeyDown (e) { handleKeyDown (e) {
let { config } = this.props
if (this.state.status !== 'CODE') return false if (this.state.status !== 'CODE') return false
const keyPressed = this.state.keyPressed const keyPressed = this.state.keyPressed
keyPressed.add(e.keyCode) keyPressed.add(e.keyCode)
this.setState({ keyPressed }) this.setState({ keyPressed })
let isNoteHandlerKey = (el) => { return keyPressed.has(el) } let isNoteHandlerKey = (el) => { return keyPressed.has(el) }
// These conditions are for ctrl-e and ctrl-w
if (keyPressed.size === this.escapeFromEditor.length && if (keyPressed.size === this.escapeFromEditor.length &&
!this.state.isLocked && this.state.status === 'CODE' && !this.state.isLocked && this.state.status === 'CODE' &&
this.escapeFromEditor.every(isNoteHandlerKey)) { this.escapeFromEditor.every(isNoteHandlerKey)) {
document.activeElement.blur() this.handleContextMenu()
if (config.editor.switchPreview === 'BLUR') document.activeElement.blur()
} }
if (keyPressed.size === this.supportMdSelectionBold.length && this.supportMdSelectionBold.every(isNoteHandlerKey)) { if (keyPressed.size === this.supportMdSelectionBold.length && this.supportMdSelectionBold.every(isNoteHandlerKey)) {
this.addMdAroundWord('**') this.addMdAroundWord('**')