You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-13 00:10:37 +02:00
This commit is contained in:
28
packages/lib/commands/deleteNote.ts
Normal file
28
packages/lib/commands/deleteNote.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { CommandRuntime, CommandDeclaration, CommandContext } from '../services/CommandService';
|
||||
import { _ } from '../locale';
|
||||
import Note from '../models/Note';
|
||||
|
||||
export const declaration: CommandDeclaration = {
|
||||
name: 'deleteNote',
|
||||
label: () => _('Delete note'),
|
||||
iconName: 'fa-times',
|
||||
};
|
||||
|
||||
export const runtime = (): CommandRuntime => {
|
||||
return {
|
||||
execute: async (context: CommandContext, noteIds: string[] = null) => {
|
||||
if (noteIds === null) noteIds = context.state.selectedNoteIds;
|
||||
if (!noteIds.length) return;
|
||||
await Note.batchDelete(noteIds, { toTrash: true, sourceDescription: 'deleteNote command' });
|
||||
|
||||
context.dispatch({
|
||||
type: 'ITEMS_TRASHED',
|
||||
value: {
|
||||
noteIds,
|
||||
folderIds: [],
|
||||
},
|
||||
});
|
||||
},
|
||||
enabledCondition: '!noteIsReadOnly && !inTrash && someNotesSelected',
|
||||
};
|
||||
};
|
@ -1,13 +1,17 @@
|
||||
// AUTO-GENERATED using `gulp buildScriptIndexes`
|
||||
import * as deleteNote from './deleteNote';
|
||||
import * as historyBackward from './historyBackward';
|
||||
import * as historyForward from './historyForward';
|
||||
import * as openMasterPasswordDialog from './openMasterPasswordDialog';
|
||||
import * as permanentlyDeleteNote from './permanentlyDeleteNote';
|
||||
import * as synchronize from './synchronize';
|
||||
|
||||
const index: any[] = [
|
||||
deleteNote,
|
||||
historyBackward,
|
||||
historyForward,
|
||||
openMasterPasswordDialog,
|
||||
permanentlyDeleteNote,
|
||||
synchronize,
|
||||
];
|
||||
|
||||
|
33
packages/lib/commands/permanentlyDeleteNote.ts
Normal file
33
packages/lib/commands/permanentlyDeleteNote.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import { CommandRuntime, CommandDeclaration, CommandContext } from '../services/CommandService';
|
||||
import { _ } from '../locale';
|
||||
import Note from '../models/Note';
|
||||
import shim from '../shim';
|
||||
|
||||
export const declaration: CommandDeclaration = {
|
||||
name: 'permanentlyDeleteNote',
|
||||
label: () => _('Permanently delete note'),
|
||||
iconName: 'fa-times',
|
||||
};
|
||||
|
||||
export const runtime = (): CommandRuntime => {
|
||||
return {
|
||||
execute: async (context: CommandContext, noteIds: string[] = null) => {
|
||||
if (noteIds === null) noteIds = context.state.selectedNoteIds;
|
||||
if (!noteIds.length) return;
|
||||
const msg = await Note.permanentlyDeleteMessage(noteIds);
|
||||
|
||||
const deleteIndex = 0;
|
||||
const result = await shim.showMessageBox(msg, {
|
||||
buttons: [_('Delete'), _('Cancel')],
|
||||
defaultId: 1,
|
||||
cancelId: 1,
|
||||
type: 'question',
|
||||
});
|
||||
|
||||
if (result === deleteIndex) {
|
||||
await Note.batchDelete(noteIds, { toTrash: false, sourceDescription: 'permanentlyDeleteNote command' });
|
||||
}
|
||||
},
|
||||
enabledCondition: '(!noteIsReadOnly || inTrash) && someNotesSelected',
|
||||
};
|
||||
};
|
Reference in New Issue
Block a user