You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-16 00:14:34 +02:00
Plugins: Add the openNote, openFolder and openTag commands
This commit is contained in:
@ -11,6 +11,7 @@ type EnabledCondition = string;
|
||||
export interface CommandContext {
|
||||
// The state may also be of type "AppState" (used by the desktop app), which inherits from "State" (used by all apps)
|
||||
state: State,
|
||||
dispatch: Function,
|
||||
}
|
||||
|
||||
export interface CommandRuntime {
|
||||
@ -203,10 +204,20 @@ export default class CommandService extends BaseService {
|
||||
delete command.runtime;
|
||||
}
|
||||
|
||||
private createContext():CommandContext {
|
||||
return {
|
||||
state: this.store_.getState(),
|
||||
dispatch: (action:any) => {
|
||||
this.store_.dispatch(action);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public async execute(commandName:string, ...args:any[]):Promise<any | void> {
|
||||
const command = this.commandByName(commandName);
|
||||
this.logger().info('CommandService::execute:', commandName, args);
|
||||
return command.runtime.execute({ state: this.store_.getState() }, ...args);
|
||||
if (!command.runtime) throw new Error(`Cannot execute a command without a runtime: ${commandName}`);
|
||||
return command.runtime.execute(this.createContext(), ...args);
|
||||
}
|
||||
|
||||
public scheduleExecute(commandName:string, args:any) {
|
||||
|
Reference in New Issue
Block a user