trix icon indicating copy to clipboard operation
trix copied to clipboard

Paste does not handle mixed content

Open oskarolsson-jimdo opened this issue 7 years ago • 1 comments

When pasting content containing both a header and normal text, if pasting or at the end of another header the pasted content gets incorrect structure.

Steps to Reproduce
  1. Go to https://trix-editor.org/
  2. Inside the editor, copy the first header and the paragraph following it
  3. Put the cursor at the end of the first header (i.e. (Trix[])
  4. Paste

peek 2019-02-11 14-17

Output:

<h1>Trix</h1>
<h1><h1>Trix</h1></h1>
<h1>Trix is an open-source project from <a href="https://basecamp.com/">Basecamp</a>, the creators of Ruby on Rails. Millions of people trust their text to Basecamp, and we built Trix to give them the best possible editing experience.</h1>
<div>Trix is an open-source project from <a href="https://basecamp.com/">Basecamp</a>, the creators of Ruby on Rails. Millions of people trust their text to Basecamp, and we built Trix to give them the best possible editing experience.</div>

Expected Output:

<h1>TrixTrix</h1>
<div>Trix is an open-source project from <a href="https://basecamp.com/">Basecamp</a>, the creators of Ruby on Rails. Millions of people trust their text to Basecamp, and we built Trix to give them the best possible editing experience.</div>
<div>Trix is an open-source project from <a href="https://basecamp.com/">Basecamp</a>, the creators of Ruby on Rails. Millions of people trust their text to Basecamp, and we built Trix to give them the best possible editing experience.</div>
Details
  • Trix version: 1.0.0
  • Browser name and version: Crome Version 72.0.3626.81
  • Operating system: Ubuntu 18.04.1 LTS
Test Case
  test "paste complex html to end of header", (done) -> 
    typeCharacters "header1", ->
      clickToolbarButton attribute: "heading1", ->
        pasteContent "text/html", "<h1>header2</h1><div>paragraph</div>", ->
          doc = getDocument()
          assert.equal doc.getBlockCount(), 2
          block = doc.getBlockAtIndex(0)
          assert.deepEqual block.getAttributes(), ["heading1"]
          block = doc.getBlockAtIndex(1)
          assert.deepEqual block.getAttributes(), []

          output = document.querySelector("trix-editor").value
          assert.equal output, "<h1>header1header2</h1><div>paragraph</div>"
          done();

oskarolsson-jimdo avatar Feb 11 '19 13:02 oskarolsson-jimdo

This issue has been automatically marked as stale after 90 days of inactivity. It will be closed if no further activity occurs.

stale[bot] avatar May 12 '19 17:05 stale[bot]