diff --git a/source/Editor.js b/source/Editor.js index f959d96..bcfe3c0 100644 --- a/source/Editor.js +++ b/source/Editor.js @@ -988,7 +988,7 @@ document.addEventListener( 'DOMContentLoaded', function () { // Save undo checkpoint recordUndoState( range ); getRangeAndRemoveBookmark( range ); - + // Selected text is overwritten, therefore delete the contents // to collapse selection. if ( !range.collapsed ) { @@ -1002,6 +1002,8 @@ document.addEventListener( 'DOMContentLoaded', function () { splitTag = nextTag[ tag ], nodeAfterSplit; + // If this is a malformed bit of document, just play it safe + // and insert a
. if ( !block ) { range._insertNode( createElement( 'BR' ) ); range.collapse( false ); diff --git a/source/Node.js b/source/Node.js index c29c0c3..40de0eb 100644 --- a/source/Node.js +++ b/source/Node.js @@ -107,6 +107,8 @@ implement( Text, { getLength: function () { return this.length; }, + // The text node is essentially its own contents. + empty: function () { return this; }, isLike: function ( node ) { return node.nodeType === TEXT_NODE; },