Skip to content

Commit

Permalink
Merge pull request 'fix/plugins' (#217) from fix/plugins into release…
Browse files Browse the repository at this point in the history
…/v8.3.0
  • Loading branch information
Julia Radzhabova committed Jan 9, 2025
2 parents 4bfcf64 + 6e59031 commit 7ef407b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
35 changes: 27 additions & 8 deletions apps/common/main/lib/controller/Plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ define([
});

this.autostart = [];
this.pluginsWinToShow = [];
this.startOnPostLoad = false;
this.customPluginsDlg = [];

Expand Down Expand Up @@ -215,9 +216,9 @@ define([
return this;
},

onAfterRender: function(panel, guid) {
onAfterRender: function(panel, guid, isActivated) {
var me = this;
this.openUIPlugin(guid);
isActivated && this.openUIPlugin(guid);
panel.pluginClose.on('click', _.bind(this.onToolClose, this, panel));
Common.NotificationCenter.on({
'layout:resizestart': function(e) {
Expand Down Expand Up @@ -644,7 +645,7 @@ define([
el: '#panel-plugins-' + name,
menu: menu
});
this.viewPlugins.pluginPanels[pluginGuid].on('render:after', _.bind(this.onAfterRender, this, this.viewPlugins.pluginPanels[pluginGuid], pluginGuid));
this.viewPlugins.pluginPanels[pluginGuid].on('render:after', _.bind(this.onAfterRender, this, this.viewPlugins.pluginPanels[pluginGuid], pluginGuid, true));
},

openUIPlugin: function (id) {
Expand Down Expand Up @@ -1111,6 +1112,10 @@ define([

// Plugin can create windows
onPluginWindowShow: function(frameId, variation) {
if (!Common.Controllers.LaunchController.isScriptLoaded()) {
this.pluginsWinToShow.push({frameId: frameId, variation: variation});
return;
}
if (variation.isVisual) {
if (this.customPluginsDlg[frameId] || this.viewPlugins.customPluginPanels[frameId]) return;

Expand Down Expand Up @@ -1187,9 +1192,18 @@ define([
me.customPluginsDlg[frameId].show();
}
}
if (this.pluginsWinToShow.length>0) {
let plg = this.pluginsWinToShow.shift();
plg && this.onPluginWindowShow(plg.frameId, plg.variation);
}
},

onPluginWindowClose: function(frameId) {
if (this.pluginsWinToShow.length>0) {
this.pluginsWinToShow = _.reject(this.pluginsWinToShow, function (item) {
return item.frameId === frameId;
});
}
if (this.customPluginsDlg[frameId]) {
this.customPluginsDlg[frameId].close();
} else if (this.viewPlugins.customPluginPanels[frameId]) {
Expand Down Expand Up @@ -1222,10 +1236,11 @@ define([
if (typeof variation.descriptionLocale == 'object')
description = variation.descriptionLocale[lang] || variation.descriptionLocale['en'] || description || '';

var baseUrl = variation.baseUrl || "";
var model = this.viewPlugins.storePlugins.findWhere({guid: guid});
var icons = variation.icons;
var icon_url, icon_cls;
var baseUrl = variation.baseUrl || "",
model = this.viewPlugins.storePlugins.findWhere({guid: guid}),
icons = variation.icons,
icon_url, icon_cls,
isActivated = variation.isActivated!==false;

if (model) {
if ("" === baseUrl)
Expand Down Expand Up @@ -1265,7 +1280,7 @@ define([
baseUrl: baseUrl,
icons: icons
});
this.viewPlugins.customPluginPanels[frameId].on('render:after', _.bind(this.onAfterRender, this, this.viewPlugins.customPluginPanels[frameId], frameId));
this.viewPlugins.customPluginPanels[frameId].on('render:after', _.bind(this.onAfterRender, this, this.viewPlugins.customPluginPanels[frameId], frameId, isActivated));

if (!this.viewPlugins.customPluginPanels[frameId].openInsideMode(description, variation.url, frameId, guid))
this.api.asc_pluginButtonClick(-1, guid, frameId);
Expand Down Expand Up @@ -1318,6 +1333,10 @@ define([
},

onPostLoadComplete: function() {
if (this.pluginsWinToShow.length>0) {
let plg = this.pluginsWinToShow.shift();
plg && this.onPluginWindowShow(plg.frameId, plg.variation);
}
this.startOnPostLoad && this.runAutoStartPlugins();
},

Expand Down
17 changes: 14 additions & 3 deletions apps/documenteditor/forms/app/controller/Plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ define([

onLaunch: function() {
this.autostart = [];

this.startOnPostLoad = false;
Common.Gateway.on('init', this.loadConfig.bind(this));
Common.NotificationCenter.on('script:loaded', this.onPostLoadComplete.bind(this));
},

loadConfig: function(data) {
Expand Down Expand Up @@ -175,7 +176,12 @@ define([
},
help: !!help,
loader: plugin.get_Loader(),
modal: isModal!==undefined ? isModal : true
modal: isModal!==undefined ? isModal : !variation.get_InsideMode(),
resizable: !!variation.get_InsideMode(),
minwidth: variation.get_InsideMode() ? 300 : undefined,
minheight: variation.get_InsideMode() ? 300 : undefined,
maxwidth: variation.get_InsideMode() ? Common.Utils.innerWidth() : undefined,
maxheight: variation.get_InsideMode() ? Common.Utils.innerHeight() : undefined
});
me.pluginDlg.on({
'render:after': function(obj){
Expand Down Expand Up @@ -231,6 +237,10 @@ define([
}
},

onPostLoadComplete: function() {
this.startOnPostLoad && this.runAutoStartPlugins();
},

resetPluginsList: function() {
this.getApplication().getCollection('Common.Collections.Plugins').reset();
},
Expand Down Expand Up @@ -341,7 +351,8 @@ define([

if (this.appOptions.canPlugins) {
this.refreshPluginsList();
this.runAutoStartPlugins();
this.startOnPostLoad = !Common.Controllers.LaunchController.isScriptLoaded();
!this.startOnPostLoad && this.runAutoStartPlugins();
}
},

Expand Down

0 comments on commit 7ef407b

Please sign in to comment.