我想使用Quill在我的网站上写文章,但我可能需要在某个时候编辑这些文章。
为了从Quill中检索格式化的内容并将其放入数据库,我调用Quill.root.innerHTML,一切都很顺利。
但是,我很难找到如何获取此HTML内容然后将其显示在我的Quill编辑器中,格式与我提交时和页面加载时完全相同。
欢迎任何帮助,提前感谢!
Quill的内容由JSONDelta
格式描述,API使用以下格式为getContents
和setContents
提供方法:
// Retrieve JSON using the Quill API
const delta = quill.getContents()
const ops = delta.ops;
// Store the JSON representation instead of the raw HTML
storeInDB(ops);
然后您可以检索JSON,它应该全部";只是工作":
const ops = fetchFromDB();
quill.setContents(ops);