Page 1 of 1

Save document using onRequestClose method

Posted: Tue Mar 16, 2021 2:38 pm
by Philippe
Hello,

We use onRequestClose method to close the editor :
  • Is there a way to know if the document has changed but not saved ?
  • Is there a way to save the document ?
Thanks.

Re: Save document using onRequestClose method

Posted: Tue Mar 16, 2021 4:15 pm
by Carl
Hello Philippe,

By default, document saving happens when the last co-editor closes the editor tab in the browser (in your case the last user who initiates the destroyEditor method by clicking the Close button).
You can learn more here:
https://api.onlyoffice.com/editors/save

If you need to manually trigger file saving, you can implement the forcesave:
https://api.onlyoffice.com/editors/save#forcesave

Information about the document being changed or ready to be saved is sent by the Document Server via status messages to the callback handler (status 1 and 2 respectively):
https://api.onlyoffice.com/editors/callback#status

Re: Save document using onRequestClose method

Posted: Fri Mar 19, 2021 3:07 pm
by Philippe
We've decided to go with auto save.
However, in the onResquestClose method, we should be able to tell the browser to alert the user that the document has changed. The browser does it by itself when the onRequestClose method is not implemented. That would leave the user a chance not to save the document. Any idea?