/*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
}\r
\r
var beginWhitespaceRegex = /^[\r\n\t ]+$/,\r
- isBookmark = CKEDITOR.dom.walker.bookmark();\r
+ // Ignore bookmark nodes.(#3783)\r
+ bookmarkGuard = CKEDITOR.dom.walker.bookmark( false, true );\r
+\r
+ // Get a reference for the next element, bookmark nodes are skipped.\r
+ function getNextSourceNode( node, startFromSibling, lastNode )\r
+ {\r
+ var next = node.getNextSourceNode( startFromSibling, null, lastNode );\r
+ while ( !bookmarkGuard( next ) )\r
+ next = next.getNextSourceNode( startFromSibling, null, lastNode );\r
+ return next;\r
+ }\r
\r
iterator.prototype = {\r
getNextParagraph : function( blockTag )\r
// to close the range, otherwise we include the parent within it.\r
if ( range && !closeRange )\r
{\r
- while ( !currentNode.getNext() && !isLast )\r
+ while ( !currentNode.getNext( bookmarkGuard ) && !isLast )\r
{\r
var parentNode = currentNode.getParent();\r
\r
if ( includeNode )\r
range.setEndAt( currentNode, CKEDITOR.POSITION_AFTER_END );\r
\r
- currentNode = currentNode.getNextSourceNode( continueFromSibling, null, lastNode );\r
+ currentNode = getNextSourceNode ( currentNode, continueFromSibling, lastNode );\r
isLast = !currentNode;\r
\r
// We have found a block boundary. Let's close the range and move out of the\r
// Create the fixed block.\r
block = this.range.document.createElement( blockTag || 'p' );\r
\r
- // Move the contents of the temporary range to the fixed block.\r
- range.extractContents().appendTo( block );\r
- block.trim();\r
+ // Move the contents of the temporary range to the fixed block.\r
+ range.extractContents().appendTo( block );\r
+ block.trim();\r
\r
- // Insert the fixed block into the DOM.\r
- range.insertNode( block );\r
+ // Insert the fixed block into the DOM.\r
+ range.insertNode( block );\r
\r
- removePreviousBr = removeLastBr = true;\r
- }\r
+ removePreviousBr = removeLastBr = true;\r
+ }\r
else if ( block.getName() != 'li' )\r
{\r
// If the range doesn't includes the entire contents of the\r
// the current range, which could be an <li> child (nested\r
// lists) or the next sibling <li>.\r
\r
- this._.nextNode = ( block.equals( lastNode ) ? null :\r
- range.getBoundaryNodes().endNode.getNextSourceNode( true, null, lastNode ) );\r
+ this._.nextNode = ( block.equals( lastNode ) ? null : getNextSourceNode( range.getBoundaryNodes().endNode, 1, lastNode ) );\r
}\r
}\r
\r
- // Ignore bookmark nodes.(#3783)\r
- var bookmarkGuard = CKEDITOR.dom.walker.bookmark( false, true );\r
-\r
if ( removePreviousBr )\r
{\r
var previousSibling = block.getPrevious();\r
if ( !this._.nextNode )\r
{\r
this._.nextNode = ( isLast || block.equals( lastNode ) ) ? null :\r
- block.getNextSourceNode( true, null, lastNode );\r
- }\r
-\r
- if ( !bookmarkGuard( this._.nextNode ) )\r
- {\r
- this._.nextNode = this._.nextNode.getNextSourceNode( true, null, function( node )\r
- { return !node.equals( lastNode ) && bookmarkGuard( node ); } );\r
+ getNextSourceNode( block, 1, lastNode );\r
}\r
\r
return block;\r