一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
27 行
914 B
TypeScript
27 行
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',
|
|
};
|
|
};
|