Make WordPress Core

Ticket #28282: 28282.2.patch

File 28282.2.patch, 1.2 KB (added by iseulde, 12 years ago)
  • src/wp-includes/js/tinymce/plugins/wordpress/plugin.js

     
    348348                }
    349349
    350350                // Keep empty paragraphs :(
    351                 e.content = e.content.replace( /<p>(<br ?\/?>|\u00a0|\uFEFF)?<\/p>/g, '<p>&nbsp;</p>' );
     351                e.content = e.content.replace( /<p>(?:<br ?\/?>|\ufeff|\s)+?<\/p>/g, '<p>&nbsp;</p>' );
    352352
    353353                if ( editor.getParam( 'wpautop', true ) && typeof window.switchEditors !== 'undefined' ) {
    354354                        e.content = window.switchEditors.pre_wpautop( e.content );
    355355                }
    356356        });
    357357
     358        // Remove spaces from empty paragraphs.
     359        editor.on( 'BeforeSetContent', function( event ) {
     360                if ( event.content ) {
     361                        event.content = event.content.replace( /<p>(?:&nbsp;|\ufeff|\s)+<\/p>/gi, '<p></p>' );
     362                }
     363        });
     364
    358365        editor.on( 'preInit', function() {
    359366                // Don't replace <i> with <em> and <b> with <strong> and don't remove them when empty
    360367                editor.schema.addValidElements( '@[id|accesskey|class|dir|lang|style|tabindex|title|contenteditable|draggable|dropzone|hidden|spellcheck|translate],i,b' );