From eb5320247a0e18bf403ca5cbbe7305d6b6d2688c Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Thu, 18 May 2017 22:55:00 +0000 Subject: [PATCH] Editor: When stripping paragraph tags, and there is a
at the beginning or the end, merge them and keep the paragraph, not the
. Props rellect. Fixes #37066. git-svn-id: https://develop.svn.wordpress.org/trunk@40787 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/editor.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/js/editor.js b/src/wp-admin/js/editor.js index 03187d9771..0a3437c7b9 100644 --- a/src/wp-admin/js/editor.js +++ b/src/wp-admin/js/editor.js @@ -224,8 +224,14 @@ window.wp = window.wp || {}; // Normalize white space chars and remove multiple line breaks. html = html.replace( /\n[\s\u00a0]+\n/g, '\n\n' ); - // Rrplace
tags with a line break. - html = html.replace( /\s*
\s*/gi, '\n' ); + // Replace
tags with line breaks. + html = html.replace( /(\s*)
\s*/gi, function( match, space ) { + if ( space && space.indexOf( '\n' ) !== -1 ) { + return '\n\n'; + } + + return '\n'; + }); // Fix line breaks around
. html = html.replace( /\s*