将带有样式的 HTML 插入到 QuillJS 中? [英] insert HTML with style into a QuillJS?

查看:47
本文介绍了将带有样式的 HTML 插入到 QuillJS 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将带有样式(css)的 html 插入到 quillJS.我有 html 喜欢:

How to insert html with style (css) to quillJS. I have html like:

var data = '<p style="color: #f00">tesst</p>';

var data = '<style> .pp { color: #0f0;} </style>
<p class="pp">tesst</p>';

我粘贴了

quill_arr[$('#docbody').attr('quill-id')].clipboard.dangerouslyPasteHTML(data);

文本加载但格式为:

<p>tesst</p>

没有所有样式.请帮忙.

without all styles. Please help.

推荐答案

的样式放在一起似乎可行.

Putting a <span> with the styles inside a <p> seemed to work.

var data = '<p><span style="color: red;">test</span></p>'
quill.clipboard.dangerouslyPasteHTML(data);

看看这个

<!-- Include stylesheet -->
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">

<!-- Create the editor container -->
<div id="editor"></div>

<!-- Include the Quill library -->
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>

<script>
  // Initialize Quill editor
  var quill = new Quill('#editor', {
    theme: 'snow'
  });
  
  // Insert HTML with style
  var data = '<p><span style="color: red;">Hello World!</span></p>'
  quill.clipboard.dangerouslyPasteHTML(data);
</script>

这篇关于将带有样式的 HTML 插入到 QuillJS 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆