javascript - insert HTML with style into a QuillJS? - Stack Overflow

How to insert html with style (css) to quillJS.I have html like:var data = '<p style="col

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

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

or

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

i paste it by

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

text load but format is:

<p>tesst</p>

without all styles. Please help.

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

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

or

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

i paste it by

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

text load but format is:

<p>tesst</p>

without all styles. Please help.

Share Improve this question asked Jul 12, 2019 at 8:07 KakerKaker 6451 gold badge11 silver badges25 bronze badges 2
  • stackoverflow./a/56846200/4051471 – shrys Commented Jul 12, 2019 at 8:09
  • @shrys this is not the solution for me – Kaker Commented Jul 12, 2019 at 9:09
Add a ment  | 

1 Answer 1

Reset to default 5

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);

Checkout this

<!-- Include stylesheet -->
<link href="https://cdn.quilljs./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./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>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744630212a4584813.html

相关推荐

  • javascript - insert HTML with style into a QuillJS? - Stack Overflow

    How to insert html with style (css) to quillJS.I have html like:var data = '<p style="col

    1天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信