问题描述
当我使用 QuillJs 编辑现有 HTML 文档时,它会删除原始 HTML 的注释、缩进等.有没有办法防止这种情况发生?
Quill 不支持任意 HTML.默认情况下,任何无法识别的内容都将在可能的情况下被转换( 标记为
标记),否则将被删除.>
在Quill 配置选项中,使用名为formats
.此属性中定义的格式将创建一个白名单,其中任何不在其中的内容都将被过滤.可以在此处找到所有格式的列表.
欲了解更多信息,请访问以下链接:
要添加对新格式的支持,您需要创建一种新格式.请参阅以下链接以了解如何做到这一点:
作为提示,如果您想创建 Blot,并且希望仅允许对其进行整体编辑或删除,请将您的 Blot 设置为 嵌入.
编辑(2019 年 12 月 20 日)
我忘了说:如果你是将内容粘贴到编辑器,你最好看看 剪贴板模块.
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?
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.
这篇关于为什么 Quill 过滤其内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!