-
Notifications
You must be signed in to change notification settings - Fork 8
New lines pasted as a plain text will always create a new paragraph #64
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -10,21 +10,12 @@ describe( 'plainTextToHtml()', () => { | |||
expect( plainTextToHtml( 'x y <z>' ) ).to.equal( 'x y <z>' ); | |||
} ); | |||
|
|||
it( 'turns double line breaks into paragraphs', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's usually good to leave all the tests of the previous implementation. Right now, we know that a single line break turns into a paragraph. But what about two? This is still a pretty distinctive case. Also, since prior to your changes there was a code which handled double line breaks, how do you know now that it's completely removed? There's actually a non-theoretical chance that that code remained there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Reinmar case with 1, 2, 3 new lines is tested in next test "turns combination of different amount of line breaks to paragraphs":
a\nb\n\nc\n\n\nd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose of the last test is to see if a varying number of line breaks doesn't e.g. cause some tags to be left open.
tests/utils/plaintexttohtml.js
Outdated
@@ -10,21 +10,12 @@ describe( 'plainTextToHtml()', () => { | |||
expect( plainTextToHtml( 'x y <z>' ) ).to.equal( 'x y <z>' ); | |||
} ); | |||
|
|||
it( 'turns double line breaks into paragraphs', () => { | |||
expect( plainTextToHtml( 'x\n\ny\n\nz' ) ).to.equal( '<p>x</p><p>y</p><p>z</p>' ); | |||
it( 'turns single line breaks into paragraphs', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, it's "single line break", not "single line breaks".
Suggested merge commit message (convention)
Other: New lines pasted as a plain text will always create a new paragraph. Closes ckeditor/ckeditor5#1727.
BREAKING CHANGE: From now every new line pasted in editor as a plain text, will create a new paragraph. Read more at ckeditor/ckeditor5#1727.