From 793f350a071e991aa822665f58a18955a3d3ac13 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 29 Jun 2022 12:37:51 +0300 Subject: [PATCH 1/4] [DE] Add cut and select all buttons to the toolbar --- .../main/app/controller/Toolbar.js | 22 ++++++++++---- .../main/app/template/Toolbar.template | 8 +++++ apps/documenteditor/main/app/view/Toolbar.js | 29 ++++++++++++++++++- apps/documenteditor/main/index.html | 16 ++++++++-- apps/documenteditor/main/index.html.deploy | 14 +++++++-- apps/documenteditor/main/locale/en.json | 2 ++ 6 files changed, 79 insertions(+), 12 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 0dff9909e..7c40e248d 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -268,8 +268,10 @@ define([ toolbar.btnUndo.on('disabled', _.bind(this.onBtnChangeState, this, 'undo:disabled')); toolbar.btnRedo.on('click', _.bind(this.onRedo, this)); toolbar.btnRedo.on('disabled', _.bind(this.onBtnChangeState, this, 'redo:disabled')); - toolbar.btnCopy.on('click', _.bind(this.onCopyPaste, this, true)); - toolbar.btnPaste.on('click', _.bind(this.onCopyPaste, this, false)); + toolbar.btnCopy.on('click', _.bind(this.onCopyPaste, this, 'copy')); + toolbar.btnPaste.on('click', _.bind(this.onCopyPaste, this, 'paste')); + toolbar.btnCut.on('click', _.bind(this.onCopyPaste, this, 'cut')); + toolbar.btnSelectAll.on('click', _.bind(this.onSelectAll, this)); toolbar.btnIncFontSize.on('click', _.bind(this.onIncrease, this)); toolbar.btnDecFontSize.on('click', _.bind(this.onDecrease, this)); toolbar.mnuChangeCase.on('item:click', _.bind(this.onChangeCase, this)); @@ -515,7 +517,7 @@ define([ onApiCanCopyCut: function(can) { if (this._state.can_copycut !== can) { - this.toolbar.lockToolbar(Common.enumLock.copyLock, !can, {array: [this.toolbar.btnCopy]}); + this.toolbar.lockToolbar(Common.enumLock.copyLock, !can, {array: [this.toolbar.btnCopy, this.toolbar.btnCut]}); this._state.can_copycut = can; } }, @@ -1101,10 +1103,10 @@ define([ Common.component.Analytics.trackEvent('ToolBar', 'Redo'); }, - onCopyPaste: function(copy, e) { + onCopyPaste: function(type, e) { var me = this; if (me.api) { - var res = (copy) ? me.api.Copy() : me.api.Paste(); + var res = (type === 'cut') ? me.api.Cut() : ((type === 'copy') ? me.api.Copy() : me.api.Paste()); if (!res) { if (!Common.localStorage.getBool("de-hide-copywarning")) { (new Common.Views.CopyWarningDialog({ @@ -1120,6 +1122,14 @@ define([ Common.NotificationCenter.trigger('edit:complete', me.toolbar); }, + onSelectAll: function(e) { + if (this.api) + this.api.asc_EditSelectAll(); + + Common.NotificationCenter.trigger('edit:complete', this.toolbar); + Common.component.Analytics.trackEvent('ToolBar', 'Select All'); + }, + onIncrease: function(e) { if (this.api) this.api.FontSizeIn(); @@ -2883,7 +2893,7 @@ define([ this.toolbar.lockToolbar(Common.enumLock.disableOnStart, false); this.toolbar.lockToolbar(Common.enumLock.undoLock, this._state.can_undo!==true, {array: [this.toolbar.btnUndo]}); this.toolbar.lockToolbar(Common.enumLock.redoLock, this._state.can_redo!==true, {array: [this.toolbar.btnRedo]}); - this.toolbar.lockToolbar(Common.enumLock.copyLock, this._state.can_copycut!==true, {array: [this.toolbar.btnCopy]}); + this.toolbar.lockToolbar(Common.enumLock.copyLock, this._state.can_copycut!==true, {array: [this.toolbar.btnCopy, this.toolbar.btnCut]}); this.toolbar.lockToolbar(Common.enumLock.mmergeLock, !!this._state.mmdisable, {array: [this.toolbar.btnMailRecepients]}); if (!this._state.mmdisable) { this.toolbar.mnuMailRecepients.items[2].setVisible(this.toolbar.mode.fileChoiceUrl || this.toolbar.mode.canRequestMailMergeRecipients); diff --git a/apps/documenteditor/main/app/template/Toolbar.template b/apps/documenteditor/main/app/template/Toolbar.template index 74b46dfcc..593bd1710 100644 --- a/apps/documenteditor/main/app/template/Toolbar.template +++ b/apps/documenteditor/main/app/template/Toolbar.template @@ -25,6 +25,14 @@ +
+
+ +
+
+ +
+
diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index 843c688f9..4d543ef61 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -255,6 +255,27 @@ define([ }); this.paragraphControls.push(this.btnPaste); + this.btnCut = new Common.UI.Button({ + id: 'id-toolbar-btn-cut', + cls: 'btn-toolbar', + iconCls: 'toolbar__icon btn-cut', + lock: [_set.copyLock, _set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.previewReviewMode, _set.viewFormMode, _set.lostConnect, _set.disableOnStart], + dataHint: '1', + dataHintDirection: 'top', + dataHintTitle: 'X' + }); + this.paragraphControls.push(this.btnCut); + + this.btnSelectAll = new Common.UI.Button({ + id: 'id-toolbar-btn-select-all', + cls: 'btn-toolbar', + iconCls: 'toolbar__icon select-all', + lock: [_set.viewFormMode, _set.disableOnStart], + dataHint: '1', + dataHintDirection: 'bottom' + }); + this.toolbarControls.push(this.btnSelectAll); + this.btnIncFontSize = new Common.UI.Button({ id: 'id-toolbar-btn-incfont', cls: 'btn-toolbar', @@ -1652,6 +1673,8 @@ define([ _injectComponent('#slot-btn-redo', this.btnRedo); _injectComponent('#slot-btn-copy', this.btnCopy); _injectComponent('#slot-btn-paste', this.btnPaste); + _injectComponent('#slot-btn-cut', this.btnCut); + _injectComponent('#slot-btn-select-all', this.btnSelectAll); _injectComponent('#slot-btn-incfont', this.btnIncFontSize); _injectComponent('#slot-btn-decfont', this.btnDecFontSize); _injectComponent('#slot-btn-bold', this.btnBold); @@ -1952,6 +1975,8 @@ define([ this.btnRedo.updateHint(this.tipRedo + Common.Utils.String.platformKey('Ctrl+Y')); this.btnCopy.updateHint(this.tipCopy + Common.Utils.String.platformKey('Ctrl+C')); this.btnPaste.updateHint(this.tipPaste + Common.Utils.String.platformKey('Ctrl+V')); + this.btnCut.updateHint(this.tipCut + Common.Utils.String.platformKey('Ctrl+X')); + this.btnSelectAll.updateHint(this.tipSelectAll + Common.Utils.String.platformKey('Ctrl+A')); this.btnIncFontSize.updateHint(this.tipIncFont + Common.Utils.String.platformKey('Ctrl+]')); this.btnDecFontSize.updateHint(this.tipDecFont + Common.Utils.String.platformKey('Ctrl+[')); this.btnBold.updateHint(this.textBold + Common.Utils.String.platformKey('Ctrl+B')); @@ -2837,7 +2862,9 @@ define([ textTabView: 'View', mniRemoveHeader: 'Remove Header', mniRemoveFooter: 'Remove Footer', - mniInsertSSE: 'Insert Spreadsheet' + mniInsertSSE: 'Insert Spreadsheet', + tipSelectAll: 'Select all', + tipCut: 'Cut' } })(), DE.Views.Toolbar || {})); }); diff --git a/apps/documenteditor/main/index.html b/apps/documenteditor/main/index.html index d5d34d2b4..6b57c5161 100644 --- a/apps/documenteditor/main/index.html +++ b/apps/documenteditor/main/index.html @@ -139,7 +139,7 @@ right: 0; top: 0; bottom: 0; - left: 525px; + left: 587px; width: inherit; height: 44px; } @@ -272,8 +272,8 @@