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

add multi selection with arrow short cut

This commit is contained in:
voidSatisfaction
2017-11-07 00:01:50 +09:00
parent 9139495f02
commit 9095fe934d

View File

@@ -153,7 +153,7 @@ class NoteList extends React.Component {
} }
let { router } = this.context let { router } = this.context
let { location } = this.props let { location } = this.props
let { selectedNoteKeys } = this.state let { selectedNoteKeys, shiftKeyDown } = this.state
let targetIndex = this.getTargetIndex() let targetIndex = this.getTargetIndex()
@@ -162,10 +162,16 @@ class NoteList extends React.Component {
} }
targetIndex-- targetIndex--
selectedNoteKeys = [] if (!shiftKeyDown) {
selectedNoteKeys = []
}
const priorNote = Object.assign({}, this.notes[targetIndex]) const priorNote = Object.assign({}, this.notes[targetIndex])
const priorNoteKey = `${priorNote.storage}-${priorNote.key}` const priorNoteKey = `${priorNote.storage}-${priorNote.key}`
selectedNoteKeys.push(priorNoteKey) if (selectedNoteKeys.includes(priorNoteKey)) {
selectedNoteKeys.pop()
} else {
selectedNoteKeys.push(priorNoteKey)
}
this.focusNote(selectedNoteKeys, priorNoteKey) this.focusNote(selectedNoteKeys, priorNoteKey)
} }
@@ -176,11 +182,13 @@ class NoteList extends React.Component {
} }
let { router } = this.context let { router } = this.context
let { location } = this.props let { location } = this.props
let { selectedNoteKeys } = this.state let { selectedNoteKeys, shiftKeyDown } = this.state
let targetIndex = this.getTargetIndex() let targetIndex = this.getTargetIndex()
if (targetIndex === this.notes.length - 1) { if (targetIndex === this.notes.length - 1) {
return
} else if (targetIndex === this.notes.length - 1) {
targetIndex = 0 targetIndex = 0
} else { } else {
targetIndex++ targetIndex++
@@ -188,10 +196,16 @@ class NoteList extends React.Component {
else if (targetIndex > this.notes.length - 1) targetIndex === this.notes.length - 1 else if (targetIndex > this.notes.length - 1) targetIndex === this.notes.length - 1
} }
selectedNoteKeys = [] if (!shiftKeyDown) {
selectedNoteKeys = []
}
const nextNote = Object.assign({}, this.notes[targetIndex]) const nextNote = Object.assign({}, this.notes[targetIndex])
const nextNoteKey = `${nextNote.storage}-${nextNote.key}` const nextNoteKey = `${nextNote.storage}-${nextNote.key}`
selectedNoteKeys.push(nextNoteKey) if (selectedNoteKeys.includes(nextNoteKey)) {
selectedNoteKeys.pop()
} else {
selectedNoteKeys.push(nextNoteKey)
}
this.focusNote(selectedNoteKeys, nextNoteKey) this.focusNote(selectedNoteKeys, nextNoteKey)
@@ -222,6 +236,7 @@ class NoteList extends React.Component {
} }
handleNoteListKeyDown (e) { handleNoteListKeyDown (e) {
const { shiftKeyDown } = this.state
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) {
@@ -231,7 +246,7 @@ class NoteList extends React.Component {
if (e.keyCode === 68) { if (e.keyCode === 68) {
e.preventDefault() e.preventDefault()
ee.emit('detail:delete') this.deleteNote()
} }
if (e.keyCode === 69) { if (e.keyCode === 69) {