html = [],\r
fragment = new CKEDITOR.htmlParser.fragment(),\r
pendingInline = [],\r
+ pendingBRs = [],\r
currentNode = fragment,\r
// Indicate we're inside a <pre> element, spaces should be touched differently.\r
inPre = false,\r
\r
function checkPending( newTagName )\r
{\r
+ var pendingBRsSent;\r
+\r
if ( pendingInline.length > 0 )\r
{\r
for ( var i = 0 ; i < pendingInline.length ; i++ )\r
\r
if ( ( !currentDtd || currentDtd[ pendingName ] ) && ( !newTagName || !pendingDtd || pendingDtd[ newTagName ] || !CKEDITOR.dtd[ newTagName ] ) )\r
{\r
+ if ( !pendingBRsSent )\r
+ {\r
+ sendPendingBRs();\r
+ pendingBRsSent = 1;\r
+ }\r
+\r
// Get a clone for the pending element.\r
pendingElement = pendingElement.clone();\r
\r
}\r
}\r
\r
+ function sendPendingBRs()\r
+ {\r
+ while ( pendingBRs.length )\r
+ currentNode.add( pendingBRs.shift() );\r
+ }\r
+\r
function addElement( element, target, enforceCurrent )\r
{\r
target = target || currentNode || fragment;\r
return;\r
}\r
\r
+ if ( tagName == 'br' )\r
+ {\r
+ pendingBRs.push( element );\r
+ return;\r
+ }\r
+\r
var currentName = currentNode.name;\r
\r
var currentDtd = currentName\r
addPoint; // New position to start adding nodes.\r
\r
// Fixing malformed nested lists by moving it into a previous list item. (#3828)\r
- if( tagName in listBlocks\r
+ if ( tagName in listBlocks\r
&& currentName in listBlocks )\r
{\r
var children = currentNode.children,\r
reApply = true;\r
}\r
\r
- if( addPoint )\r
+ if ( addPoint )\r
currentNode = addPoint;\r
// Try adding it to the return point, or the parent element.\r
else\r
\r
currentNode = candidate;\r
\r
- if( currentNode.name == 'pre' )\r
+ if ( currentNode.name == 'pre' )\r
inPre = false;\r
\r
+ if ( candidate._.isBlockLike )\r
+ sendPendingBRs();\r
+\r
addElement( candidate, candidate.parent );\r
\r
// The parent should start receiving new nodes now, except if\r
pendingInline = pendingInline.concat( newPendingInline );\r
}\r
\r
- if( tagName == 'body' )\r
+ if ( tagName == 'body' )\r
fixForBody = false;\r
};\r
\r
return;\r
}\r
\r
+ sendPendingBRs();\r
checkPending();\r
\r
if ( fixForBody\r
// Parse it.\r
parser.parse( fragmentHtml );\r
\r
+ sendPendingBRs();\r
+\r
// Close all pending nodes.\r
while ( currentNode.type )\r
{\r