X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=_source%2Fplugins%2Fdomiterator%2Fplugin.js;h=22815c45e2d80622a2fc20fde5ac4433d63729d8;hb=48b1db88210b4160dce439c6e3e32e14af8c106b;hp=f0b18357659138979c2f5c292ff6d93d26e7a66e;hpb=c9fdde67e6384bd5a66adc2b3bba5c4ce9db56c7;p=ckeditor.git
diff --git a/_source/plugins/domiterator/plugin.js b/_source/plugins/domiterator/plugin.js
index f0b1835..22815c4 100644
--- a/_source/plugins/domiterator/plugin.js
+++ b/_source/plugins/domiterator/plugin.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
@@ -20,17 +20,27 @@ CKEDITOR.plugins.add( 'domiterator' );
return;
this.range = range;
- this.forceBrBreak = false;
+ this.forceBrBreak = 0;
// Whether include
s into the enlarged range.(#3730).
- this.enlargeBr = true;
- this.enforceRealBlocks = false;
+ this.enlargeBr = 1;
+ this.enforceRealBlocks = 0;
this._ || ( this._ = {} );
}
var beginWhitespaceRegex = /^[\r\n\t ]+$/,
- isBookmark = CKEDITOR.dom.walker.bookmark();
+ // Ignore bookmark nodes.(#3783)
+ bookmarkGuard = CKEDITOR.dom.walker.bookmark( false, true );
+
+ // Get a reference for the next element, bookmark nodes are skipped.
+ function getNextSourceNode( node, startFromSibling, lastNode )
+ {
+ var next = node.getNextSourceNode( startFromSibling, null, lastNode );
+ while ( !bookmarkGuard( next ) )
+ next = next.getNextSourceNode( startFromSibling, null, lastNode );
+ return next;
+ }
iterator.prototype = {
getNextParagraph : function( blockTag )
@@ -80,7 +90,7 @@ CKEDITOR.plugins.add( 'domiterator' );
// next block.(#3887)
if ( this._.lastNode &&
this._.lastNode.type == CKEDITOR.NODE_TEXT &&
- !CKEDITOR.tools.trim( this._.lastNode.getText( ) ) &&
+ !CKEDITOR.tools.trim( this._.lastNode.getText() ) &&
this._.lastNode.getParent().isBlockBoundary() )
{
var testRange = new CKEDITOR.dom.range( range.document );
@@ -112,13 +122,13 @@ CKEDITOR.plugins.add( 'domiterator' );
{
// closeRange indicates that a paragraph boundary has been found,
// so the range can be closed.
- var closeRange = false,
- parentPre = currentNode.hasAscendant( 'pre' );
+ var closeRange = 0,
+ parentPre = currentNode.hasAscendant( 'pre' );
// includeNode indicates that the current node is good to be part
// of the range. By default, any non-element node is ok for it.
var includeNode = ( currentNode.type != CKEDITOR.NODE_ELEMENT ),
- continueFromSibling = false;
+ continueFromSibling = 0;
// If it is an element node, let's check if it can be part of the
// range.
@@ -132,7 +142,7 @@ CKEDITOR.plugins.add( 'domiterator' );
//
boundaries must be part of the range. It will
// happen only if ForceBrBreak.
if ( nodeName == 'br' )
- includeNode = true;
+ includeNode = 1;
else if ( !range && !currentNode.getChildCount() && nodeName != 'hr' )
{
// If we have found an empty block, and haven't started
@@ -154,7 +164,7 @@ CKEDITOR.plugins.add( 'domiterator' );
this._.nextNode = currentNode;
}
- closeRange = true;
+ closeRange = 1;
}
else
{
@@ -171,7 +181,7 @@ CKEDITOR.plugins.add( 'domiterator' );
currentNode = currentNode.getFirst();
continue;
}
- includeNode = true;
+ includeNode = 1;
}
}
else if ( currentNode.type == CKEDITOR.NODE_TEXT )
@@ -179,7 +189,7 @@ CKEDITOR.plugins.add( 'domiterator' );
// Ignore normal whitespaces (i.e. not including or
// other unicode whitespaces) before/after a block node.
if ( beginWhitespaceRegex.test( currentNode.getText() ) )
- includeNode = false;
+ includeNode = 0;
}
// The current node is good to be part of the range and we are
@@ -197,22 +207,22 @@ CKEDITOR.plugins.add( 'domiterator' );
// to close the range, otherwise we include the parent within it.
if ( range && !closeRange )
{
- while ( !currentNode.getNext() && !isLast )
+ while ( !currentNode.getNext( bookmarkGuard ) && !isLast )
{
var parentNode = currentNode.getParent();
if ( parentNode.isBlockBoundary( this.forceBrBreak
&& !parentPre && { br : 1 } ) )
{
- closeRange = true;
+ closeRange = 1;
isLast = isLast || ( parentNode.equals( lastNode) );
break;
}
currentNode = parentNode;
- includeNode = true;
+ includeNode = 1;
isLast = ( currentNode.equals( lastNode ) );
- continueFromSibling = true;
+ continueFromSibling = 1;
}
}
@@ -220,7 +230,7 @@ CKEDITOR.plugins.add( 'domiterator' );
if ( includeNode )
range.setEndAt( currentNode, CKEDITOR.POSITION_AFTER_END );
- currentNode = currentNode.getNextSourceNode( continueFromSibling, null, lastNode );
+ currentNode = getNextSourceNode ( currentNode, continueFromSibling, lastNode );
isLast = !currentNode;
// We have found a block boundary. Let's close the range and move out of the
@@ -256,15 +266,15 @@ CKEDITOR.plugins.add( 'domiterator' );
// Create the fixed block.
block = this.range.document.createElement( blockTag || 'p' );
- // Move the contents of the temporary range to the fixed block.
- range.extractContents().appendTo( block );
- block.trim();
+ // Move the contents of the temporary range to the fixed block.
+ range.extractContents().appendTo( block );
+ block.trim();
- // Insert the fixed block into the DOM.
- range.insertNode( block );
+ // Insert the fixed block into the DOM.
+ range.insertNode( block );
- removePreviousBr = removeLastBr = true;
- }
+ removePreviousBr = removeLastBr = true;
+ }
else if ( block.getName() != 'li' )
{
// If the range doesn't includes the entire contents of the
@@ -297,8 +307,7 @@ CKEDITOR.plugins.add( 'domiterator' );
// the current range, which could be an