You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-12-17 23:27:48 +02:00
27 lines
914 B
TypeScript
27 lines
914 B
TypeScript
import { CommandRuntime, CommandDeclaration, CommandContext } from '@joplin/lib/services/CommandService';
|
|
import { _ } from '@joplin/lib/locale';
|
|
import restoreItems from '@joplin/lib/services/trash/restoreItems';
|
|
import Folder from '@joplin/lib/models/Folder';
|
|
import { ModelType } from '@joplin/lib/BaseModel';
|
|
|
|
export const declaration: CommandDeclaration = {
|
|
name: 'restoreFolder',
|
|
label: () => _('Restore notebook'),
|
|
iconName: 'fas fa-trash-restore',
|
|
};
|
|
|
|
export const runtime = (): CommandRuntime => {
|
|
return {
|
|
execute: async (context: CommandContext, folderIds: string|string[] = null) => {
|
|
if (folderIds === null) folderIds = context.state.selectedFolderIds;
|
|
if (!Array.isArray(folderIds)) {
|
|
folderIds = [folderIds];
|
|
}
|
|
|
|
const folders = await Folder.loadItemsByIdsOrFail(folderIds);
|
|
await restoreItems(ModelType.Folder, folders);
|
|
},
|
|
enabledCondition: 'foldersAreDeleted',
|
|
};
|
|
};
|