Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linebreaks with multiple successive BRs are wrapped in P tags #1341

Closed
kylebragger opened this issue Mar 1, 2017 · 8 comments
Closed

Linebreaks with multiple successive BRs are wrapped in P tags #1341

kylebragger opened this issue Mar 1, 2017 · 8 comments

Comments

@kylebragger
Copy link

Lines with multiple successive <br> tags (created with e.g. Shift+Enter) get wrapped with <p> tags. It seems like this should not be the case, since it turns the hard line break into a bona fide new paragraph, and a user may have e.g. pasted text which contains these types of breaks, or might just want to add multiple hard line breaks for stylistic purposes.

Steps for Reproduction

  1. Type some text in a Quill editor
  2. Pick a point to create a newline and press Shift+Enter (or your OS' equivalent) 2 or more times to add a blank line between the two text blocks
  3. When Quill is re-initialized with that content, the BRs have been wrapped in P tags

Expected behavior:
BRs outside of P tags should be left alone

Actual behavior:
BRs outside of P tags are wrapped in P tags

Platforms:

Chrome 56, Mac OS Sierra

Version:

1.1

@jhchen
Copy link
Member

jhchen commented Mar 13, 2017

Quill wrapping <br> with paragraph tags is by design and has been discussed in numerous other issues.

@kylebragger
Copy link
Author

kylebragger commented Mar 24, 2017

It would seem that I was slightly mistaken before as to what the behavior is that's confusing me.

At least in our editor instance, Quill seems to be inserting an additional <p><br></p> between a <p> and <blockquote>. Do you have any direction on what Quill might be doing there? Maybe related or similar to #797?

(I can provide a demo login for this as well if you'd like to see the issue in our editor.)

@kylebragger
Copy link
Author

I just confirmed this seems to be the case on our end. Even with a few simple paragraphs, if I target one para with CSS and give it a big top margin e.g. p:nth-child(2) { margin-top: 40px; } the same behavior as in #797 occurs; a blank line is inserted above the real 2nd para.

Shall I open a different ticket for this?

@jhchen
Copy link
Member

jhchen commented Mar 25, 2017

Can you produce the issue in a minimal Codepen?

@kylebragger
Copy link
Author

@jhchen here you go: https://jsfiddle.net/y500jh11/11/

Interestingly the bug only happens when the paragraph above the blockquote wraps to multiple lines.

@jhchen
Copy link
Member

jhchen commented Mar 28, 2017

If I understand correctly the issue is you have is if you initialize the contents of Quill as

<div id="editor">
  <p>test</p>
  <blockquote>testing</blockquote>
</div>

You get

<div id="editor">
  <p>test</p>
  <p><br></p>
  <blockquote>testing</blockquote>
</div>

Quill expects its own paragraphs to have so when it sees content with spacing it inserts empty lines to compensate. You can change this behavior by modifying its matchers. Quill uses the same code to handle pasting and initialization.

As a side note if you are saving content to resume an edit session it is highly recommended to be saving Deltas.

If I have misunderstood, please be very explicit in your reproduction steps and what you expect to see and actually see.

@kylebragger
Copy link
Author

kylebragger commented Mar 28, 2017 via email

@youradds
Copy link

If I understand correctly the issue is you have is if you initialize the contents of Quill as

<div id="editor">
  <p>test</p>
  <blockquote>testing</blockquote>
</div>

You get

<div id="editor">
  <p>test</p>
  <p><br></p>
  <blockquote>testing</blockquote>
</div>

Quill expects its own paragraphs to have so when it sees content with spacing it inserts empty lines to compensate. You can change this behavior by modifying its matchers. Quill uses the same code to handle pasting and initialization.

As a side note if you are saving content to resume an edit session it is highly recommended to be saving Deltas.

If I have misunderstood, please be very explicit in your reproduction steps and what you expect to see and actually see.

I'm having this issue now. How are you supposed to deal with it? I'm trying to get what the person sees in the editor to look exactly the same as what they see when its on the static page. This extra line is making that tricky :(

TIA

Andy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants