[SSE mobile] Moved edit functions of context menu to private branch
This commit is contained in:
		
							parent
							
								
									cfbb8ce795
								
							
						
					
					
						commit
						588a7f0386
					
				| 
						 | 
				
			
			@ -7,6 +7,7 @@ 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';
 | 
			
		||||
 | 
			
		||||
@inject ( stores => ({
 | 
			
		||||
    isEdit: stores.storeAppOptions.isEdit,
 | 
			
		||||
| 
						 | 
				
			
			@ -61,11 +62,14 @@ class ContextMenu extends ContextMenuController {
 | 
			
		|||
 | 
			
		||||
        super.onMenuItemClick(action);
 | 
			
		||||
 | 
			
		||||
        if ( EditorUIController.ContextMenu && EditorUIController.ContextMenu.handleMenuItemClick(this, action) )
 | 
			
		||||
            return;
 | 
			
		||||
 | 
			
		||||
        const api = Common.EditorApi.get();
 | 
			
		||||
        const info = api.asc_getCellInfo();
 | 
			
		||||
        switch (action) {
 | 
			
		||||
            case 'cut':
 | 
			
		||||
                if (!api.asc_Cut() && !LocalStorage.getBool("sse-hide-copy-cut-paste-warning")) {
 | 
			
		||||
                if (!LocalStorage.getBool("sse-hide-copy-cut-paste-warning")) {
 | 
			
		||||
                    this.showCopyCutPasteModal();
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
| 
						 | 
				
			
			@ -75,55 +79,13 @@ class ContextMenu extends ContextMenuController {
 | 
			
		|||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            case 'paste':
 | 
			
		||||
                if (!api.asc_Paste() && !LocalStorage.getBool("sse-hide-copy-cut-paste-warning")) {
 | 
			
		||||
                if (!LocalStorage.getBool("sse-hide-copy-cut-paste-warning")) {
 | 
			
		||||
                    this.showCopyCutPasteModal();
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            case 'addcomment':
 | 
			
		||||
                Common.Notifications.trigger('addcomment');
 | 
			
		||||
                break;
 | 
			
		||||
            case 'viewcomment':
 | 
			
		||||
                Common.Notifications.trigger('viewcomment');
 | 
			
		||||
                break;
 | 
			
		||||
            case 'del':
 | 
			
		||||
                api.asc_emptyCells(Asc.c_oAscCleanOptions.All);
 | 
			
		||||
                break;
 | 
			
		||||
            case 'wrap':
 | 
			
		||||
                api.asc_setCellTextWrap(true);
 | 
			
		||||
                break;
 | 
			
		||||
            case 'unwrap':
 | 
			
		||||
                api.asc_setCellTextWrap(false);
 | 
			
		||||
                break;
 | 
			
		||||
            case 'edit':
 | 
			
		||||
                setTimeout(() => {
 | 
			
		||||
                    this.props.openOptions('edit');
 | 
			
		||||
                }, 0);
 | 
			
		||||
                break;
 | 
			
		||||
            case 'merge':
 | 
			
		||||
                if (api.asc_mergeCellsDataLost(Asc.c_oAscMergeOptions.Merge)) {
 | 
			
		||||
                    setTimeout(() => {
 | 
			
		||||
                        f7.dialog.confirm(_t.warnMergeLostData, _t.notcriticalErrorTitle, () => {
 | 
			
		||||
                            api.asc_mergeCells(Asc.c_oAscMergeOptions.Merge);
 | 
			
		||||
                        });
 | 
			
		||||
                    }, 0);
 | 
			
		||||
                } else {
 | 
			
		||||
                    api.asc_mergeCells(Asc.c_oAscMergeOptions.Merge);
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            case 'unmerge':
 | 
			
		||||
                api.asc_mergeCells(Asc.c_oAscMergeOptions.None);
 | 
			
		||||
                break;
 | 
			
		||||
            case 'hide':
 | 
			
		||||
                api[info.asc_getSelectionType() == Asc.c_oAscSelectionType.RangeRow ? 'asc_hideRows' : 'asc_hideColumns']();
 | 
			
		||||
                break;
 | 
			
		||||
            case 'show':
 | 
			
		||||
                api[info.asc_getSelectionType() == Asc.c_oAscSelectionType.RangeRow ? 'asc_showRows' : 'asc_showColumns']();
 | 
			
		||||
                break;
 | 
			
		||||
            case 'addlink':
 | 
			
		||||
                setTimeout(() => {
 | 
			
		||||
                    this.props.openOptions('add', 'link');
 | 
			
		||||
                }, 400)
 | 
			
		||||
                break;
 | 
			
		||||
            case 'openlink':
 | 
			
		||||
                const linkinfo = info.asc_getHyperlink();
 | 
			
		||||
                if ( linkinfo.asc_getType() == Asc.c_oAscHyperlinkType.RangeLink ) {
 | 
			
		||||
| 
						 | 
				
			
			@ -145,12 +107,22 @@ class ContextMenu extends ContextMenuController {
 | 
			
		|||
                    api.asc_getUrlType(url) > 0 && this.openLink(url);
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            case 'freezePanes':
 | 
			
		||||
                api.asc_freezePane();
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        console.log("click context menu item: " + action);
 | 
			
		||||
    onMergeCells() {
 | 
			
		||||
        const { t } = this.props;
 | 
			
		||||
        const _t = t("ContextMenu", { returnObjects: true });
 | 
			
		||||
        const api = Common.EditorApi.get();
 | 
			
		||||
        if (api.asc_mergeCellsDataLost(Asc.c_oAscMergeOptions.Merge)) {
 | 
			
		||||
            setTimeout(() => {
 | 
			
		||||
                f7.dialog.confirm(_t.warnMergeLostData, _t.notcriticalErrorTitle, () => {
 | 
			
		||||
                    api.asc_mergeCells(Asc.c_oAscMergeOptions.Merge);
 | 
			
		||||
                });
 | 
			
		||||
            }, 0);
 | 
			
		||||
        } else {
 | 
			
		||||
            api.asc_mergeCells(Asc.c_oAscMergeOptions.Merge);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    showCopyCutPasteModal() {
 | 
			
		||||
| 
						 | 
				
			
			@ -198,33 +170,35 @@ class ContextMenu extends ContextMenuController {
 | 
			
		|||
        const { t } = this.props;
 | 
			
		||||
        const _t = t("ContextMenu", { returnObjects: true });
 | 
			
		||||
 | 
			
		||||
        const { isEdit, canViewComments, isDisconnected } = this.props;
 | 
			
		||||
        const { isEdit } = this.props;
 | 
			
		||||
 | 
			
		||||
        const api = Common.EditorApi.get();
 | 
			
		||||
        const cellinfo = api.asc_getCellInfo();
 | 
			
		||||
        if (isEdit && EditorUIController.ContextMenu) {
 | 
			
		||||
            return EditorUIController.ContextMenu.mapMenuItems(this);
 | 
			
		||||
        } else {
 | 
			
		||||
            const {canViewComments } = this.props;
 | 
			
		||||
 | 
			
		||||
        const itemsIcon = [];
 | 
			
		||||
        const itemsText = [];
 | 
			
		||||
            const api = Common.EditorApi.get();
 | 
			
		||||
            const cellinfo = api.asc_getCellInfo();
 | 
			
		||||
 | 
			
		||||
        let iscellmenu, isrowmenu, iscolmenu, isallmenu, ischartmenu, isimagemenu, istextshapemenu, isshapemenu, istextchartmenu;
 | 
			
		||||
        let iscelllocked = cellinfo.asc_getLocked();
 | 
			
		||||
        const seltype = cellinfo.asc_getSelectionType();
 | 
			
		||||
        const xfs = cellinfo.asc_getXfs();
 | 
			
		||||
        const isComments = cellinfo.asc_getComments().length > 0; //prohibit adding multiple comments in one cell;
 | 
			
		||||
            const itemsIcon = [];
 | 
			
		||||
            const itemsText = [];
 | 
			
		||||
 | 
			
		||||
        switch (seltype) {
 | 
			
		||||
            case Asc.c_oAscSelectionType.RangeCells:     iscellmenu  = true;     break;
 | 
			
		||||
            case Asc.c_oAscSelectionType.RangeRow:       isrowmenu   = true;     break;
 | 
			
		||||
            case Asc.c_oAscSelectionType.RangeCol:       iscolmenu   = true;     break;
 | 
			
		||||
            case Asc.c_oAscSelectionType.RangeMax:       isallmenu   = true;     break;
 | 
			
		||||
            case Asc.c_oAscSelectionType.RangeImage:     isimagemenu = true;     break;
 | 
			
		||||
            case Asc.c_oAscSelectionType.RangeShape:     isshapemenu = true;     break;
 | 
			
		||||
            case Asc.c_oAscSelectionType.RangeChart:     ischartmenu = true;     break;
 | 
			
		||||
            case Asc.c_oAscSelectionType.RangeChartText: istextchartmenu = true; break;
 | 
			
		||||
            case Asc.c_oAscSelectionType.RangeShapeText: istextshapemenu = true; break;
 | 
			
		||||
        }
 | 
			
		||||
            let iscellmenu, isrowmenu, iscolmenu, isallmenu, ischartmenu, isimagemenu, istextshapemenu, isshapemenu, istextchartmenu;
 | 
			
		||||
            const seltype = cellinfo.asc_getSelectionType();
 | 
			
		||||
            const isComments = cellinfo.asc_getComments().length > 0; //prohibit adding multiple comments in one cell;
 | 
			
		||||
 | 
			
		||||
            switch (seltype) {
 | 
			
		||||
                case Asc.c_oAscSelectionType.RangeCells:     iscellmenu  = true;     break;
 | 
			
		||||
                case Asc.c_oAscSelectionType.RangeRow:       isrowmenu   = true;     break;
 | 
			
		||||
                case Asc.c_oAscSelectionType.RangeCol:       iscolmenu   = true;     break;
 | 
			
		||||
                case Asc.c_oAscSelectionType.RangeMax:       isallmenu   = true;     break;
 | 
			
		||||
                case Asc.c_oAscSelectionType.RangeImage:     isimagemenu = true;     break;
 | 
			
		||||
                case Asc.c_oAscSelectionType.RangeShape:     isshapemenu = true;     break;
 | 
			
		||||
                case Asc.c_oAscSelectionType.RangeChart:     ischartmenu = true;     break;
 | 
			
		||||
                case Asc.c_oAscSelectionType.RangeChartText: istextchartmenu = true; break;
 | 
			
		||||
                case Asc.c_oAscSelectionType.RangeShapeText: istextshapemenu = true; break;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        if (!isEdit) {
 | 
			
		||||
            if (iscellmenu || istextchartmenu || istextshapemenu) {
 | 
			
		||||
                itemsIcon.push({
 | 
			
		||||
                    event: 'copy',
 | 
			
		||||
| 
						 | 
				
			
			@ -243,136 +217,9 @@ class ContextMenu extends ContextMenuController {
 | 
			
		|||
                    event: 'viewcomment'
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
 | 
			
		||||
            if (!iscelllocked && (isimagemenu || isshapemenu || ischartmenu || istextshapemenu || istextchartmenu)) {
 | 
			
		||||
                api.asc_getGraphicObjectProps().every((object) => {
 | 
			
		||||
                    if (object.asc_getObjectType() == Asc.c_oAscTypeSelectElement.Image) {
 | 
			
		||||
                        iscelllocked = object.asc_getObjectValue().asc_getLocked();
 | 
			
		||||
                    }
 | 
			
		||||
                    return !iscelllocked;
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (iscelllocked || api.isCellEdited) {
 | 
			
		||||
                itemsIcon.push({
 | 
			
		||||
                    event: 'copy',
 | 
			
		||||
                    icon: 'icon-copy'
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
            } else {
 | 
			
		||||
                itemsIcon.push({
 | 
			
		||||
                    event: 'cut',
 | 
			
		||||
                    icon: 'icon-cut'
 | 
			
		||||
                });
 | 
			
		||||
                itemsIcon.push({
 | 
			
		||||
                    event: 'copy',
 | 
			
		||||
                    icon: 'icon-copy'
 | 
			
		||||
                });
 | 
			
		||||
                itemsIcon.push({
 | 
			
		||||
                    event: 'paste',
 | 
			
		||||
                    icon: 'icon-paste'
 | 
			
		||||
                });
 | 
			
		||||
                itemsText.push({
 | 
			
		||||
                    caption: _t.menuDelete,
 | 
			
		||||
                    event: 'del'
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
                if (isimagemenu || isshapemenu || ischartmenu ||
 | 
			
		||||
                    istextshapemenu || istextchartmenu) {
 | 
			
		||||
                    itemsText.push({
 | 
			
		||||
                        caption: _t.menuEdit,
 | 
			
		||||
                        event: 'edit'
 | 
			
		||||
                    });
 | 
			
		||||
                } else {
 | 
			
		||||
                    if (iscolmenu || isrowmenu) {
 | 
			
		||||
                        itemsText.push({
 | 
			
		||||
                            caption: _t.menuHide,
 | 
			
		||||
                            event: 'hide'
 | 
			
		||||
                        });
 | 
			
		||||
                        itemsText.push({
 | 
			
		||||
                            caption: _t.menuShow,
 | 
			
		||||
                            event: 'show'
 | 
			
		||||
                        });
 | 
			
		||||
                    } else if (iscellmenu) {
 | 
			
		||||
                        if (!iscelllocked) {
 | 
			
		||||
                            itemsText.push({
 | 
			
		||||
                                caption: _t.menuCell,
 | 
			
		||||
                                event: 'edit'
 | 
			
		||||
                            });
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        if (cellinfo.asc_getMerge() == Asc.c_oAscMergeOptions.None) {
 | 
			
		||||
                            itemsText.push({
 | 
			
		||||
                                caption: _t.menuMerge,
 | 
			
		||||
                                event: 'merge'
 | 
			
		||||
                            });
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        if (cellinfo.asc_getMerge() == Asc.c_oAscMergeOptions.Merge) {
 | 
			
		||||
                            itemsText.push({
 | 
			
		||||
                                caption: _t.menuUnmerge,
 | 
			
		||||
                                event: 'unmerge'
 | 
			
		||||
                            });
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        itemsText.push(
 | 
			
		||||
                            xfs.asc_getWrapText() ?
 | 
			
		||||
                                {
 | 
			
		||||
                                    caption: _t.menuUnwrap,
 | 
			
		||||
                                    event: 'unwrap'
 | 
			
		||||
                                } :
 | 
			
		||||
                                {
 | 
			
		||||
                                    caption: _t.menuWrap,
 | 
			
		||||
                                    event: 'wrap'
 | 
			
		||||
                                });
 | 
			
		||||
 | 
			
		||||
                        if (cellinfo.asc_getHyperlink() && !cellinfo.asc_getMultiselect()) {
 | 
			
		||||
                            itemsText.push({
 | 
			
		||||
                                caption: _t.menuOpenLink,
 | 
			
		||||
                                event: 'openlink'
 | 
			
		||||
                            });
 | 
			
		||||
                        } else if (!cellinfo.asc_getHyperlink() && !cellinfo.asc_getMultiselect() &&
 | 
			
		||||
                            !cellinfo.asc_getLockText() && !!cellinfo.asc_getText()) {
 | 
			
		||||
                            itemsText.push({
 | 
			
		||||
                                caption: _t.menuAddLink,
 | 
			
		||||
                                event: 'addlink'
 | 
			
		||||
                            });
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    itemsText.push({
 | 
			
		||||
                        caption: api.asc_getSheetViewSettings().asc_getIsFreezePane() ? _t.menuUnfreezePanes : _t.menuFreezePanes,
 | 
			
		||||
                        event: 'freezePanes'
 | 
			
		||||
                    });
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (canViewComments) {
 | 
			
		||||
                    if (isComments) {
 | 
			
		||||
                        itemsText.push({
 | 
			
		||||
                            caption: _t.menuViewComment,
 | 
			
		||||
                            event: 'viewcomment'
 | 
			
		||||
                        });
 | 
			
		||||
                    } else if (iscellmenu) {
 | 
			
		||||
                        itemsText.push({
 | 
			
		||||
                            caption: _t.menuAddComment,
 | 
			
		||||
                            event: 'addcomment'
 | 
			
		||||
                        });
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return itemsIcon.concat(itemsText);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        if ( Device.phone && itemsText.length > 2 ) {
 | 
			
		||||
            this.extraItems = itemsText.splice(2,itemsText.length, {
 | 
			
		||||
                caption: _t.menuMore,
 | 
			
		||||
                event: 'showActionSheet'
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return itemsIcon.concat(itemsText);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    initExtraItems () {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue