1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-30 23:44:55 +02:00

Desktop: Added support for Menu API for plugins

This commit is contained in:
Laurent Cozic
2020-10-13 12:57:03 +01:00
parent 2caaf8e8c1
commit c648f19693
37 changed files with 5561 additions and 34 deletions

View File

@ -172,12 +172,14 @@ export default class KeymapService extends BaseService {
.replace(/Alt/g, this.platform === 'darwin' ? 'Option' : 'Alt');
}
registerCommandAccelerator(commandName:string, accelerator:string) {
public registerCommandAccelerator(commandName:string, accelerator:string) {
// If the command is already registered, we don't register it again and
// we don't update the accelerator. This is because it might have been
// modified by the user and we don't want the plugin to overwrite this.
if (this.keymap[commandName]) return;
if (!commandName) throw new Error('Cannot register an accelerator without a command name');
const validatedAccelerator = this.convertToPlatform(accelerator);
this.validateAccelerator(validatedAccelerator);