Editor: When stripping paragraph tags, and there is a <br> at the beginning or the end, merge them and keep the paragraph, not the <br>.

Props rellect.
Fixes #37066.

git-svn-id: https://develop.svn.wordpress.org/trunk@40787 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2017-05-18 22:55:00 +00:00
parent ee2ffd6ba2
commit eb5320247a
1 changed files with 8 additions and 2 deletions

View File

@ -224,8 +224,14 @@ window.wp = window.wp || {};
// Normalize white space chars and remove multiple line breaks. // Normalize white space chars and remove multiple line breaks.
html = html.replace( /\n[\s\u00a0]+\n/g, '\n\n' ); html = html.replace( /\n[\s\u00a0]+\n/g, '\n\n' );
// Rrplace <br> tags with a line break. // Replace <br> tags with line breaks.
html = html.replace( /\s*<br ?\/?>\s*/gi, '\n' ); html = html.replace( /(\s*)<br ?\/?>\s*/gi, function( match, space ) {
if ( space && space.indexOf( '\n' ) !== -1 ) {
return '\n\n';
}
return '\n';
});
// Fix line breaks around <div>. // Fix line breaks around <div>.
html = html.replace( /\s*<div/g, '\n<div' ); html = html.replace( /\s*<div/g, '\n<div' );