[SSE] Get link to cell's range from context menu

This commit is contained in:
Julia Radzhabova 2022-06-15 17:35:51 +03:00
parent 57a17401bf
commit ec328dd48e
3 changed files with 54 additions and 4 deletions

View file

@ -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";

View file

@ -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;

View file

@ -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 || {}));
});