Make WordPress Core

Ticket #20943: 20943_patch.diff

File 20943_patch.diff, 2.1 KB (added by sandyr, 10 years ago)

Patch to fix html, tinymce toggle issue for tables and lists

  • wp-admin/js/editor.js

     
    142142                        });
    143143                }
    144144
     145                //Blocks for which to retain the p tag
     146                skipBlocklist = 'ul|ol|li|table|thead|tbody|tfoot|tr|th|td';
     147                preserve_p = new RegExp( '\\s*</(' + skipBlocklist + ')>\\s*', 'g' ).test(content);
     148
    145149                // Pretty it up for the source editor
    146150                blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|div|h[1-6]|p|fieldset';
    147151                content = content.replace( new RegExp( '\\s*</(' + blocklist1 + ')>\\s*', 'g' ), '</$1>\n' );
     
    153157                // Separate <div> containing <p>
    154158                content = content.replace( /<div( [^>]*)?>\s*<p>/gi, '<div$1>\n\n' );
    155159
    156                 // Remove <p> and <br />
    157                 content = content.replace( /\s*<p>/gi, '' );
    158                 content = content.replace( /\s*<\/p>\s*/gi, '\n\n' );
    159                 content = content.replace( /\n[\s\u00a0]+\n/g, '\n\n' );
    160                 content = content.replace( /\s*<br ?\/?>\s*/gi, '\n' );
     160                // Remove <p> and <br />. Also check the block list to be skipped.
     161                if ( false === preserve_p ) {
     162                        content = content.replace( /\s*<p>/gi, '' );
     163                        content = content.replace( /\s*<\/p>\s*/gi, '\n\n' );
     164                        content = content.replace( /\n[\s\u00a0]+\n/g, '\n\n' );
     165                        content = content.replace( /\s*<br ?\/?>\s*/gi, '\n' );
     166                }
    161167
    162168                // Fix some block element newline issues
    163169                content = content.replace( /\s*<div/g, '\n<div' );
  • wp-includes/js/tinymce/plugins/wordpress/plugin.js

     
    379379
    380380        editor.on( 'SaveContent', function( e ) {
    381381                // If editor is hidden, we just want the textarea's value to be saved
    382                 if ( ! editor.inline && editor.isHidden() ) {
     382                if ( ( ! editor.inline && editor.isHidden() ) || editor.isNotDirty ) {
    383383                        e.content = e.element.value;
    384384                        return;
    385385                }