Make WordPress Core

Changeset 28685


Ignore:
Timestamp:
06/06/2014 04:19:09 AM (11 years ago)
Author:
azaozz
Message:

TinyMCE: remove &nbsp from empty paragraphs inside the visual editor, props avryl, fixes #28282

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js

    r28626 r28685  
    356356
    357357        // Keep empty paragraphs :(
    358         e.content = e.content.replace( /<p>(<br ?\/?>|\u00a0|\uFEFF)?<\/p>/g, '<p>&nbsp;</p>' );
     358        e.content = e.content.replace( /<p>(?:<br ?\/?>|\u00a0|\uFEFF| )*<\/p>/g, '<p>&nbsp;</p>' );
    359359
    360360        if ( editor.getParam( 'wpautop', true ) && typeof window.switchEditors !== 'undefined' ) {
    361361            e.content = window.switchEditors.pre_wpautop( e.content );
     362        }
     363    });
     364
     365    // Remove spaces from empty paragraphs.
     366    editor.on( 'BeforeSetContent', function( event ) {
     367        if ( event.content ) {
     368            event.content = event.content.replace( /<p>(?:&nbsp;|\u00a0|\uFEFF| )+<\/p>/gi, '<p></p>' );
    362369        }
    363370    });
Note: See TracChangeset for help on using the changeset viewer.