Why does Quill filter it's content?

烂漫一生 提交于 2020-01-21 19:24:06

问题


When I use QuillJs to edit an existing HTML document, it removes the comments, indentations etc of the original HTML. Is there anyway to prevent this?


回答1:


Quill does not support arbitrary HTML. By default, anything that is not recognized will be converted (the <strong> tag to the <b> tag) when possible, or removed when not.

In Quill configuration options, use the configuration named formats. The formats defined in this property will create a whitelist, where anything not in it will be filtered. A list of all formats can be found here.

For more information, visit the following links:

  • Quill JavaScript Rich Text Editor restrict tags
  • Suppress certain formats in Quill
  • How to use format whitelist in QuillJS?

To add support for new formats you will need to create a new one. See the following links to find out how this can be done:

  • What, how and when to use static formats, formats and format on custom blot?
  • Cloning Medium with Parchment
  • Parchment API
  • Native examples
  • A emoji blot example

As a tip, if you want to create Blot, and you want to allow it to be only edited or removed as a whole, set your Blot to be a child of Embed.

EDIT (DEC 20, 2019)

I forgot to say something: If you are pasting content to the editor, you better take a look at the clipboard module.



来源:https://stackoverflow.com/questions/59397115/why-does-quill-filter-its-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!