Merge pull request #953 from ONLYOFFICE/fix/fix-bugs-on-mobiles

[mobile] Fix bug 47933, fix context menu in comment mode
This commit is contained in:
maxkadushkin 2021-06-29 23:24:49 +03:00 committed by GitHub
commit 18dfe1500e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 17 deletions

View file

@ -11,7 +11,9 @@ import EditorUIController from '../lib/patch';
@inject ( stores => ({
isEdit: stores.storeAppOptions.isEdit,
canComments: stores.storeAppOptions.canComments,
canViewComments: stores.storeAppOptions.canViewComments,
canCoAuthoring: stores.storeAppOptions.canCoAuthoring,
canReview: stores.storeAppOptions.canReview,
users: stores.users,
isDisconnected: stores.users.isDisconnected
@ -216,12 +218,35 @@ class ContextMenu extends ContextMenuController {
} else {
const { t } = this.props;
const _t = t("ContextMenu", {returnObjects: true});
const { canViewComments } = this.props;
const { canViewComments, canCoAuthoring, canComments } = this.props;
const api = Common.EditorApi.get();
const stack = api.getSelectedElements();
const canCopy = api.can_CopyCut();
let isText = false,
isObject = false,
isLink = false,
locked = false;
stack.forEach(item => {
const objectType = item.get_ObjectType(),
objectValue = item.get_ObjectValue();
if ( objectType == Asc.c_oAscTypeSelectElement.Header ) {
locked = objectValue.get_Locked();
} else
if ( objectType == Asc.c_oAscTypeSelectElement.Paragraph ) {
locked = objectValue.get_Locked();
isText = true;
} else
if ( objectType == Asc.c_oAscTypeSelectElement.Image || objectType == Asc.c_oAscTypeSelectElement.Table) {
locked = objectValue.get_Locked();
isObject = true;
} else if ( objectType == Asc.c_oAscTypeSelectElement.Hyperlink ) {
isLink = true;
}
});
let itemsIcon = [],
itemsText = [];
@ -239,13 +264,12 @@ class ContextMenu extends ContextMenuController {
});
}
let isLink = false;
stack.forEach(item => {
const objectType = item.get_ObjectType();
if ( objectType === Asc.c_oAscTypeSelectElement.Hyperlink ) {
isLink = true;
}
if (api.can_AddQuotedComment() !== false && canCoAuthoring && canComments && !locked && !(!isText && isObject)) {
itemsText.push({
caption: _t.menuAddComment,
event: 'addcomment'
});
}
if ( isLink ) {
itemsText.push({

View file

@ -11,7 +11,9 @@ import EditorUIController from '../lib/patch';
@inject ( stores => ({
isEdit: stores.storeAppOptions.isEdit,
canComments: stores.storeAppOptions.canComments,
canViewComments: stores.storeAppOptions.canViewComments,
canCoAuthoring: stores.storeAppOptions.canCoAuthoring,
users: stores.users,
isDisconnected: stores.users.isDisconnected
}))
@ -198,7 +200,7 @@ class ContextMenu extends ContextMenuController {
const { t } = this.props;
const _t = t("ContextMenu", { returnObjects: true });
const { canViewComments, isDisconnected } = this.props;
const { canViewComments, canCoAuthoring, canComments } = this.props;
const api = Common.EditorApi.get();
const stack = api.getSelectedElements();
@ -214,11 +216,13 @@ class ContextMenu extends ContextMenuController {
isShape = false,
isLink = false,
isSlide = false,
isObject = false;
isObject,
locked = false;
stack.forEach(item => {
const objectType = item.get_ObjectType(),
objectValue = item.get_ObjectValue();
locked = typeof objectValue.get_Locked === 'function' ? objectValue.get_Locked() : false;
if (objectType == Asc.c_oAscTypeSelectElement.Paragraph) {
isText = true;
@ -252,6 +256,13 @@ class ContextMenu extends ContextMenuController {
});
}
if (!isChart && api.can_AddQuotedComment() !== false && canCoAuthoring && canComments && !locked) {
itemsText.push({
caption: _t.menuAddComment,
event: 'addcomment'
});
}
if (isLink) {
itemsText.push({
caption: _t.menuOpenLink,

View file

@ -11,7 +11,9 @@ import EditorUIController from '../lib/patch';
@inject ( stores => ({
isEdit: stores.storeAppOptions.isEdit,
canComments: stores.storeAppOptions.canComments,
canViewComments: stores.storeAppOptions.canViewComments,
canCoAuthoring: stores.storeAppOptions.canCoAuthoring,
users: stores.users,
isDisconnected: stores.users.isDisconnected,
storeSheets: stores.sheets
@ -175,7 +177,7 @@ class ContextMenu extends ContextMenuController {
if (isEdit && EditorUIController.ContextMenu) {
return EditorUIController.ContextMenu.mapMenuItems(this);
} else {
const {canViewComments } = this.props;
const {canViewComments, canCoAuthoring, canComments } = this.props;
const api = Common.EditorApi.get();
const cellinfo = api.asc_getCellInfo();
@ -199,12 +201,11 @@ class ContextMenu extends ContextMenuController {
case Asc.c_oAscSelectionType.RangeShapeText: istextshapemenu = true; break;
}
if (iscellmenu || istextchartmenu || istextshapemenu) {
itemsIcon.push({
event: 'copy',
icon: 'icon-copy'
});
}
if (iscellmenu && cellinfo.asc_getHyperlink()) {
itemsText.push({
caption: _t.menuOpenLink,
@ -218,6 +219,13 @@ class ContextMenu extends ContextMenuController {
});
}
if (iscellmenu && !api.isCellEdited && canCoAuthoring && canComments && !isComments) {
itemsText.push({
caption: _t.menuAddComment,
event: 'addcomment'
});
}
return itemsIcon.concat(itemsText);
}
}