trix
trix copied to clipboard
Paste does not handle mixed content
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
- Go to https://trix-editor.org/
- Inside the editor, copy the first header and the paragraph following it
- Put the cursor at the end of the first header (i.e. (
Trix[]) - Paste

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();
This issue has been automatically marked as stale after 90 days of inactivity. It will be closed if no further activity occurs.