Skip to main content

How to call methods

To execute certain editor methods using the plugin, define the executeMethod method.

The callback is the result that the method returns. It is an optional parameter. In case it is missing, the window.Asc.plugin.onMethodReturn function will be used to return the result of the method execution.

executeMethod

Parameters

NameTypeDescription
namestringThe name of the specific method that must be executed.
paramsarrayThe arguments that the method in use has (if it has any).
callbackfunctionThe result that the method returns.

Returns

Type boolean

Example

Asc.plugin.executeMethod("methodName", [param1, param2], (returnValue) => {
console.log(returnValue);
});

Debugging

To log all executeMethod and callCommand calls to the browser console, set the asc_plugin_commands_log key in the browser's local storage:

localStorage.setItem("asc_plugin_commands_log", "true");

To disable logging, remove the key:

localStorage.removeItem("asc_plugin_commands_log");

The setting persists across page reloads.