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:
parent
5f9d1fa799
commit
d51e116298
@ -117,7 +117,15 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
}
|
||||
|
||||
// Remove spaces from empty paragraphs.
|
||||
event.content = event.content.replace( /<p>(?: |\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 ( /^( |\s|\u00a0|\ufeff)+$/i.test( text ) ) {
|
||||
return '<p><br /></p>';
|
||||
}
|
||||
|
||||
return tag;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user