+
this.handleDeleteKeyDown(e)}
+ >
Are you sure to delete this note?
@@ -221,6 +231,7 @@ class MarkdownNoteDetail extends React.Component {
>Cancel
diff --git a/browser/main/Detail/SnippetNoteDetail.js b/browser/main/Detail/SnippetNoteDetail.js
index d53a33dd..fba354ff 100644
--- a/browser/main/Detail/SnippetNoteDetail.js
+++ b/browser/main/Detail/SnippetNoteDetail.js
@@ -186,6 +186,8 @@ class SnippetNoteDetail extends React.Component {
handleDeleteMenuClick (e) {
this.setState({
isDeleting: true
+ }, () => {
+ this.refs.deleteConfirmButton.focus()
})
}
@@ -300,6 +302,10 @@ class SnippetNoteDetail extends React.Component {
}
}
+ handleDeleteKeyDown (e) {
+ if (e.keyCode === 27) this.handleDeleteCancelButtonClick(e)
+ }
+
render () {
let { storages, config } = this.props
let { note } = this.state
@@ -383,7 +389,10 @@ class SnippetNoteDetail extends React.Component {
>
{this.state.isDeleting
?
-
+
this.handleDeleteKeyDown(e)}
+ >
Are you sure to delete this note?
@@ -393,6 +402,7 @@ class SnippetNoteDetail extends React.Component {
>Cancel
diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js
index f60a45da..7cee9e27 100644
--- a/browser/main/NoteList/index.js
+++ b/browser/main/NoteList/index.js
@@ -16,12 +16,16 @@ class NoteList extends React.Component {
this.selectPriorNoteHandler = () => {
this.selectPriorNote()
}
+ this.focusHandler = () => {
+ this.refs.root.focus()
+ }
}
componentDidMount () {
this.refreshTimer = setInterval(() => this.forceUpdate(), 60 * 1000)
ee.on('list:next', this.selectNextNoteHandler)
ee.on('list:prior', this.selectPriorNoteHandler)
+ ee.on('lost:focus', this.focusHandler)
}
componentWillUnmount () {
@@ -29,6 +33,7 @@ class NoteList extends React.Component {
ee.off('list:next', this.selectNextNoteHandler)
ee.off('list:prior', this.selectPriorNoteHandler)
+ ee.off('lost:focus', this.focusHandler)
}
componentDidUpdate () {
@@ -120,34 +125,20 @@ class NoteList extends React.Component {
handleNoteListKeyDown (e) {
if (e.metaKey || e.ctrlKey) return true
- // if (e.keyCode === 65 && !e.shiftKey) {
- // e.preventDefault()
- // remote.getCurrentWebContents().send('top-new-post')
- // }
+ if (e.keyCode === 65 && !e.shiftKey) {
+ e.preventDefault()
+ ee.emit('top:new-note')
+ }
- // if (e.keyCode === 65 && e.shiftKey) {
- // e.preventDefault()
- // remote.getCurrentWebContents().send('nav-new-folder')
- // }
+ if (e.keyCode === 68) {
+ e.preventDefault()
+ ee.emit('detail:delete')
+ }
- // if (e.keyCode === 68) {
- // e.preventDefault()
- // remote.getCurrentWebContents().send('detail-delete')
- // }
-
- // if (e.keyCode === 84) {
- // e.preventDefault()
- // remote.getCurrentWebContents().send('detail-title')
- // }
-
- // if (e.keyCode === 69) {
- // e.preventDefault()
- // }
-
- // if (e.keyCode === 83) {
- // e.preventDefault()
- // remote.getCurrentWebContents().send('detail-save')
- // }
+ if (e.keyCode === 69) {
+ e.preventDefault()
+ ee.emit('detail:focus')
+ }
if (e.keyCode === 38) {
e.preventDefault()
@@ -275,7 +266,7 @@ class NoteList extends React.Component {
this.handleNoteListKeyDown(e)}
style={this.props.style}
>
diff --git a/browser/main/TopBar/index.js b/browser/main/TopBar/index.js
index e575056d..06a05482 100644
--- a/browser/main/TopBar/index.js
+++ b/browser/main/TopBar/index.js
@@ -63,19 +63,21 @@ class TopBar extends React.Component {
searchBlocks.forEach((block) => {
if (block.match(/^#.+/)) {
let tag = block.match(/#(.+)/)[1]
+ let regExp = new RegExp(_.escapeRegExp(tag), 'i')
notes = notes
.filter((note) => {
if (!_.isArray(note.tags)) return false
return note.tags.some((_tag) => {
- return _tag === tag
+ return _tag.match(regExp)
})
})
} else {
+ let regExp = new RegExp(_.escapeRegExp(block), 'i')
notes = notes.filter((note) => {
if (note.type === 'SNIPPET_NOTE') {
- return note.description.match(block)
+ return note.description.match(regExp)
} else if (note.type === 'MARKDOWN_NOTE') {
- return note.content.match(block)
+ return note.content.match(regExp)
}
return false
})