Index: /FCKeditor/trunk/_test/automated/_jsunit/app/jsUnitCore.js
===================================================================
--- /FCKeditor/trunk/_test/automated/_jsunit/app/jsUnitCore.js	(revision 1713)
+++ /FCKeditor/trunk/_test/automated/_jsunit/app/jsUnitCore.js	(revision 1714)
@@ -76,9 +76,9 @@
 
 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';
 }
 
Index: /FCKeditor/trunk/_test/automated/tests/fckdomtools.html
===================================================================
--- /FCKeditor/trunk/_test/automated/tests/fckdomtools.html	(revision 1713)
+++ /FCKeditor/trunk/_test/automated/tests/fckdomtools.html	(revision 1714)
@@ -29,4 +29,29 @@
 
 FCKScriptLoader.Load( 'FCKDomTools' ) ;
+
+	</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>
@@ -89,4 +114,49 @@
 }
 
+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>
@@ -116,4 +186,6 @@
 			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: /FCKeditor/trunk/_test/automated/tests/fckw3crange.html
===================================================================
--- /FCKeditor/trunk/_test/automated/tests/fckw3crange.html	(revision 1713)
+++ /FCKeditor/trunk/_test/automated/tests/fckw3crange.html	(revision 1714)
@@ -629,4 +629,52 @@
 }
 
+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()
@@ -848,9 +896,17 @@
 <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 ;
 }
 
Index: /FCKeditor/trunk/_whatsnew.html
===================================================================
--- /FCKeditor/trunk/_whatsnew.html	(revision 1713)
+++ /FCKeditor/trunk/_whatsnew.html	(revision 1714)
@@ -75,4 +75,7 @@
 			to override JavaScript errors occuring inside the editing frame due to user added
 			JavaScript code.</li>
+		<li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/1647">#1647</a>] Hitting
+			ENTER on list items containing block elements will not create new list item elements,
+			instead of adding further blocks to the same list item.</li>
 	</ul>
 	<h3>
Index: /FCKeditor/trunk/editor/_source/classes/fckenterkey.js
===================================================================
--- /FCKeditor/trunk/editor/_source/classes/fckenterkey.js	(revision 1713)
+++ /FCKeditor/trunk/editor/_source/classes/fckenterkey.js	(revision 1714)
@@ -401,6 +401,4 @@
 	var oSplitInfo = oRange.SplitBlock() ;
 
-	// FCKDebug.OutputObject( oSplitInfo ) ;
-
 	if ( oSplitInfo )
 	{
@@ -411,4 +409,20 @@
 		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
Index: /FCKeditor/trunk/editor/_source/classes/fckw3crange.js
===================================================================
--- /FCKeditor/trunk/editor/_source/classes/fckw3crange.js	(revision 1713)
+++ /FCKeditor/trunk/editor/_source/classes/fckw3crange.js	(revision 1714)
@@ -263,17 +263,21 @@
 			// 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 )
-				{
-					// 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 ;
-			}
+
+			// 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 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 ;
 		}
 
Index: /FCKeditor/trunk/editor/_source/fckscriptloader.js
===================================================================
--- /FCKeditor/trunk/editor/_source/fckscriptloader.js	(revision 1713)
+++ /FCKeditor/trunk/editor/_source/fckscriptloader.js	(revision 1714)
@@ -41,4 +41,6 @@
 		return ;
 
+	FCKScriptLoader._LoadedScripts[ scriptName ] = true ;
+
 	var oScriptInfo = this._Scripts[ scriptName ] ;
 
@@ -66,6 +68,4 @@
 			this._LoadScript( sBaseScriptName + '_gecko.js' ) ;
 	}
-
-	FCKScriptLoader._LoadedScripts[ scriptName ] = true ;
 }
 
@@ -111,5 +111,5 @@
 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 ) ;
