133 | | // Remove spaces from empty paragraphs. |
134 | | // Try to avoid a lot of backtracking, can freeze the editor. See #35890 and #38294. |
135 | | event.content = event.content.replace( /<p>([^<>]+)<\/p>/gi, function( tag, text ) { |
136 | | if ( text === ' ' || ! /\S/.test( text ) ) { |
137 | | return '<p><br /></p>'; |
| 135 | editor.on( 'setcontent', function() { |
| 136 | // Remove spaces from empty paragraphs. |
| 137 | editor.$( 'p' ).each( function( i, node ) { |
| 138 | if ( node.innerHTML && node.innerHTML.length < 10 ) { |
| 139 | var html = tinymce.trim( node.innerHTML ); |
| 140 | |
| 141 | if ( ! html || html === ' ' ) { |
| 142 | node.innerHTML = ( tinymce.Env.ie && tinymce.Env.ie < 11 ) ? '' : '<br data-mce-bogus="1">'; |