* Trigger a command by `type` with `...args`. * * @param {String|Function} type * @param {Any} ...args * @return {Editor}
(type, ...args)
| 156 | */ |
| 157 | |
| 158 | command(type, ...args) { |
| 159 | const { controller } = this |
| 160 | |
| 161 | if (typeof type === 'function') { |
| 162 | type(controller, ...args) |
| 163 | normalizeDirtyPaths(this) |
| 164 | return controller |
| 165 | } |
| 166 | |
| 167 | debug('command', { type, args }) |
| 168 | const obj = { type, args } |
| 169 | this.run('onCommand', obj) |
| 170 | normalizeDirtyPaths(this) |
| 171 | return controller |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Checks if a command by `type` has been registered. |
no test coverage detected