简体   繁体   English

如何在 CKEditor 5 中使用文档编辑器设置数据

[英]How to set Data with document editor in CKEditor 5

I create a system to save the document by cookie, everything works well, but I just miss how to put the text on the document ... I have a DecoupledEditor, but when I try to make DecoupledEditor.setData (cookie) it tells me that setData does not exist!我创建了一个通过 cookie 保存文档的系统,一切正常,但我只是想念如何将文本放在文档上......我有一个 DecoupledEditor,但是当我尝试制作 DecoupledEditor.setData (cookie) 时,它告诉我该 setData 不存在! Have a nice day祝你今天过得愉快

DecoupledEditor.setData(docu);

To get the editor获取编辑器

DecoupledEditor
    .create( document.querySelector.....

Something like this.像这样的东西。

 (async function() { try { const editor = await DecoupledEditor .create( document.querySelector( '#editor' )); editor.setData('This text is generated from setdata() method.'); } catch(e) { console.error(e); } })();
 <script src="https://cdn.ckeditor.com/ckeditor5/23.0.0/decoupled-document/ckeditor.js"></script> <h1>ckeditor</h1> <div id="editor"> Default Text </div>

Doc Refrenence 文档参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM