Index: _test/automated/_jsunit/app/jsUnitCore.js
===================================================================
--- _test/automated/_jsunit/app/jsUnitCore.js	(revision 1693)
+++ _test/automated/_jsunit/app/jsUnitCore.js	(working copy)
@@ -75,11 +75,11 @@
 }
 
 function _displayStringForValue(aVar) {
-    var result = '<' + aVar + '>';
+    var result = '[' + aVar + ']';
     if (!(aVar === null || aVar === top.JSUNIT_UNDEFINED_VALUE)) {
         result += ' (' + _trueTypeOf(aVar) + ')';
     }
-    return result;
+    return '\n' + result + '\n';
 }
 
 function fail(failureMessage) {
Index: _test/automated/tests/fckdomtools.html
===================================================================
--- _test/automated/tests/fckdomtools.html	(revision 1693)
+++ _test/automated/tests/fckdomtools.html	(working copy)
@@ -32,6 +32,31 @@
 	</script>
 	<script type="text/javascript">
 
+var _BodyHtml ;
+
+function setUpPage()
+{
+	_BodyHtml = document.body.innerHTML ;
+	setUpPageStatus = 'complete' ;
+}
+
+// JsUnit special function called before every test start.
+function setUp()
+{
+	// Reset the body (because of changes by test functions).
+	document.body.innerHTML = _BodyHtml ;
+}
+
+// Use window.onload to call a test outside JsUnit (for debugging).
+// The "tests.js" script must be commented.
+//window.onload = function()
+//{
+//	test_GetNextSourceNode() ;
+//}
+
+	</script>
+	<script type="text/javascript">
+
 function test_GetNextSourceNode()
 {
 	var el = document.getElementById( 'xP' ) ;
@@ -88,6 +113,51 @@
 		FCKDomTools.HasAttribute( document.getElementById( 'xIMG' ), 'unknown' ) ) ;
 }
 
+function test_BreakParent_1()
+{
+	var p = document.getElementById( 'xBreakParent_P1' ) ;
+	
+	FCKDomTools.BreakParent( p.getElementsByTagName('span')[0], p.getElementsByTagName('i')[0] ) ;
+
+	assertEquals( 'SPAN breaks I', '<b>this <i>is some</i><span></span><i> sample</i> test text</b>', GetTestInnerHtml( p ) ) ;
+}
+
+function test_BreakParent_2()
+{
+	var p = document.getElementById( 'xBreakParent_P1' ) ;
+	
+	FCKDomTools.BreakParent( p.getElementsByTagName('span')[0], p.getElementsByTagName('b')[0] ) ;
+
+	assertEquals( 'SPAN breaks B', '<b>this <i>is some</i></b><span></span><b><i> sample</i> test text</b>', GetTestInnerHtml( p ) ) ;
+}
+
+function test_BreakParent_3()
+{
+	var p = document.getElementById( 'xBreakParent_P2' ) ;
+	
+	FCKDomTools.BreakParent( p.getElementsByTagName('span')[0], p.getElementsByTagName('i')[0] ) ;
+
+	assertEquals( 'SPAN breaks I', '<b><i></i><span>test</span><i></i></b>', GetTestInnerHtml( p ) ) ;
+}
+
+function test_BreakParent_4()
+{
+	var p = document.getElementById( 'xBreakParent_P2' ) ;
+	
+	FCKDomTools.BreakParent( p.getElementsByTagName('span')[0], p.getElementsByTagName('b')[0] ) ;
+
+	assertEquals( 'SPAN breaks B', '<b><i></i></b><span>test</span><b><i></i></b>', GetTestInnerHtml( p ) ) ;
+}
+
+function test_BreakParent_5()
+{
+	var p = document.getElementById( 'xBreakParent_P2' ) ;
+	
+	FCKDomTools.BreakParent( p.getElementsByTagName('i')[0], p.getElementsByTagName('b')[0] ) ;
+
+	assertEquals( 'I breaks B', '<b></b><i><span>test</span></i><b></b>', GetTestInnerHtml( p ) ) ;
+}
+
 	</script>
 </head>
 <body>
@@ -115,5 +185,7 @@
 		This paragraph has and image at the very end of its contents.<img id="xIMG" src="http://www.fckeditor.net/images/logotop.gif"
 			alt="" />
 	</p>
+	<p id="xBreakParent_P1"><b>This <i>is some<span></span> sample</i> test text</b></p>
+	<p id="xBreakParent_P2"><b><i><span>test</span></i></b></p>
 </body>
 </html>
Index: _test/automated/tests/fckw3crange.html
===================================================================
--- _test/automated/tests/fckw3crange.html	(revision 1693)
+++ _test/automated/tests/fckw3crange.html	(working copy)
@@ -628,6 +628,54 @@
 	assertTrue( 'range.collapsed', range.collapsed ) ;
 }
 
+function test_extractContents_Other_5()
+{
+	document.body.innerHTML = '<p><b><i>test</i></b></p>' ;
+
+	var range = FCKW3CRange.CreateRange( document ) ;
+
+	range.setStartAfter( document.getElementsByTagName('i')[0] ) ;
+	range.setEndAfter( document.getElementsByTagName('b')[0] ) ;
+
+	var docFrag = range.extractContents() ;
+
+	var tmpDiv = document.createElement( 'div' ) ;
+	if ( docFrag.AppendTo ) docFrag.AppendTo( tmpDiv ) ; else tmpDiv.appendChild( docFrag ) ;
+
+	assertEquals( 'Extracted HTML', '<b></b>', GetTestInnerHtml( tmpDiv ) ) ;
+	assertEquals( 'HTML after extraction', '<p><b><i>test</i></b></p>', GetTestInnerHtml( document.body ) ) ;
+
+	assertEquals( 'range.startContainer', document.body.firstChild, range.startContainer ) ;
+	assertEquals( 'range.startOffset', 1, range.startOffset ) ;
+	assertEquals( 'range.endContainer', document.body.firstChild, range.endContainer ) ;
+	assertEquals( 'range.endOffset', 1, range.endOffset ) ;
+	assertTrue( 'range.collapsed', range.collapsed ) ;
+}
+
+function test_extractContents_Other_6()
+{
+	document.body.innerHTML = '<p><b><i>test</i></b></p>' ;
+
+	var range = FCKW3CRange.CreateRange( document ) ;
+
+	range.setStartBefore( document.getElementsByTagName('b')[0] ) ;
+	range.setEndBefore( document.getElementsByTagName('i')[0] ) ;
+
+	var docFrag = range.extractContents() ;
+
+	var tmpDiv = document.createElement( 'div' ) ;
+	if ( docFrag.AppendTo ) docFrag.AppendTo( tmpDiv ) ; else tmpDiv.appendChild( docFrag ) ;
+
+	assertEquals( 'Extracted HTML', '<b></b>', GetTestInnerHtml( tmpDiv ) ) ;
+	assertEquals( 'HTML after extraction', '<p><b><i>test</i></b></p>', GetTestInnerHtml( document.body ) ) ;
+
+	assertEquals( 'range.startContainer', document.body.firstChild, range.startContainer ) ;
+	assertEquals( 'range.startOffset', 0, range.startOffset ) ;
+	assertEquals( 'range.endContainer', document.body.firstChild, range.endContainer ) ;
+	assertEquals( 'range.endOffset', 0, range.endOffset ) ;
+	assertTrue( 'range.collapsed', range.collapsed ) ;
+}
+
 // W3C DOM Range Specs - Section 2.7 - Example 1
 function test_cloneContents_W3C_1()
 {
@@ -847,11 +895,19 @@
 	</script>
 <script type="text/javascript">
 
+var _BodyHtml ;
+
+function setUpPage()
+{
+	_BodyHtml = document.body.innerHTML ;
+	setUpPageStatus = 'complete' ;
+}
+
 // JsUnit special function called before every test start.
 function setUp()
 {
 	// Reset the body (because of changes by test functions).
-	document.body.innerHTML = '<h1 id="_H1">FCKW3CRange Test</h1><p id="_P">This is <b id="_B">some</b> text.</p><p>Another paragraph.</p>' ;
+	document.body.innerHTML = _BodyHtml ;
 }
 
 // Use window.onload to call a test outside JsUnit (for debugging).
Index: editor/_source/classes/fckenterkey.js
===================================================================
--- editor/_source/classes/fckenterkey.js	(revision 1693)
+++ editor/_source/classes/fckenterkey.js	(working copy)
@@ -400,8 +400,6 @@
 
 	var oSplitInfo = oRange.SplitBlock() ;
 
-	// FCKDebug.OutputObject( oSplitInfo ) ;
-
 	if ( oSplitInfo )
 	{
 		// Get the current blocks.
@@ -411,6 +409,22 @@
 		var bIsStartOfBlock	= oSplitInfo.WasStartOfBlock ;
 		var bIsEndOfBlock	= oSplitInfo.WasEndOfBlock ;
 
+		// If there is one block under a list item, modify the split so that the list item gets split as well. (Bug #1647)
+		if ( eNextBlock )
+		{
+			if ( eNextBlock.parentNode.nodeName.IEquals( 'li' ) )
+			{
+				FCKDomTools.BreakParent( eNextBlock, eNextBlock.parentNode ) ;
+				FCKDomTools.MoveNode( eNextBlock, eNextBlock.nextSibling, true ) ;
+			}
+		}
+		else if ( ePreviousBlock && ePreviousBlock.parentNode.nodeName.IEquals( 'li' ) )
+		{
+			FCKDomTools.BreakParent( ePreviousBlock, ePreviousBlock.parentNode ) ;
+			oRange.MoveToElementEditStart( ePreviousBlock.nextSibling );
+			FCKDomTools.MoveNode( ePreviousBlock, ePreviousBlock.previousSibling ) ;
+		}
+
 		// If we have both the previous and next blocks, it means that the
 		// boundaries were on separated blocks, or none of them where on the
 		// block limits (start/end).
Index: editor/_source/classes/fckw3crange.js
===================================================================
--- editor/_source/classes/fckw3crange.js	(revision 1693)
+++ editor/_source/classes/fckw3crange.js	(working copy)
@@ -262,19 +262,23 @@
 		{
 			// If the start container has children and the offset is pointing
 			// to a child, then we should start from its previous sibling.
-			if ( startNode.childNodes.length > 0 &&  startOffset <= startNode.childNodes.length - 1 )
+
+			// If the offset points to the first node, we don't have a
+			// sibling, so let's use the first one, but mark it for removal.
+			if ( startOffset == 0 )
 			{
-				// If the offset points to the first node, we don't have a
-				// sibling, so let's use the first one, but mark it for removal.
-				if ( startOffset == 0 )
-				{
-					// Let's create a temporary node and mark it for removal.
-					startNode = startNode.insertBefore( this._Document.createTextNode(''), startNode.firstChild ) ;
-					removeStartNode = true ;
-				}
-				else
-					startNode = startNode.childNodes[ startOffset ].previousSibling ;
+				// Let's create a temporary node and mark it for removal.
+				startNode = startNode.insertBefore( this._Document.createTextNode(''), startNode.firstChild ) ;
+				removeStartNode = true ;
 			}
+			else if ( startOffset > startNode.childNodes.length - 1 )
+			{
+				// Let's create a temporary node and mark it for removal.
+				startNode = startNode.appendChild( this._Document.createTextNode('') ) ;
+				removeStartNode = true ;
+			}
+			else
+				startNode = startNode.childNodes[ startOffset ].previousSibling ;
 		}
 
 		// Get the parent nodes tree for the start and end boundaries.
Index: editor/_source/fckscriptloader.js
===================================================================
--- editor/_source/fckscriptloader.js	(revision 1693)
+++ editor/_source/fckscriptloader.js	(working copy)
@@ -40,6 +40,8 @@
 	if ( scriptName in FCKScriptLoader._LoadedScripts )
 		return ;
 
+	FCKScriptLoader._LoadedScripts[ scriptName ] = true ;
+
 	var oScriptInfo = this._Scripts[ scriptName ] ;
 
 	if ( !oScriptInfo )
@@ -65,8 +67,6 @@
 		else
 			this._LoadScript( sBaseScriptName + '_gecko.js' ) ;
 	}
-
-	FCKScriptLoader._LoadedScripts[ scriptName ] = true ;
 }
 
 FCKScriptLoader._LoadScript = function( scriptPathFromSource )
@@ -110,7 +110,7 @@
 FCKScriptLoader.AddScript( 'FCKCodeFormatter'	, 'internals/' ) ;
 FCKScriptLoader.AddScript( 'FCKConfig'			, 'internals/'	, ['FCKBrowserInfo','FCKConstants'] ) ;
 FCKScriptLoader.AddScript( 'FCKDebug'			, 'internals/'	, ['FCKConfig'] ) ;
-FCKScriptLoader.AddScript( 'FCKDomTools'		, 'internals/'	, ['FCKJSCoreExtensions','FCKBrowserInfo','FCKTools'], FCK_GENERIC ) ;
+FCKScriptLoader.AddScript( 'FCKDomTools'		, 'internals/'	, ['FCKJSCoreExtensions','FCKBrowserInfo','FCKTools','FCKDomRange'], FCK_GENERIC ) ;
 FCKScriptLoader.AddScript( 'FCKListsLib'		, 'internals/' ) ;
 FCKScriptLoader.AddScript( 'FCKListHandler'		, 'internals/'	, ['FCKConfig', 'FCKDocumentFragment', 'FCKJSCoreExtensions','FCKDomTools'], FCK_GENERIC ) ;
 FCKScriptLoader.AddScript( 'FCKRegexLib'		, 'internals/' ) ;
