mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
Change to use Object.assign by checking keyPressed and remove unnecessary processing
This commit is contained in:
@@ -146,23 +146,21 @@ class MarkdownEditor extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleKeyDown(e) {
|
handleKeyDown(e) {
|
||||||
let newKeyPressed = this.state.keyPressed
|
const keyPressed = Object.assign(this.state.keyPressed, {
|
||||||
newKeyPressed[e.key] = true
|
[e.key]: true
|
||||||
this.setState({keyPressed: newKeyPressed})
|
})
|
||||||
|
this.setState({ keyPressed })
|
||||||
let isNoteHandlerKey = (el) => { return this.state.keyPressed[el] }
|
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) => {
|
|
||||||
newKeyPressed[e.key] = false
|
|
||||||
this.setState({keyPressed: newKeyPressed})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleKeyUp (e) {
|
handleKeyUp (e) {
|
||||||
let newKeyPressed = this.state.keyPressed
|
const keyPressed = Object.assign(this.state.keyPressed, {
|
||||||
newKeyPressed[e.key] = false
|
[e.key]: false
|
||||||
this.setState({keyPressed: newKeyPressed})
|
})
|
||||||
|
this.setState({ keyPressed })
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
|||||||
Reference in New Issue
Block a user