TinyMCE: wptextpattern: fix issue that removes content
* If the resulting text node is empty, don't remove all the content from the paragraph. * If there's an empty text node at the start of the paragraph, ignore it and consider the next node to be the start. See #31441. git-svn-id: https://develop.svn.wordpress.org/trunk@32832 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b1446f4221
commit
fa1a214eb6
@ -87,6 +87,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! child.nodeValue ) {
|
||||
child = child.nextSibling;
|
||||
}
|
||||
|
||||
if ( child !== node ) {
|
||||
return;
|
||||
}
|
||||
@ -109,10 +113,18 @@
|
||||
editor.undoManager.add();
|
||||
|
||||
editor.undoManager.transact( function() {
|
||||
var $$parent;
|
||||
|
||||
if ( replace ) {
|
||||
$$( node ).replaceWith( document.createTextNode( replace ) );
|
||||
} else {
|
||||
$$( node.parentNode ).empty().append( '<br>' );
|
||||
$$parent = $$( node.parentNode );
|
||||
|
||||
$$( node ).remove();
|
||||
|
||||
if ( ! $$parent.html() ) {
|
||||
$$parent.append( '<br>' );
|
||||
}
|
||||
}
|
||||
|
||||
editor.selection.setCursorLocation( parent );
|
||||
|
@ -77,7 +77,7 @@
|
||||
}, assert.async() );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Ordered list with content.', function( assert ) {
|
||||
QUnit.test( 'Ordered list with content. (1)', function( assert ) {
|
||||
editor.setContent( '<p><strong>test</strong></p>' );
|
||||
editor.selection.setCursorLocation();
|
||||
|
||||
@ -86,6 +86,15 @@
|
||||
}, assert.async() );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Ordered list with content. (2)', function( assert ) {
|
||||
editor.setContent( '<p><strong>test</strong></p>' );
|
||||
editor.selection.setCursorLocation( editor.$( 'p' )[0], 0 );
|
||||
|
||||
type( '* ', function() {
|
||||
assert.equal( editor.getContent(), '<ul>\n<li><strong>test</strong></li>\n</ul>' );
|
||||
}, assert.async() );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Only transform inside a P tag.', function( assert ) {
|
||||
editor.setContent( '<h1>test</h1>' );
|
||||
editor.selection.setCursorLocation();
|
||||
|
Loading…
Reference in New Issue
Block a user