You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-16 00:14:34 +02:00
Desktop: Simplified and improve command service, and added command palette
- Commands "enabled" state is now expressed using a "when-clause" like in VSCode - A command palette has been added to the Tools menu
This commit is contained in:
@ -1,8 +1,7 @@
|
||||
import { utils, CommandRuntime, CommandDeclaration } from '../../../lib/services/CommandService';
|
||||
import { utils, CommandRuntime, CommandDeclaration, CommandContext } from 'lib/services/CommandService';
|
||||
import { _ } from 'lib/locale';
|
||||
const Setting = require('lib/models/Setting').default;
|
||||
const Note = require('lib/models/Note');
|
||||
const Folder = require('lib/models/Folder');
|
||||
const TemplateUtils = require('lib/TemplateUtils');
|
||||
|
||||
export const declaration:CommandDeclaration = {
|
||||
@ -13,7 +12,7 @@ export const declaration:CommandDeclaration = {
|
||||
|
||||
export const runtime = ():CommandRuntime => {
|
||||
return {
|
||||
execute: async ({ template, isTodo }:any) => {
|
||||
execute: async (_context:CommandContext, template:string = null, isTodo:boolean = false) => {
|
||||
const folderId = Setting.value('activeFolderId');
|
||||
if (!folderId) return;
|
||||
|
||||
@ -34,12 +33,6 @@ export const runtime = ():CommandRuntime => {
|
||||
id: newNote.id,
|
||||
});
|
||||
},
|
||||
isEnabled: () => {
|
||||
const { folders, selectedFolderId } = utils.store.getState();
|
||||
return !!folders.length && selectedFolderId !== Folder.conflictFolderId();
|
||||
},
|
||||
title: () => {
|
||||
return _('New note');
|
||||
},
|
||||
enabledCondition: 'oneFolderSelected && !inConflictFolder',
|
||||
};
|
||||
};
|
||||
|
Reference in New Issue
Block a user