quill icon indicating copy to clipboard operation
quill copied to clipboard

Pasting HTML with Strong and List Separated by Newline Places the Strong Content within the List

Open chadrschroeder opened this issue 1 year ago • 4 comments

Steps for Reproduction

  1. Copy HTML from a page that includes this:
<strong>one</strong>
<ol>
  <li>two</li>
  <li>three</li>
</ol>
  1. Paste it into the Quill Playground.

Expected behavior:

The editor should show:

one

  1. two
  2. three

Actual behavior:

The editor displays this instead:

  1. onetwo
  2. three

This happens if there is a newline between the <strong> element and the <ol>. For example, it works if the newline isn't there:

// Good
quill.clipboard.dangerouslyPasteHTML('<strong>one</strong><ol><li>two</li><li>three</li></ol>')
<p><strong>one</strong></p><ol><li>two</li><li>three</li></ol>

But the position of the <strong> shifts into the <ol> when there's a newline:

// Bad
quill.clipboard.dangerouslyPasteHTML('<strong>one</strong>\n<ol><li>two</li><li>three</li></ol>')
<ol><li><strong>one</strong>two</li><li>three</li></ol>

Pasting the example works fine in other WYSIWYG editors like Trix.

Platforms: Chrome, macOS Version: 1.3.7

chadrschroeder avatar Jun 26 '23 16:06 chadrschroeder

Hey @luin is it a valid bug? if yes can I try fixing this?

Shubhdeep12 avatar Jul 09 '23 15:07 Shubhdeep12

@Shubhdeep12 Yeah looks like a bug.

luin avatar Feb 03 '24 11:02 luin

Ok thanks for the confirmation @luin , i'll push a fix for this.

Shubhdeep12 avatar Feb 03 '24 11:02 Shubhdeep12

Hi @luin added a PR with fix. Thanks cc @benbro

Shubhdeep12 avatar Feb 03 '24 15:02 Shubhdeep12