The reference figure and the steps below explain the process of comparing documents in ONLYOFFICE Docs.
Specify the event handler for the Document from Storage button to be displayed in the Compare options in the configuration script for Document Editor initialization. When the user clicks the button, the onRequestCompareFile event is called and they can select the document for comparing from the Storage.
var onRequestCompareFile = function() { docEditor.setRevisedFile({ "fileType": "docx", "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmaWxlVHlwZSI6ImRvY3giLCJ1cmwiOiJodHRwczovL2V4YW1wbGUuY29tL3VybC10by1leGFtcGxlLWRvY3VtZW50LmRvY3gifQ.t8660n_GmxJIppxcwkr_mUxmXYtE8cg-jF2cTLMtuk8", "url": "https://example.com/url-to-example-document.docx" }); }; var docEditor = new DocsAPI.DocEditor("placeholder", { "events": { "onRequestCompareFile": onRequestCompareFile, ... }, ... });
In order to select a document for comparing, the setRevisedFile method must be called. When calling this method, the token must be added to validate the parameters.
docEditor.setRevisedFile({ "fileType": "docx", "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmaWxlVHlwZSI6ImRvY3giLCJ1cmwiOiJodHRwczovL2V4YW1wbGUuY29tL3VybC10by1leGFtcGxlLWRvY3VtZW50LmRvY3gifQ.t8660n_GmxJIppxcwkr_mUxmXYtE8cg-jF2cTLMtuk8", "url": "https://example.com/url-to-example-document.docx" });
After that the user can accept or reject the changes using the corresponding buttons on the top toolbar.