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

Fix/fix bugs on mobiles
This commit is contained in:
maxkadushkin 2021-06-18 21:13:12 +03:00 committed by GitHub
commit 71e1dd4669
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 72 additions and 86 deletions

View file

@ -35,8 +35,6 @@ const PluginsController = inject('storeAppOptions')(observer(props => {
api.asc_unregisterCallback("asc_onPluginClose", pluginClose);
api.asc_unregisterCallback("asc_onPluginResize", pluginResize);
api.asc_unregisterCallback('asc_onPluginsInit', onPluginsInit);
Common.Gateway.off('init', loadConfig);
};
});

View file

@ -17,6 +17,7 @@ class CollaborationController extends Component {
api.asc_registerCallback('asc_OnTryUndoInFastCollaborative', this.onTryUndoInFastCollaborative.bind(this));
});
Common.Notifications.on('api:disconnect', this.onCoAuthoringDisconnect.bind(this));
Common.Notifications.on('document:ready', this.onDocumentReady.bind(this));
}

View file

@ -1,10 +1,10 @@
import React, { useEffect, useState } from 'react';
import { inject } from 'mobx-react';
import { inject, observer } from 'mobx-react';
import { f7 } from 'framework7-react';
import { useTranslation } from 'react-i18next';
import ToolbarView from "../view/Toolbar";
const ToolbarController = inject('storeAppOptions', 'users', 'storeReview')(props => {
const ToolbarController = inject('storeAppOptions', 'users', 'storeReview')(observer(props => {
const {t} = useTranslation();
const _t = t("Toolbar", { returnObjects: true });
@ -23,8 +23,6 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeReview')(prop
api.asc_registerCallback('asc_onCanUndo', onApiCanUndo);
api.asc_registerCallback('asc_onCanRedo', onApiCanRedo);
api.asc_registerCallback('asc_onFocusObject', onApiFocusObject);
api.asc_registerCallback('asc_onCoAuthoringDisconnect', onCoAuthoringDisconnect);
Common.Notifications.on('api:disconnect', onCoAuthoringDisconnect);
Common.Notifications.on('toolbar:activatecontrols', activateControls);
Common.Notifications.on('toolbar:deactivateeditcontrols', deactivateEditControls);
Common.Notifications.on('goback', goBack);
@ -37,10 +35,15 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeReview')(prop
onDocumentReady();
}
if (isDisconnected) {
f7.popover.close();
f7.sheet.close();
f7.popup.close();
}
return () => {
Common.Notifications.off('document:ready', onDocumentReady);
Common.Notifications.off('setdoctitle', setDocTitle);
Common.Notifications.off('api:disconnect', onCoAuthoringDisconnect);
Common.Notifications.off('toolbar:activatecontrols', activateControls);
Common.Notifications.off('toolbar:deactivateeditcontrols', deactivateEditControls);
Common.Notifications.off('goback', goBack);
@ -49,7 +52,6 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeReview')(prop
api.asc_unregisterCallback('asc_onCanUndo', onApiCanUndo);
api.asc_unregisterCallback('asc_onCanRedo', onApiCanRedo);
api.asc_unregisterCallback('asc_onFocusObject', onApiFocusObject);
api.asc_unregisterCallback('asc_onCoAuthoringDisconnect', onCoAuthoringDisconnect);
}
});
@ -163,15 +165,6 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeReview')(prop
}
};
const onCoAuthoringDisconnect = (enableDownload) => {
deactivateEditControls(enableDownload);
setCanUndo(false);
setCanRedo(false);
f7.popover.close();
f7.sheet.close();
f7.popup.close();
};
const [disabledControls, setDisabledControls] = useState(true);
const activateControls = () => {
setDisabledControls(false);
@ -200,8 +193,9 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeReview')(prop
readerMode={readerMode}
showEditDocument={showEditDocument}
onEditDocument={onEditDocument}
isDisconnected={isDisconnected}
/>
)
});
}));
export {ToolbarController as Toolbar};

View file

@ -25,6 +25,7 @@ class DownloadController extends Component {
const _t = t("Settings", { returnObjects: true });
if(format) {
this.closeModal();
if (format == Asc.c_oAscFileType.TXT || format == Asc.c_oAscFileType.RTF) {
f7.dialog.confirm(
(format === Asc.c_oAscFileType.TXT) ? _t.textDownloadTxt : _t.textDownloadRtf,
@ -35,16 +36,18 @@ class DownloadController extends Component {
onAdvancedOptions(Asc.c_oAscAdvancedOptionsID.TXT, api.asc_getAdvancedOptions(), 2, new Asc.asc_CDownloadOptions(format), _t, isDocReady);
}
else {
api.asc_DownloadAs(new Asc.asc_CDownloadOptions(format));
setTimeout(() => {
api.asc_DownloadAs(new Asc.asc_CDownloadOptions(format));
}, 400);
}
}
);
}
else {
api.asc_DownloadAs(new Asc.asc_CDownloadOptions(format));
setTimeout(() => {
api.asc_DownloadAs(new Asc.asc_CDownloadOptions(format));
}, 400);
}
this.closeModal();
}
}

View file

@ -19,11 +19,6 @@ const Settings = props => {
}
});
const onviewclosed = () => {
if ( props.onclosed )
props.onclosed();
};
const closeModal = () => {
if (Device.phone) {
f7.sheet.close('.settings-popup');
@ -46,15 +41,14 @@ const Settings = props => {
};
const onPrint = () => {
closeModal();
setTimeout(() => {
Common.EditorApi.get().asc_Print();
}, 1);
closeModal();
}, 400);
};
const showHelp = () => {
let url = __HELP_URL__;
// let url = 'https://helpcenter.onlyoffice.com';
if (url.charAt(url.length-1) !== '/') {
url += '/';
@ -68,17 +62,21 @@ const Settings = props => {
}
closeModal();
window.open(url, "_blank");
setTimeout(() => {
window.open(url, "_blank");
}, 400);
};
const onOrthographyCheck = () => {
closeModal();
Common.EditorApi.get().asc_pluginRun("asc.{B631E142-E40B-4B4C-90B9-2D00222A286E}", 0);
setTimeout(() => {
Common.EditorApi.get().asc_pluginRun("asc.{B631E142-E40B-4B4C-90B9-2D00222A286E}", 0);
}, 400);
};
return <SettingsView usePopover={!Device.phone}
openOptions={props.openOptions}
onclosed={onviewclosed}
onclosed={props.onclosed}
onReaderMode={onReaderMode}
onPrint={onPrint}
showHelp={showHelp}

View file

@ -129,7 +129,7 @@ class MainPage extends Component {
}
{
!this.state.settingsVisible ? null :
<Settings openOptions={this.handleClickToOpenOptions} onclosed={this.handleOptionsViewClosed.bind(this, 'settings')} />
<Settings openOptions={this.handleClickToOpenOptions.bind(this)} onclosed={this.handleOptionsViewClosed.bind(this, 'settings')} />
}
{
!this.state.collaborationVisible ? null :

View file

@ -4,14 +4,15 @@ import { Device } from '../../../../common/mobile/utils/device';
import EditorUIController from '../lib/patch'
const ToolbarView = props => {
const disableEditBtn = props.isObjectLocked || props.stateDisplayMode || props.disabledEditControls;
const isDisconnected = props.isDisconnected;
const disableEditBtn = props.isObjectLocked || props.stateDisplayMode || props.disabledEditControls || isDisconnected;
return (
<Fragment>
<NavLeft>
{props.isShowBack && <Link className={`btn-doc-back${props.disabledControls && ' disabled'}`} icon='icon-back' onClick={props.onBack}></Link>}
{Device.ios && props.isEdit && EditorUIController.getUndoRedo && EditorUIController.getUndoRedo({
disabledUndo: !props.isCanUndo,
disabledRedo: !props.isCanRedo,
disabledUndo: !props.isCanUndo || isDisconnected,
disabledRedo: !props.isCanRedo || isDisconnected,
onUndoClick: props.onUndo,
onRedoClick: props.onRedo
})}

View file

@ -3,6 +3,7 @@ import { inject } from 'mobx-react';
import { f7 } from 'framework7-react';
import { useTranslation } from 'react-i18next';
import Preview from "../view/Preview";
import ContextMenu from './ContextMenu';
const PreviewController = props => {
const { t } = useTranslation();
@ -20,6 +21,7 @@ const PreviewController = props => {
api.DemonstrationEndShowMessage(_t.textFinalMessage);
};
ContextMenu.closeContextMenu();
show();
onDocumentReady();

View file

@ -1,10 +1,10 @@
import React, { useEffect, useState } from 'react';
import { inject } from 'mobx-react';
import { inject, observer } from 'mobx-react';
import { f7 } from 'framework7-react';
import { useTranslation } from 'react-i18next';
import ToolbarView from "../view/Toolbar";
const ToolbarController = inject('storeAppOptions', 'users')(props => {
const ToolbarController = inject('storeAppOptions', 'users')(observer(props => {
const {t} = useTranslation();
const _t = t("Toolbar", { returnObjects: true });
@ -20,9 +20,7 @@ const ToolbarController = inject('storeAppOptions', 'users')(props => {
api.asc_registerCallback('asc_onCanUndo', onApiCanUndo);
api.asc_registerCallback('asc_onCanRedo', onApiCanRedo);
api.asc_registerCallback('asc_onFocusObject', onApiFocusObject);
api.asc_registerCallback('asc_onCoAuthoringDisconnect', onCoAuthoringDisconnect);
api.asc_registerCallback('asc_onCountPages', onApiCountPages);
Common.Notifications.on('api:disconnect', onCoAuthoringDisconnect);
Common.Notifications.on('toolbar:activatecontrols', activateControls);
Common.Notifications.on('toolbar:deactivateeditcontrols', deactivateEditControls);
Common.Notifications.on('goback', goBack);
@ -35,10 +33,15 @@ const ToolbarController = inject('storeAppOptions', 'users')(props => {
onDocumentReady();
}
if (isDisconnected) {
f7.popover.close();
f7.sheet.close();
f7.popup.close();
}
return () => {
Common.Notifications.off('document:ready', onDocumentReady);
Common.Notifications.off('setdoctitle', setDocTitle);
Common.Notifications.off('api:disconnect', onCoAuthoringDisconnect);
Common.Notifications.off('toolbar:activatecontrols', activateControls);
Common.Notifications.off('toolbar:deactivateeditcontrols', deactivateEditControls);
Common.Notifications.off('goback', goBack);
@ -47,7 +50,6 @@ const ToolbarController = inject('storeAppOptions', 'users')(props => {
api.asc_unregisterCallback('asc_onCanUndo', onApiCanUndo);
api.asc_unregisterCallback('asc_onCanRedo', onApiCanRedo);
api.asc_unregisterCallback('asc_onFocusObject', onApiFocusObject);
api.asc_unregisterCallback('asc_onCoAuthoringDisconnect', onCoAuthoringDisconnect);
api.asc_unregisterCallback('asc_onCountPages', onApiCountPages);
}
});
@ -178,15 +180,6 @@ const ToolbarController = inject('storeAppOptions', 'users')(props => {
setDisabledControls(false);
};
const onCoAuthoringDisconnect = (enableDownload) => {
deactivateEditControls(enableDownload);
setCanUndo(false);
setCanRedo(false);
f7.popover.close();
f7.sheet.close();
f7.popup.close();
};
const onEditDocument = () => {
Common.Gateway.requestEditRights();
};
@ -210,8 +203,9 @@ const ToolbarController = inject('storeAppOptions', 'users')(props => {
displayCollaboration={displayCollaboration}
showEditDocument={showEditDocument}
onEditDocument={onEditDocument}
isDisconnected={isDisconnected}
/>
)
});
}));
export {ToolbarController as Toolbar};

View file

@ -2,7 +2,7 @@ import React from 'react';
const Preview = () => {
return (
<div id="pe-preview" style={{position: 'absolute', left: 0, top: 0, width: '100%', height: '100%', zIndex: 1000}}>
<div id="pe-preview" style={{position: 'absolute', left: 0, top: 0, width: '100%', height: '100%', zIndex: 14000}}>
<div id="presentation-preview" style={{width: '100%', height: '100%'}}></div>
</div>
)

View file

@ -4,13 +4,14 @@ import { Device } from '../../../../common/mobile/utils/device';
import EditorUIController from '../lib/patch'
const ToolbarView = props => {
const isDisconnected = props.isDisconnected;
return (
<Fragment>
<NavLeft>
{props.isShowBack && <Link className={`btn-doc-back${props.disabledControls && ' disabled'}`} icon='icon-back' onClick={props.onBack}></Link>}
{Device.ios && props.isEdit && EditorUIController.getUndoRedo && EditorUIController.getUndoRedo({
disabledUndo: !props.isCanUndo,
disabledRedo: !props.isCanRedo,
disabledUndo: !props.isCanUndo || isDisconnected,
disabledRedo: !props.isCanRedo || isDisconnected,
onUndoClick: props.onUndo,
onRedoClick: props.onRedo
})}
@ -18,8 +19,8 @@ const ToolbarView = props => {
{!Device.phone && <NavTitle>{props.docTitle}</NavTitle>}
<NavRight>
{Device.android && props.isEdit && EditorUIController.getUndoRedo && EditorUIController.getUndoRedo({
disabledUndo: !props.isCanUndo,
disabledRedo: !props.isCanRedo,
disabledUndo: !props.isCanUndo || isDisconnected,
disabledRedo: !props.isCanRedo || isDisconnected,
onUndoClick: props.onUndo,
onRedoClick: props.onRedo
})}
@ -28,8 +29,8 @@ const ToolbarView = props => {
<Link className={props.disabledControls ? 'disabled' : ''} icon='icon-edit' href={false} onClick={props.onEditDocument}></Link>
}
{props.isEdit && EditorUIController.getToolbarOptions && EditorUIController.getToolbarOptions({
disabledAdd: props.disabledAdd || props.disabledControls,
disabledEdit: props.disabledEdit || props.disabledControls,
disabledAdd: props.disabledAdd || props.disabledControls || isDisconnected,
disabledEdit: props.disabledEdit || props.disabledControls || isDisconnected,
onEditClick: () => props.openOptions('edit'),
onAddClick: () => props.openOptions('add')
})}

View file

@ -1,10 +1,10 @@
import React, { useEffect, useState } from 'react';
import { inject } from 'mobx-react';
import { inject, observer } from 'mobx-react';
import { f7 } from 'framework7-react';
import { useTranslation } from 'react-i18next';
import ToolbarView from "../view/Toolbar";
const ToolbarController = inject('storeAppOptions', 'users', 'storeSpreadsheetInfo')(props => {
const ToolbarController = inject('storeAppOptions', 'users', 'storeSpreadsheetInfo')(observer(props => {
const {t} = useTranslation();
const _t = t("Toolbar", { returnObjects: true });
@ -24,9 +24,7 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeSpreadsheetIn
api.asc_registerCallback('asc_onWorkbookLocked', onApiSelectionChanged);
api.asc_registerCallback('asc_onWorksheetLocked', onApiSelectionChanged);
api.asc_registerCallback('asc_onActiveSheetChanged', onApiActiveSheetChanged);
api.asc_registerCallback('asc_onCoAuthoringDisconnect', onCoAuthoringDisconnect);
Common.Notifications.on('api:disconnect', onCoAuthoringDisconnect);
Common.Notifications.on('toolbar:activatecontrols', activateControls);
Common.Notifications.on('toolbar:deactivateeditcontrols', deactivateEditControls);
Common.Notifications.on('goback', goBack);
@ -39,9 +37,14 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeSpreadsheetIn
onDocumentReady();
}
if (isDisconnected) {
f7.popover.close();
f7.sheet.close();
f7.popup.close();
}
return () => {
Common.Notifications.off('document:ready', onDocumentReady);
Common.Notifications.off('api:disconnect', onCoAuthoringDisconnect);
Common.Notifications.off('toolbar:activatecontrols', activateControls);
Common.Notifications.off('toolbar:deactivateeditcontrols', deactivateEditControls);
Common.Notifications.off('goback', goBack);
@ -54,7 +57,6 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeSpreadsheetIn
api.asc_unregisterCallback('asc_onWorkbookLocked', onApiSelectionChanged);
api.asc_unregisterCallback('asc_onWorksheetLocked', onApiSelectionChanged);
api.asc_unregisterCallback('asc_onActiveSheetChanged', onApiActiveSheetChanged);
api.asc_unregisterCallback('asc_onCoAuthoringDisconnect', onCoAuthoringDisconnect);
}
});
@ -179,15 +181,6 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeSpreadsheetIn
setDisabledControls(false);
};
const onCoAuthoringDisconnect = (enableDownload) => {
deactivateEditControls(enableDownload);
setCanUndo(false);
setCanRedo(false);
f7.popover.close();
f7.sheet.close();
f7.popup.close();
};
const onEditDocument = () => {
Common.Gateway.requestEditRights();
};
@ -208,8 +201,9 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeSpreadsheetIn
displayCollaboration={displayCollaboration}
showEditDocument={showEditDocument}
onEditDocument={onEditDocument}
isDisconnected={isDisconnected}
/>
)
});
}));
export {ToolbarController as Toolbar};

View file

@ -1,21 +1,20 @@
import {action, computed, makeObservable} from 'mobx';
import {action, observable, makeObservable} from 'mobx';
export class storeFunctions {
constructor() {
makeObservable(this, {
initFunctions: action,
functions: computed
functions: observable
});
}
functions = {};
initFunctions (groups, data) {
this.groups = groups;
this.data = data;
this.functions = this.getFunctions(groups, data);
}
get functions () {
const groups = this.groups;
const data = this.data;
getFunctions (groups, data) {
const functions = {};
for (let g in groups) {
const group = groups[g];

View file

@ -4,9 +4,10 @@ import { Device } from '../../../../common/mobile/utils/device';
import EditorUIController from '../lib/patch'
const ToolbarView = props => {
const isDisconnected = props.isDisconnected;
const undo_box = props.isEdit && EditorUIController.toolbarOptions ? EditorUIController.toolbarOptions.getUndoRedo({
disabledUndo: !props.isCanUndo,
disabledRedo: !props.isCanRedo,
disabledUndo: !props.isCanUndo || isDisconnected,
disabledRedo: !props.isCanRedo || isDisconnected,
onUndoClick: props.onUndo,
onRedoClick: props.onRedo
}) : null;
@ -23,7 +24,7 @@ const ToolbarView = props => {
<Link className={props.disabledControls ? 'disabled' : ''} icon='icon-edit' href={false} onClick={props.onEditDocument}></Link>
}
{props.isEdit && EditorUIController.toolbarOptions && EditorUIController.toolbarOptions.getEditOptions({
disabled: props.disabledEditControls || props.disabledControls,
disabled: props.disabledEditControls || props.disabledControls || isDisconnected,
onEditClick: () => props.openOptions('edit'),
onAddClick: () => props.openOptions('add')
})}