You've already forked joplin
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:
@ -1,5 +1,4 @@
|
||||
const Logger = require('lib/Logger').default;
|
||||
const KeymapService = require('lib/services/KeymapService').default;
|
||||
|
||||
class PluginManager {
|
||||
constructor() {
|
||||
@ -52,6 +51,7 @@ class PluginManager {
|
||||
const p = this.pluginInstance_(event.pluginName);
|
||||
p.onTrigger({
|
||||
itemName: event.itemName,
|
||||
userData: event.userData,
|
||||
});
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ class PluginManager {
|
||||
|
||||
return {
|
||||
Dialog: Class.Dialog,
|
||||
props: this.dialogProps_(name),
|
||||
props: Object.assign({}, this.dialogProps_(name), { userData: p.userData }),
|
||||
};
|
||||
}
|
||||
|
||||
@ -81,20 +81,24 @@ class PluginManager {
|
||||
|
||||
menuItems() {
|
||||
let output = [];
|
||||
const keymapService = KeymapService.instance();
|
||||
|
||||
for (const name in this.plugins_) {
|
||||
const menuItems = this.plugins_[name].Class.manifest.menuItems;
|
||||
const menuItems = this.plugins_[name].Class.manifest.menuItems.slice();
|
||||
if (!menuItems) continue;
|
||||
|
||||
for (const item of menuItems) {
|
||||
for (let i = 0; i < menuItems.length; i++) {
|
||||
const item = Object.assign({}, menuItems[i]);
|
||||
|
||||
item.click = () => {
|
||||
this.onPluginMenuItemTrigger_({
|
||||
pluginName: name,
|
||||
itemName: item.name,
|
||||
userData: item.userData,
|
||||
});
|
||||
};
|
||||
item.accelerator = keymapService.getAccelerator(name);
|
||||
|
||||
item.accelerator = menuItems[i].accelerator();
|
||||
|
||||
menuItems[i] = item;
|
||||
}
|
||||
|
||||
output = output.concat(menuItems);
|
||||
|
Reference in New Issue
Block a user