2021-12-31 08:26:06 +02:00
|
|
|
import CommandService, { CommandContext, CommandDeclaration, CommandRuntime } from '@joplin/lib/services/CommandService';
|
2020-11-07 17:59:37 +02:00
|
|
|
import { _ } from '@joplin/lib/locale';
|
2021-12-31 08:26:06 +02:00
|
|
|
import { Options } from './openFolderDialog';
|
2020-07-03 23:32:39 +02:00
|
|
|
|
2020-11-12 21:13:28 +02:00
|
|
|
export const declaration: CommandDeclaration = {
|
2020-09-15 15:01:07 +02:00
|
|
|
name: 'newFolder',
|
2020-07-03 23:32:39 +02:00
|
|
|
label: () => _('New notebook'),
|
|
|
|
iconName: 'fa-book',
|
|
|
|
};
|
|
|
|
|
2021-12-31 08:26:06 +02:00
|
|
|
export const runtime = (): CommandRuntime => {
|
2020-07-03 23:32:39 +02:00
|
|
|
return {
|
2020-11-12 21:13:28 +02:00
|
|
|
execute: async (_context: CommandContext, parentId: string = null) => {
|
2021-12-31 08:26:06 +02:00
|
|
|
const options: Options = {
|
|
|
|
isNew: true,
|
|
|
|
parentId: parentId,
|
|
|
|
};
|
2020-07-03 23:32:39 +02:00
|
|
|
|
2021-12-31 08:26:06 +02:00
|
|
|
void CommandService.instance().execute('openFolderDialog', options);
|
2020-07-03 23:32:39 +02:00
|
|
|
},
|
2023-07-16 18:42:42 +02:00
|
|
|
enabledCondition: '!folderIsReadOnly',
|
2020-07-03 23:32:39 +02:00
|
|
|
};
|
|
|
|
};
|