ONLYOFFICE Historical Version Development Technology II

 1. It only supports the historical version of word, PowerPoint and Excel do not support the historical version.
Document history
If the document has been previously edited using Document Editor, you can view the document history.
The history is currently available for text document files only.
After editing in Document Editor the information about the changes during the editing session is sent together with the changed document:
history -this information allows to display the time and the author for each documentversion when you view the document history in the side panel. Must be sent as aproperty changes of the object sent as the argument to the refreshHistory method.This method must be called after the onRequestHistory events.

2. And the historical version can only be viewed and cannot be edited again.
3. But you can see where the changes have been made.
4. The server only keeps the historical version within 1 month.
5. It can be downloaded and re-uploaded for collaboration. This is the value of its existence.
Its principle:
When a collaborative document is closed by the last person, the collaborative server (hereinafter abbreviated as OODS - onlyoffice document server) will return a json data to cms. After cms obtains this data, it parses it into a structure, and then does 2 One thing is that this data contains the address (url) of the latest document in OODS, cms downloads the document according to this url, saves it in cms, and updates the time of this document in the database at the same time - this new The time (updatedtime) is used to open the key of this document next time; another thing is that the data contains the address of the modification record file (changesurl), and the author user of this version, time created, key1 and other information, which is required after cms is obtained. Stored in the database, there is no need to download the real historical version file, as long as the data such as key1, the historical version modification record file address (changesurl).
When the file is opened next time, OO only recognizes the key generated by updatedtime, the key1 of the historical version is stored in the database, check the historical version key1, and OODS will call the version stored in it.
If you think about it, you may have discovered that the file does not actually need to exist locally (cms)? ? Isn't it enough to have key1?

No, the one opened by key1 cannot be edited. Because look at point 2 of the beginning, haha.


Preliminary test code:

//The historical version is kept for 1 month. For example, Unix timestamp (Unix timestamp) expires=1524547423
      var onRequestHistory = function() {
        // var changes=[{
        //     "created":"2018-03-10 14:22:15",
        //     "user":{"id":"8","name":"qin8.xc"}
        // }];
        // alert(changes[0].created);
      	docEditor.refreshHistory({
        "currentVersion": 2,
        "history": [
          {
          	"changes": [{{.changes1}}], //the changes from the history object returned after saving the document
            "created": "2018-03-9 10:15:55",
            "key": "{{.Key}}",//1521951775531484800 This affects historical version switching
            "serverVersion": "{{.serverVersion1}}", //the serverVersion from the history object returned after saving the document
        	  "user": {
        	    "id": "7",
        	    "name": "qin.xc"
        	  },
        	  "version": 1
        	},
        	{
      		  "changes": [{{.changes2}}],
      		  "created": "2018-03-10 14:11:35",
      		  "key": "1521951775531484800",//
      		  "user": {
      		      "id": "8",
      		      "name": "qin8.xc"
      		  },
      		  "version": 2
      		},
        	{
      		  "changes": [{{.changes2}}],
      		  "created": "2018-03-11 14:11:35",
      		  "key": "1521803509579508900",//current version
      		  "user": {
      		      "id": "9",
      		      "name": "qin9.xc"
      		  },
      		  "version": 3
      		},
    		]
  	});
	};

			var onRequestHistoryClose = function() {
  		  document.location.reload();
			};
			var onRequestHistoryData = function(event) {
    		var version = event.data;
    		docEditor.setHistoryData({
    			//The location of the change is stored here - a document attachment corresponds to this address, each update? ?
      		"changesUrl": "http://192.168.99.100:9000/cache/files/1521953170330601700_4540/changes.zip/changes.zip?md5=w6DItkSwyBJkuHDl_CiZZQ==&expires=1524547423&disposition=attachment&ooname=output.zip", //the changesUrl from the JSON object returned after saving the document
      		"key": "",
      		"previous": {
      		  "key": "",//This does not affect version switching
      		  "url": ""//http://192.168.99.100:9000/cache/files/1521953170330601700_4540/output.docx/output.docx?md5=eSwnrSSumTeMuh59IoXhCQ==&expires=1524547423&disposition=attachment&ooname=output.docx here affects version
      		},
      		"url": "",
      		"version":4 //version
    		})
	};

    	window.docEditor = new DocsAPI.DocEditor("placeholder",
      {
        "events": {
          "onRequestHistory": onRequestHistory,
          "onRequestHistoryClose": onRequestHistoryClose,
          "onRequestHistoryData": onRequestHistoryData,
        },

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325533081&siteId=291194637