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

inhance UX & search case insensitive

This commit is contained in:
Dick Choi
2016-07-24 15:03:18 +09:00
parent 787bb0a9e6
commit d73b567bd4
4 changed files with 46 additions and 32 deletions

View File

@@ -175,6 +175,8 @@ class MarkdownNoteDetail extends React.Component {
handleDeleteMenuClick (e) { handleDeleteMenuClick (e) {
this.setState({ this.setState({
isDeleting: true isDeleting: true
}, () => {
this.refs.deleteConfirmButton.focus()
}) })
} }
@@ -191,6 +193,7 @@ class MarkdownNoteDetail extends React.Component {
} }
ee.once('list:moved', dispatchHandler) ee.once('list:moved', dispatchHandler)
ee.emit('list:next') ee.emit('list:next')
ee.emit('list:focus')
}) })
} }
@@ -200,6 +203,10 @@ class MarkdownNoteDetail extends React.Component {
}) })
} }
handleDeleteKeyDown (e) {
if (e.keyCode === 27) this.handleDeleteCancelButtonClick(e)
}
render () { render () {
let { storages, config } = this.props let { storages, config } = this.props
let { note } = this.state let { note } = this.state
@@ -211,7 +218,10 @@ class MarkdownNoteDetail extends React.Component {
> >
{this.state.isDeleting {this.state.isDeleting
? <div styleName='info'> ? <div styleName='info'>
<div styleName='info-delete'> <div styleName='info-delete'
tabIndex='-1'
onKeyDown={(e) => this.handleDeleteKeyDown(e)}
>
<span styleName='info-delete-message'> <span styleName='info-delete-message'>
Are you sure to delete this note? Are you sure to delete this note?
@@ -221,6 +231,7 @@ class MarkdownNoteDetail extends React.Component {
>Cancel</button> >Cancel</button>
<button styleName='info-delete-confirmButton' <button styleName='info-delete-confirmButton'
onClick={(e) => this.handleDeleteConfirmButtonClick(e)} onClick={(e) => this.handleDeleteConfirmButtonClick(e)}
ref='deleteConfirmButton'
>Confirm</button> >Confirm</button>
</div> </div>
</div> </div>

View File

@@ -186,6 +186,8 @@ class SnippetNoteDetail extends React.Component {
handleDeleteMenuClick (e) { handleDeleteMenuClick (e) {
this.setState({ this.setState({
isDeleting: true 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 () { render () {
let { storages, config } = this.props let { storages, config } = this.props
let { note } = this.state let { note } = this.state
@@ -383,7 +389,10 @@ class SnippetNoteDetail extends React.Component {
> >
{this.state.isDeleting {this.state.isDeleting
? <div styleName='info'> ? <div styleName='info'>
<div styleName='info-delete'> <div styleName='info-delete'
tabIndex='-1'
onKeyDown={(e) => this.handleDeleteKeyDown(e)}
>
<span styleName='info-delete-message'> <span styleName='info-delete-message'>
Are you sure to delete this note? Are you sure to delete this note?
@@ -393,6 +402,7 @@ class SnippetNoteDetail extends React.Component {
>Cancel</button> >Cancel</button>
<button styleName='info-delete-confirmButton' <button styleName='info-delete-confirmButton'
onClick={(e) => this.handleDeleteConfirmButtonClick(e)} onClick={(e) => this.handleDeleteConfirmButtonClick(e)}
ref='deleteConfirmButton'
>Confirm</button> >Confirm</button>
</div> </div>
</div> </div>

View File

@@ -16,12 +16,16 @@ class NoteList extends React.Component {
this.selectPriorNoteHandler = () => { this.selectPriorNoteHandler = () => {
this.selectPriorNote() this.selectPriorNote()
} }
this.focusHandler = () => {
this.refs.root.focus()
}
} }
componentDidMount () { componentDidMount () {
this.refreshTimer = setInterval(() => this.forceUpdate(), 60 * 1000) this.refreshTimer = setInterval(() => this.forceUpdate(), 60 * 1000)
ee.on('list:next', this.selectNextNoteHandler) ee.on('list:next', this.selectNextNoteHandler)
ee.on('list:prior', this.selectPriorNoteHandler) ee.on('list:prior', this.selectPriorNoteHandler)
ee.on('lost:focus', this.focusHandler)
} }
componentWillUnmount () { componentWillUnmount () {
@@ -29,6 +33,7 @@ class NoteList extends React.Component {
ee.off('list:next', this.selectNextNoteHandler) ee.off('list:next', this.selectNextNoteHandler)
ee.off('list:prior', this.selectPriorNoteHandler) ee.off('list:prior', this.selectPriorNoteHandler)
ee.off('lost:focus', this.focusHandler)
} }
componentDidUpdate () { componentDidUpdate () {
@@ -120,34 +125,20 @@ class NoteList extends React.Component {
handleNoteListKeyDown (e) { handleNoteListKeyDown (e) {
if (e.metaKey || e.ctrlKey) return true if (e.metaKey || e.ctrlKey) return true
// if (e.keyCode === 65 && !e.shiftKey) { if (e.keyCode === 65 && !e.shiftKey) {
// e.preventDefault() e.preventDefault()
// remote.getCurrentWebContents().send('top-new-post') ee.emit('top:new-note')
// } }
// if (e.keyCode === 65 && e.shiftKey) { if (e.keyCode === 68) {
// e.preventDefault() e.preventDefault()
// remote.getCurrentWebContents().send('nav-new-folder') ee.emit('detail:delete')
// } }
// if (e.keyCode === 68) { if (e.keyCode === 69) {
// e.preventDefault() e.preventDefault()
// remote.getCurrentWebContents().send('detail-delete') ee.emit('detail:focus')
// } }
// 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 === 38) { if (e.keyCode === 38) {
e.preventDefault() e.preventDefault()
@@ -275,7 +266,7 @@ class NoteList extends React.Component {
<div className='NoteList' <div className='NoteList'
styleName='root' styleName='root'
ref='root' ref='root'
tabIndex='0' tabIndex='-1'
onKeyDown={(e) => this.handleNoteListKeyDown(e)} onKeyDown={(e) => this.handleNoteListKeyDown(e)}
style={this.props.style} style={this.props.style}
> >

View File

@@ -63,19 +63,21 @@ class TopBar extends React.Component {
searchBlocks.forEach((block) => { searchBlocks.forEach((block) => {
if (block.match(/^#.+/)) { if (block.match(/^#.+/)) {
let tag = block.match(/#(.+)/)[1] let tag = block.match(/#(.+)/)[1]
let regExp = new RegExp(_.escapeRegExp(tag), 'i')
notes = notes notes = notes
.filter((note) => { .filter((note) => {
if (!_.isArray(note.tags)) return false if (!_.isArray(note.tags)) return false
return note.tags.some((_tag) => { return note.tags.some((_tag) => {
return _tag === tag return _tag.match(regExp)
}) })
}) })
} else { } else {
let regExp = new RegExp(_.escapeRegExp(block), 'i')
notes = notes.filter((note) => { notes = notes.filter((note) => {
if (note.type === 'SNIPPET_NOTE') { if (note.type === 'SNIPPET_NOTE') {
return note.description.match(block) return note.description.match(regExp)
} else if (note.type === 'MARKDOWN_NOTE') { } else if (note.type === 'MARKDOWN_NOTE') {
return note.content.match(block) return note.content.match(regExp)
} }
return false return false
}) })