1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

Fix pointed part by review

This commit is contained in:
asmsuechan
2017-01-18 12:01:22 +09:00
parent cdb079dc81
commit 2b0bdbf1c8
3 changed files with 17 additions and 12 deletions

View File

@@ -10,11 +10,10 @@ class MarkdownEditor extends React.Component {
this.hotkey = props.config.hotkey this.hotkey = props.config.hotkey
this.keyPressed = []
this.state = { this.state = {
status: 'PREVIEW', status: 'PREVIEW',
renderValue: props.value renderValue: props.value,
keyPressed: {}
} }
} }
@@ -147,16 +146,23 @@ class MarkdownEditor extends React.Component {
} }
handleKeyDown(e) { handleKeyDown(e) {
this.keyPressed[e.key] = true let newKeyPressed = this.state.keyPressed
let isNoteHandlerKey = (el) => { return this.keyPressed[el] } newKeyPressed[e.key] = true
this.setState({keyPressed: newKeyPressed})
let isNoteHandlerKey = (el) => { return this.state.keyPressed[el] }
if (this.state.status === 'CODE' && this.hotkey.noteHandlerKey.escapeFromEditor.every(isNoteHandlerKey)) { if (this.state.status === 'CODE' && this.hotkey.noteHandlerKey.escapeFromEditor.every(isNoteHandlerKey)) {
document.activeElement.blur() document.activeElement.blur()
this.hotkey.noteHandlerKey.escapeFromEditor.forEach((el) => {this.keyPressed[el] = false}) this.hotkey.noteHandlerKey.escapeFromEditor.forEach((el) => {
newKeyPressed[e.key] = false
this.setState({keyPressed: newKeyPressed})
})
} }
} }
handleKeyUp (e) { handleKeyUp (e) {
this.keyPressed[e.key] = false let newKeyPressed = this.state.keyPressed
newKeyPressed[e.key] = false
this.setState({keyPressed: newKeyPressed})
} }
render () { render () {

View File

@@ -26,7 +26,7 @@ class TopBar extends React.Component {
} }
this.focusSearchHandler = () => { this.focusSearchHandler = () => {
this.handleFocusSearch() this.handleOnSearchFocus()
} }
} }
@@ -250,7 +250,7 @@ class TopBar extends React.Component {
}) })
} }
handleFocusSearch () { handleOnSearchFocus () {
if (this.state.searchPopupOpen) { if (this.state.searchPopupOpen) {
this.refs.search.childNodes[0].blur() this.refs.search.childNodes[0].blur()
} else { } else {
@@ -301,7 +301,6 @@ class TopBar extends React.Component {
onChange={(e) => this.handleSearchChange(e)} onChange={(e) => this.handleSearchChange(e)}
placeholder='Search' placeholder='Search'
type='text' type='text'
id='Search'
/> />
{this.state.searchPopupOpen && {this.state.searchPopupOpen &&
<div styleName='control-search-optionList'> <div styleName='control-search-optionList'>

View File

@@ -62,7 +62,7 @@ var file = {
{ {
label: 'Focus Note', label: 'Focus Note',
accelerator: 'Control + E', accelerator: 'Control + E',
click: function () { click () {
mainWindow.webContents.send('detail:focus') mainWindow.webContents.send('detail:focus')
} }
}, },
@@ -155,7 +155,7 @@ var view = {
} }
}, },
{ {
label: 'Prior Note', label: 'Privious Note',
accelerator: 'Control + U', accelerator: 'Control + U',
click: function () { click: function () {
mainWindow.webContents.send('list:prior') mainWindow.webContents.send('list:prior')