diff --git a/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js b/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js index 62c786783b..f7f2b3cd40 100644 --- a/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js @@ -355,13 +355,20 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } // Keep empty paragraphs :( - e.content = e.content.replace( /

(
|\u00a0|\uFEFF)?<\/p>/g, '

 

' ); + e.content = e.content.replace( /

(?:
|\u00a0|\uFEFF| )*<\/p>/g, '

 

' ); if ( editor.getParam( 'wpautop', true ) && typeof window.switchEditors !== 'undefined' ) { e.content = window.switchEditors.pre_wpautop( e.content ); } }); + // Remove spaces from empty paragraphs. + editor.on( 'BeforeSetContent', function( event ) { + if ( event.content ) { + event.content = event.content.replace( /

(?: |\u00a0|\uFEFF| )+<\/p>/gi, '

' ); + } + }); + editor.on( 'preInit', function() { // Don't replace with and with and don't remove them when empty editor.schema.addValidElements( '@[id|accesskey|class|dir|lang|style|tabindex|title|contenteditable|draggable|dropzone|hidden|spellcheck|translate],i,b' );