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:
Ella Iseulde Van Dorpe
2015-06-18 11:33:11 +00:00
parent b1446f4221
commit fa1a214eb6
2 changed files with 23 additions and 2 deletions

View File

@@ -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 );