WordPress.org

Make WordPress Core

Changeset 40787


Ignore:
Timestamp:
05/18/2017 10:55:00 PM (12 months ago)
Author:
azaozz
Message:

Editor: When stripping paragraph tags, and there is a <br> at the beginning or the end, merge them and keep the paragraph, not the <br>.

Props rellect.
Fixes #37066.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/editor.js

    r40599 r40787  
    225225            html = html.replace( /\n[\s\u00a0]+\n/g, '\n\n' );
    226226
    227             // Rrplace <br> tags with a line break.
    228             html = html.replace( /\s*<br ?\/?>\s*/gi, '\n' );
     227            // Replace <br> tags with line breaks.
     228            html = html.replace( /(\s*)<br ?\/?>\s*/gi, function( match, space ) {
     229                if ( space && space.indexOf( '\n' ) !== -1 ) {
     230                    return '\n\n';
     231                }
     232
     233                return '\n';
     234            });
    229235
    230236            // Fix line breaks around <div>.
Note: See TracChangeset for help on using the changeset viewer.