// Revisions data will be available under a global variable `revisions`.const revisions =[{"id":"initial","name":"Initial revision","creatorId":"user-1","authorsIds":["user-1"],"diffData":{"main":{"insertions":'[{"name":"h1","attributes":[],"children":["PUBLISHING AGREEMENT"]},{"name":"h3","attributes":[],"children":["Introduction"]},{"name":"p","attributes":[],"children":["This publishing contract, the “contract”, is entered into as of ………… by and between The Lower Shelf, the “Publisher”, and …………, the “Author”."]},{"name":"h3","attributes":[],"children":["Grant of Rights"]},{"name":"p","attributes":[],"children":["The Author grants the Publisher full right and title to the following, in perpetuity:"]},{"name":"ul","attributes":[],"children":[{"name":"li","attributes":[],"children":["To publish, sell, and profit from the listed works in all languages and formats in existence today and at any point in the future."]},{"name":"li","attributes":[],"children":["To create or devise modified, abridged, or derivative works based on the works listed."]},{"name":"li","attributes":[],"children":["To allow others to use the listed works at their discretion, without providing additional compensation to the Author."]}]},{"name":"p","attributes":[],"children":["These rights are granted by the Author on behalf of him/herself and their successors, heirs, executors, and any other party who may attempt to lay claim to these rights at any point now or in the future."]},{"name":"p","attributes":[],"children":["Any rights not granted to the Publisher above remain with the Author."]},{"name":"p","attributes":[],"children":["The rights granted to the Publisher by the Author shall not be constrained by geographic territories and are considered global in nature."]},{"name":"p","attributes":[],"children":["Publishing formats are enumerated in Appendix A."]}]',"deletions":'[{"name":"h1","attributes":[],"children":["PUBLISHING AGREEMENT"]},{"name":"h3","attributes":[],"children":["Introduction"]},{"name":"p","attributes":[],"children":["This publishing contract, the “contract”, is entered into as of ………… by and between The Lower Shelf, the “Publisher”, and …………, the “Author”."]},{"name":"h3","attributes":[],"children":["Grant of Rights"]},{"name":"p","attributes":[],"children":["The Author grants the Publisher full right and title to the following, in perpetuity:"]},{"name":"ul","attributes":[],"children":[{"name":"li","attributes":[],"children":["To publish, sell, and profit from the listed works in all languages and formats in existence today and at any point in the future."]},{"name":"li","attributes":[],"children":["To create or devise modified, abridged, or derivative works based on the works listed."]},{"name":"li","attributes":[],"children":["To allow others to use the listed works at their discretion, without providing additional compensation to the Author."]}]},{"name":"p","attributes":[],"children":["These rights are granted by the Author on behalf of him/herself and their successors, heirs, executors, and any other party who may attempt to lay claim to these rights at any point now or in the future."]},{"name":"p","attributes":[],"children":["Any rights not granted to the Publisher above remain with the Author."]},{"name":"p","attributes":[],"children":["The rights granted to the Publisher by the Author shall not be constrained by geographic territories and are considered global in nature."]},{"name":"p","attributes":[],"children":["Publishing formats are enumerated in Appendix A."]}]'}},"createdAt":"2024-05-27T13:22:59.077Z","attributes":{},"fromVersion":1,"toVersion":1},{"id":"e6f80e6be6ee6057fd5a449ab13fba25d","name":"Updated with the actual data","creatorId":"user-1","authorsIds":["user-1"],"diffData":{"main":{"insertions":'[{"name":"h1","attributes":[],"children":["PUBLISHING AGREEMENT"]},{"name":"h3","attributes":[],"children":["Introduction"]},{"name":"p","attributes":[],"children":["This publishing contract, the “contract”, is entered into as of ",{"name":"revision-start","attributes":[["name","insertion:user-1:0"]],"children":[]},"1st",{"name":"revision-end","attributes":[["name","insertion:user-1:0"]],"children":[]}," ",{"name":"revision-start","attributes":[["name","insertion:user-1:1"]],"children":[]},"June 2020 ",{"name":"revision-end","attributes":[["name","insertion:user-1:1"]],"children":[]},"by and between The Lower Shelf, the “Publisher”, and ",{"name":"revision-start","attributes":[["name","insertion:user-1:2"]],"children":[]},"John Smith",{"name":"revision-end","attributes":[["name","insertion:user-1:2"]],"children":[]},", the “Author”."]},{"name":"h3","attributes":[],"children":["Grant of Rights"]},{"name":"p","attributes":[],"children":["The Author grants the Publisher full right and title to the following, in perpetuity:"]},{"name":"ul","attributes":[],"children":[{"name":"li","attributes":[],"children":["To publish, sell, and profit from the listed works in all languages and formats in existence today and at any point in the future."]},{"name":"li","attributes":[],"children":["To create or devise modified, abridged, or derivative works based on the works listed."]},{"name":"li","attributes":[],"children":["To allow others to use the listed works at their discretion, without providing additional compensation to the Author."]}]},{"name":"p","attributes":[],"children":["These rights are granted by the Author on behalf of him and their successors, heirs, executors, and any other party who may attempt to lay claim to these rights at any point now or in the future."]},{"name":"p","attributes":[],"children":["Any rights not granted to the Publisher above remain with the Author."]},{"name":"p","attributes":[],"children":["The rights granted to the Publisher by the Author shall not be constrained by geographic territories and are considered global in nature."]}]',"deletions":'[{"name":"h1","attributes":[],"children":["PUBLISHING AGREEMENT"]},{"name":"h3","attributes":[],"children":["Introduction"]},{"name":"p","attributes":[],"children":["This publishing contract, the “contract”, is entered into as of ",{"name":"revision-start","attributes":[["name","deletion:user-1:0"]],"children":[]},"…………",{"name":"revision-end","attributes":[["name","deletion:user-1:0"]],"children":[]}," by and between The Lower Shelf, the “Publisher”, and ",{"name":"revision-start","attributes":[["name","deletion:user-1:1"]],"children":[]},"…………",{"name":"revision-end","attributes":[["name","deletion:user-1:1"]],"children":[]},", the “Author”."]},{"name":"h3","attributes":[],"children":["Grant of Rights"]},{"name":"p","attributes":[],"children":["The Author grants the Publisher full right and title to the following, in perpetuity:"]},{"name":"ul","attributes":[],"children":[{"name":"li","attributes":[],"children":["To publish, sell, and profit from the listed works in all languages and formats in existence today and at any point in the future."]},{"name":"li","attributes":[],"children":["To create or devise modified, abridged, or derivative works based on the works listed."]},{"name":"li","attributes":[],"children":["To allow others to use the listed works at their discretion, without providing additional compensation to the Author."]}]},{"name":"p","attributes":[],"children":["These rights are granted by the Author on behalf of him",{"name":"revision-start","attributes":[["name","deletion:user-1:2"]],"children":[]},"/herself",{"name":"revision-end","attributes":[["name","deletion:user-1:2"]],"children":[]}," and their successors, heirs, executors, and any other party who may attempt to lay claim to these rights at any point now or in the future."]},{"name":"p","attributes":[],"children":["Any rights not granted to the Publisher above remain with the Author."]},{"name":"p","attributes":[],"children":["The rights granted to the Publisher by the Author shall not be constrained by geographic territories and are considered global in nature.",{"name":"revision-start","attributes":[["name","deletion:user-1:3"]],"children":[]}]},{"name":"p","attributes":[],"children":["Publishing formats are enumerated in Appendix A.",{"name":"revision-end","attributes":[["name","deletion:user-1:3"]],"children":[]}]}]'}},"createdAt":"2024-05-27T13:23:52.553Z","attributes":{},"fromVersion":1,"toVersion":20},{"id":"e6590c50ccbc86acacb7d27231ad32064","name":"Inserted logo","creatorId":"user-1","authorsIds":["user-1"],"diffData":{"main":{"insertions":'[{"name":"figure","attributes":[["data-revision-start-before","insertion:user-1:0"],["class","image"]],"children":[{"name":"img","attributes":[["src","https://ckeditor.npmjs.net.cn/docs/ckeditor5/latest/assets/img/revision-history-demo.png"]],"children":[]}]},{"name":"h1","attributes":[],"children":[{"name":"revision-end","attributes":[["name","insertion:user-1:0"]],"children":[]},"PUBLISHING AGREEMENT"]},{"name":"h3","attributes":[],"children":["Introduction"]},{"name":"p","attributes":[],"children":["This publishing contract, the “contract”, is entered into as of 1st June 2020 by and between The Lower Shelf, the “Publisher”, and John Smith, the “Author”."]},{"name":"h3","attributes":[],"children":["Grant of Rights"]},{"name":"p","attributes":[],"children":["The Author grants the Publisher full right and title to the following, in perpetuity:"]},{"name":"ul","attributes":[],"children":[{"name":"li","attributes":[],"children":["To publish, sell, and profit from the listed works in all languages and formats in existence today and at any point in the future."]},{"name":"li","attributes":[],"children":["To create or devise modified, abridged, or derivative works based on the works listed."]},{"name":"li","attributes":[],"children":["To allow others to use the listed works at their discretion, without providing additional compensation to the Author."]}]},{"name":"p","attributes":[],"children":["These rights are granted by the Author on behalf of him and their successors, heirs, executors, and any other party who may attempt to lay claim to these rights at any point now or in the future."]},{"name":"p","attributes":[],"children":["Any rights not granted to the Publisher above remain with the Author."]},{"name":"p","attributes":[],"children":["The rights granted to the Publisher by the Author shall not be constrained by geographic territories and are considered global in nature."]}]',"deletions":'[{"name":"h1","attributes":[["data-revision-start-before","deletion:user-1:0"]],"children":[{"name":"revision-end","attributes":[["name","deletion:user-1:0"]],"children":[]},"PUBLISHING AGREEMENT"]},{"name":"h3","attributes":[],"children":["Introduction"]},{"name":"p","attributes":[],"children":["This publishing contract, the “contract”, is entered into as of 1st June 2020 by and between The Lower Shelf, the “Publisher”, and John Smith, the “Author”."]},{"name":"h3","attributes":[],"children":["Grant of Rights"]},{"name":"p","attributes":[],"children":["The Author grants the Publisher full right and title to the following, in perpetuity:"]},{"name":"ul","attributes":[],"children":[{"name":"li","attributes":[],"children":["To publish, sell, and profit from the listed works in all languages and formats in existence today and at any point in the future."]},{"name":"li","attributes":[],"children":["To create or devise modified, abridged, or derivative works based on the works listed."]},{"name":"li","attributes":[],"children":["To allow others to use the listed works at their discretion, without providing additional compensation to the Author."]}]},{"name":"p","attributes":[],"children":["These rights are granted by the Author on behalf of him and their successors, heirs, executors, and any other party who may attempt to lay claim to these rights at any point now or in the future."]},{"name":"p","attributes":[],"children":["Any rights not granted to the Publisher above remain with the Author."]},{"name":"p","attributes":[],"children":["The rights granted to the Publisher by the Author shall not be constrained by geographic territories and are considered global in nature."]}]'}},"createdAt":"2024-05-27T13:26:39.252Z","attributes":{},"fromVersion":20,"toVersion":24},// An empty current revision.{"id":"egh91t5jccbi894cacxx7dz7t36aj3k021","name":null,"creatorId":null,"authorsIds":[],"diffData":{"main":{"insertions":'[{"name":"figure","attributes":[["class","image"]],"children":[{"name":"img","attributes":[["src","https://ckeditor.npmjs.net.cn/docs/ckeditor5/latest/assets/img/revision-history-demo.png"]],"children":[]}]},{"name":"h1","attributes":[],"children":["PUBLISHING AGREEMENT"]},{"name":"h3","attributes":[],"children":["Introduction"]},{"name":"p","attributes":[],"children":["This publishing contract, the “contract”, is entered into as of 1st June 2020 by and between The Lower Shelf, the “Publisher”, and John Smith, the “Author”."]},{"name":"h3","attributes":[],"children":["Grant of Rights"]},{"name":"p","attributes":[],"children":["The Author grants the Publisher full right and title to the following, in perpetuity:"]},{"name":"ul","attributes":[],"children":[{"name":"li","attributes":[],"children":["To publish, sell, and profit from the listed works in all languages and formats in existence today and at any point in the future."]},{"name":"li","attributes":[],"children":["To create or devise modified, abridged, or derivative works based on the works listed."]},{"name":"li","attributes":[],"children":["To allow others to use the listed works at their discretion, without providing additional compensation to the Author."]}]},{"name":"p","attributes":[],"children":["These rights are granted by the Author on behalf of him and their successors, heirs, executors, and any other party who may attempt to lay claim to these rights at any point now or in the future."]},{"name":"p","attributes":[],"children":["Any rights not granted to the Publisher above remain with the Author."]},{"name":"p","attributes":[],"children":["The rights granted to the Publisher by the Author shall not be constrained by geographic territories and are considered global in nature."]}]',"deletions":'[{"name":"h1","attributes":[],"children":["PUBLISHING AGREEMENT"]},{"name":"h3","attributes":[],"children":["Introduction"]},{"name":"p","attributes":[],"children":["This publishing contract, the “contract”, is entered into as of 1st June 2020 by and between The Lower Shelf, the “Publisher”, and John Smith, the “Author”."]},{"name":"h3","attributes":[],"children":["Grant of Rights"]},{"name":"p","attributes":[],"children":["The Author grants the Publisher full right and title to the following, in perpetuity:"]},{"name":"ul","attributes":[],"children":[{"name":"li","attributes":[],"children":["To publish, sell, and profit from the listed works in all languages and formats in existence today and at any point in the future."]},{"name":"li","attributes":[],"children":["To create or devise modified, abridged, or derivative works based on the works listed."]},{"name":"li","attributes":[],"children":["To allow others to use the listed works at their discretion, without providing additional compensation to the Author."]}]},{"name":"p","attributes":[],"children":["These rights are granted by the Author on behalf of him and their successors, heirs, executors, and any other party who may attempt to lay claim to these rights at any point now or in the future."]},{"name":"p","attributes":[],"children":["Any rights not granted to the Publisher above remain with the Author."]},{"name":"p","attributes":[],"children":["The rights granted to the Publisher by the Author shall not be constrained by geographic territories and are considered global in nature."]}]'}},"createdAt":"2024-05-27T13:26:39.252Z","attributes":{},"fromVersion":24,"toVersion":24}];
然后,修改 RevisionHistoryIntegration 插件以从 revisions 数组中读取数据,并使用 RevisionsRepository API 将其加载到编辑器中。
如果您的应用程序需要异步地从服务器请求修订数据,您可以创建一个插件,从数据库中获取数据,而不是将数据放在 HTML 源代码中。在这种情况下,您的插件应该 从 Plugin.init 方法返回一个 Promise,以确保编辑器初始化等待您的数据。
然后,使用该数据以您选择的方式将其保存在您的数据库中。请参阅以下示例。请记住更新您的 HTML 结构以包含一个具有 get-data ID 的按钮,例如 <button id="get-data">获取编辑器数据</button>。
ClassicEditor
.create(document.querySelector('#editor'), editorConfig).then(editor=>{// After the editor is initialized, add an action to be performed after a button is clicked.
document.querySelector('#get-data').addEventListener('click',()=>{const revisionHistory = editor.plugins.get('RevisionHistory');// Get the document data and the revisions data (in JSON format, so it is easier to save).const editorData = editor.data.get();const revisionsData = revisionHistory.getRevisions({toJSON:true});// Now, use `editorData` and `revisionsData` to save the data in your application.//// Note: it is a good idea to verify the revision `creatorId` parameter when saving// a revision in the database. However, do not overwrite the value if it was set to `null`!
console.log( editorData );
console.log( revisionsData );});}).catch(error=> console.error( error ));
This publishing contract, the “contract”, is entered into as of 1st June 2020 by and between The Lower Shelf, the “Publisher”, and John Smith, the “Author”.
Grant of Rights
The Author grants the Publisher full right and title to the following, in perpetuity:
To publish, sell, and profit from the listed works in all languages and formats in existence today and at any point in the future.
To create or devise modified, abridged, or derivative works based on the works listed.
To allow others to use the listed works at their discretion, without providing additional compensation to the Author.
These rights are granted by the Author on behalf of him and their successors, heirs, executors, and any other party who may attempt to lay claim to these rights at any point now or in the future.
Any rights not granted to the Publisher above remain with the Author.
The rights granted to the Publisher by the Author shall not be constrained by geographic territories and are considered global in nature.
控制台
// Use the `Save revisions` button to see the result...
// Revisions data will be available under a global variable `revisions`.const revisions =[{"id":"initial","name":"Initial revision","creatorId":"user-1","authorsIds":["user-1"],"diffData":{"main":{"insertions":'[{"name":"h1","attributes":[],"children":["PUBLISHING AGREEMENT"]},{"name":"h3","attributes":[],"children":["Introduction"]},{"name":"p","attributes":[],"children":["This publishing contract, the “contract”, is entered into as of ………… by and between The Lower Shelf, the “Publisher”, and …………, the “Author”."]},{"name":"h3","attributes":[],"children":["Grant of Rights"]},{"name":"p","attributes":[],"children":["The Author grants the Publisher full right and title to the following, in perpetuity:"]},{"name":"ul","attributes":[],"children":[{"name":"li","attributes":[],"children":["To publish, sell, and profit from the listed works in all languages and formats in existence today and at any point in the future."]},{"name":"li","attributes":[],"children":["To create or devise modified, abridged, or derivative works based on the works listed."]},{"name":"li","attributes":[],"children":["To allow others to use the listed works at their discretion, without providing additional compensation to the Author."]}]},{"name":"p","attributes":[],"children":["These rights are granted by the Author on behalf of him/herself and their successors, heirs, executors, and any other party who may attempt to lay claim to these rights at any point now or in the future."]},{"name":"p","attributes":[],"children":["Any rights not granted to the Publisher above remain with the Author."]},{"name":"p","attributes":[],"children":["The rights granted to the Publisher by the Author shall not be constrained by geographic territories and are considered global in nature."]},{"name":"p","attributes":[],"children":["Publishing formats are enumerated in Appendix A."]}]',"deletions":'[{"name":"h1","attributes":[],"children":["PUBLISHING AGREEMENT"]},{"name":"h3","attributes":[],"children":["Introduction"]},{"name":"p","attributes":[],"children":["This publishing contract, the “contract”, is entered into as of ………… by and between The Lower Shelf, the “Publisher”, and …………, the “Author”."]},{"name":"h3","attributes":[],"children":["Grant of Rights"]},{"name":"p","attributes":[],"children":["The Author grants the Publisher full right and title to the following, in perpetuity:"]},{"name":"ul","attributes":[],"children":[{"name":"li","attributes":[],"children":["To publish, sell, and profit from the listed works in all languages and formats in existence today and at any point in the future."]},{"name":"li","attributes":[],"children":["To create or devise modified, abridged, or derivative works based on the works listed."]},{"name":"li","attributes":[],"children":["To allow others to use the listed works at their discretion, without providing additional compensation to the Author."]}]},{"name":"p","attributes":[],"children":["These rights are granted by the Author on behalf of him/herself and their successors, heirs, executors, and any other party who may attempt to lay claim to these rights at any point now or in the future."]},{"name":"p","attributes":[],"children":["Any rights not granted to the Publisher above remain with the Author."]},{"name":"p","attributes":[],"children":["The rights granted to the Publisher by the Author shall not be constrained by geographic territories and are considered global in nature."]},{"name":"p","attributes":[],"children":["Publishing formats are enumerated in Appendix A."]}]'}},"createdAt":"2024-05-27T13:22:59.077Z","attributes":{},"fromVersion":1,"toVersion":1},{"id":"e6f80e6be6ee6057fd5a449ab13fba25d","name":"Updated with the actual data","creatorId":"user-1","authorsIds":["user-1"],"diffData":{"main":{"insertions":'[{"name":"h1","attributes":[],"children":["PUBLISHING AGREEMENT"]},{"name":"h3","attributes":[],"children":["Introduction"]},{"name":"p","attributes":[],"children":["This publishing contract, the “contract”, is entered into as of ",{"name":"revision-start","attributes":[["name","insertion:user-1:0"]],"children":[]},"1st",{"name":"revision-end","attributes":[["name","insertion:user-1:0"]],"children":[]}," ",{"name":"revision-start","attributes":[["name","insertion:user-1:1"]],"children":[]},"June 2020 ",{"name":"revision-end","attributes":[["name","insertion:user-1:1"]],"children":[]},"by and between The Lower Shelf, the “Publisher”, and ",{"name":"revision-start","attributes":[["name","insertion:user-1:2"]],"children":[]},"John Smith",{"name":"revision-end","attributes":[["name","insertion:user-1:2"]],"children":[]},", the “Author”."]},{"name":"h3","attributes":[],"children":["Grant of Rights"]},{"name":"p","attributes":[],"children":["The Author grants the Publisher full right and title to the following, in perpetuity:"]},{"name":"ul","attributes":[],"children":[{"name":"li","attributes":[],"children":["To publish, sell, and profit from the listed works in all languages and formats in existence today and at any point in the future."]},{"name":"li","attributes":[],"children":["To create or devise modified, abridged, or derivative works based on the works listed."]},{"name":"li","attributes":[],"children":["To allow others to use the listed works at their discretion, without providing additional compensation to the Author."]}]},{"name":"p","attributes":[],"children":["These rights are granted by the Author on behalf of him and their successors, heirs, executors, and any other party who may attempt to lay claim to these rights at any point now or in the future."]},{"name":"p","attributes":[],"children":["Any rights not granted to the Publisher above remain with the Author."]},{"name":"p","attributes":[],"children":["The rights granted to the Publisher by the Author shall not be constrained by geographic territories and are considered global in nature."]}]',"deletions":'[{"name":"h1","attributes":[],"children":["PUBLISHING AGREEMENT"]},{"name":"h3","attributes":[],"children":["Introduction"]},{"name":"p","attributes":[],"children":["This publishing contract, the “contract”, is entered into as of ",{"name":"revision-start","attributes":[["name","deletion:user-1:0"]],"children":[]},"…………",{"name":"revision-end","attributes":[["name","deletion:user-1:0"]],"children":[]}," by and between The Lower Shelf, the “Publisher”, and ",{"name":"revision-start","attributes":[["name","deletion:user-1:1"]],"children":[]},"…………",{"name":"revision-end","attributes":[["name","deletion:user-1:1"]],"children":[]},", the “Author”."]},{"name":"h3","attributes":[],"children":["Grant of Rights"]},{"name":"p","attributes":[],"children":["The Author grants the Publisher full right and title to the following, in perpetuity:"]},{"name":"ul","attributes":[],"children":[{"name":"li","attributes":[],"children":["To publish, sell, and profit from the listed works in all languages and formats in existence today and at any point in the future."]},{"name":"li","attributes":[],"children":["To create or devise modified, abridged, or derivative works based on the works listed."]},{"name":"li","attributes":[],"children":["To allow others to use the listed works at their discretion, without providing additional compensation to the Author."]}]},{"name":"p","attributes":[],"children":["These rights are granted by the Author on behalf of him",{"name":"revision-start","attributes":[["name","deletion:user-1:2"]],"children":[]},"/herself",{"name":"revision-end","attributes":[["name","deletion:user-1:2"]],"children":[]}," and their successors, heirs, executors, and any other party who may attempt to lay claim to these rights at any point now or in the future."]},{"name":"p","attributes":[],"children":["Any rights not granted to the Publisher above remain with the Author."]},{"name":"p","attributes":[],"children":["The rights granted to the Publisher by the Author shall not be constrained by geographic territories and are considered global in nature.",{"name":"revision-start","attributes":[["name","deletion:user-1:3"]],"children":[]}]},{"name":"p","attributes":[],"children":["Publishing formats are enumerated in Appendix A.",{"name":"revision-end","attributes":[["name","deletion:user-1:3"]],"children":[]}]}]'}},"createdAt":"2024-05-27T13:23:52.553Z","attributes":{},"fromVersion":1,"toVersion":20},{"id":"e6590c50ccbc86acacb7d27231ad32064","name":"Inserted logo","creatorId":"user-1","authorsIds":["user-1"],"diffData":{"main":{"insertions":'[{"name":"figure","attributes":[["data-revision-start-before","insertion:user-1:0"],["class","image"]],"children":[{"name":"img","attributes":[["src","https://ckeditor.npmjs.net.cn/docs/ckeditor5/latest/assets/img/revision-history-demo.png"]],"children":[]}]},{"name":"h1","attributes":[],"children":[{"name":"revision-end","attributes":[["name","insertion:user-1:0"]],"children":[]},"PUBLISHING AGREEMENT"]},{"name":"h3","attributes":[],"children":["Introduction"]},{"name":"p","attributes":[],"children":["This publishing contract, the “contract”, is entered into as of 1st June 2020 by and between The Lower Shelf, the “Publisher”, and John Smith, the “Author”."]},{"name":"h3","attributes":[],"children":["Grant of Rights"]},{"name":"p","attributes":[],"children":["The Author grants the Publisher full right and title to the following, in perpetuity:"]},{"name":"ul","attributes":[],"children":[{"name":"li","attributes":[],"children":["To publish, sell, and profit from the listed works in all languages and formats in existence today and at any point in the future."]},{"name":"li","attributes":[],"children":["To create or devise modified, abridged, or derivative works based on the works listed."]},{"name":"li","attributes":[],"children":["To allow others to use the listed works at their discretion, without providing additional compensation to the Author."]}]},{"name":"p","attributes":[],"children":["These rights are granted by the Author on behalf of him and their successors, heirs, executors, and any other party who may attempt to lay claim to these rights at any point now or in the future."]},{"name":"p","attributes":[],"children":["Any rights not granted to the Publisher above remain with the Author."]},{"name":"p","attributes":[],"children":["The rights granted to the Publisher by the Author shall not be constrained by geographic territories and are considered global in nature."]}]',"deletions":'[{"name":"h1","attributes":[["data-revision-start-before","deletion:user-1:0"]],"children":[{"name":"revision-end","attributes":[["name","deletion:user-1:0"]],"children":[]},"PUBLISHING AGREEMENT"]},{"name":"h3","attributes":[],"children":["Introduction"]},{"name":"p","attributes":[],"children":["This publishing contract, the “contract”, is entered into as of 1st June 2020 by and between The Lower Shelf, the “Publisher”, and John Smith, the “Author”."]},{"name":"h3","attributes":[],"children":["Grant of Rights"]},{"name":"p","attributes":[],"children":["The Author grants the Publisher full right and title to the following, in perpetuity:"]},{"name":"ul","attributes":[],"children":[{"name":"li","attributes":[],"children":["To publish, sell, and profit from the listed works in all languages and formats in existence today and at any point in the future."]},{"name":"li","attributes":[],"children":["To create or devise modified, abridged, or derivative works based on the works listed."]},{"name":"li","attributes":[],"children":["To allow others to use the listed works at their discretion, without providing additional compensation to the Author."]}]},{"name":"p","attributes":[],"children":["These rights are granted by the Author on behalf of him and their successors, heirs, executors, and any other party who may attempt to lay claim to these rights at any point now or in the future."]},{"name":"p","attributes":[],"children":["Any rights not granted to the Publisher above remain with the Author."]},{"name":"p","attributes":[],"children":["The rights granted to the Publisher by the Author shall not be constrained by geographic territories and are considered global in nature."]}]'}},"createdAt":"2024-05-27T13:26:39.252Z","attributes":{},"fromVersion":20,"toVersion":24},// An empty current revision.{"id":"egh91t5jccbi894cacxx7dz7t36aj3k021","name":null,"creatorId":null,"authorsIds":[],"diffData":{"main":{"insertions":'[{"name":"figure","attributes":[["class","image"]],"children":[{"name":"img","attributes":[["src","https://ckeditor.npmjs.net.cn/docs/ckeditor5/latest/assets/img/revision-history-demo.png"]],"children":[]}]},{"name":"h1","attributes":[],"children":["PUBLISHING AGREEMENT"]},{"name":"h3","attributes":[],"children":["Introduction"]},{"name":"p","attributes":[],"children":["This publishing contract, the “contract”, is entered into as of 1st June 2020 by and between The Lower Shelf, the “Publisher”, and John Smith, the “Author”."]},{"name":"h3","attributes":[],"children":["Grant of Rights"]},{"name":"p","attributes":[],"children":["The Author grants the Publisher full right and title to the following, in perpetuity:"]},{"name":"ul","attributes":[],"children":[{"name":"li","attributes":[],"children":["To publish, sell, and profit from the listed works in all languages and formats in existence today and at any point in the future."]},{"name":"li","attributes":[],"children":["To create or devise modified, abridged, or derivative works based on the works listed."]},{"name":"li","attributes":[],"children":["To allow others to use the listed works at their discretion, without providing additional compensation to the Author."]}]},{"name":"p","attributes":[],"children":["These rights are granted by the Author on behalf of him and their successors, heirs, executors, and any other party who may attempt to lay claim to these rights at any point now or in the future."]},{"name":"p","attributes":[],"children":["Any rights not granted to the Publisher above remain with the Author."]},{"name":"p","attributes":[],"children":["The rights granted to the Publisher by the Author shall not be constrained by geographic territories and are considered global in nature."]}]',"deletions":'[{"name":"h1","attributes":[],"children":["PUBLISHING AGREEMENT"]},{"name":"h3","attributes":[],"children":["Introduction"]},{"name":"p","attributes":[],"children":["This publishing contract, the “contract”, is entered into as of 1st June 2020 by and between The Lower Shelf, the “Publisher”, and John Smith, the “Author”."]},{"name":"h3","attributes":[],"children":["Grant of Rights"]},{"name":"p","attributes":[],"children":["The Author grants the Publisher full right and title to the following, in perpetuity:"]},{"name":"ul","attributes":[],"children":[{"name":"li","attributes":[],"children":["To publish, sell, and profit from the listed works in all languages and formats in existence today and at any point in the future."]},{"name":"li","attributes":[],"children":["To create or devise modified, abridged, or derivative works based on the works listed."]},{"name":"li","attributes":[],"children":["To allow others to use the listed works at their discretion, without providing additional compensation to the Author."]}]},{"name":"p","attributes":[],"children":["These rights are granted by the Author on behalf of him and their successors, heirs, executors, and any other party who may attempt to lay claim to these rights at any point now or in the future."]},{"name":"p","attributes":[],"children":["Any rights not granted to the Publisher above remain with the Author."]},{"name":"p","attributes":[],"children":["The rights granted to the Publisher by the Author shall not be constrained by geographic territories and are considered global in nature."]}]'}},"createdAt":"2024-05-27T13:26:39.252Z","attributes":{},"fromVersion":24,"toVersion":24}];
// A plugin that introduces the adapter.classRevisionHistoryIntegrationextendsPlugin{staticgetpluginName(){return'RevisionHistoryIntegration';}staticgetrequires(){return['RevisionHistory'];}asyncinit(){const revisionHistory =this.editor.plugins.get('RevisionHistory');
revisionHistory.adapter ={getRevision:({ revisionId })=>{returnthis._findRevision( revisionId );},updateRevisions:revisionsData=>{const documentData =this.editor.getData();// This should be an asynchronous request to your database// that saves `revisionsData` and `documentData`.//// The document data should be saved each time a revision is saved.//// `revisionsData` is an array with objects,// where each object contains updated and new revisions.//// See the API reference for `RevisionHistoryAdapter` to learn// how to correctly integrate the feature with your application.//return Promise.resolve();}};// Add the revisions data for existing revisions.const revisionsData =awaitthis._fetchRevisionsData();for(const revisionData of revisionsData ){
revisionHistory.addRevisionData( revisionData );}}async_findRevision(revisionId){// Get the revision data based on its ID.// This should be an asynchronous request to your database.return Promise.resolve( revisions.find(revision=> revision.id === revisionId ));}async_fetchRevisionsData(){// Get a list of all revisions.// This should be an asynchronous call to your database.//// Note that the revision list should not contain the `diffData` property.// The `diffData` property may be big and will be fetched on demand by `adapter.getRevision()`.return Promise.resolve(revisions.map(revision=>({...revision,diffData:undefined})));}}
This publishing contract, the “contract”, is entered into as of 1st June 2020 by and between The Lower Shelf, the “Publisher”, and John Smith, the “Author”.
Grant of Rights
The Author grants the Publisher full right and title to the following, in perpetuity:
To publish, sell, and profit from the listed works in all languages and formats in existence today and at any point in the future.
To create or devise modified, abridged, or derivative works based on the works listed.
To allow others to use the listed works at their discretion, without providing additional compensation to the Author.
These rights are granted by the Author on behalf of him and their successors, heirs, executors, and any other party who may attempt to lay claim to these rights at any point now or in the future.
Any rights not granted to the Publisher above remain with the Author.
The rights granted to the Publisher by the Author shall not be constrained by geographic territories and are considered global in nature.
修订历史适配器操作控制台
getRevision()
{"id":"egh91t5jccbi894cacxx7dz7t36aj3k021","name":null,"creatorId":null,"authorsIds":[],"diffData":{"main":{"insertions":"[{\"name\":\"figure\",\"attributes\":[[\"class\",\"image\"]],\"children\":[{\"name\":\"img\",\"attributes\":[[\"src\",\"../../../assets/img/revision-history-demo.png\"]],\"children\":[]}]},{\"name\":\"h1\",\"attributes\":[],\"children\":[\"PUBLISHING AGREEMENT\"]},{\"name\":\"h3\",\"attributes\":[],\"children\":[\"Introduction\"]},{\"name\":\"p\",\"attributes\":[],\"children\":[\"This publishing contract, the “contract”, is entered into as of 1st June 2020 by and between The Lower Shelf, the “Publisher”, and John Smith, the “Author”.\"]},{\"name\":\"h3\",\"attributes\":[],\"children\":[\"Grant of Rights\"]},{\"name\":\"p\",\"attributes\":[],\"children\":[\"The Author grants the Publisher full right and title to the following, in perpetuity:\"]},{\"name\":\"ul\",\"attributes\":[],\"children\":[{\"name\":\"li\",\"attributes\":[],\"children\":[\"To publish, sell, and profit from the listed works in all languages and formats in existence today and at any point in the future.\"]},{\"name\":\"li\",\"attributes\":[],\"children\":[\"To create or devise modified, abridged, or derivative works based on the works listed.\"]},{\"name\":\"li\",\"attributes\":[],\"children\":[\"To allow others to use the listed works at their discretion, without providing additional compensation to the Author.\"]}]},{\"name\":\"p\",\"attributes\":[],\"children\":[\"These rights are granted by the Author on behalf of him and their successors, heirs, executors, and any other party who may attempt to lay claim to these rights at any point now or in the future.\"]},{\"name\":\"p\",\"attributes\":[],\"children\":[\"Any rights not granted to the Publisher above remain with the Author.\"]},{\"name\":\"p\",\"attributes\":[],\"children\":[\"The rights granted to the Publisher by the Author shall not be constrained by geographic territories and are considered global in nature.\"]}]","deletions":"[{\"name\":\"h1\",\"attributes\":[],\"children\":[\"PUBLISHING AGREEMENT\"]},{\"name\":\"h3\",\"attributes\":[],\"children\":[\"Introduction\"]},{\"name\":\"p\",\"attributes\":[],\"children\":[\"This publishing contract, the “contract”, is entered into as of 1st June 2020 by and between The Lower Shelf, the “Publisher”, and John Smith, the “Author”.\"]},{\"name\":\"h3\",\"attributes\":[],\"children\":[\"Grant of Rights\"]},{\"name\":\"p\",\"attributes\":[],\"children\":[\"The Author grants the Publisher full right and title to the following, in perpetuity:\"]},{\"name\":\"ul\",\"attributes\":[],\"children\":[{\"name\":\"li\",\"attributes\":[],\"children\":[\"To publish, sell, and profit from the listed works in all languages and formats in existence today and at any point in the future.\"]},{\"name\":\"li\",\"attributes\":[],\"children\":[\"To create or devise modified, abridged, or derivative works based on the works listed.\"]},{\"name\":\"li\",\"attributes\":[],\"children\":[\"To allow others to use the listed works at their discretion, without providing additional compensation to the Author.\"]}]},{\"name\":\"p\",\"attributes\":[],\"children\":[\"These rights are granted by the Author on behalf of him and their successors, heirs, executors, and any other party who may attempt to lay claim to these rights at any point now or in the future.\"]},{\"name\":\"p\",\"attributes\":[],\"children\":[\"Any rights not granted to the Publisher above remain with the Author.\"]},{\"name\":\"p\",\"attributes\":[],\"children\":[\"The rights granted to the Publisher by the Author shall not be constrained by geographic territories and are considered global in nature.\"]}]"}},"createdAt":"2021-05-27T13:26:39.252Z","attributes":{},"fromVersion":24,"toVersion":24}
autosave:{save:asynceditor=>{const revisionTracker = editor.plugins.get('RevisionTracker');await revisionTracker.update();const revisionData = revisionTracker.currentRevision.toJSON();const documentData = editor.getData();// `saveData()` should save the document and revision data in your database// and return a `Promise` that resolves when the save is completed.returnsaveData( documentData, revisionData );}}
// Create a new plugin that will handle the autosave logic.classRevisionHistoryAutosaveIntegrationextendsPlugin{init(){this._saveAfter =100;// Create a new revision after 100 saves.this._autosaveCount =1;// Current autosave counter.this._lastCreatedAt =null;// Revision `createdAt` value, when the revision was last autosaved.}asyncautosave(){const revisionTracker =this.editor.plugins.get('RevisionTracker');const currentRevision = revisionTracker.currentRevision;if( currentRevision.createdAt >this._lastCreatedAt ){// Revision was saved or updated in the meantime by a different source (not autosave).// Reset the counter.this._autosaveCount =1;}if(this._autosaveCount ===this._saveAfter ){// We reached the count. Save all changes as a new revision. Reset the counter.await revisionTracker.saveRevision();this._autosaveCount =1;this._lastCreatedAt = currentRevision.createdAt;}else{// Try updating the "current revision" with the new document changes.// If there are any new changes, the `createdAt` property will change its value.// Do not raise the counter, if the revision has not been updated!await revisionTracker.update();if( currentRevision.createdAt >this._lastCreatedAt ){this._autosaveCount++;this._lastCreatedAt = currentRevision.createdAt;}}returntrue;}}
ClassicEditor
.create( document.querySelector('#editor'),{extraPlugins:[// ...// Add the new plugin to the editor configuration:
RevisionHistoryAutosaveIntegration
],// ...// Add the autosave configuration -- call the plugin method:autosave:{save:editor=>{return editor.plugins.get( RevisionHistoryAutosaveIntegration ).autosave();}}}).catch(error=> console.error( error ));
const revisionTrackerPlugin =this.editor.plugins.get('RevisionTracker');// Updates the "current revision", that is, the revision containing unsaved changes.
revisionTrackerPlugin.update();// Creates a new revision that will contain all the unsaved changes.// See the API reference to learn more.
revisionTrackerPlugin.saveRevision();
revisionTrackerPlugin.saveRevision({name:'My revision'});