From 7c7e7125156a9608b00167a3bb5d0075c77f7ac2 Mon Sep 17 00:00:00 2001 From: nikita_bartoshuk Date: Thu, 26 Feb 2026 16:46:19 +0300 Subject: [PATCH 1/5] added paste special btn in DE --- .../main/lib/controller/PasteOptions.js | 214 ++++++++++++++++++ apps/documenteditor/main/app.js | 2 + .../main/app/controller/DocumentHolderExt.js | 11 +- .../main/app/controller/Toolbar.js | 13 ++ .../main/app/template/Toolbar.template | 2 +- apps/documenteditor/main/app/view/Toolbar.js | 7 + apps/documenteditor/main/app_dev.js | 2 + apps/documenteditor/main/locale/en.json | 10 + 8 files changed, 256 insertions(+), 5 deletions(-) create mode 100644 apps/common/main/lib/controller/PasteOptions.js diff --git a/apps/common/main/lib/controller/PasteOptions.js b/apps/common/main/lib/controller/PasteOptions.js new file mode 100644 index 0000000000..ecaf13c9cf --- /dev/null +++ b/apps/common/main/lib/controller/PasteOptions.js @@ -0,0 +1,214 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2024 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ +/** + * PasteOptions.js + * + * Created on 26.02.2026 + * + */ +define([ + 'core', +], function () { + 'use strict'; + Common.Controllers.PasteOptions = Backbone.Controller.extend(_.extend({ + models : [], + collections : [ + ], + sdkViewName : '#id_main', + initialize: function () { + + this.addListeners({ + 'Toolbar': { + 'paste:options': _.bind(this.onBtnPasteOptionsClick, this) + } + }); + }, + + setApi: function(api) { + if (api) { + this.api = api; + this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.SetDisabled, this)); + Common.NotificationCenter.on('api:disconnect', _.bind(this.SetDisabled, this)); + this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onApiFocusObject, this)); + this.api.asc_registerCallback('asc_onAddChartStylesPreview', _.bind(this.onAddChartStylesPreview, this)); + this.api.asc_registerCallback('asc_onUpdateChartStyles', _.bind(this._onUpdateChartStyles, this)); + this.api.asc_registerCallback('asc_onStartUpdateExternalReference', _.bind(this.onStartUpdateExternalReference, this)); + Common.NotificationCenter.on('cells:range', _.bind(this.onCellsRange, this)); + Common.NotificationCenter.on('uitheme:changed', _.bind(this.onThemeChanged, this)); + + } + return this; + }, + + setMode: function(mode) { + this.appConfig = mode; + return this; + }, + + onBtnPasteOptionsClick: function (btn, api) { + console.log('onBtnPasteOptionsClick') + this.api = api; + this.btn = btn; + var me = this; + var menu = btn.menu; + if (menu && menu.items && menu.items.length > 0) { + for (var i = 0; i < menu.items.length; i++) { + menu.removeItem(menu.items[i]); + i--; + } + } + + this.api.asc_getPasteOptions(function (options) { + me.handlePasteOptions(options) + }); + }, + + handlePasteOptions: function(options) { + console.log('handlePasteOptions') + var me = this; + + if (options === null) { + var menu = me.btn.menu; + + var mnu = new Common.UI.MenuItem({ + caption: 'Paste', + disabled: true + }); + + menu.addItem(mnu) + menu.show(); + console.log('options === null') + return + } + + var pasteItems = options.asc_getOptions(), + isTable = !!options.asc_getContainTables(); + + console.log(pasteItems, 'Paste items') + if (!pasteItems) return; + + me._arrSpecialPaste = []; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.paste] = documentHolder.textPaste; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceformatting] = documentHolder.txtPasteSourceFormat; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.keepTextOnly] = documentHolder.txtKeepTextOnly; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.insertAsNestedTable] = documentHolder.textNest; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.overwriteCells] = documentHolder.txtOverwriteCells; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceFormattingEmbedding] = documentHolder.txtSourceEmbed; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.destinationFormattingEmbedding] = documentHolder.txtDestEmbed; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceFormattingLink] = documentHolder.txtSourceLink; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.destinationFormattingLink] = documentHolder.txtDestLink; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.picture] = documentHolder.txtPastePicture; + + me.initSpecialPasteEvents(); + + if (pasteItems.length>0) { + var menu = me.btn.menu; + for (var i = 0; i < menu.items.length; i++) { + menu.removeItem(menu.items[i]); + i--; + } + + var group_prev = -1; + _.each(pasteItems, function(menuItem, index) { + var mnu = new Common.UI.MenuItem({ + caption: me._arrSpecialPaste[menuItem] + ' (' + me.hkSpecPaste[menuItem] + ')', + value: menuItem, + checkable: true, + toggleGroup : 'specialPasteGroup' + }).on('click', _.bind(me.onSpecialPasteItemClick, me)); + menu.addItem(mnu); + }); + } + }, + + initSpecialPasteEvents: function() { + if (this.specialPasteEventsInited) return + + var me = this; + me.hkSpecPaste = []; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.paste] = 'P'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.sourceformatting] = 'K'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.keepTextOnly] = 'T'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.insertAsNestedTable] = 'N'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.overwriteCells] = 'O'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.sourceFormattingEmbedding] = 'K'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.destinationFormattingEmbedding] = 'H'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.sourceFormattingLink] = 'F'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.destinationFormattingLink] = 'L'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.picture] = 'U'; + + var str = ''; + for(var key in me.hkSpecPaste){ + if(me.hkSpecPaste.hasOwnProperty(key)){ + if (str.indexOf(me.hkSpecPaste[key])<0) + str += me.hkSpecPaste[key] + ','; + } + } + str = str.substring(0, str.length-1) + var keymap = {}; + keymap[str + ' ' + 'special-paste-toolbar'] = _.bind(function(e) { + var menu = this.btn.menu; + for (var i = 0; i < menu.items.length; i++) { + if (this.hkSpecPaste[menu.items[i].value] === String.fromCharCode(e.keyCode)) { + return me.onSpecialPasteItemClick({value: menu.items[i].value}); + } + } + }, me); + Common.util.Shortcuts.delegateShortcuts({shortcuts:keymap}); + window.key.setScope('special-paste-toolbar'); + + me.btn.menu.on('show:after', function(menu) { + window.key.setScope('special-paste-toolbar'); + Common.util.Shortcuts.resumeEvents(str); + $(window).on('blur.pastemenuhide', closeMenuOnWindowBlur); + }).on('hide:after', function(menu) { + window.key.setScope('all'); + Common.util.Shortcuts.suspendEvents(str, undefined, true); + $(window).off('blur.pastemenuhide', closeMenuOnWindowBlur); + }); + + this.specialPasteEventsInited = true; + }, + + onSpecialPasteItemClick: function(item, e) { + if (this.api) { + this.api.asc_SpecialPaste(item.value, true); + var menu = this.btn.menu; + setTimeout(function(){ + menu.hide(); + }, 100); + } + return false; + }, + + }, Common.Controllers.PasteOptions || {})); +}); \ No newline at end of file diff --git a/apps/documenteditor/main/app.js b/apps/documenteditor/main/app.js index 296ff28eb6..a53adeb379 100644 --- a/apps/documenteditor/main/app.js +++ b/apps/documenteditor/main/app.js @@ -164,6 +164,7 @@ require([ ,'Common.Controllers.ReviewChanges' ,'Common.Controllers.Protection' ,'Common.Controllers.Shortcuts' + ,'Common.Controllers.PasteOptions' ] }); @@ -210,6 +211,7 @@ require([ ,'common/main/lib/controller/Protection' ,'common/main/lib/controller/Shortcuts' ,'common/main/lib/controller/Draw' + ,'common/main/lib/controller/PasteOptions' ], function() { const code_path = !window.isIEBrowser ? 'documenteditor/main/code' : 'documenteditor/main/ie/code'; diff --git a/apps/documenteditor/main/app/controller/DocumentHolderExt.js b/apps/documenteditor/main/app/controller/DocumentHolderExt.js index b5d0bd6aa1..7fc2b069de 100644 --- a/apps/documenteditor/main/app/controller/DocumentHolderExt.js +++ b/apps/documenteditor/main/app/controller/DocumentHolderExt.js @@ -1372,6 +1372,7 @@ define([], function () { dh.onShowSpecialPasteOptions = function(specialPasteShowOptions) { if (this.mode && !this.mode.isEdit) return; + console.log(this.api.asc_getPasteOptions) var me = this, documentHolder = me.documentHolder; @@ -1492,7 +1493,7 @@ define([], function () { } str = str.substring(0, str.length-1) var keymap = {}; - keymap[str] = _.bind(function(e) { + keymap[str + ' ' + 'special-paste-context'] = _.bind(function(e) { var menu = this.btnSpecialPaste.menu; for (var i = 0; i < menu.items.length; i++) { if (this.hkSpecPaste[menu.items[i].value] === String.fromCharCode(e.keyCode)) { @@ -1501,12 +1502,14 @@ define([], function () { } }, me); Common.util.Shortcuts.delegateShortcuts({shortcuts:keymap}); - Common.util.Shortcuts.suspendEvents(str, undefined, true); + Common.util.Shortcuts.suspendEvents(str, 'special-paste-context', true); me.btnSpecialPaste.menu.on('show:after', function(menu) { - Common.util.Shortcuts.resumeEvents(str); + window.key.setScope('special-paste-context'); + Common.util.Shortcuts.resumeEvents(str, 'special-paste-context'); }).on('hide:after', function(menu) { - Common.util.Shortcuts.suspendEvents(str, undefined, true); + window.key.setScope('all'); + Common.util.Shortcuts.suspendEvents(str, 'special-paste-context', true); }); }; diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 0a69f25859..4abb3a8012 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -335,6 +335,19 @@ define([ toolbar.btnRedo.on('disabled', _.bind(this.onBtnChangeState, this, 'redo:disabled')); toolbar.btnCopy.on('click', _.bind(this.onCopyPaste, this, 'copy')); toolbar.btnPaste.on('click', _.bind(this.onCopyPaste, this, 'paste')); + $('#slot-btn-paste').on('click', '.dropdown-toggle', _.bind(function(e) { + e.preventDefault(); + e.stopImmediatePropagation(); + + var menu = this.toolbar.btnPaste.menu; + + if (menu && menu.isVisible && menu.isVisible()) { + menu.hide(); + return; + } + + this.toolbar.fireEvent('paste:options', [toolbar.btnPaste, this.api]) + }, this)); toolbar.btnCut.on('click', _.bind(this.onCopyPaste, this, 'cut')); toolbar.btnSelectAll.on('click', _.bind(this.onSelectAll, this)); toolbar.btnReplace.on('click', _.bind(this.onReplace, this)); diff --git a/apps/documenteditor/main/app/template/Toolbar.template b/apps/documenteditor/main/app/template/Toolbar.template index 6f91a8e87d..681e537c5d 100644 --- a/apps/documenteditor/main/app/template/Toolbar.template +++ b/apps/documenteditor/main/app/template/Toolbar.template @@ -18,7 +18,7 @@
- +
diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index c4b04519e4..4030549a0d 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -170,6 +170,7 @@ define([ applyLayout: function (config) { var me = this; me.lockControls = []; + me.config = config; var _set = Common.enumLock; if ( config.isEdit ) { Common.UI.Mixtbar.prototype.initialize.call(this, { @@ -279,6 +280,8 @@ define([ iconCls: 'toolbar__icon btn-paste', lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.previewReviewMode, _set.viewFormMode, _set.lostConnect, _set.disableOnStart, _set.docLockViewIns, _set.docLockCommentsIns, _set.viewMode], dataHint: '1', + menu: config.isDesktopApp ? new Common.UI.Menu({items: []}) : false, + split: config.isDesktopApp, dataHintDirection: 'top', dataHintTitle: 'V' }); @@ -2232,6 +2235,10 @@ define([ _injectComponent('#slot-lbl-space-after', this.lblSpacingAfter); _injectComponent('#slot-btn-pagecolor', this.btnPageColor); + if (!this.config || !this.config.isDesktopApp) { + $host.find('#slot-btn-paste').removeClass('split'); + } + this.btnsPageBreak = Common.Utils.injectButtons($host.find('.btn-slot.btn-pagebreak'), '', 'toolbar__icon btn-pagebreak', this.capBtnInsPagebreak, [Common.enumLock.paragraphLock, Common.enumLock.headerLock, Common.enumLock.richEditLock, Common.enumLock.plainEditLock, Common.enumLock.inEquation, Common.enumLock.richDelLock, Common.enumLock.plainDelLock, Common.enumLock.inHeader, Common.enumLock.inFootnote, Common.enumLock.cantPageBreak, Common.enumLock.previewReviewMode, diff --git a/apps/documenteditor/main/app_dev.js b/apps/documenteditor/main/app_dev.js index 24e9b01c2e..e44830b73b 100644 --- a/apps/documenteditor/main/app_dev.js +++ b/apps/documenteditor/main/app_dev.js @@ -154,6 +154,7 @@ require([ ,'Common.Controllers.ReviewChanges' ,'Common.Controllers.Protection' ,'Common.Controllers.Shortcuts' + ,'Common.Controllers.PasteOptions' ] }); @@ -200,6 +201,7 @@ require([ ,'common/main/lib/controller/Protection' ,'common/main/lib/controller/Shortcuts' ,'common/main/lib/controller/Draw' + ,'common/main/lib/controller/PasteOptions' ], function() { app.postLaunchScripts = [ 'common/main/lib/controller/ScreenReaderFocus', diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index e5f99542d9..65833ae601 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -394,6 +394,16 @@ "Common.Controllers.Shortcuts.txtLabelZoom100": "Zoom100", "Common.Controllers.Shortcuts.txtLabelZoomIn": "ZoomIn", "Common.Controllers.Shortcuts.txtLabelZoomOut": "ZoomOut", + "Common.Controllers.PasteOptions.textPaste": "Paste", + "Common.Controllers.PasteOptions.txtPasteSourceFormat": "Keep source formatting", + "Common.Controllers.PasteOptions.txtKeepTextOnly": "Keep text only", + "Common.Controllers.PasteOptions.textNest": "Nest table", + "Common.Controllers.PasteOptions.txtOverwriteCells": "Overwrite cells", + "Common.Controllers.PasteOptions.txtSourceEmbed": "Keep source formatting & Embed workbook", + "Common.Controllers.PasteOptions.txtDestEmbed": "Use destination theme & Embed workbook", + "Common.Controllers.PasteOptions.txtSourceLink": "Keep source formatting & Link data", + "Common.Controllers.PasteOptions.txtDestLink": "Use destination theme & Link data", + "Common.Controllers.PasteOptions.txtPastePicture": "Picture", "Common.define.chartData.textArea": "Area", "Common.define.chartData.textAreaStacked": "Stacked area", "Common.define.chartData.textAreaStackedPer": "100% Stacked area", From b59647559d353b4bed7a7ceab396e61714722361 Mon Sep 17 00:00:00 2001 From: nikita_bartoshuk Date: Fri, 27 Feb 2026 00:00:19 +0300 Subject: [PATCH 2/5] fixed captions and menu blur --- .../main/lib/controller/PasteOptions.js | 34 +++++++++++-------- .../main/app/controller/DocumentHolderExt.js | 1 + 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/apps/common/main/lib/controller/PasteOptions.js b/apps/common/main/lib/controller/PasteOptions.js index ecaf13c9cf..686a2aa1c2 100644 --- a/apps/common/main/lib/controller/PasteOptions.js +++ b/apps/common/main/lib/controller/PasteOptions.js @@ -117,27 +117,22 @@ define([ if (!pasteItems) return; me._arrSpecialPaste = []; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.paste] = documentHolder.textPaste; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceformatting] = documentHolder.txtPasteSourceFormat; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.keepTextOnly] = documentHolder.txtKeepTextOnly; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.insertAsNestedTable] = documentHolder.textNest; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.overwriteCells] = documentHolder.txtOverwriteCells; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceFormattingEmbedding] = documentHolder.txtSourceEmbed; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.destinationFormattingEmbedding] = documentHolder.txtDestEmbed; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceFormattingLink] = documentHolder.txtSourceLink; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.destinationFormattingLink] = documentHolder.txtDestLink; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.picture] = documentHolder.txtPastePicture; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.paste] = me.textPaste; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceformatting] = me.txtPasteSourceFormat; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.keepTextOnly] = me.txtKeepTextOnly; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.insertAsNestedTable] = me.textNest; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.overwriteCells] = me.txtOverwriteCells; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceFormattingEmbedding] = me.txtSourceEmbed; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.destinationFormattingEmbedding] = me.txtDestEmbed; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceFormattingLink] = me.txtSourceLink; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.destinationFormattingLink] = me.txtDestLink; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.picture] = me.txtPastePicture; me.initSpecialPasteEvents(); if (pasteItems.length>0) { var menu = me.btn.menu; - for (var i = 0; i < menu.items.length; i++) { - menu.removeItem(menu.items[i]); - i--; - } - var group_prev = -1; _.each(pasteItems, function(menuItem, index) { var mnu = new Common.UI.MenuItem({ caption: me._arrSpecialPaste[menuItem] + ' (' + me.hkSpecPaste[menuItem] + ')', @@ -145,8 +140,10 @@ define([ checkable: true, toggleGroup : 'specialPasteGroup' }).on('click', _.bind(me.onSpecialPasteItemClick, me)); + console.log(mnu) menu.addItem(mnu); }); + menu.show(); } }, @@ -186,6 +183,13 @@ define([ Common.util.Shortcuts.delegateShortcuts({shortcuts:keymap}); window.key.setScope('special-paste-toolbar'); + var closeMenuOnWindowBlur = function() { + if (me.btn.menu.$el && me.btn.menu.$el.is(':visible')) { + me.btn.menu.hide(); + } + }; + $(window).on('blur.pastemenuhide', closeMenuOnWindowBlur); + me.btn.menu.on('show:after', function(menu) { window.key.setScope('special-paste-toolbar'); Common.util.Shortcuts.resumeEvents(str); diff --git a/apps/documenteditor/main/app/controller/DocumentHolderExt.js b/apps/documenteditor/main/app/controller/DocumentHolderExt.js index 7fc2b069de..6c51d9705a 100644 --- a/apps/documenteditor/main/app/controller/DocumentHolderExt.js +++ b/apps/documenteditor/main/app/controller/DocumentHolderExt.js @@ -1380,6 +1380,7 @@ define([], function () { pasteContainer = documentHolder.cmpEl.find('#special-paste-container'), pasteItems = specialPasteShowOptions.asc_getOptions(); if (!pasteItems) return; + console.log(pasteItems, 'Paste items') // Prepare menu container if (pasteContainer.length < 1) { From 9bfaa8b80cbc0781b1656502450dc7529983c7ec Mon Sep 17 00:00:00 2001 From: nikita_bartoshuk Date: Fri, 27 Feb 2026 17:32:53 +0300 Subject: [PATCH 3/5] added btn in PE --- .../main/lib/controller/PasteOptions.js | 221 +++++++++++++--- .../main/app/controller/Toolbar.js | 2 +- apps/presentationeditor/main/app.js | 2 + .../main/app/controller/DocumentHolderExt.js | 10 +- .../main/app/controller/Toolbar.js | 13 + .../main/app/template/Toolbar.template | 2 +- .../main/app/view/Toolbar.js | 7 + apps/presentationeditor/main/app_dev.js | 2 + apps/presentationeditor/main/locale/en.json | 9 + apps/spreadsheeteditor/main/app.js | 2 + .../main/app/controller/Toolbar.js | 240 +----------------- apps/spreadsheeteditor/main/app_dev.js | 2 + apps/spreadsheeteditor/main/locale/en.json | 75 ++++-- 13 files changed, 284 insertions(+), 303 deletions(-) diff --git a/apps/common/main/lib/controller/PasteOptions.js b/apps/common/main/lib/controller/PasteOptions.js index 686a2aa1c2..c169c01e80 100644 --- a/apps/common/main/lib/controller/PasteOptions.js +++ b/apps/common/main/lib/controller/PasteOptions.js @@ -74,10 +74,11 @@ define([ return this; }, - onBtnPasteOptionsClick: function (btn, api) { + onBtnPasteOptionsClick: function (btn, api, isSSE) { console.log('onBtnPasteOptionsClick') this.api = api; this.btn = btn; + this.isSSE = isSSE; var me = this; var menu = btn.menu; if (menu && menu.items && menu.items.length > 0) { @@ -117,32 +118,130 @@ define([ if (!pasteItems) return; me._arrSpecialPaste = []; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.paste] = me.textPaste; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceformatting] = me.txtPasteSourceFormat; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.keepTextOnly] = me.txtKeepTextOnly; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.insertAsNestedTable] = me.textNest; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.overwriteCells] = me.txtOverwriteCells; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceFormattingEmbedding] = me.txtSourceEmbed; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.destinationFormattingEmbedding] = me.txtDestEmbed; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceFormattingLink] = me.txtSourceLink; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.destinationFormattingLink] = me.txtDestLink; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.picture] = me.txtPastePicture; + if (!me.isSSE) { + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.paste] = me.textPaste; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceformatting] = me.txtPasteSourceFormat; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.keepTextOnly] = me.txtKeepTextOnly; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.insertAsNestedTable] = me.textNest; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.overwriteCells] = me.txtOverwriteCells; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceFormattingEmbedding] = me.txtSourceEmbed; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.destinationFormattingEmbedding] = me.txtDestEmbed; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceFormattingLink] = me.txtSourceLink; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.destinationFormattingLink] = me.txtDestLink; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.picture] = me.txtPastePicture; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.destinationFormatting] = me.txtPasteDestFormat; + } else { + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.paste] = [me.txtPaste, 0]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.pasteOnlyFormula] = [me.txtPasteFormulas, 0]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaNumberFormat] = [me.txtPasteFormulaNumFormat, 0]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaAllFormatting] = [me.txtPasteKeepSourceFormat, 0]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaWithoutBorders] = [me.txtPasteBorders, 0]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaColumnWidth] = [me.txtPasteColWidths, 0]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.mergeConditionalFormating] = [me.txtPasteMerge, 0]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.pasteOnlyValues] = [me.txtPasteValues, 1]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.valueNumberFormat] = [me.txtPasteValNumFormat, 1]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.valueAllFormating] = [me.txtPasteValFormat, 1]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.pasteOnlyFormating] = [me.txtPasteFormat, 2]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.link] = [me.txtPasteLink, 2]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.transpose] = [me.txtPasteTranspose, 2]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.picture] = [me.txtPastePicture, 2]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.linkedPicture] = [me.txtPasteLinkPicture, 2]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceformatting] = [me.txtPasteSourceFormat, 2]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.destinationFormatting] = [me.txtPasteDestFormat, 2]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.keepTextOnly] = [me.txtKeepTextOnly, 2]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.useTextImport] = [me.txtUseTextImport, 3]; + } me.initSpecialPasteEvents(); if (pasteItems.length>0) { var menu = me.btn.menu; + if (me.isSSE) { + var groups = []; + for (var i = 0; i < 3; i++) { + groups[i] = []; + } + + var importText, pasteItem; + } + _.each(pasteItems, function(menuItem, index) { - var mnu = new Common.UI.MenuItem({ - caption: me._arrSpecialPaste[menuItem] + ' (' + me.hkSpecPaste[menuItem] + ')', - value: menuItem, - checkable: true, - toggleGroup : 'specialPasteGroup' - }).on('click', _.bind(me.onSpecialPasteItemClick, me)); - console.log(mnu) - menu.addItem(mnu); + if (me._arrSpecialPaste[menuItem]) { + var mnu = new Common.UI.MenuItem({ + caption: !me.isSSE ? me._arrSpecialPaste[menuItem] + ' (' + me.hkSpecPaste[menuItem] + ')' : + me._arrSpecialPaste[menuItem][0] + (me.hkSpecPaste[menuItem] ? ' (' + me.hkSpecPaste[menuItem] + ')' : ''), + value: menuItem, + checkable: true, + toggleGroup : 'specialPasteGroup' + }).on('click', _.bind(me.onSpecialPasteItemClick, me)); + + if (!me.isSSE) { + menu.addItem(mnu); + } else { + if (menuItem == Asc.c_oSpecialPasteProps.paste) { + pasteItem = mnu; + } else if (menuItem == Asc.c_oSpecialPasteProps.useTextImport) { + importText = mnu; + } else { + groups[me._arrSpecialPaste[menuItem][1]].push(mnu); + } + + me._arrSpecialPaste[menuItem][2] = mnu; + } + } }); + + if (me.isSSE) { + var groupTitles = [me.txtFormula, me.txtValue, me.txtOther]; + + if (pasteItem) { + menu.addItem(pasteItem); + } + + for (var i = 0; i < 3; i++) { + if (groups[i].length > 0) { + if (menu.items.length > 0) { + menu.addItem(new Common.UI.MenuItem({ caption: '--' })); + } + menu.addItem(new Common.UI.MenuItem({ + header: groupTitles[i], + disabled: true, + cls: 'menu-header' + })); + _.each(groups[i], function (menuItem, index) { + menu.addItem(menuItem); + }); + } + } + + if (importText) { + menu.addItem(new Common.UI.MenuItem({ caption: '--' })); + menu.addItem(importText); + } + if (menu.items.length>0 && options.asc_getShowPasteSpecial()) { + menu.addItem(new Common.UI.MenuItem({ caption: '--' })); + var mnu = new Common.UI.MenuItem({ + caption: me.textPasteSpecial, + value: 'special' + }).on('click', function(item, e) { + (new SSE.Views.SpecialPasteDialog({ + props: pasteItems, + isTable: isTable, + handler: function (result, settings) { + if (result == 'ok') { + if (me && me.api) { + me.api.asc_SpecialPaste(settings, true); + } + } + } + })).show(); + setTimeout(function(){menu.hide();}, 100); + }); + menu.addItem(mnu); + } + } + menu.show(); } }, @@ -152,16 +251,41 @@ define([ var me = this; me.hkSpecPaste = []; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.paste] = 'P'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.sourceformatting] = 'K'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.keepTextOnly] = 'T'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.insertAsNestedTable] = 'N'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.overwriteCells] = 'O'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.sourceFormattingEmbedding] = 'K'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.destinationFormattingEmbedding] = 'H'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.sourceFormattingLink] = 'F'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.destinationFormattingLink] = 'L'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.picture] = 'U'; + + if (!me.isSSE) { + me.hkSpecPaste[Asc.c_oSpecialPasteProps.paste] = 'P'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.sourceformatting] = 'K'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.keepTextOnly] = 'T'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.insertAsNestedTable] = 'N'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.overwriteCells] = 'O'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.destinationFormatting] = 'H'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.sourceFormattingEmbedding] = 'K'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.destinationFormattingEmbedding] = 'H'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.sourceFormattingLink] = 'F'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.destinationFormattingLink] = 'L'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.picture] = 'U'; + } else { + me.hkSpecPaste[Asc.c_oSpecialPasteProps.paste] = 'P'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.pasteOnlyFormula] = 'F'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.formulaNumberFormat] = 'O'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.formulaAllFormatting] = 'K'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.formulaWithoutBorders] = 'B'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.formulaColumnWidth] = 'W'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.mergeConditionalFormating] = 'G'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.transpose] = 'T'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.pasteOnlyValues] = 'V'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.valueNumberFormat] = 'A'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.valueAllFormating] = 'E'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.pasteOnlyFormating] = 'R'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.link] = 'N'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.picture] = 'U'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.linkedPicture] = 'I'; + + me.hkSpecPaste[Asc.c_oSpecialPasteProps.sourceformatting] = 'K'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.destinationFormatting] = 'M'; + me.hkSpecPaste[Asc.c_oSpecialPasteProps.keepTextOnly] = 'T'; + // me.hkSpecPaste[Asc.c_oSpecialPasteProps.useTextImport] = ''; + } var str = ''; for(var key in me.hkSpecPaste){ @@ -204,12 +328,43 @@ define([ }, onSpecialPasteItemClick: function(item, e) { + var me = this; + if (this.api) { - this.api.asc_SpecialPaste(item.value, true); var menu = this.btn.menu; - setTimeout(function(){ - menu.hide(); - }, 100); + if (!this.isSSE) { + this.api.asc_SpecialPaste(item.value, true); + setTimeout(function(){ + menu.hide(); + }, 100); + } else { + if (item.value == Asc.c_oSpecialPasteProps.useTextImport) { + (new Common.Views.OpenDialog({ + title: me.txtImportWizard, + closable: true, + type: Common.Utils.importTextType.Paste, + preview: true, + api: me.api, + fromToolbar: true, + handler: function (result, settings) { + if (result == 'ok') { + if (me && me.api) { + var props = new Asc.SpecialPasteProps(); + props.asc_setProps(Asc.c_oSpecialPasteProps.useTextImport); + props.asc_setAdvancedOptions(settings.textOptions); + me.api.asc_SpecialPaste(props, true); + } + } + } + })).show(); + setTimeout(function(){menu.hide();}, 100); + } else { + var props = new Asc.SpecialPasteProps(); + props.asc_setProps(item.value); + me.api.asc_SpecialPaste(props, true); + setTimeout(function(){menu.hide();}, 100); + } + } } return false; }, diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 4abb3a8012..7e644c6827 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -346,7 +346,7 @@ define([ return; } - this.toolbar.fireEvent('paste:options', [toolbar.btnPaste, this.api]) + this.toolbar.fireEvent('paste:options', [toolbar.btnPaste, this.api]); }, this)); toolbar.btnCut.on('click', _.bind(this.onCopyPaste, this, 'cut')); toolbar.btnSelectAll.on('click', _.bind(this.onSelectAll, this)); diff --git a/apps/presentationeditor/main/app.js b/apps/presentationeditor/main/app.js index fe0365e537..4116e32339 100644 --- a/apps/presentationeditor/main/app.js +++ b/apps/presentationeditor/main/app.js @@ -157,6 +157,7 @@ require([ ,'Common.Controllers.ReviewChanges' ,'Common.Controllers.Protection' ,'Common.Controllers.Shortcuts' + ,'Common.Controllers.PasteOptions' ,'Transitions' ,'Animation' ] @@ -206,6 +207,7 @@ require([ ,'common/main/lib/controller/Protection' ,'common/main/lib/controller/Shortcuts' ,'common/main/lib/controller/Draw' + ,'common/main/lib/controller/PasteOptions' ,'presentationeditor/main/app/controller/Transitions' ,'presentationeditor/main/app/controller/Animation' ], function() { diff --git a/apps/presentationeditor/main/app/controller/DocumentHolderExt.js b/apps/presentationeditor/main/app/controller/DocumentHolderExt.js index 565fc4fdcc..f5a10b8196 100644 --- a/apps/presentationeditor/main/app/controller/DocumentHolderExt.js +++ b/apps/presentationeditor/main/app/controller/DocumentHolderExt.js @@ -1438,7 +1438,7 @@ define([], function () { } str = str.substring(0, str.length-1) var keymap = {}; - keymap[str] = _.bind(function(e) { + keymap[str + ' ' + 'special-paste-context'] = _.bind(function(e) { var menu = this.btnSpecialPaste.menu; for (var i = 0; i < menu.items.length; i++) { if (this.hkSpecPaste[menu.items[i].value] === String.fromCharCode(e.keyCode)) { @@ -1447,12 +1447,14 @@ define([], function () { } }, me); Common.util.Shortcuts.delegateShortcuts({shortcuts:keymap}); - Common.util.Shortcuts.suspendEvents(str, undefined, true); + Common.util.Shortcuts.suspendEvents(str, 'special-paste-context', true); me.btnSpecialPaste.menu.on('show:after', function(menu) { - Common.util.Shortcuts.resumeEvents(str); + window.key.setScope('special-paste-context'); + Common.util.Shortcuts.resumeEvents(str, 'special-paste-context'); }).on('hide:after', function(menu) { - Common.util.Shortcuts.suspendEvents(str, undefined, true); + window.key.setScope('all'); + Common.util.Shortcuts.suspendEvents(str, 'special-paste-context', true); }); }; diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index da600e5130..22a3846b09 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -340,6 +340,19 @@ define([ toolbar.btnRedo.on('disabled', _.bind(this.onBtnChangeState, this, 'redo:disabled')); toolbar.btnCopy.on('click', _.bind(this.onCopyPaste, this, 'copy')); toolbar.btnPaste.on('click', _.bind(this.onCopyPaste, this, 'paste')); + $('#slot-btn-paste').on('click', '.dropdown-toggle', _.bind(function(e) { + e.preventDefault(); + e.stopImmediatePropagation(); + + var menu = this.toolbar.btnPaste.menu; + + if (menu && menu.isVisible && menu.isVisible()) { + menu.hide(); + return; + } + + this.toolbar.fireEvent('paste:options', [toolbar.btnPaste, this.api]); + }, this)); toolbar.btnCut.on('click', _.bind(this.onCopyPaste, this, 'cut')); toolbar.btnSelectAll.on('click', _.bind(this.onSelectAll, this)); toolbar.btnReplace.on('click', _.bind(this.onReplace, this)); diff --git a/apps/presentationeditor/main/app/template/Toolbar.template b/apps/presentationeditor/main/app/template/Toolbar.template index 9b7b3a5007..69017c724a 100644 --- a/apps/presentationeditor/main/app/template/Toolbar.template +++ b/apps/presentationeditor/main/app/template/Toolbar.template @@ -18,7 +18,7 @@
- +
diff --git a/apps/presentationeditor/main/app/view/Toolbar.js b/apps/presentationeditor/main/app/view/Toolbar.js index b3874118b0..82847f228c 100644 --- a/apps/presentationeditor/main/app/view/Toolbar.js +++ b/apps/presentationeditor/main/app/view/Toolbar.js @@ -145,6 +145,7 @@ define([ applyLayout: function (config) { var me = this; + me.config = config; me.lockControls = []; me.nolockControls = []; if ( config.isEdit ) { @@ -263,6 +264,8 @@ define([ cls: 'btn-toolbar', iconCls: 'toolbar__icon btn-paste', lock: [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides], + menu: config.isDesktopApp ? new Common.UI.Menu({items: []}) : false, + split: config.isDesktopApp, dataHint: '1', dataHintDirection: 'top', dataHintTitle: 'V' @@ -1566,6 +1569,10 @@ define([ _injectComponent('#slot-btn-datetime', this.btnInsDateTime); _injectComponent('#slot-btn-slidenum', this.btnInsSlideNum); + if (!this.config || !this.config.isDesktopApp) { + $host.find('#slot-btn-paste').removeClass('split'); + } + this.cmbsInsertShape = []; $host.find('.slot-combo-insertshape').each(function (index, el) { var cmb = new Common.UI.ComboDataViewShape({ diff --git a/apps/presentationeditor/main/app_dev.js b/apps/presentationeditor/main/app_dev.js index fa1a4faca0..a18bb1922e 100644 --- a/apps/presentationeditor/main/app_dev.js +++ b/apps/presentationeditor/main/app_dev.js @@ -148,6 +148,7 @@ require([ ,'Common.Controllers.ReviewChanges' ,'Common.Controllers.Protection' ,'Common.Controllers.Shortcuts' + ,'Common.Controllers.PasteOptions' ,'Transitions' ,'Animation' ] @@ -196,6 +197,7 @@ require([ ,'common/main/lib/controller/ReviewChanges' ,'common/main/lib/controller/Protection' ,'common/main/lib/controller/Shortcuts' + ,'common/main/lib/controller/PasteOptions' ,'common/main/lib/controller/Draw' ,'presentationeditor/main/app/controller/Transitions' ,'presentationeditor/main/app/controller/Animation' diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index ce7c207983..e7c0c7a53c 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -283,6 +283,15 @@ "Common.Controllers.Shortcuts.txtLabelZoom100": "Zoom100", "Common.Controllers.Shortcuts.txtLabelZoomIn": "ZoomIn", "Common.Controllers.Shortcuts.txtLabelZoomOut": "ZoomOut", + "Common.Controllers.PasteOptions.textPaste": "Paste", + "Common.Controllers.PasteOptions.txtPasteSourceFormat": "Keep source formatting", + "Common.Controllers.PasteOptions.txtKeepTextOnly": "Keep text only", + "Common.Controllers.PasteOptions.txtSourceEmbed": "Keep source formatting & Embed workbook", + "Common.Controllers.PasteOptions.txtDestEmbed": "Use destination theme & Embed workbook", + "Common.Controllers.PasteOptions.txtSourceLink": "Keep source formatting & Link data", + "Common.Controllers.PasteOptions.txtDestLink": "Use destination theme & Link data", + "Common.Controllers.PasteOptions.txtPastePicture": "Picture", + "Common.Controllers.PasteOptions.txtPasteDestFormat": "Use destination theme", "Common.define.chartData.textArea": "Area", "Common.define.chartData.textAreaStacked": "Stacked area", "Common.define.chartData.textAreaStackedPer": "100% Stacked area", diff --git a/apps/spreadsheeteditor/main/app.js b/apps/spreadsheeteditor/main/app.js index 83eab0c59c..77b5d82a1f 100644 --- a/apps/spreadsheeteditor/main/app.js +++ b/apps/spreadsheeteditor/main/app.js @@ -161,6 +161,7 @@ require([ ,'Common.Controllers.ReviewChanges' ,'Common.Controllers.Protection' ,'Common.Controllers.Shortcuts' + ,'Common.Controllers.PasteOptions' ] }); @@ -210,6 +211,7 @@ require([ ,'common/main/lib/controller/Protection' ,'common/main/lib/controller/Shortcuts' ,'common/main/lib/controller/Draw' + ,'common/main/lib/controller/PasteOptions' ], function() { const code_path = !window.isIEBrowser ? 'spreadsheeteditor/main/code' : 'spreadsheeteditor/main/ie/code'; app.postLaunchScripts = [ diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index fa02c744a9..890ead559d 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -500,9 +500,8 @@ define([ return; } - this.onBtnPasteOptionsClick(); + this.toolbar.fireEvent('paste:options', [toolbar.btnPaste, this.api, true]); }, this)); - // toolbar.btnPaste.menu && toolbar.btnPaste.menu.on('show:before', _.bind(this.onBtnPasteOptionsClick, this)); toolbar.btnPageOrient.menu.on('item:click', _.bind(this.onPageOrientSelect, this)); toolbar.btnPageMargins.menu.on('item:click', _.bind(this.onPageMarginsSelect, this)); toolbar.mnuPageSize.on('item:click', _.bind(this.onPageSizeClick, this)); @@ -1071,243 +1070,6 @@ define([ Common.component.Analytics.trackEvent('ToolBar', 'Table'); }, - onBtnPasteOptionsClick: function (btn, e) { - var me = this; - var menu = me.toolbar.btnPaste.menu; - if (menu && menu.items && menu.items.length > 0) { - for (var i = 0; i < menu.items.length; i++) { - menu.removeItem(menu.items[i]); - i--; - } - } - - this.api.asc_getPasteOptions(function (options) { - me.handlePasteOptions(options) - }); - }, - - handlePasteOptions: function (options) { - var me = this; - - if (options === null) { - var menu = me.toolbar.btnPaste.menu; - - var mnu = new Common.UI.MenuItem({ - caption: me.txtPasteNoOptions, - disabled: true - }); - - menu.addItem(mnu) - menu.show(); - return - } - - var pasteItems = options.asc_getOptions(), - isTable = !!options.asc_getContainTables(); - if (!pasteItems) return; - - me._arrSpecialPaste = []; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.paste] = [me.txtPaste, 0]; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.pasteOnlyFormula] = [me.txtPasteFormulas, 0]; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaNumberFormat] = [me.txtPasteFormulaNumFormat, 0]; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaAllFormatting] = [me.txtPasteKeepSourceFormat, 0]; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaWithoutBorders] = [me.txtPasteBorders, 0]; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaColumnWidth] = [me.txtPasteColWidths, 0]; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.mergeConditionalFormating] = [me.txtPasteMerge, 0]; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.pasteOnlyValues] = [me.txtPasteValues, 1]; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.valueNumberFormat] = [me.txtPasteValNumFormat, 1]; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.valueAllFormating] = [me.txtPasteValFormat, 1]; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.pasteOnlyFormating] = [me.txtPasteFormat, 2]; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.link] = [me.txtPasteLink, 2]; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.transpose] = [me.txtPasteTranspose, 2]; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.picture] = [me.txtPastePicture, 2]; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.linkedPicture] = [me.txtPasteLinkPicture, 2]; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceformatting] = [me.txtPasteSourceFormat, 2]; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.destinationFormatting] = [me.txtPasteDestFormat, 2]; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.keepTextOnly] = [me.txtKeepTextOnly, 2]; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.useTextImport] = [me.txtUseTextImport, 3]; - - me.initSpecialPasteEvents(); - - if (pasteItems.length>0) { - var menu = me.toolbar.btnPaste.menu; - - var groups = []; - for (var i = 0; i < 3; i++) { - groups[i] = []; - } - - var importText, pasteItem; - - _.each(pasteItems, function(menuItem, index) { - if (me._arrSpecialPaste[menuItem]) { - var mnu = new Common.UI.MenuItem({ - caption: me._arrSpecialPaste[menuItem][0] + (me.hkSpecPaste[menuItem] ? ' (' + me.hkSpecPaste[menuItem] + ')' : ''), - value: menuItem, - checkable: true, - toggleGroup: 'specialPasteGroup' - }).on('click', _.bind(me.onSpecialPasteItemClick, me)); - - if (menuItem == Asc.c_oSpecialPasteProps.paste) { - pasteItem = mnu; - } else if (menuItem == Asc.c_oSpecialPasteProps.useTextImport) { - importText = mnu; - } else { - groups[me._arrSpecialPaste[menuItem][1]].push(mnu); - } - - me._arrSpecialPaste[menuItem][2] = mnu; - } - }); - var groupTitles = [me.txtFormula, me.txtValue, me.txtOther]; - - if (pasteItem) { - menu.addItem(pasteItem); - } - - for (var i = 0; i < 3; i++) { - if (groups[i].length > 0) { - if (menu.items.length > 0) { - menu.addItem(new Common.UI.MenuItem({ caption: '--' })); - } - menu.addItem(new Common.UI.MenuItem({ - header: groupTitles[i], - disabled: true, - cls: 'menu-header' - })); - _.each(groups[i], function (menuItem, index) { - menu.addItem(menuItem); - }); - } - } - - if (importText) { - menu.addItem(new Common.UI.MenuItem({ caption: '--' })); - menu.addItem(importText); - } - if (menu.items.length>0 && options.asc_getShowPasteSpecial()) { - menu.addItem(new Common.UI.MenuItem({ caption: '--' })); - var mnu = new Common.UI.MenuItem({ - caption: me.textPasteSpecial, - value: 'special' - }).on('click', function(item, e) { - (new SSE.Views.SpecialPasteDialog({ - props: pasteItems, - isTable: isTable, - handler: function (result, settings) { - if (result == 'ok') { - if (me && me.api) { - me.api.asc_SpecialPaste(settings, true); - } - } - } - })).show(); - setTimeout(function(){menu.hide();}, 100); - }); - menu.addItem(mnu); - } - menu.show(); - } - }, - - onSpecialPasteItemClick: function (item, e) { - var me = this, - menu = this.toolbar.btnPaste.menu; - if (item.value == Asc.c_oSpecialPasteProps.useTextImport) { - (new Common.Views.OpenDialog({ - title: me.txtImportWizard, - closable: true, - type: Common.Utils.importTextType.Paste, - preview: true, - api: me.api, - fromToolbar: true, - handler: function (result, settings) { - if (result == 'ok') { - if (me && me.api) { - var props = new Asc.SpecialPasteProps(); - props.asc_setProps(Asc.c_oSpecialPasteProps.useTextImport); - props.asc_setAdvancedOptions(settings.textOptions); - me.api.asc_SpecialPaste(props, true); - } - } - } - })).show(); - setTimeout(function(){menu.hide();}, 100); - } else { - var props = new Asc.SpecialPasteProps(); - props.asc_setProps(item.value); - me.api.asc_SpecialPaste(props, true); - setTimeout(function(){menu.hide();}, 100); - } - return false; - }, - - initSpecialPasteEvents: function() { - if (this.specialPasteEventsInited) return - - var me = this; - - me.hkSpecPaste = []; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.paste] = 'P'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.pasteOnlyFormula] = 'F'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.formulaNumberFormat] = 'O'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.formulaAllFormatting] = 'K'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.formulaWithoutBorders] = 'B'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.formulaColumnWidth] = 'W'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.mergeConditionalFormating] = 'G'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.transpose] = 'T'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.pasteOnlyValues] = 'V'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.valueNumberFormat] = 'A'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.valueAllFormating] = 'E'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.pasteOnlyFormating] = 'R'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.link] = 'N'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.picture] = 'U'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.linkedPicture] = 'I'; - - me.hkSpecPaste[Asc.c_oSpecialPasteProps.sourceformatting] = 'K'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.destinationFormatting] = 'M'; - me.hkSpecPaste[Asc.c_oSpecialPasteProps.keepTextOnly] = 'T'; - // me.hkSpecPaste[Asc.c_oSpecialPasteProps.useTextImport] = ''; - - var str = ''; - for(var key in me.hkSpecPaste){ - if(me.hkSpecPaste.hasOwnProperty(key)){ - if (str.indexOf(me.hkSpecPaste[key])<0) - str += me.hkSpecPaste[key] + ','; - } - } - str = str.substring(0, str.length-1) - var keymap = {}; - keymap[str + ' ' + 'special-paste-toolbar'] = _.bind(function(e) { - var menu = this.toolbar.btnPaste.menu; - for (var i = 0; i < menu.items.length; i++) { - if (this.hkSpecPaste[menu.items[i].value] === String.fromCharCode(e.keyCode)) { - return me.onSpecialPasteItemClick({value: menu.items[i].value}); - } - } - }, me); - Common.util.Shortcuts.delegateShortcuts({shortcuts:keymap}); - window.key.setScope('special-paste-toolbar'); - - var closeMenuOnWindowBlur = function() { - if (me.toolbar.btnPaste.menu.$el && me.toolbar.btnPaste.menu.$el.is(':visible')) { - me.toolbar.btnPaste.menu.hide(); - } - }; - $(window).on('blur.pastemenuhide', closeMenuOnWindowBlur); - - me.toolbar.btnPaste.menu.on('show:after', function(menu) { - window.key.setScope('special-paste-toolbar'); - Common.util.Shortcuts.resumeEvents(str); - $(window).on('blur.pastemenuhide', closeMenuOnWindowBlur); - }).on('hide:after', function(menu) { - window.key.setScope('all'); - Common.util.Shortcuts.suspendEvents(str, undefined, true); - $(window).off('blur.pastemenuhide', closeMenuOnWindowBlur); - }); - this.specialPasteEventsInited = true; - }, - onInsertImageMenu: function(menu, item, e) { var me = this; if (item.value === 'file') { diff --git a/apps/spreadsheeteditor/main/app_dev.js b/apps/spreadsheeteditor/main/app_dev.js index 6b101d4112..5979570d4b 100644 --- a/apps/spreadsheeteditor/main/app_dev.js +++ b/apps/spreadsheeteditor/main/app_dev.js @@ -151,6 +151,7 @@ require([ ,'Common.Controllers.ReviewChanges' ,'Common.Controllers.Protection' ,'Common.Controllers.Shortcuts' + ,'Common.Controllers.PasteOptions' ] }); @@ -201,6 +202,7 @@ require([ ,'common/main/lib/controller/Protection' ,'common/main/lib/controller/Shortcuts' ,'common/main/lib/controller/Draw' + ,'common/main/lib/controller/PasteOptions' ], function() { app.postLaunchScripts = [ 'common/main/lib/controller/ScreenReaderFocus', diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 75f35cd2f6..5b693f684e 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -375,6 +375,31 @@ "Common.Controllers.Shortcuts.txtLabelZoom100": "Zoom100", "Common.Controllers.Shortcuts.txtLabelZoomIn": "ZoomIn", "Common.Controllers.Shortcuts.txtLabelZoomOut": "ZoomOut", + "Common.Controllers.PasteOptions.txtOther": "Other", + "Common.Controllers.PasteOptions.txtPaste": "Paste", + "Common.Controllers.PasteOptions.txtPasteBorders": "Formula without borders", + "Common.Controllers.PasteOptions.txtPasteColWidths": "Formula + column width", + "Common.Controllers.PasteOptions.txtPasteDestFormat": "Destination formatting", + "Common.Controllers.PasteOptions.txtPasteFormat": "Paste only formatting", + "Common.Controllers.PasteOptions.txtPasteFormulaNumFormat": "Formula + number format", + "Common.Controllers.PasteOptions.txtPasteFormulas": "Paste only formula", + "Common.Controllers.PasteOptions.txtPasteKeepSourceFormat": "Formula + all formatting", + "Common.Controllers.PasteOptions.txtPasteLink": "Paste link", + "Common.Controllers.PasteOptions.txtPasteLinkPicture": "Linked picture", + "Common.Controllers.PasteOptions.txtPasteMerge": "Merge conditional formatting", + "Common.Controllers.PasteOptions.txtPasteNoOptions": "Paste (P)", + "Common.Controllers.PasteOptions.txtPastePicture": "Picture", + "Common.Controllers.PasteOptions.txtPasteSourceFormat": "Source formatting", + "Common.Controllers.PasteOptions.txtPasteTranspose": "Transpose", + "Common.Controllers.PasteOptions.txtPasteValFormat": "Value + all formatting", + "Common.Controllers.PasteOptions.txtPasteValNumFormat": "Value + number format", + "Common.Controllers.PasteOptions.txtPasteValues": "Paste only value", + "Common.Controllers.PasteOptions.txtKeepTextOnly": "Keep text only", + "Common.Controllers.PasteOptions.txtUseTextImport": "Use text import", + "Common.Controllers.PasteOptions.txtFormula": "Formula", + "Common.Controllers.PasteOptions.txtValue": "Value", + "Common.Controllers.PasteOptions.textPasteSpecial": "Paste special", + "Common.Controllers.PasteOptions.txtImportWizard": "Text Import", "Common.define.chartData.textArea": "Area", "Common.define.chartData.textAreaStacked": "Stacked area", "Common.define.chartData.textAreaStackedPer": "100% Stacked area", @@ -2102,7 +2127,7 @@ "SSE.Controllers.Toolbar.textLongOperation": "Long operation", "SSE.Controllers.Toolbar.textMatrix": "Matrices", "SSE.Controllers.Toolbar.textOperator": "Operators", - "SSE.Controllers.Toolbar.textPasteSpecial": "Paste special", + "del_SSE.Controllers.Toolbar.textPasteSpecial": "Paste special", "SSE.Controllers.Toolbar.textPivot": "Pivot Table", "SSE.Controllers.Toolbar.textRadical": "Radicals", "SSE.Controllers.Toolbar.textRating": "Ratings", @@ -2182,7 +2207,7 @@ "SSE.Controllers.Toolbar.txtDeleteCells": "Delete cells", "SSE.Controllers.Toolbar.txtExpand": "Expand and sort", "SSE.Controllers.Toolbar.txtExpandSort": "The data next to the selection will not be sorted. Do you want to expand the selection to include the adjacent data or continue with sorting the currently selected cells only?", - "SSE.Controllers.Toolbar.txtFormula": "Formula", + "del_SSE.Controllers.Toolbar.txtFormula": "Formula", "SSE.Controllers.Toolbar.txtFractionDiagonal": "Skewed fraction", "SSE.Controllers.Toolbar.txtFractionDifferential_1": "dx over dy", "SSE.Controllers.Toolbar.txtFractionDifferential_2": "cap delta y over cap delta x", @@ -2230,7 +2255,7 @@ "SSE.Controllers.Toolbar.txtGroupTable_Dark": "Dark", "SSE.Controllers.Toolbar.txtGroupTable_Light": "Light", "SSE.Controllers.Toolbar.txtGroupTable_Medium": "Medium", - "SSE.Controllers.Toolbar.txtImportWizard": "Text Import", + "del_SSE.Controllers.Toolbar.txtImportWizard": "Text Import", "SSE.Controllers.Toolbar.txtInsertCells": "Insert cells", "SSE.Controllers.Toolbar.txtIntegral": "Integral", "SSE.Controllers.Toolbar.txtIntegral_dtheta": "Differential theta", @@ -2254,7 +2279,7 @@ "SSE.Controllers.Toolbar.txtIntegralTripleCenterSubSup": "Triple integral with stacked limits", "SSE.Controllers.Toolbar.txtIntegralTripleSubSup": "Triple integral with limits", "SSE.Controllers.Toolbar.txtInvalidRange": "ERROR! Invalid cell range", - "SSE.Controllers.Toolbar.txtKeepTextOnly": "Keep text only", + "del_SSE.Controllers.Toolbar.txtKeepTextOnly": "Keep text only", "SSE.Controllers.Toolbar.txtLargeOperator_Conjunction": "Logical And", "SSE.Controllers.Toolbar.txtLargeOperator_Conjunction_CenterSub": "Logical And with lower limit", "SSE.Controllers.Toolbar.txtLargeOperator_Conjunction_CenterSubSup": "Logical And with limits", @@ -2347,25 +2372,25 @@ "SSE.Controllers.Toolbar.txtOperator_MinusEquals": "Minus equal", "SSE.Controllers.Toolbar.txtOperator_PlusEquals": "Plus equal", "SSE.Controllers.Toolbar.txtOperator_UnitOfMeasure": "Measured by", - "SSE.Controllers.Toolbar.txtOther": "Other", - "SSE.Controllers.Toolbar.txtPaste": "Paste", - "SSE.Controllers.Toolbar.txtPasteBorders": "Formula without borders", - "SSE.Controllers.Toolbar.txtPasteColWidths": "Formula + column width", - "SSE.Controllers.Toolbar.txtPasteDestFormat": "Destination formatting", - "SSE.Controllers.Toolbar.txtPasteFormat": "Paste only formatting", - "SSE.Controllers.Toolbar.txtPasteFormulaNumFormat": "Formula + number format", - "SSE.Controllers.Toolbar.txtPasteFormulas": "Paste only formula", - "SSE.Controllers.Toolbar.txtPasteKeepSourceFormat": "Formula + all formatting", - "SSE.Controllers.Toolbar.txtPasteLink": "Paste link", - "SSE.Controllers.Toolbar.txtPasteLinkPicture": "Linked picture", - "SSE.Controllers.Toolbar.txtPasteMerge": "Merge conditional formatting", - "SSE.Controllers.Toolbar.txtPasteNoOptions": "Paste (P)", - "SSE.Controllers.Toolbar.txtPastePicture": "Picture", - "SSE.Controllers.Toolbar.txtPasteSourceFormat": "Source formatting", - "SSE.Controllers.Toolbar.txtPasteTranspose": "Transpose", - "SSE.Controllers.Toolbar.txtPasteValFormat": "Value + all formatting", - "SSE.Controllers.Toolbar.txtPasteValNumFormat": "Value + number format", - "SSE.Controllers.Toolbar.txtPasteValues": "Paste only value", + "del_SSE.Controllers.Toolbar.txtOther": "Other", + "del_SSE.Controllers.Toolbar.txtPaste": "Paste", + "del_SSE.Controllers.Toolbar.txtPasteBorders": "Formula without borders", + "del_SSE.Controllers.Toolbar.txtPasteColWidths": "Formula + column width", + "del_SSE.Controllers.Toolbar.txtPasteDestFormat": "Destination formatting", + "del_SSE.Controllers.Toolbar.txtPasteFormat": "Paste only formatting", + "del_SSE.Controllers.Toolbar.txtPasteFormulaNumFormat": "Formula + number format", + "del_SSE.Controllers.Toolbar.txtPasteFormulas": "Paste only formula", + "del_SSE.Controllers.Toolbar.txtPasteKeepSourceFormat": "Formula + all formatting", + "del_SSE.Controllers.Toolbar.txtPasteLink": "Paste link", + "del_SSE.Controllers.Toolbar.txtPasteLinkPicture": "Linked picture", + "del_SSE.Controllers.Toolbar.txtPasteMerge": "Merge conditional formatting", + "del_SSE.Controllers.Toolbar.txtPasteNoOptions": "Paste (P)", + "del_SSE.Controllers.Toolbar.txtPastePicture": "Picture", + "del_SSE.Controllers.Toolbar.txtPasteSourceFormat": "Source formatting", + "del_SSE.Controllers.Toolbar.txtPasteTranspose": "Transpose", + "del_SSE.Controllers.Toolbar.txtPasteValFormat": "Value + all formatting", + "del_SSE.Controllers.Toolbar.txtPasteValNumFormat": "Value + number format", + "del_SSE.Controllers.Toolbar.txtPasteValues": "Paste only value", "SSE.Controllers.Toolbar.txtRadicalCustom_1": "Right hand side of quadratic formula", "SSE.Controllers.Toolbar.txtRadicalCustom_2": "Square root of a squared plus b squared", "SSE.Controllers.Toolbar.txtRadicalRoot_2": "Square root with degree", @@ -2471,8 +2496,8 @@ "SSE.Controllers.Toolbar.txtTable_TableStyleDark": "Table style Dark", "SSE.Controllers.Toolbar.txtTable_TableStyleLight": "Table style Light", "SSE.Controllers.Toolbar.txtTable_TableStyleMedium": "Table style Medium", - "SSE.Controllers.Toolbar.txtUseTextImport": "Use text import", - "SSE.Controllers.Toolbar.txtValue": "Value", + "del_SSE.Controllers.Toolbar.txtUseTextImport": "Use text import", + "del_SSE.Controllers.Toolbar.txtValue": "Value", "SSE.Controllers.Toolbar.warnLongOperation": "The operation you are about to perform might take rather much time to complete.
Are you sure you want to continue?", "SSE.Controllers.Toolbar.warnMergeLostData": "Only the data from the upper-left cell will remain in the merged cell.
Are you sure you want to continue?", "SSE.Controllers.Toolbar.warnNoRecommended": "To create a chart, select the cells that contain the data you'd like to use.
If you have names for the rows and columns and you'd like use them as labels, include them in your selection.", From 95f2c45d88f7d2ef096353e96e0a535a5a9520d7 Mon Sep 17 00:00:00 2001 From: nikita_bartoshuk Date: Sun, 1 Mar 2026 17:33:46 +0300 Subject: [PATCH 4/5] added saving paste option in context menu --- .../main/app/controller/DocumentHolderExt.js | 20 ++++++++++++++++++- .../main/app/controller/DocumentHolderExt.js | 20 ++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/apps/documenteditor/main/app/controller/DocumentHolderExt.js b/apps/documenteditor/main/app/controller/DocumentHolderExt.js index 6c51d9705a..50c0840e9a 100644 --- a/apps/documenteditor/main/app/controller/DocumentHolderExt.js +++ b/apps/documenteditor/main/app/controller/DocumentHolderExt.js @@ -1426,7 +1426,25 @@ define([], function () { }).on('click', _.bind(me.onSpecialPasteItemClick, me)); menu.addItem(mnu); }); - (menu.items.length>0) && menu.items[0].setChecked(true, true); + var lastSelected = specialPasteShowOptions.asc_getLastSelectedPasteProperty(); + (menu.items.length>0) && !lastSelected && menu.items[0].setChecked(true, true); + + if (lastSelected) { + var foundItem = null; + if (me.btnSpecialPaste && me.btnSpecialPaste.menu && me.btnSpecialPaste.menu.items.length > 0) { + for (var i = 0; i < me.btnSpecialPaste.menu.items.length; i++) { + var menuItem = me.btnSpecialPaste.menu.items[i]; + if (menuItem.value === lastSelected) { + foundItem = menuItem; + break; + } + } + } + + if (foundItem) { + foundItem.setChecked(true, true); + } + } } var showPoint = [coord.asc_getX() + coord.asc_getWidth() + 3, coord.asc_getY() + coord.asc_getHeight() + 3]; diff --git a/apps/presentationeditor/main/app/controller/DocumentHolderExt.js b/apps/presentationeditor/main/app/controller/DocumentHolderExt.js index f5a10b8196..0d3845c49a 100644 --- a/apps/presentationeditor/main/app/controller/DocumentHolderExt.js +++ b/apps/presentationeditor/main/app/controller/DocumentHolderExt.js @@ -1366,7 +1366,25 @@ define([], function () { }).on('click', _.bind(me.onSpecialPasteItemClick, me)); menu.addItem(mnu); }); - (menu.items.length>0) && menu.items[0].setChecked(true, true); + var lastSelected = specialPasteShowOptions.asc_getLastSelectedPasteProperty(); + (menu.items.length>0) && !lastSelected && menu.items[0].setChecked(true, true); + + if (lastSelected) { + var foundItem = null; + if (me.btnSpecialPaste && me.btnSpecialPaste.menu && me.btnSpecialPaste.menu.items.length > 0) { + for (var i = 0; i < me.btnSpecialPaste.menu.items.length; i++) { + var menuItem = me.btnSpecialPaste.menu.items[i]; + if (menuItem.value === lastSelected) { + foundItem = menuItem; + break; + } + } + } + + if (foundItem) { + foundItem.setChecked(true, true); + } + } } if (coord.asc_getX()<0 || coord.asc_getY()<0) { if (pasteContainer.is(':visible')) pasteContainer.hide(); From f3f20fd36e3c3bd8c918cf63aba881ac927cd684 Mon Sep 17 00:00:00 2001 From: nikita_bartoshuk Date: Thu, 5 Mar 2026 13:24:49 +0300 Subject: [PATCH 5/5] removed redundant --- apps/common/main/lib/controller/PasteOptions.js | 4 ---- apps/documenteditor/main/app/controller/DocumentHolderExt.js | 2 -- 2 files changed, 6 deletions(-) diff --git a/apps/common/main/lib/controller/PasteOptions.js b/apps/common/main/lib/controller/PasteOptions.js index c169c01e80..ae29c6ccb3 100644 --- a/apps/common/main/lib/controller/PasteOptions.js +++ b/apps/common/main/lib/controller/PasteOptions.js @@ -75,7 +75,6 @@ define([ }, onBtnPasteOptionsClick: function (btn, api, isSSE) { - console.log('onBtnPasteOptionsClick') this.api = api; this.btn = btn; this.isSSE = isSSE; @@ -94,7 +93,6 @@ define([ }, handlePasteOptions: function(options) { - console.log('handlePasteOptions') var me = this; if (options === null) { @@ -107,14 +105,12 @@ define([ menu.addItem(mnu) menu.show(); - console.log('options === null') return } var pasteItems = options.asc_getOptions(), isTable = !!options.asc_getContainTables(); - console.log(pasteItems, 'Paste items') if (!pasteItems) return; me._arrSpecialPaste = []; diff --git a/apps/documenteditor/main/app/controller/DocumentHolderExt.js b/apps/documenteditor/main/app/controller/DocumentHolderExt.js index 50c0840e9a..ece88e07f2 100644 --- a/apps/documenteditor/main/app/controller/DocumentHolderExt.js +++ b/apps/documenteditor/main/app/controller/DocumentHolderExt.js @@ -1372,7 +1372,6 @@ define([], function () { dh.onShowSpecialPasteOptions = function(specialPasteShowOptions) { if (this.mode && !this.mode.isEdit) return; - console.log(this.api.asc_getPasteOptions) var me = this, documentHolder = me.documentHolder; @@ -1380,7 +1379,6 @@ define([], function () { pasteContainer = documentHolder.cmpEl.find('#special-paste-container'), pasteItems = specialPasteShowOptions.asc_getOptions(); if (!pasteItems) return; - console.log(pasteItems, 'Paste items') // Prepare menu container if (pasteContainer.length < 1) {