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( brsToIgnore )\r
+ {\r
+ while ( pendingBRs.length - ( brsToIgnore || 0 ) > 0 )\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
{\r
addElement( currentNode, currentNode.parent );\r
}\r
+ else if ( tagName in CKEDITOR.dtd.$listItem )\r
+ {\r
+ parser.onTagOpen( 'ul', {} );\r
+ addPoint = currentNode;\r
+ reApply = true;\r
+ }\r
else\r
{\r
if ( nonBreakingBlocks[ currentName ] )\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
\r
checkPending( tagName );\r
+ sendPendingBRs();\r
\r
element.parent = currentNode;\r
element.returnPoint = returnPoint;\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
\r
parser.onComment = function( comment )\r
{\r
+ checkPending();\r
currentNode.add( new CKEDITOR.htmlParser.comment( comment ) );\r
};\r
\r
// Parse it.\r
parser.parse( fragmentHtml );\r
\r
+ // Send all pending BRs except one, which we consider a unwanted bogus. (#5293)\r
+ sendPendingBRs( !CKEDITOR.env.ie && 1 );\r
+\r
// Close all pending nodes.\r
while ( currentNode.type )\r
{\r