From c49fc13b80f3b8b4c38cd0f4b7112c6f68a4842e Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Thu, 15 Apr 2021 15:42:51 +0300 Subject: [PATCH] [DE mobile] Fix show context menu items for view mode --- .../mobile/src/controller/ContextMenu.jsx | 78 ++++++++++++++----- 1 file changed, 60 insertions(+), 18 deletions(-) diff --git a/apps/documenteditor/mobile/src/controller/ContextMenu.jsx b/apps/documenteditor/mobile/src/controller/ContextMenu.jsx index aedb54c99..978afa679 100644 --- a/apps/documenteditor/mobile/src/controller/ContextMenu.jsx +++ b/apps/documenteditor/mobile/src/controller/ContextMenu.jsx @@ -73,17 +73,27 @@ class ContextMenu extends ContextMenuController { case 'cut': if ( !LocalStorage.getBool("de-hide-copy-cut-paste-warning") ) this.showCopyCutPasteModal(); - break; case 'copy': - if ( !LocalStorage.getBool("de-hide-copy-cut-paste-warning") ) + if (!api.Copy() && !LocalStorage.getBool("de-hide-copy-cut-paste-warning") ) this.showCopyCutPasteModal(); - break; case 'paste': if ( !LocalStorage.getBool("de-hide-copy-cut-paste-warning") ) this.showCopyCutPasteModal(); - + break; + case 'viewcomment': + Common.Notifications.trigger('viewcomment'); + break; + case 'openlink': + const stack = api.getSelectedElements(); + let value; + stack.forEach((item) => { + if (item.get_ObjectType() == Asc.c_oAscTypeSelectElement.Hyperlink) { + value = item.get_ObjectValue().get_Value(); + } + }); + value && this.openLink(value); break; case 'review': setTimeout(() => { @@ -95,19 +105,6 @@ class ContextMenu extends ContextMenuController { this.props.openOptions('coauth', 'cm-review-change'); }, 400); break; - case 'split': - this.showSplitModal(); - break; - case 'edit': - setTimeout(() => { - this.props.openOptions('edit'); - }, 0); - break; - case 'addlink': - setTimeout(() => { - this.props.openOptions('add', 'link'); - }, 400); - break; } console.log("click context menu item: " + action); @@ -206,8 +203,53 @@ class ContextMenu extends ContextMenuController { initMenuItems() { if ( !Common.EditorApi ) return []; + const { isEdit } = this.props; - return EditorUIController.ContextMenu.mapMenuItems(this); + if (isEdit) { + return EditorUIController.ContextMenu.mapMenuItems(this); + } else { + const { t } = this.props; + const _t = t("ContextMenu", {returnObjects: true}); + const { canViewComments } = this.props; + + const api = Common.EditorApi.get(); + const stack = api.getSelectedElements(); + const canCopy = api.can_CopyCut(); + + let itemsIcon = [], + itemsText = []; + + if ( canCopy ) { + itemsIcon.push({ + event: 'copy', + icon: 'icon-copy' + }); + } + + if ( canViewComments && this.isComments ) { + itemsText.push({ + caption: _t.menuViewComment, + event: 'viewcomment' + }); + } + + let isLink = false; + stack.forEach(item => { + const objectType = item.get_ObjectType(); + if ( objectType === Asc.c_oAscTypeSelectElement.Hyperlink ) { + isLink = true; + } + }); + + if ( isLink ) { + itemsText.push({ + caption: _t.menuOpenLink, + event: 'openlink' + }); + } + + return itemsIcon.concat(itemsText); + } } initExtraItems () {