2024-03-02 14:25:27 +00:00
|
|
|
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 {
|
2025-11-17 14:14:28 -08:00
|
|
|
execute: async (context: CommandContext, folderIds: string|string[] = null) => {
|
|
|
|
|
if (folderIds === null) folderIds = context.state.selectedFolderIds;
|
|
|
|
|
if (!Array.isArray(folderIds)) {
|
|
|
|
|
folderIds = [folderIds];
|
|
|
|
|
}
|
2024-03-02 14:25:27 +00:00
|
|
|
|
2025-11-17 14:14:28 -08:00
|
|
|
const folders = await Folder.loadItemsByIdsOrFail(folderIds);
|
|
|
|
|
await restoreItems(ModelType.Folder, folders);
|
2024-03-02 14:25:27 +00:00
|
|
|
},
|
2025-11-17 14:14:28 -08:00
|
|
|
enabledCondition: 'foldersAreDeleted',
|
2024-03-02 14:25:27 +00:00
|
|
|
};
|
|
|
|
|
};
|