Index: /FCKeditor/trunk/_whatsnew.html
===================================================================
--- /FCKeditor/trunk/_whatsnew.html	(revision 206)
+++ /FCKeditor/trunk/_whatsnew.html	(revision 207)
@@ -106,4 +106,6 @@
 		<li>Hidden fields will now show up as an icon in IE, instead of a normal text field.
 			They are also selectable and draggable, in all browsers.</li>
+		<li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/213">#213</a>] Styles
+			are now preserved when hitting enter at the end of a paragraph.</li>
 	</ul>
 	<h3>
Index: /FCKeditor/trunk/editor/_source/classes/fckdomrange.js
===================================================================
--- /FCKeditor/trunk/editor/_source/classes/fckdomrange.js	(revision 206)
+++ /FCKeditor/trunk/editor/_source/classes/fckdomrange.js	(revision 207)
@@ -118,4 +118,17 @@
 	},
 
+	// Moves to the first editing point inside a element. For example, in a
+	// element tree like "<p><b><i></i></b> Text</p>", the start editing point
+	// is "<p><b><i>^</i></b> Text</p>" (inside <i>).
+	MoveToElementEditStart : function( targetElement )
+	{
+		var child ;
+
+		while ( ( child = targetElement.firstChild ) && child.nodeType == 1 && FCKListsLib.EmptyElements[ child.nodeName.toLowerCase() ] == null )
+			targetElement = child ;
+
+		this.MoveToElementStart( targetElement ) ;
+	},
+
 	InsertNode : function( node )
 	{
@@ -167,6 +180,31 @@
 		oTestRange.SetEnd( oTestRange.EndBlock || oTestRange.EndBlockLimit, 2 ) ;
 
-		var bIsEndOfBlock = oTestRange.CheckIsEmpty( true ) ;
-
+		var bIsEndOfBlock = oTestRange.CheckIsCollapsed() ;
+		
+		if ( !bIsEndOfBlock )
+		{
+			// Inserts the contents of the range in a div tag.
+			var eToolDiv = this.Window.document.createElement( 'div' ) ;
+			oTestRange._Range.cloneContents().AppendTo( eToolDiv ) ;
+			FCKDomTools.TrimNode( eToolDiv, true ) ;
+			
+			// Find out if we are in an empty tree of inline elements, like <b><i><span></span></i></b>
+			bIsEndOfBlock = true ;
+			var eLastChild = eToolDiv ;
+			while ( ( eLastChild = eLastChild.lastChild ) )
+			{
+				// Check the following:
+				//		1. Is there more than one node in the parents children?
+				//		2. Is the node not an element node?
+				//		3. Is it not a inline element.
+				if ( eLastChild.previousSibling || eLastChild.nodeType != 1 || FCKListsLib.InlineChildReqElements[ eLastChild.nodeName.toLowerCase() ] == null )
+				{
+					// So we are not in the end of the range.
+					bIsEndOfBlock = false ;
+					break ;
+				}
+			}
+		}
+		
 		oTestRange.Release() ;
 
Index: /FCKeditor/trunk/editor/_source/classes/fckenterkey.js
===================================================================
--- /FCKeditor/trunk/editor/_source/classes/fckenterkey.js	(revision 206)
+++ /FCKeditor/trunk/editor/_source/classes/fckenterkey.js	(revision 207)
@@ -57,6 +57,8 @@
 	var oEnterKey = this._EnterKey ;
 
+	/* @Packager.RemoveLine
 	try
 	{
+	@Packager.RemoveLine */
 		switch ( keystrokeValue )
 		{
@@ -76,4 +78,5 @@
 				return oEnterKey.DoDelete() ;
 		}
+	/* @Packager.RemoveLine
 	}
 	catch (e)
@@ -82,4 +85,5 @@
 		// ahead with the browser default behavior.
 	}
+	@Packager.RemoveLine */
 
 	return false ;
@@ -277,5 +281,5 @@
 	// Get the current selection.
 	var oRange = range || new FCKDomRange( this.Window ) ;
-	
+
 	// If we don't have a range, move it to the selection.
 	if ( !range )
@@ -330,5 +334,5 @@
 
 				// Move the selection to the new block.
-				oRange.MoveToElementStart( eStartBlock ) ;
+				oRange.MoveToElementEditStart( eStartBlock ) ;
 			}
 			else
@@ -343,5 +347,5 @@
 					{
 						var eOutdented = FCKListHandler.OutdentListItem( eStartBlock ) ;
-						oRange.MoveToElementStart( eOutdented ) ;
+						oRange.MoveToElementEditStart( eOutdented ) ;
 					}
 					else
@@ -352,5 +356,8 @@
 						// Otherwise, duplicate the current block.
 						else
+						{
 							eNewBlock = eStartBlock.cloneNode(false) ;
+							this._RecreateEndingTree( eStartBlock, eNewBlock ) ;
+						}
 
 						if ( FCKBrowserInfo.IsGeckoLike )
@@ -384,8 +391,6 @@
 					{
 						// In Gecko, the last child node must be a bogus <br>.
-						var eLastChild = FCKDomTools.GetLastChild( eNewBlock ) ;
-
-						if ( !eLastChild || eLastChild.nodeName.toLowerCase() != 'br' || eLastChild.getAttribute( 'type', 2 ) != '_moz' )
-							eNewBlock.appendChild( FCKTools.CreateBogusBR( this.Window.document ) ) ;
+						this._AppendBogusBr( eStartBlock ) ;
+						this._AppendBogusBr( eNewBlock ) ;
 					}
 				}
@@ -396,5 +401,5 @@
 
 					// Move the selection to the new block.
-					oRange.MoveToElementStart( eNewBlock ) ;
+					oRange.MoveToElementEditStart( eNewBlock ) ;
 
 					if ( FCKBrowserInfo.IsGecko )
@@ -406,5 +411,5 @@
 		{
 			// Move the selection to the end block.
-			oRange.MoveToElementStart( eEndBlock ) ;
+			oRange.MoveToElementEditStart( eEndBlock ) ;
 		}
 
@@ -471,10 +476,5 @@
 			// If we are at the end of a block, we must be sure the bogus node is available in that block.
 			if ( bIsEndOfBlock && FCKBrowserInfo.IsGecko )
-			{
-				var eLastBr = FCKDomTools.GetLastChild( eBr.parentNode, 'BR' ) ;
-
-				if ( eLastBr && eLastBr.getAttribute( 'type', 2 ) != '_moz' )
-					eBr.parentNode.appendChild( FCKTools.CreateBogusBR( this.Window.document ) ) ;
-			}
+				this._AppendBogusBr( eBr.parentNode ) ;
 
 			if ( FCKBrowserInfo.IsIE )
@@ -522,2 +522,24 @@
 	range.MoveToBookmark( oBookmark ) ;
 }
+
+// Appends a bogus <br> at the end of the element, if not yet available.
+FCKEnterKey.prototype._AppendBogusBr = function( element )
+{
+	var eLastChild = element.getElementsByTagName('br') ;
+
+	if ( eLastChild )
+		eLastChild = eLastChild[ eLastChild.legth - 1 ] ;
+
+	if ( !eLastChild || eLastChild.getAttribute( 'type', 2 ) != '_moz' )
+		element.appendChild( FCKTools.CreateBogusBR( this.Window.document ) ) ;
+}
+
+// Recreate the elements tree at the end of the source block, at the beginning
+// of the target block. Eg.: 
+//	If source = <p><u>Some</u> sample <b><i>text</i></b></p> then target = <p><b><i></i></b></p>
+//	If source = <p><u>Some</u> sample text</p> then target = <p></p>
+FCKEnterKey.prototype._RecreateEndingTree = function( source, target )
+{
+	while ( ( source = source.lastChild ) && source.nodeType == 1 && FCKListsLib.InlineChildReqElements[ source.nodeName.toLowerCase() ] != null )
+		target = target.insertBefore( source.cloneNode( false ), target.firstChild ) ;
+}
