mirror of https://github.com/laurent22/joplin.git
Desktop: Delete note using keyboard
parent
998bdf3b56
commit
ed541dac3b
|
@ -176,14 +176,19 @@ class NoteListComponent extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.append(new MenuItem({label: _('Delete'), click: async () => {
|
menu.append(new MenuItem({label: _('Delete'), click: async () => {
|
||||||
const ok = bridge().showConfirmMessageBox(noteIds.length > 1 ? _('Delete notes?') : _('Delete note?'));
|
await this.confirmDeleteNotes(noteIds);
|
||||||
if (!ok) return;
|
|
||||||
await Note.batchDelete(noteIds);
|
|
||||||
}}));
|
}}));
|
||||||
|
|
||||||
menu.popup(bridge().window());
|
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) {
|
itemRenderer(item) {
|
||||||
const theme = themeStyle(this.props.theme);
|
const theme = themeStyle(this.props.theme);
|
||||||
const width = this.props.style.width;
|
const width = this.props.style.width;
|
||||||
|
@ -337,10 +342,10 @@ class NoteListComponent extends React.Component {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
onKeyDown(event) {
|
async onKeyDown(event) {
|
||||||
const keyCode = event.keyCode;
|
const keyCode = event.keyCode;
|
||||||
const noteIds = this.props.selectedNoteIds;
|
const noteIds = this.props.selectedNoteIds;
|
||||||
|
|
||||||
if (noteIds.length === 1 && (keyCode === 40 || keyCode === 38)) { // DOWN / UP
|
if (noteIds.length === 1 && (keyCode === 40 || keyCode === 38)) { // DOWN / UP
|
||||||
const noteId = noteIds[0];
|
const noteId = noteIds[0];
|
||||||
let noteIndex = BaseModel.modelIndexById(this.props.notes, noteId);
|
let noteIndex = BaseModel.modelIndexById(this.props.notes, noteId);
|
||||||
|
@ -379,6 +384,11 @@ class NoteListComponent extends React.Component {
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (noteIds.length && keyCode === 46) { // DELETE
|
||||||
|
event.preventDefault();
|
||||||
|
await this.confirmDeleteNotes(noteIds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
|
Loading…
Reference in New Issue