简体   繁体   English

如何使用 Quill 文本编辑器在元素中添加内联样式?

[英]How to add inline style in element with Quill Text Editor?

Jsfiddle提琴手

When inserting content using dangerouslyPasteHTML , inline styles are not inserted?使用dangerouslyPasteHTML插入内容时,未插入内联 styles?

For example, margin-right is not applied to p element.例如,margin-right 不适用于p元素。

How to set inline styles on p element?如何在p元素上设置内联 styles? 在此处输入图像描述

Quoting from the docs :引用文档

dangerouslyPasteHTML危险地粘贴HTML

Inserts content represented by HTML snippet into editor at a given index.将由 HTML 片段表示的内容插入到给定索引处的编辑器中。 The snippet is interpreted by Clipboard matchers, which may not produce the exactly input HTML.该片段由剪贴板匹配器解释,它可能不会产生精确的输入 HTML。

Quill was made as the new generation of WYSIWYG text editor and, by design, prevents arbitrary html insertion which often made previous editors buggy and unreliable. Quill 是作为新一代 WYSIWYG 文本编辑器而设计的,它通过设计防止任意 html 插入,这经常使以前的编辑器出现故障和不可靠。

When you use dangerouslyPasteHTML , Quill is trying to build a representation of the content that makes sense and will strip anything that doesn't fit this representation (which inline-styles are a part of).当您使用dangerouslyPasteHTML时,Quill 会尝试构建有意义的内容表示,并将删除任何不适合此表示的内容(内联样式是其中的一部分)。

If you want to read more about this, here is an interesting conversation on this exact issue: https://github.com/quilljs/quill/issues/1896如果你想了解更多关于这个的信息,这里有一个关于这个确切问题的有趣对话: https://github.com/quilljs/quill/issues/1896

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM