wysihtml5 icon indicating copy to clipboard operation
wysihtml5 copied to clipboard

Wrap text outside of <p> in <p> when hitting enter with useLineBreaks==false

Open DouweM opened this issue 12 years ago • 2 comments

Suppose that for some reason the body ends up like this (and it has for me):

<p>Hey</p>
Just testing|

Currently, when hitting return with the caret after Just testing, we end up with this:

<p>Hey</p>
Just testing<br>
|

Or worse (in Chrome), this:

<p>Hey</p>
Just testing
<div>|</div>

Using this fix, when useLineBreaks == false, the result will be a clean:

<p>Hey</p>
<p>Just testing</p>
<p>|<br></p>

(The <br> is just there to give the <p> some height, exactly as Wysihtml5 currently behaves when hitting enter from within a <p>.)

It also works great with Shift-Enter, in which case the result would be:

<p>Hey</p>
<p>Just testing<br>
|</p>

DouweM avatar Mar 07 '13 01:03 DouweM

@DouweM, does shift enter also work on safari with this commit?

steverandy avatar Mar 07 '13 03:03 steverandy

I've only tested Shift-Enter in Chrome, so I'm not sure. I'll check it out tomorrow.

DouweM avatar Mar 07 '13 03:03 DouweM