1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-24 08:12:24 +02:00

Desktop: Delete note using keyboard

This commit is contained in:
Laurent Cozic 2019-01-26 15:15:16 +00:00
parent 998bdf3b56
commit ed541dac3b

View File

@ -176,14 +176,19 @@ class NoteListComponent extends React.Component {
}
menu.append(new MenuItem({label: _('Delete'), click: async () => {
const ok = bridge().showConfirmMessageBox(noteIds.length > 1 ? _('Delete notes?') : _('Delete note?'));
if (!ok) return;
await Note.batchDelete(noteIds);
await this.confirmDeleteNotes(noteIds);
}}));
menu.popup(bridge().window());
}
async confirmDeleteNotes(noteIds) {
if (!noteIds.length) return;
const ok = bridge().showConfirmMessageBox(noteIds.length > 1 ? _('Delete notes?') : _('Delete note?'));
if (!ok) return;
await Note.batchDelete(noteIds);
}
itemRenderer(item) {
const theme = themeStyle(this.props.theme);
const width = this.props.style.width;
@ -337,10 +342,10 @@ class NoteListComponent extends React.Component {
return null;
}
onKeyDown(event) {
async onKeyDown(event) {
const keyCode = event.keyCode;
const noteIds = this.props.selectedNoteIds;
if (noteIds.length === 1 && (keyCode === 40 || keyCode === 38)) { // DOWN / UP
const noteId = noteIds[0];
let noteIndex = BaseModel.modelIndexById(this.props.notes, noteId);
@ -379,6 +384,11 @@ class NoteListComponent extends React.Component {
event.preventDefault();
}
if (noteIds.length && keyCode === 46) { // DELETE
event.preventDefault();
await this.confirmDeleteNotes(noteIds);
}
}
componentWillUnmount() {