I have a basic functionality I need to implement and can't find the information on how to do it: I simply want to replace all of CKEditor's content with custom markup and add an undo history entry so you can go back to the version before replacing.
- So the basic command for replacing the content is
editor.setDatabut it won't add an undo history, entry wrapping the call ineditor.model.changewon't change the behavior too. Then there is somewhere deep in the documentationthe information on how to add (but not replace) custom html to the editor which is adding an undo history entry:
this.editor.model.change((writer) => { const html = '<p>aaa</p><ul><li>huu</li><li>zzzz</li></ul><p>ssss</p>' const viewFragment = this.editor.data.processor.toView(html); const modelFragment = this.editor.data.toModel(viewFragment); this.editor.model.insertContent(modelFragment); this.editor.model.insertContent(modelFragment); this.editor.editing.view.scrollToTheSelection(); });
So how do I replace the content of the editor and add an undo history entry? I can only achieve one of the requirements but not both.
