简体   繁体   English

如何为羽毛笔编辑器设置内容?

[英]How to set content for quill editor?

I am trying to set content like this:我正在尝试设置这样的内容:

  quill.setContents("<div class='r'>some text</div> ");

But it does not work.但它不起作用。 Please help.请帮忙。

assigning it to the innerHTML usually works.将其分配给 innerHTML 通常有效。 try this quill.root.innerHTML = "<div class='r'>Some text</div>";试试这个quill.root.innerHTML = "<div class='r'>Some text</div>";

For me (Quill 1.3.6), .pasteHTML works:对我来说(Quill 1.3.6) .pasteHTML有效:

quill.pasteHTML("<div class='r'>some text</div> ");

.setText() does not allow the setting of HTML and instead encodes HTML entities to show as plain text. .setText()不允许设置 HTML 而是编码 HTML 实体以显示为纯文本。

.setContents() didn't seem to work at all for me either. .setContents()似乎对我也根本不起作用。

.root.innerHTML() did not work either (threw a Javascript error). .root.innerHTML()也不起作用(抛出 Javascript 错误)。

Using setText you can set HTML data使用 setText 您可以设置 HTML 数据

var quill = new Quill(".editor", {
  modules: {
    toolbar: toolbarOptions
  },
  theme: "snow"
});

quill.setText("<div class='r'>some text</div>");

Read more from quilljs documentquilljs 文档中阅读更多内容

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

相关问题 羽毛笔编辑器 - 在 cursor 的羽毛笔编辑器中插入内容 - Quill editor - insert content in quill editor at the cursor 如何捕获在富文本编辑器 div 中键入的内容 - Quill 富文本编辑器 - How to capture content typed in a rich text editor div - Quill rich editor 羽毛笔编辑器-无法设置点击数据 - Quill Editor - unable to set data on click Quill - 提及不在 Quill JS 编辑器内容中插入提及值(使用 React Quill) - Quill - Mention not inserting mention value in Quill JS editor content (Using React Quill) 如何将 ngx-quill 编辑器内容从我的数据库渲染到视图组件? - How can i render ngx-quill editor content from my database to a view component? 如何在 Angular 中将 html 标签添加到 Quill 文本编辑器的内容 div? - How can I add html tag to the content div of Quill text editor in Angular? 如何使用vue-quill包关注Quill编辑器? - How to focus Quill editor using the vue-quill package? Quill Editor - 获取总行数/动态设置编辑器高度 - Quill Editor - get total number of lines / dynamically set editor height 完成编辑后如何关闭羽毛笔编辑器 - How to close the quill editor when done with editing 如何将 Wiris 或 Mathjax 添加到 Quill 编辑器 - How to add Wiris or Mathjax to Quill editor
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM