From bd331d9d837cd32827b5e559138f4c698e3a5a96 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Fri, 16 Sep 2022 16:27:25 +0400 Subject: [PATCH] Up TS add command --- index.d.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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