From ec328dd48ed0092595b9f71706a0ec8c85b7b899 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 15 Jun 2022 17:35:51 +0300 Subject: [PATCH 1/3] [SSE] Get link to cell's range from context menu --- apps/api/documents/api.js | 4 +-- .../main/app/controller/DocumentHolder.js | 34 +++++++++++++++++++ .../main/app/view/DocumentHolder.js | 20 +++++++++-- 3 files changed, 54 insertions(+), 4 deletions(-) diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index 19d552bea..c12dd3d17 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -1006,8 +1006,8 @@ iframe.allowFullscreen = true; iframe.setAttribute("allowfullscreen",""); // for IE11 iframe.setAttribute("onmousewheel",""); // for Safari on Mac - iframe.setAttribute("allow", "autoplay; camera; microphone; display-capture"); - + iframe.setAttribute("allow", "autoplay; camera; microphone; display-capture; clipboard-write;"); + if (config.type == "mobile") { iframe.style.position = "fixed"; diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 672e45836..1bbe801e4 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -184,6 +184,7 @@ define([ 'protect:wslock': _.bind(me.onChangeProtectSheet, me) }); Common.Gateway.on('processmouse', _.bind(me.onProcessMouse, me)); + Common.Gateway.on('setactionlink', _.bind(me.onSetActionLink, me)); }, onCreateDelayedElements: function(view) { @@ -260,6 +261,7 @@ define([ view.tableTotalMenu.on('item:click', _.bind(me.onTotalMenuClick, me)); view.menuImgMacro.on('click', _.bind(me.onImgMacro, me)); view.menuImgEditPoints.on('click', _.bind(me.onImgEditPoints, me)); + view.pmiGetRangeList.on('click', _.bind(me.onGetLink, me)); if (!me.permissions.isEditMailMerge && !me.permissions.isEditDiagram && !me.permissions.isEditOle) { var oleEditor = me.getApplication().getController('Common.Controllers.ExternalOleEditor').getView('Common.Views.ExternalOleEditor'); @@ -1157,6 +1159,30 @@ define([ this.api && this.api.asc_editPointsGeometry(); }, + onGetLink: function(item) { + if (this.api) { + var range = this.api.asc_getActiveRangeStr(Asc.referenceType.A, false, true), + name = this.api.asc_getEscapeSheetName(this.api.asc_getWorksheetName(this.api.asc_getActiveWorksheetIndex())); + name = (name + ((name!=='' && range!=='') ? '!' : '') + range); + name && Common.Gateway.requestMakeActionLink({ + action: { + type: "internallink", data: name + } + }); + } + }, + + onSetActionLink: function (url) { + var me = this; + navigator.clipboard && navigator.clipboard.writeText(url) + .then(function() { + console.log('OK'); + }) + .catch(function(err) { + console.log(err); + }); + }, + onApiCoAuthoringDisconnect: function() { this.permissions.isEdit = false; }, @@ -2309,6 +2335,8 @@ define([ documentHolder.pmiAdvancedNumFormat.options.numformatinfo = documentHolder.pmiNumFormat.menu.options.numformatinfo = xfs.asc_getNumFormatInfo(); documentHolder.pmiAdvancedNumFormat.options.numformat = xfs.asc_getNumFormat(); + documentHolder.pmiGetRangeList.setVisible(!Common.Utils.isIE && iscellmenu && !iscelledit && !ismultiselect && !internaleditor && this.permissions.canMakeActionLink && !!navigator.clipboard); + _.each(documentHolder.ssMenu.items, function(item) { item.setDisabled(isCellLocked); }); @@ -2338,6 +2366,7 @@ define([ documentHolder.pmiEntriesList.setDisabled(isCellLocked || this._state.wsLock); documentHolder.pmiAddNamedRange.setDisabled(isCellLocked || this._state.wsLock); documentHolder.pmiAddComment.setDisabled(isCellLocked || this._state.wsProps['Objects']); + documentHolder.pmiGetRangeList.setDisabled(false); if (inPivot) { var canGroup = this.api.asc_canGroupPivot(); @@ -2346,6 +2375,11 @@ define([ } if (showMenu) this.showPopupMenu(documentHolder.ssMenu, {}, event); + + documentHolder.pmiFunctionSeparator.setVisible(documentHolder.pmiInsFunction.isVisible() || documentHolder.menuAddHyperlink.isVisible() || documentHolder.menuHyperlink.isVisible() || + isrowmenu || iscolmenu || isallmenu); + documentHolder.pmiFreezeSeparator.setVisible(documentHolder.pmiFreezePanes.isVisible()); + } else if (this.permissions.isEditDiagram && seltype == Asc.c_oAscSelectionType.RangeChartText) { if (!showMenu && !documentHolder.textInShapeMenu.isVisible()) return; diff --git a/apps/spreadsheeteditor/main/app/view/DocumentHolder.js b/apps/spreadsheeteditor/main/app/view/DocumentHolder.js index bcf77715e..1cb8e067e 100644 --- a/apps/spreadsheeteditor/main/app/view/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/view/DocumentHolder.js @@ -418,6 +418,14 @@ define([ me.pmiCellMenuSeparator = new Common.UI.MenuItem({ caption : '--' + }) + + me.pmiFunctionSeparator = new Common.UI.MenuItem({ + caption : '--' + }); + + me.pmiFreezeSeparator = new Common.UI.MenuItem({ + caption : '--' }); me.pmiAddNamedRange = new Common.UI.MenuItem({ @@ -549,7 +557,11 @@ define([ me.pmiCondFormat = new Common.UI.MenuItem({ caption : me.txtCondFormat }); - + + me.pmiGetRangeList = new Common.UI.MenuItem({ + caption : me.txtGetLink + }); + me.ssMenu = new Common.UI.Menu({ cls: 'shifted-right', restoreHeightAndTop: true, @@ -580,7 +592,9 @@ define([ me.pmiNumFormat, me.pmiCondFormat, me.pmiEntriesList, + me.pmiGetRangeList, me.pmiAddNamedRange, + me.pmiFunctionSeparator, me.pmiInsFunction, me.menuAddHyperlink, me.menuHyperlink, @@ -588,6 +602,7 @@ define([ me.pmiColumnWidth, me.pmiEntireHide, me.pmiEntireShow, + me.pmiFreezeSeparator, me.pmiFreezePanes ] }); @@ -1303,7 +1318,8 @@ define([ tipMarkersFRhombus: 'Filled rhombus bullets', tipMarkersDash: 'Dash bullets', chartDataText: 'Select Chart Data', - chartTypeText: 'Change Chart Type' + chartTypeText: 'Change Chart Type', + txtGetLink: 'Get link to this range' }, SSE.Views.DocumentHolder || {})); }); \ No newline at end of file From 75d6ab646f3eec2d0009f6341273de310387df76 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 15 Jun 2022 20:56:13 +0300 Subject: [PATCH 2/3] [SSE] Refactoring set action link event --- .../main/app/controller/DocumentHolder.js | 3 +++ .../main/app/view/HyperlinkSettingsDialog.js | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 1bbe801e4..b0ab95032 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -1173,6 +1173,9 @@ define([ }, onSetActionLink: function (url) { + if (Common.Utils.InternalSettings.get("sse-dialog-link-visible")) + return; + var me = this; navigator.clipboard && navigator.clipboard.writeText(url) .then(function() { diff --git a/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js b/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js index 3373a71d2..f9a263282 100644 --- a/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js +++ b/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js @@ -258,6 +258,16 @@ define([ return [this.inputUrl, this.internalList, this.inputRange, this.inputDisplay, this.inputTip]; }, + show: function() { + Common.UI.Window.prototype.show.apply(this, arguments); + Common.Utils.InternalSettings.set("sse-dialog-link-visible", true); + }, + + close: function() { + Common.Utils.InternalSettings.set("sse-dialog-link-visible", false); + Common.UI.Window.prototype.close.apply(this, arguments); + }, + setSettings: function(settings) { if (settings) { var me = this; From a86fe8a7f660f9ad6b03bcbdba623ae166f1ff44 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 15 Jun 2022 22:09:53 +0300 Subject: [PATCH 3/3] Refactoring show external message. [SSE] Show tip when link is copies --- apps/common/main/lib/component/Tooltip.js | 6 ++- .../main/lib/controller/ReviewChanges.js | 38 +------------------ .../main/app/controller/Main.js | 31 +++++++++------ .../main/app/controller/Main.js | 2 +- .../main/app/controller/DocumentHolder.js | 5 ++- .../main/app/controller/Main.js | 31 +++++++++------ apps/spreadsheeteditor/main/locale/en.json | 2 + 7 files changed, 53 insertions(+), 62 deletions(-) diff --git a/apps/common/main/lib/component/Tooltip.js b/apps/common/main/lib/component/Tooltip.js index 83d8f9c84..5d3a123dd 100644 --- a/apps/common/main/lib/component/Tooltip.js +++ b/apps/common/main/lib/component/Tooltip.js @@ -109,8 +109,12 @@ }); if (opts.hideonclick) { + var me = this; var tip = this.$element.data('bs.tooltip'); - if (tip) tip.tip().on('click', function() {tip.hide();}); + if (tip) tip.tip().on('click', function() { + tip.hide(); + me.trigger('tooltip:hideonclick', this); + }); } this.$element.on('shown.bs.tooltip', _.bind(this.onTipShown, this)); diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index 64386ade3..8597fd11e 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -613,7 +613,8 @@ define([ this.view.turnChanges(state, global); if (userId && this.userCollection) { var rec = this.userCollection.findOriginalUser(userId); - rec && this.showTips(Common.Utils.String.format(globalFlag ? this.textOnGlobal : this.textOffGlobal, AscCommon.UserInfoParser.getParsedName(rec.get('username')))); + rec && Common.NotificationCenter.trigger('showmessage', {msg: Common.Utils.String.format(globalFlag ? this.textOnGlobal : this.textOffGlobal, AscCommon.UserInfoParser.getParsedName(rec.get('username')))}, + {timeout: 5000, hideCloseTip: true}); } } }, @@ -903,41 +904,6 @@ define([ me.appConfig.reviewHoverMode = val; }, - showTips: function(strings) { - var me = this; - if (!strings.length) return; - if (typeof(strings)!='object') strings = [strings]; - - function showNextTip() { - var str_tip = strings.shift(); - if (str_tip) { - me.tooltip.setTitle(str_tip); - me.tooltip.show(); - me.tipTimeout = setTimeout(function () { - me.tooltip.hide(); - }, 5000); - } - } - - if (!this.tooltip) { - this.tooltip = new Common.UI.Tooltip({ - owner: this.getApplication().getController('Toolbar').getView(), - hideonclick: true, - placement: 'bottom', - cls: 'main-info', - offset: 30 - }); - this.tooltip.on('tooltip:hide', function(cmp){ - if (cmp==me.tooltip) { - clearTimeout(me.tipTimeout); - setTimeout(showNextTip, 300); - } - }); - } - - showNextTip(); - }, - applySettings: function(menu) { this.view && this.view.turnSpelling( Common.localStorage.getBool(this.view.appPrefix + "settings-spellcheck", true) ); this.view && this.view.turnCoAuthMode( Common.localStorage.getBool(this.view.appPrefix + "settings-coauthmode", true) ); diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 6515c7024..392e100bf 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1752,10 +1752,10 @@ define([ } }, - onExternalMessage: function(msg) { + onExternalMessage: function(msg, options) { if (msg && msg.msg) { msg.msg = (msg.msg).toString(); - this.showTips([msg.msg.charAt(0).toUpperCase() + msg.msg.substring(1)]); + this.showTips([msg.msg.charAt(0).toUpperCase() + msg.msg.substring(1)], options); Common.component.Analytics.trackEvent('External Error'); } @@ -2043,17 +2043,30 @@ define([ this._state.isDisconnected = true; }, - showTips: function(strings) { + showTips: function(strings, options) { var me = this; if (!strings.length) return; if (typeof(strings)!='object') strings = [strings]; + function closeTip(cmp){ + me.tipTimeout && clearTimeout(me.tipTimeout); + setTimeout(showNextTip, 300); + } + function showNextTip() { var str_tip = strings.shift(); if (str_tip) { - str_tip += '\n' + me.textCloseTip; - tooltip.setTitle(str_tip); - tooltip.show(); + if (!(options && options.hideCloseTip)) + str_tip += '\n' + me.textCloseTip; + me.tooltip.setTitle(str_tip); + me.tooltip.show(); + me.tipTimeout && clearTimeout(me.tipTimeout); + if (options && options.timeout) { + me.tipTimeout = setTimeout(function () { + me.tooltip.hide(); + closeTip(); + }, options.timeout); + } } } @@ -2065,13 +2078,9 @@ define([ cls: 'main-info', offset: 30 }); + this.tooltip.on('tooltip:hideonclick',closeTip); } - var tooltip = this.tooltip; - tooltip.on('tooltip:hide', function(){ - setTimeout(showNextTip, 300); - }); - showNextTip(); }, diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 10b7f09e3..645b319e6 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -1667,7 +1667,7 @@ define([ } var tooltip = this.tooltip; - tooltip.on('tooltip:hide', function(){ + tooltip.on('tooltip:hideonclick', function(){ setTimeout(showNextTip, 300); }); diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index b0ab95032..be63a942a 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -1179,7 +1179,7 @@ define([ var me = this; navigator.clipboard && navigator.clipboard.writeText(url) .then(function() { - console.log('OK'); + Common.NotificationCenter.trigger('showmessage', {msg: me.txtCopySuccess}, {timeout: 3000, hideCloseTip: true}); }) .catch(function(err) { console.log(err); @@ -4382,7 +4382,8 @@ define([ txtAllTableHint: 'Returns the entire contents of the table or specified table columns including column headers, data and total rows', txtDataTableHint: 'Returns the data cells of the table or specified table columns', txtHeadersTableHint: 'Returns the column headers for the table or specified table columns', - txtTotalsTableHint: 'Returns the total rows for the table or specified table columns' + txtTotalsTableHint: 'Returns the total rows for the table or specified table columns', + txtCopySuccess: 'Link copied to the clipboard' }, SSE.Controllers.DocumentHolder || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 275aa3f6c..f132fa985 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1523,10 +1523,10 @@ define([ } }, - onExternalMessage: function(msg) { + onExternalMessage: function(msg, options) { if (msg && msg.msg) { msg.msg = (msg.msg).toString(); - this.showTips([msg.msg.charAt(0).toUpperCase() + msg.msg.substring(1)]); + this.showTips([msg.msg.charAt(0).toUpperCase() + msg.msg.substring(1)], options); Common.component.Analytics.trackEvent('External Error'); } @@ -2009,17 +2009,30 @@ define([ this._state.isDisconnected = true; }, - showTips: function(strings) { + showTips: function(strings, options) { var me = this; if (!strings.length) return; if (typeof(strings)!='object') strings = [strings]; + function closeTip(cmp){ + me.tipTimeout && clearTimeout(me.tipTimeout); + setTimeout(showNextTip, 300); + } + function showNextTip() { var str_tip = strings.shift(); if (str_tip) { - str_tip += '\n' + me.textCloseTip; - tooltip.setTitle(str_tip); - tooltip.show(); + if (!(options && options.hideCloseTip)) + str_tip += '\n' + me.textCloseTip; + me.tooltip.setTitle(str_tip); + me.tooltip.show(); + me.tipTimeout && clearTimeout(me.tipTimeout); + if (options && options.timeout) { + me.tipTimeout = setTimeout(function () { + me.tooltip.hide(); + closeTip(); + }, options.timeout); + } } } @@ -2031,13 +2044,9 @@ define([ cls: 'main-info', offset: 30 }); + this.tooltip.on('tooltip:hideonclick',closeTip); } - var tooltip = this.tooltip; - tooltip.on('tooltip:hide', function(){ - setTimeout(showNextTip, 300); - }); - showNextTip(); }, diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index da990f93b..b02d7d009 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -645,6 +645,7 @@ "SSE.Controllers.DocumentHolder.txtUseTextImport": "Use text import wizard", "SSE.Controllers.DocumentHolder.txtWarnUrl": "Clicking this link can be harmful to your device and data.
Are you sure you want to continue?", "SSE.Controllers.DocumentHolder.txtWidth": "Width", + "SSE.Controllers.DocumentHolder.txtCopySuccess": "Link copied to the clipboard", "SSE.Controllers.FormulaDialog.sCategoryAll": "All", "SSE.Controllers.FormulaDialog.sCategoryCube": "Cube", "SSE.Controllers.FormulaDialog.sCategoryDatabase": "Database", @@ -2051,6 +2052,7 @@ "SSE.Views.DocumentHolder.txtUngroup": "Ungroup", "SSE.Views.DocumentHolder.txtWidth": "Width", "SSE.Views.DocumentHolder.vertAlignText": "Vertical Alignment", + "SSE.Views.DocumentHolder.txtGetLink": "Get link to this range", "SSE.Views.FieldSettingsDialog.strLayout": "Layout", "SSE.Views.FieldSettingsDialog.strSubtotals": "Subtotals", "SSE.Views.FieldSettingsDialog.textReport": "Report Form",