diff --git a/index.d.ts b/index.d.ts index cc98fe09c..678434e9b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1665,6 +1665,12 @@ declare namespace grapesjs { self(): Block; } + interface Command { + run: (editor: Editor, sender?: any, opts?: Record) => any; + stop?: (editor: Editor, sender?: any, opts?: Record) => any; + [key: string]: unknown; + } + /** * You can customize the initial state of the module from the editor initialization, by passing the following [Configuration Object](https://github.com/artf/grapesjs/blob/master/src/commands/config/config.js) * ```js @@ -1720,14 +1726,9 @@ declare namespace grapesjs { * // As a function * commands.add('myCommand2', editor => { ... }); */ - add( + add( id: string, - command: ((editor: Editor, sender?: any, opts?: Record) => any) | - { - run?: (editor: Editor, sender?: any, opts?: Record) => any; - stop?: (editor: Editor, sender?: any, opts?: Record) => any; - [key: string]: unknown; - } + command: Command['run'] | (Command & S & ThisType), ): void; /** * Get command by ID