trix icon indicating copy to clipboard operation
trix copied to clipboard

Inserting Content Attachment deletes existing <br> tag

Open lylo opened this issue 4 years ago • 4 comments

I'm starting with a Trix editor with two text lines, a blank line and a heading:

<div>
  Test<br>
  Test<br>
  <br>
</div>
<h1>Test</h1>

It renders correctly like this:

image

I am then implementing the 'horizontal rule' approach (as described in this comment from @javan a couple of years ago).

I've noticed that if I insert such a content attachment in the blank space, one of the <br> tags is deleted from the DOM - there is now only one after the second Test:

<div>
  <!--block-->Test<br>
  Test<br>
  <span data-trix-cursor-target="left" data-trix-serialize="false"></span>
  <figure contenteditable="false" data-trix-attachment="{&quot;content&quot;:&quot;<hr>&quot;,&quot;contentType&quot;:&quot;application/vnd.trix.horizontal-rule.html&quot;}" data-trix-content-type="application/vnd.trix.horizontal-rule.html" data-trix-id="646" class="attachment attachment--content"><hr><figcaption class="attachment__caption"></figcaption>
  </figure>
  <span data-trix-cursor-target="right" data-trix-serialize="false"></span>
</div>

I'm not entirely sure why this is (I've attempted to look at the Trix code but I'm very unfamiliar with it) but it's causing me an issue further down the line (I won't go into my use case here, unless you want me to). Is it possible for someone to explain why this is happening and where in the code it's doing it?

Interestingly, if the content attachment is deleted, the missing <br> returns!

This fiddle allows you to see the issue in action (you need to inspect the HTML of the Trix editor before and after to see it): https://codepen.io/codepatterns/pen/YzqoKqY.

I would expect the insertion of the content attachment not to remove the <br> tag as it has been typed in on purpose.

Thanks! 🙏

lylo avatar Sep 30 '20 21:09 lylo

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 Mar 11 '21 14:03 stale[bot]

I'd rather this issue wasn't closed until there has been a response from the maintainer. Might that be possible?

lylo avatar Mar 11 '21 16:03 lylo

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 Jun 11 '21 01:06 stale[bot]

I wonder if this repo is no longer maintained since the recent Basecamp ruckus? I think the issue should remain open until a new maintainer or a formal update is made.

lylo avatar Jun 11 '21 07:06 lylo