TinyMCE: improve removal of spaces from empty paragraphs when loading HTML in the editor.
Fixes #39437. git-svn-id: https://develop.svn.wordpress.org/trunk@39902 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
2fa90d1077
commit
976976b4a1
@ -129,19 +129,22 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
|||||||
'/>';
|
'/>';
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove spaces from empty paragraphs.
|
|
||||||
// Try to avoid a lot of backtracking, can freeze the editor. See #35890 and #38294.
|
|
||||||
event.content = event.content.replace( /<p>([^<>]+)<\/p>/gi, function( tag, text ) {
|
|
||||||
if ( text === ' ' || ! /\S/.test( text ) ) {
|
|
||||||
return '<p><br /></p>';
|
|
||||||
}
|
|
||||||
|
|
||||||
return tag;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
editor.on( 'setcontent', function() {
|
||||||
|
// Remove spaces from empty paragraphs.
|
||||||
|
editor.$( 'p' ).each( function( i, node ) {
|
||||||
|
if ( node.innerHTML && node.innerHTML.length < 10 ) {
|
||||||
|
var html = tinymce.trim( node.innerHTML );
|
||||||
|
|
||||||
|
if ( ! html || html === ' ' ) {
|
||||||
|
node.innerHTML = ( tinymce.Env.ie && tinymce.Env.ie < 11 ) ? '' : '<br data-mce-bogus="1">';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
});
|
||||||
|
|
||||||
editor.on( 'PostProcess', function( event ) {
|
editor.on( 'PostProcess', function( event ) {
|
||||||
if ( event.get ) {
|
if ( event.get ) {
|
||||||
event.content = event.content.replace(/<img[^>]+>/g, function( image ) {
|
event.content = event.content.replace(/<img[^>]+>/g, function( image ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user