TinyMCE: fix the regex that removes spaces from empty paragraphs. Was causing problems when wpautop is disabled and there are many U+00A0 chars between the opening <p> and an inline tag. These chars are inserted by the browsers to maintain consecutive spaces typed by the users in contentEditable.

Fixes #35890.

git-svn-id: https://develop.svn.wordpress.org/trunk@36597 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2016-02-20 19:55:03 +00:00
parent 5f9d1fa799
commit d51e116298

View File

@ -117,7 +117,15 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
}
// Remove spaces from empty paragraphs.
event.content = event.content.replace( /<p>(?:&nbsp;|\u00a0|\uFEFF|\s)+<\/p>/gi, '<p><br /></p>' );
// Avoid backtracking, can freeze the editor. See #35890.
// (This is also quite faster than using only one regex.)
event.content = event.content.replace( /<p>([^<>]+)<\/p>/gi, function( tag, text ) {
if ( /^(&nbsp;|\s|\u00a0|\ufeff)+$/i.test( text ) ) {
return '<p><br /></p>';
}
return tag;
});
}
});