1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-27 23:28:38 +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:
Laurent Cozic
2020-10-18 21:52:10 +01:00
parent f529adac99
commit 3a57cfea02
78 changed files with 897 additions and 756 deletions

View File

@ -87,9 +87,9 @@ export default class MenuUtils {
return item;
}
public commandToStatefulMenuItem(commandName:string, props:any = null):MenuItem {
public commandToStatefulMenuItem(commandName:string, ...args:any[]):MenuItem {
return this.commandToMenuItem(commandName, () => {
return this.service.execute(commandName, props ? props : {});
return this.service.execute(commandName, ...args);
});
}
@ -108,11 +108,14 @@ export default class MenuUtils {
return output;
}
public commandsToMenuItemProps(state:any, commandNames:string[]):MenuItemProps {
public commandsToMenuItemProps(commandNames:string[], whenClauseContext:any):MenuItemProps {
const output:MenuItemProps = {};
for (const commandName of commandNames) {
const newProps = this.service.commandMapStateToProps(commandName, state);
const newProps = {
enabled: this.service.isEnabled(commandName, whenClauseContext),
};
if (newProps === null || propsHaveChanged(this.menuItemPropsCache_[commandName], newProps)) {
output[commandName] = newProps;
this.menuItemPropsCache_[commandName] = newProps;