From e418fc3fa98ac2babb507283469b855ec172f617 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 18 Feb 2025 13:45:58 +0300 Subject: [PATCH] Fix dock/undock plugins --- apps/common/main/lib/controller/Plugins.js | 13 +++++++------ apps/common/main/lib/view/PluginDlg.js | 6 +++++- apps/common/main/lib/view/PluginPanel.js | 20 +++++++++++++------- apps/common/main/resources/less/plugins.less | 18 +----------------- apps/documenteditor/main/locale/en.json | 2 ++ apps/pdfeditor/main/locale/en.json | 2 ++ apps/presentationeditor/main/locale/en.json | 2 ++ apps/spreadsheeteditor/main/locale/en.json | 2 ++ apps/visioeditor/main/locale/en.json | 2 ++ 9 files changed, 36 insertions(+), 31 deletions(-) diff --git a/apps/common/main/lib/controller/Plugins.js b/apps/common/main/lib/controller/Plugins.js index e93223f12e..c2398f74d3 100644 --- a/apps/common/main/lib/controller/Plugins.js +++ b/apps/common/main/lib/controller/Plugins.js @@ -773,12 +773,12 @@ define([ var langName = plugin.get_Name(lang); var isCanDocked = variation.get_IsCanDocked(); var dockedPosition = this.getPluginDockedPosition(plugin.get_Guid()); - var menu = this.isPDFEditor ? 'left' : (variation.get_Type() == Asc.PluginType.PanelRight ? 'right' : 'left'); + var menu = this.isPDFEditor ? 'left' : (variation.get_Type() === Asc.PluginType.PanelRight ? 'right' : 'left'); var isInsideMode = variation.get_InsideMode(); if(isCanDocked) { isInsideMode = dockedPosition === Asc.PluginType.Panel || dockedPosition === Asc.PluginType.PanelRight; - menu = isInsideMode ? dockedPosition : menu; + menu = isInsideMode ? (dockedPosition === Asc.PluginType.PanelRight ? 'right' : 'left') : menu; } !menu && (menu = 'left'); @@ -1230,7 +1230,7 @@ define([ help && window.open(help, '_blank'); }, 'docked': function(frameId){ - me.triggerDockedEvent(frameId); + me.triggerDockedEvent(frameId, isPanel ? variation.type : 'panel'); // if the initial state of plugin is 'panelRight'/'panel' - move to corresponding panel, otherwise move to left panel setTimeout(function () { me.customPluginsDlg[frameId].close(); me.onPluginPanelShow(frameId, variation, lang); @@ -1250,10 +1250,11 @@ define([ } }, - triggerDockedEvent: function(frameId) { + triggerDockedEvent: function(frameId, placement) { $('#' + frameId)[0].contentWindow.postMessage(JSON.stringify({ type: 'plugin_docked', - frameId: frameId + frameId: frameId, + placement: placement }), "*"); }, @@ -1343,7 +1344,7 @@ define([ }); this.viewPlugins.customPluginPanels[frameId].on('render:after', _.bind(this.onAfterRender, this, this.viewPlugins.customPluginPanels[frameId], frameId, isActivated)); this.viewPlugins.customPluginPanels[frameId].on('docked', _.bind(function(frameId) { - this.triggerDockedEvent(frameId); + this.triggerDockedEvent(frameId, 'window'); setTimeout( _.bind(function() { this.onPluginWindowClose(frameId); this.onPluginWindowShow(frameId, variation); diff --git a/apps/common/main/lib/view/PluginDlg.js b/apps/common/main/lib/view/PluginDlg.js index 895bd254bd..a86258505b 100644 --- a/apps/common/main/lib/view/PluginDlg.js +++ b/apps/common/main/lib/view/PluginDlg.js @@ -215,9 +215,12 @@ define([], function () { var iconCls = 'btn-promote'; btn = $('
'); btn.on('click', _.bind(function() { + var tip = btn.data('bs.tooltip'); + if (tip) tip.dontShow = true; this.fireEvent('docked', this.frameId); }, this)); header.append(btn); + btn.tooltip({title: this.textDock, placement: 'cursor', zIndex: parseInt(this.$window.css('z-index')) + 10}); } btn.show(); header.removeClass('hidden'); @@ -249,6 +252,7 @@ define([], function () { this.frame && (this.frame.style.pointerEvents = enable ? "" : "none"); }, - textLoading : 'Loading' + textLoading : 'Loading', + textDock: 'Pin plugin' }, Common.Views.PluginDlg || {})); }); \ No newline at end of file diff --git a/apps/common/main/lib/view/PluginPanel.js b/apps/common/main/lib/view/PluginPanel.js index b5f94f10c3..75e71b43b8 100644 --- a/apps/common/main/lib/view/PluginPanel.js +++ b/apps/common/main/lib/view/PluginPanel.js @@ -91,15 +91,20 @@ define([], function () { showDockedButton: function() { var header = this.$el.find('.current-plugin-header .tools'), - btnId = 'id-pluginpnl-docked', - btn = header.find('#' + btnId); + btnCls = 'plugin-undock', + btn = header.find('.' + btnCls); if (btn.length < 1) { - var iconCls = 'btn-demote'; - btn = $('
'); - btn.on('click', _.bind(function() { + btn = $('
'); + header.append(btn); + var btnUndock = new Common.UI.Button({ + parentEl: this.$el.find('.' + btnCls), + cls: 'btn-toolbar', + iconCls: 'toolbar__icon btn-demote', + hint: this.textUndock + }); + btnUndock.on('click', _.bind(function() { this.fireEvent('docked', this.iframePlugin.id); }, this)); - header.append(btn); } btn.show(); header.removeClass('hidden'); @@ -155,7 +160,8 @@ define([], function () { }, textClosePanel: 'Close plugin', - textLoading: 'Loading' + textLoading: 'Loading', + textUndock: 'Unpin plugin' }, Common.Views.PluginPanel || {})); }); \ No newline at end of file diff --git a/apps/common/main/resources/less/plugins.less b/apps/common/main/resources/less/plugins.less index f08feaf953..242e4ba775 100644 --- a/apps/common/main/resources/less/plugins.less +++ b/apps/common/main/resources/less/plugins.less @@ -113,24 +113,8 @@ } & > * { - width: 20px; - height: 20px; &:not(:first-child) { - .margin-right-2(); - } - } - - - .custom { - border-radius: 1px; - &:hover { - background-color: @highlight-button-hover-ie; - background-color: @highlight-button-hover; - } - &:active { - background-color: @highlight-button-pressed-ie; - background-color: @highlight-button-pressed; - background-position-x: @button-small-active-icon-offset-x;; + .margin-right-4(); } } } diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 7908d262dd..6a08f3264a 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -642,8 +642,10 @@ "Common.Views.PasswordDialog.txtRepeat": "Repeat password", "Common.Views.PasswordDialog.txtTitle": "Set password", "Common.Views.PasswordDialog.txtWarning": "Warning: If you lose or forget the password, it cannot be recovered. Please keep it in a safe place.", + "Common.Views.PluginDlg.textDock": "Pin plugin", "Common.Views.PluginDlg.textLoading": "Loading", "Common.Views.PluginPanel.textClosePanel": "Close plugin", + "Common.Views.PluginPanel.textUndock": "Unpin plugin", "Common.Views.PluginPanel.textLoading": "Loading", "Common.Views.Plugins.groupCaption": "Plugins", "Common.Views.Plugins.strPlugins": "Plugins", diff --git a/apps/pdfeditor/main/locale/en.json b/apps/pdfeditor/main/locale/en.json index 60bd0f75e0..968bad2229 100644 --- a/apps/pdfeditor/main/locale/en.json +++ b/apps/pdfeditor/main/locale/en.json @@ -270,8 +270,10 @@ "Common.Views.PasswordDialog.txtRepeat": "Repeat password", "Common.Views.PasswordDialog.txtTitle": "Set password", "Common.Views.PasswordDialog.txtWarning": "Warning: If you lose or forget the password, it cannot be recovered. Please keep it in a safe place.", + "Common.Views.PluginDlg.textDock": "Pin plugin", "Common.Views.PluginDlg.textLoading": "Loading", "Common.Views.PluginPanel.textClosePanel": "Close plugin", + "Common.Views.PluginPanel.textUndock": "Unpin plugin", "Common.Views.PluginPanel.textLoading": "Loading", "Common.Views.Plugins.groupCaption": "Plugins", "Common.Views.Plugins.strPlugins": "Plugins", diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index 471b908909..ca2f6f13f9 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -745,8 +745,10 @@ "Common.Views.PasswordDialog.txtRepeat": "Repeat password", "Common.Views.PasswordDialog.txtTitle": "Set password", "Common.Views.PasswordDialog.txtWarning": "Warning: If you lose or forget the password, it cannot be recovered. Please keep it in a safe place.", + "Common.Views.PluginDlg.textDock": "Pin plugin", "Common.Views.PluginDlg.textLoading": "Loading", "Common.Views.PluginPanel.textClosePanel": "Close plugin", + "Common.Views.PluginPanel.textUndock": "Unpin plugin", "Common.Views.PluginPanel.textLoading": "Loading", "Common.Views.Plugins.groupCaption": "Plugins", "Common.Views.Plugins.strPlugins": "Plugins", diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index d264b054e2..11bd0b2e47 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -584,8 +584,10 @@ "Common.Views.PasswordDialog.txtRepeat": "Repeat password", "Common.Views.PasswordDialog.txtTitle": "Set password", "Common.Views.PasswordDialog.txtWarning": "Warning: If you lose or forget the password, it cannot be recovered. Please keep it in a safe place.", + "Common.Views.PluginDlg.textDock": "Pin plugin", "Common.Views.PluginDlg.textLoading": "Loading", "Common.Views.PluginPanel.textClosePanel": "Close plugin", + "Common.Views.PluginPanel.textUndock": "Unpin plugin", "Common.Views.PluginPanel.textLoading": "Loading", "Common.Views.Plugins.groupCaption": "Plugins", "Common.Views.Plugins.strPlugins": "Plugins", diff --git a/apps/visioeditor/main/locale/en.json b/apps/visioeditor/main/locale/en.json index 79a2764624..3266d6479c 100644 --- a/apps/visioeditor/main/locale/en.json +++ b/apps/visioeditor/main/locale/en.json @@ -114,8 +114,10 @@ "Common.Views.OpenDialog.txtProtected": "Once you enter the password and open the file, the current password to the file will be reset.", "Common.Views.OpenDialog.txtTitle": "Choose %1 options", "Common.Views.OpenDialog.txtTitleProtected": "Protected file", + "Common.Views.PluginDlg.textDock": "Pin plugin", "Common.Views.PluginDlg.textLoading": "Loading", "Common.Views.PluginPanel.textClosePanel": "Close plugin", + "Common.Views.PluginPanel.textUndock": "Unpin plugin", "Common.Views.PluginPanel.textLoading": "Loading", "Common.Views.Plugins.groupCaption": "Plugins", "Common.Views.Plugins.strPlugins": "Plugins",