mirror of
https://github.com/ONLYOFFICE/sdkjs.git
synced 2026-02-10 18:15:19 +08:00
Add support plugin events to editor/another plugin
This commit is contained in:
@ -5893,6 +5893,21 @@
|
||||
return (0 !== results.length) ? true : false;
|
||||
};
|
||||
|
||||
baseEditorsApi.prototype["checkAIActions"] = baseEditorsApi.prototype.checkAIActions = function(resolve)
|
||||
{
|
||||
if (this.checkAI())
|
||||
{
|
||||
resolve({
|
||||
"error" : true
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.AI({
|
||||
"type" : "Actions"
|
||||
}, resolve);
|
||||
};
|
||||
|
||||
baseEditorsApi.prototype.onAttachPluginEvent = function(guid, name)
|
||||
{
|
||||
};
|
||||
|
||||
@ -2371,6 +2371,49 @@
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Catch AI event from plugin.
|
||||
* @memberof Api
|
||||
* @undocumented
|
||||
* @typeofeditors ["CDE", "CSE", "CPE", "PDF"]
|
||||
* @alias onAIRequest
|
||||
* @param {object} data - Data.
|
||||
* @since 9.0.0
|
||||
*/
|
||||
Api.prototype["pluginMethod_AI"] = function(data)
|
||||
{
|
||||
if (!window.g_asc_plugins)
|
||||
return;
|
||||
|
||||
window.g_asc_plugins._internalEvents["ai_onStartAction"] = function(data) {
|
||||
window.g_asc_plugins.api.sync_StartAction((data.type === "Block") ? Asc.c_oAscAsyncActionType.BlockInteraction : Asc.c_oAscAsyncActionType.Information, data.description);
|
||||
};
|
||||
window.g_asc_plugins._internalEvents["ai_onEndAction"] = function(data) {
|
||||
window.g_asc_plugins.api.sync_EndAction((data.type === "Block") ? Asc.c_oAscAsyncActionType.BlockInteraction : Asc.c_oAscAsyncActionType.Information, data.description);
|
||||
};
|
||||
window.g_asc_plugins._internalEvents["ai_onRequest"] = function(data) {
|
||||
let api = window.g_asc_plugins.api;
|
||||
let curItem = api.aiResolvers[0];
|
||||
api.aiResolvers.shift();
|
||||
|
||||
curItem.resolve(data);
|
||||
|
||||
if (api.aiResolvers.length > 0)
|
||||
api._AI();
|
||||
};
|
||||
|
||||
window.g_asc_plugins.setPluginMethodReturnAsync();
|
||||
|
||||
data["isFromMethod"] = true;
|
||||
this.AI(data, function(data) {
|
||||
delete window.g_asc_plugins._internalEvents["ai_onStartAction"];
|
||||
delete window.g_asc_plugins._internalEvents["ai_onEndAction"];
|
||||
delete window.g_asc_plugins._internalEvents["ai_onRequest"];
|
||||
|
||||
window.g_asc_plugins.onPluginMethodReturn(data);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Catch AI event from plugin.
|
||||
* @memberof Api
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -783,6 +783,16 @@ window.startPluginApi = function() {
|
||||
return true;
|
||||
};
|
||||
|
||||
Plugin.sendEvent = function(name, data)
|
||||
{
|
||||
window.Asc.plugin.executeMethod("SendEvent", [name, data]);
|
||||
};
|
||||
|
||||
Plugin.sendEventInternal = function(name, data)
|
||||
{
|
||||
window.Asc.plugin.executeMethod("SendEventInternal", [name, data]);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user