diff --git a/apps/documenteditor/mobile/src/controller/ContextMenu.jsx b/apps/documenteditor/mobile/src/controller/ContextMenu.jsx index a569c98dd..4955f7372 100644 --- a/apps/documenteditor/mobile/src/controller/ContextMenu.jsx +++ b/apps/documenteditor/mobile/src/controller/ContextMenu.jsx @@ -1,15 +1,15 @@ -import React, { useContext } from 'react'; -import { f7 } from 'framework7-react'; +import React, { useContext } from "react"; +import { f7 } from "framework7-react"; import { inject, observer } from "mobx-react"; -import { withTranslation} from 'react-i18next'; -import { LocalStorage } from '../../../../common/mobile/utils/LocalStorage'; +import { withTranslation } from "react-i18next"; +import { LocalStorage } from "../../../../common/mobile/utils/LocalStorage"; -import ContextMenuController from '../../../../common/mobile/lib/controller/ContextMenu'; -import { idContextMenuElement } from '../../../../common/mobile/lib/view/ContextMenu'; -import { Device } from '../../../../common/mobile/utils/device'; -import EditorUIController from '../lib/patch'; +import ContextMenuController from "../../../../common/mobile/lib/controller/ContextMenu"; +import { idContextMenuElement } from "../../../../common/mobile/lib/view/ContextMenu"; +import { Device } from "../../../../common/mobile/utils/device"; +import EditorUIController from "../lib/patch"; -@inject ( stores => ({ +@inject((stores) => ({ isEdit: stores.storeAppOptions.isEdit, canComments: stores.storeAppOptions.canComments, canViewComments: stores.storeAppOptions.canViewComments, @@ -19,7 +19,7 @@ import EditorUIController from '../lib/patch'; users: stores.users, isDisconnected: stores.users.isDisconnected, displayMode: stores.storeReview.displayMode, - dataDoc: stores.storeDocumentInfo.dataDoc + dataDoc: stores.storeDocumentInfo.dataDoc, })) class ContextMenu extends ContextMenuController { constructor(props) { @@ -45,23 +45,30 @@ class ContextMenu extends ContextMenuController { isUserVisible(id) { const user = this.props.users.searchUserByCurrentId(id); - return user ? (user.asc_getIdOriginal()===this.props.users.currentUser.asc_getIdOriginal() || AscCommon.UserInfoParser.isUserVisible(user.asc_getUserName())) : true; + return user + ? user.asc_getIdOriginal() === + this.props.users.currentUser.asc_getIdOriginal() || + AscCommon.UserInfoParser.isUserVisible(user.asc_getUserName()) + : true; } componentWillUnmount() { super.componentWillUnmount(); const api = Common.EditorApi.get(); - api.asc_unregisterCallback('asc_onShowComment', this.onApiShowComment); - api.asc_unregisterCallback('asc_onHideComment', this.onApiHideComment); - api.asc_unregisterCallback('asc_onShowRevisionsChange', this.onApiShowChange); - Common.Notifications.off('showSplitModal', this.ShowModal); + api.asc_unregisterCallback("asc_onShowComment", this.onApiShowComment); + api.asc_unregisterCallback("asc_onHideComment", this.onApiHideComment); + api.asc_unregisterCallback( + "asc_onShowRevisionsChange", + this.onApiShowChange + ); + Common.Notifications.off("showSplitModal", this.ShowModal); } ShowModal() { - this.showSplitModal() + this.showSplitModal(); } - + onApiShowComment(comments) { this.isComments = comments && comments.length > 0; } @@ -71,7 +78,7 @@ class ContextMenu extends ContextMenuController { } onApiShowChange(sdkchange, isShow) { - this.inRevisionChange = isShow && sdkchange && sdkchange.length>0; + this.inRevisionChange = isShow && sdkchange && sdkchange.length > 0; } // onMenuClosed() { @@ -81,44 +88,53 @@ class ContextMenu extends ContextMenuController { onMenuItemClick(action) { super.onMenuItemClick(action); - if ( EditorUIController.ContextMenu && EditorUIController.ContextMenu.handleMenuItemClick(this, action) ) + if ( + EditorUIController.ContextMenu && + EditorUIController.ContextMenu.handleMenuItemClick(this, action) + ) return; const api = Common.EditorApi.get(); switch (action) { - case 'cut': - if ( !LocalStorage.getBool("de-hide-copy-cut-paste-warning") ) + case "cut": + if (!LocalStorage.getBool("de-hide-copy-cut-paste-warning")) this.showCopyCutPasteModal(); break; - case 'copy': - if (!api.Copy() && !LocalStorage.getBool("de-hide-copy-cut-paste-warning") ) + case "copy": + 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") ) + case "paste": + if (!LocalStorage.getBool("de-hide-copy-cut-paste-warning")) this.showCopyCutPasteModal(); break; - case 'viewcomment': - Common.Notifications.trigger('viewcomment'); + case "viewcomment": + Common.Notifications.trigger("viewcomment"); break; - case 'openlink': + case "openlink": const stack = api.getSelectedElements(); let value; stack.forEach((item) => { - if (item.get_ObjectType() == Asc.c_oAscTypeSelectElement.Hyperlink) { + if ( + item.get_ObjectType() == + Asc.c_oAscTypeSelectElement.Hyperlink + ) { value = item.get_ObjectValue().get_Value(); } }); value && this.openLink(value); break; - case 'review': + case "review": setTimeout(() => { - this.props.openOptions('coauth', 'cm-review'); + this.props.openOptions("coauth", "cm-review"); }, 400); break; - case 'reviewchange': + case "reviewchange": setTimeout(() => { - this.props.openOptions('coauth', 'cm-review-change'); + this.props.openOptions("coauth", "cm-review-change"); }, 400); break; } @@ -127,81 +143,97 @@ class ContextMenu extends ContextMenuController { showCopyCutPasteModal() { const { t } = this.props; const _t = t("ContextMenu", { returnObjects: true }); - f7.dialog.create({ - title: _t.textCopyCutPasteActions, - text: _t.errorCopyCutPaste, - content: `