I have to integrate onlyOffice in ReactJS.
OnlyOffice is running on docker and accessible on localhost
Showing this error while opening editor in react app:
“Document security key is not correctly formed. Please contact your document server administrator”
React component:
import React, { useRef } from 'react';
import { DocumentEditor } from "@onlyoffice/document-editor-react";
var onDocumentReady = function (event) {
console.log("Document is loaded");
};
var onLoadComponentError = function (errorCode, errorDescription) {
switch(errorCode) {
case -1: // Unknown error loading component
console.log(errorDescription);
break;
case -2: // Error load DocsAPI from http://documentserver/
console.log(errorDescription);
break;
case -3: // DocsAPI is not defined
console.log(errorDescription);
break;
}
};
const formUrl = `${process.env.PUBLIC_URL}/sample4.docx`;
const OnlyOffice = () => {
return (
<>
<DocumentEditor
id="docxEditor"
documentServerUrl="http://localhost"
config={{
"document": {
"fileType": "docx",
"title": "Example Document Title.docx",
"url": formUrl
},
"documentType": "word",
"editorConfig": {
"callbackUrl": "https://example.com/url-to-callback.ashx"
}
}}
events_onDocumentReady={onDocumentReady}
onLoadComponentError={onLoadComponentError}
/>
</>
);
}
export default OnlyOffice