Deploy document editor component for mobile in EJ2 JavaScript Document editor control
26 Nov 20231 minute to read
Document editor component for Mobile
At present, Document editor component is not responsive for mobile, and we haven’t ensured the editing functionalities in mobile browsers. Whereas it works properly as a document viewer in mobile browsers.
Hence, it is recommended to switch the Document editor component as read-only in mobile browsers. Also, invoke fitPage
method with FitPageWidth
parameter in document change event, such as to display one full page by adjusting the zoom factor.
The following example code illustrates how to deploy Document Editor component for Mobile.
//Initialize Document Editor Container component.
import { DocumentEditorContainer, Toolbar } from '@syncfusion/ej2-documenteditor';
DocumentEditorContainer.Inject(Toolbar);
let container: DocumentEditorContainer = new DocumentEditorContainer({
enableToolbar: true, height: '590px'
});
container.serviceUrl = 'https://services.syncfusion.com/js/production/api/documenteditor/';
container.appendTo('#DocumentEditor');
//To detect the device
let isMobileDevice: bool = /Android|Windows Phone|webOS/i.test(navigator.userAgent);
container.documentChange = () => {
if (isMobileDevice) {
container.restrictEditing = true;
setTimeout(() => {
container.documentEditor.fitPage("FitPageWidth");
}, 50);
}
else {
container.restrictEditing = false;
}
}
You can download the complete working example from this GitHub location
Note: You can use the
restrictEditing
in DocumentEditorContainer andisReadOnly
in DocumentEditor based on your requirement to change component to read only mode.