Cloud Computing Insider Awards 2022: Vote for ONLYOFFICE

Is it necessary to reload the editor every time we change document key in the config i.e after every edit and save?

  • after I edit and save in the editor, I am updating the key, but this doesn’t update the editor. So I had to destroyEditor() and then reconnect again to make the updated key work but UX is bad as the editor refreshes on every save so I need a solution. The pseudo code on what I am doing currently:
  let docEditor;
	const connectEditor = () => {
		try {
			let editor = new DocsAPI.DocEditor(editorDivId, config);
			docEditor = editor;
		} catch (error) {
       const reloadEditor = () => {
		if (docEditor) {
			docEditor = undefined;

       //some event triggered after document edit and save
       config.document.key = <some new key>
        //but only updating key in the config is not actually updating the key in the editor, 
        //unless I explicitly do

Hello @bipana.shrestha ,
Yes, it is necessary to reinitialize document editor.

Hello @Farkhod, thanks for replying. Wanted to ask if docEditor.destroyEditor() is necessary? Or just connectEditor() will be enough after updating the key?

It does not matter, which way you are going to do this. You can even reload the webpage manually. The main point is to reinitialize the document editor.

@Farkhod The issue I have is when I am editing the doc, say if I am on page 3 and I edit and save then reinitialize the editor. But I lose my place in the editor i.e on page 3. How can I retain my place in the editor after reinitializing?

You can do this by using “Bookmarks”.

But doesn’t this mean the editor needs to add bookmarks manually from the editor and we can’t do it for the editors on every edit and save i.e reinitialize. We cannot trigger the event onMakeActionLink unless the editor adds the bookmark from within the editor and therefore don’t have action_data to create the link . Here “we” means document manager @Farkhod

If you want to open a document at a particular place, the only way to do it is via bookmarks and action links.