Add async functions to plugin object

This commit is contained in:
Oleg Korshul
2025-06-23 11:29:03 +03:00
parent 61a3365488
commit 3e46800d89
2 changed files with 18 additions and 1 deletions

File diff suppressed because one or more lines are too long

View File

@ -762,6 +762,23 @@ window.startPluginApi = function() {
_client.send();
};
let isAsyncSupported = false;
try
{
new Function("async function test() {}");
isAsyncSupported = true;
}
catch (e)
{
isAsyncSupported = false;
}
if (isAsyncSupported)
{
eval("Asc.plugin.callCommandAsync = function(func) { return new Promise(function(resolve) { Asc.plugin.callCommand(func, false, true, function(retValue) { resolve(retValue); }) }); };");
eval("Asc.plugin.callMethodAsync = function(name, args) { return new Promise(function(resolve) { Asc.plugin.executeMethod(name, args || [], function(retValue) { resolve(retValue); }) }); };");
}
/**
* @function attachEvent
* @undocumented