Make WordPress Core

Ticket #31441: 31441.18.patch

File 31441.18.patch, 2.0 KB (added by iseulde, 10 years ago)
  • src/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js

     
    8787                                }
    8888                        }
    8989
     90                        if ( ! child.nodeValue ) {
     91                                child = child.nextSibling;
     92                        }
     93
    9094                        if ( child !== node ) {
    9195                                return;
    9296                        }
     
    109113                                editor.undoManager.add();
    110114
    111115                                editor.undoManager.transact( function() {
     116                                        var $$parent;
     117
    112118                                        if ( replace ) {
    113119                                                $$( node ).replaceWith( document.createTextNode( replace ) );
    114120                                        } else  {
    115                                                 $$( node.parentNode ).empty().append( '<br>' );
     121                                                $$parent = $$( node.parentNode );
     122
     123                                                $$( node ).remove();
     124
     125                                                if ( ! $$parent.html() ) {
     126                                                        $$parent.append( '<br>' );
     127                                                }
    116128                                        }
    117129
    118130                                        editor.selection.setCursorLocation( parent );
  • tests/qunit/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js

     
    7777                }, assert.async() );
    7878        } );
    7979
    80         QUnit.test( 'Ordered list with content.', function( assert ) {
     80        QUnit.test( 'Ordered list with content. (1)', function( assert ) {
    8181                editor.setContent( '<p><strong>test</strong></p>' );
    8282                editor.selection.setCursorLocation();
    8383
     
    8686                }, assert.async() );
    8787        } );
    8888
     89        QUnit.test( 'Ordered list with content. (2)', function( assert ) {
     90                editor.setContent( '<p><strong>test</strong></p>' );
     91                editor.selection.setCursorLocation( editor.$( 'p' )[0], 0 );
     92
     93                type( '* ', function() {
     94                        assert.equal( editor.getContent(), '<ul>\n<li><strong>test</strong></li>\n</ul>' );
     95                }, assert.async() );
     96        } );
     97
    8998        QUnit.test( 'Only transform inside a P tag.', function( assert ) {
    9099                editor.setContent( '<h1>test</h1>' );
    91100                editor.selection.setCursorLocation();