Index: editor/_source/classes/fckstyle.js
===================================================================
--- editor/_source/classes/fckstyle.js	(revision 1386)
+++ editor/_source/classes/fckstyle.js	(working copy)
@@ -769,6 +769,45 @@
 			// Move everything from the current node to the new one.
 			FCKDomTools.MoveChildren( block, newBlock ) ;
 
+			// If we're in a non-IE browser, and the newBlock is <pre>, and the old block is not <pre>,
+			// then we need to clear linebreaks and compress ANSI whitespaces so that we don't get disrupted
+			// output in <pre> mode. (Bug #1355)
+			if ( !FCKBrowserInfo.IsIE && newBlock.nodeName.IEquals( 'pre' ) && !block.nodeName.IEquals( 'pre' ) )
+			{
+				// If the newBlock's first child is a text node, left-trim it since any ANSI whitespace 
+				// after a non-pre block is meaningless.
+				if ( newBlock.firstChild && newBlock.firstChild.nodeType == 3 )
+					newBlock.firstChild.nodeValue = newBlock.firstChild.nodeValue.LTrim() ;
+
+				// Ditto for the last child.
+				if ( newBlock.lastChild && newBlock.lastChild.nodeType == 3 )
+					newBlock.lastChild.nodeValue = newBlock.lastChild.nodeValue.RTrim() ;
+
+				// DFS walk the newBlock to compress ANSI whitespaces and delete excessive linebreaks.
+				var currentNode = newBlock ;
+				while ( currentNode )
+				{
+					currentNode = FCKDomTools.GetNextSourceNode( currentNode, false, 3, newBlock.parentNode ) ;
+					if ( currentNode )
+					{
+						// If the text node ends with a line break, and its next sibling is a <BR>,
+						// then right-trim the text node.
+						if ( currentNode.nodeValue.charAt( currentNode.nodeValue.length - 1 ) == '\n'
+								&& currentNode.nextSibling 
+								&& currentNode.nextSibling.nodeName.IEquals( 'br' ) )
+							currentNode.nodeValue = currentNode.nodeValue.RTrim() ;
+						// If the text node begins with a line break, and its next sibling is a <BR>,
+						// then left-trim the text node.
+						if ( currentNode.nodeValue.charAt( 0 ) == '\n'
+								&& currentNode.previousSibling 
+								&& currentNode.previousSibling.nodeName.IEquals( 'br' ) )
+							currentNode.nodeValue = currentNode.nodeValue.LTrim() ;
+						// Compress any ANSI whitespaces left.
+						currentNode.nodeValue = currentNode.nodeValue.replace( /[\r\n\t ]+/g, ' ' ) ;
+					}
+				}
+			}
+
 			// Delete the current node.
 			FCKDomTools.RemoveNode( block ) ;
 		}
