trix icon indicating copy to clipboard operation
trix copied to clipboard

Extra space inserted before paragraphs on paste

Open terreng opened this issue 4 years ago • 1 comments

An extra line is inserted before every paragraph when copying and pasting from a webpage.

Steps to Reproduce
  1. Copy the sample HTML from example 1 on this demo page.
  2. Paste into Trix and observe the extra space before both paragraphs

Copying this HTML results in extra space before both paragraphs, but it shouldn't:

<p>Line 1</p>
<p>Line 2</p>

Here's a video demonstrating the issue:

https://user-images.githubusercontent.com/11605395/121762262-a6d37a00-cae9-11eb-8b15-dcf2912e5d47.mov

Expected result:

Screen Shot 2021-06-11 at 7 18 43 PM

Interestingly, adding margin-top: 0px; to the <p> tags prevents the extra space from being inserted when pasting.

It looks like Trix inserts a new line before / after paragraphs depending on if there was margin, but it fails to understand how margins combine, which results in extra space.

Copying this HTML does not result in extra space before paragraphs:

<p style="margin-top: 0px;">Line 1</p>
<p style="margin-top: 0px;">Line 2</p>
Details
  • Trix version: 1.3.1
  • Browser name and version: Chrome 91, Safari
  • Operating system: macOS, Android, iOS

(This issue doesn't appear to be platform-specific)

terreng avatar Jun 12 '21 02:06 terreng

Is there any fix / work around for this?

Pasting text into Basecamp (which uses Trix) means going through and removing extra spaces between each paragraph.

shofetim avatar Apr 04 '22 19:04 shofetim