basecamp / trix

A rich text editor for everyday writing
https://trix-editor.org/
MIT License
19.15k stars 1.12k forks source link

Quote and code blocks merge if adjacent #433

Open emilbruckner opened 7 years ago

emilbruckner commented 7 years ago

When there are no paragraphs between two blockquotes, the blockquotes get merged into one. That alone is a problem for me (I sort content by blocks), but the biggest problem is, that not even any newline is kept → two words of different paragraphs become a single word It's the same with code-blocks

I would suggest that two blocks always stay two blocks. Is there a quick way to solve this via the api? Thank you

screen recording 2017-07-30 at 02 29 pm screen recording 2017-07-30 at 02 30 pm

Steps to Reproduce
  1. in line 1, create a quote and write something
  2. press enter 3 times
  3. create a quote and write something
  4. delete line 2
Details
javan commented 7 years ago

Hey @emilbruckner, I've confirmed this issue and agree that the outcome is not correct. There should either be two blocks or a single merged block with a newline between the two texts after deleting the empty block. Curiously, it works correctly with heading blocks.

djhopper01 commented 6 years ago

Hi @emilbruckner and @javan,

I was doing a little digging into this issue and documented a few things.

As @javan mentioned, it works correctly with heading blocks. The document ends up having two blocks with the heading1 attribute. The generated html is <h1>abc</h1><h1>def</h1>.

After following the steps to reproduce from @emilbruckner, the document also ends up having two blocks - this time with quote attribute. However, the generated html is <blockquote>abcdef</blockquote>.

I'm not too familiar with the source yet, so pardon me if any of this is obvious. If you set group: false for quote in src/trix/config/block_attributes.coffee, the generated html becomes <blockquote>abc</blockquote><blockquote>def</blockquote>. However, this breaks a handful of tests, so I'm not sure if this is the right to go about it.

stale[bot] commented 6 years ago

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

emilbruckner commented 6 years ago

I currently don’t work with trix, but I just tested this and the issue still exists. I haven’t looked into @djhopper01’s suggestion though

@javan I’ll leave it up to you whether this should be closed.

anew-bhav commented 6 years ago

@javan I am interested to look into the issue and submit a PR possibly

marcw commented 2 months ago

It is possible to change the behavior of quote by customizing Trix configuration

Trix.config.blockAttributes.quote = { tagName: "blockquote", nestable: true, group: false };