Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
556 views
in Technique[技术] by (71.8m points)

javascript - Why does Quill filter its content?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:

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:

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...