@univerjs/core v0.4.2 • Docs
Interface: ICommandService
The service to register and execute commands.
Methods
beforeCommandExecuted()
beforeCommandExecuted(listener): IDisposable
Register a callback function that will be executed before a command is executed.
Parameters
Parameter | Type |
---|---|
listener | CommandListener |
Returns
Defined in
submodules/univer/packages/core/src/services/command/command.service.ts:235 (opens in a new tab)
executeCommand()
executeCommand<P, R>(
id,
params?,
options?): Promise<R>
Execute a command with the given id and parameters.
Type Parameters
Type Parameter | Default type |
---|---|
P extends object | object |
R | boolean |
Parameters
Parameter | Type | Description |
---|---|---|
id | string | Identifier of the command. |
params ? | P | Parameters of this execution. |
options ? | IExecutionOptions | Options of this execution. |
Returns
Promise
<R
>
The result of the execution. It is a boolean value by default which indicates the command is executed.
Defined in
submodules/univer/packages/core/src/services/command/command.service.ts:213 (opens in a new tab)
hasCommand()
hasCommand(commandId): boolean
Check if a command is already registered at the current command service.
Parameters
Parameter | Type | Description |
---|---|---|
commandId | string | The id of the command. |
Returns
boolean
If the command is registered, return true
, otherwise return false
.
Defined in
submodules/univer/packages/core/src/services/command/command.service.ts:195 (opens in a new tab)
onCommandExecuted()
onCommandExecuted(listener): IDisposable
Register a callback function that will be executed after a command is executed.
Parameters
Parameter | Type |
---|---|
listener | CommandListener |
Returns
Defined in
submodules/univer/packages/core/src/services/command/command.service.ts:230 (opens in a new tab)
registerCommand()
registerCommand(command): IDisposable
Register a command to the command service.
Parameters
Parameter | Type | Description |
---|---|---|
command | ICommand <object , unknown > | The command to register. |
Returns
Defined in
submodules/univer/packages/core/src/services/command/command.service.ts:200 (opens in a new tab)
registerMultipleCommand()
registerMultipleCommand(command): IDisposable
Register a command as a multi command.
Parameters
Parameter | Type | Description |
---|---|---|
command | ICommand <object , unknown > | The command to register as a multi command. |
Returns
Defined in
submodules/univer/packages/core/src/services/command/command.service.ts:205 (opens in a new tab)
syncExecuteCommand()
syncExecuteCommand<P, R>(
id,
params?,
options?): R
Execute a command with the given id and parameters synchronously.
Type Parameters
Type Parameter | Default type |
---|---|
P extends object | object |
R | boolean |
Parameters
Parameter | Type | Description |
---|---|---|
id | string | Identifier of the command. |
params ? | P | Parameters of this execution. |
options ? | IExecutionOptions | Options of this execution. |
Returns
R
The result of the execution. It is a boolean value by default which indicates the command is executed.
Defined in
submodules/univer/packages/core/src/services/command/command.service.ts:225 (opens in a new tab)