From 319299d42b339f894b90ebb96923e5c586a7cb0c Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Fri, 6 Jun 2014 04:19:09 +0000 Subject: [PATCH] TinyMCE: remove   from empty paragraphs inside the visual editor, props avryl, fixes #28282 git-svn-id: https://develop.svn.wordpress.org/trunk@28685 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/tinymce/plugins/wordpress/plugin.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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' );