X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fcore%2Fdom%2Frange.js;h=264ee4eff190acd6baa08a3c2e12023fbd05a62f;hp=a8b102d933599d5a5f332b7df784b4633457b9e1;hb=941b0a9ba4e673e292510d80a5a86806994b8ea6;hpb=7cd80714081a8ffdf4a1a8d2c72f120ed5ef3d6d
diff --git a/_source/core/dom/range.js b/_source/core/dom/range.js
index a8b102d..264ee4e 100644
--- a/_source/core/dom/range.js
+++ b/_source/core/dom/range.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
@@ -1468,6 +1468,7 @@ CKEDITOR.dom.range = function( document )
else
{
endBlock = this.splitElement( startBlock );
+
// In Gecko, the last child node must be a bogus
.
// Note: bogus
added under
or would cause
// lists to be incorrectly rendered.
@@ -1604,14 +1605,15 @@ CKEDITOR.dom.range = function( document )
},
/**
- * Moves the range boundaries to the first editing point inside an
+ * Moves the range boundaries to the first/end editing point inside an
* element. For example, in an element tree like
* "<p><b><i></i></b> Text</p>", the start editing point is
* "<p><b><i>^</i></b> Text</p>" (inside <i>).
* @param {CKEDITOR.dom.element} el The element into which look for the
* editing spot.
+ * @param {Boolean} isMoveToEnd Whether move to the end editable position.
*/
- moveToElementEditStart : function( el )
+ moveToElementEditablePosition : function( el, isMoveToEnd )
{
var isEditable;
@@ -1621,24 +1623,30 @@ CKEDITOR.dom.range = function( document )
// If an editable element is found, move inside it.
if ( isEditable )
- this.moveToPosition( el, CKEDITOR.POSITION_AFTER_START );
+ this.moveToPosition( el, isMoveToEnd ?
+ CKEDITOR.POSITION_BEFORE_END :
+ CKEDITOR.POSITION_AFTER_START );
// Stop immediately if we've found a non editable inline element (e.g ).
else if ( CKEDITOR.dtd.$inline[ el.getName() ] )
{
- this.moveToPosition( el, CKEDITOR.POSITION_BEFORE_START );
+ this.moveToPosition( el, isMoveToEnd ?
+ CKEDITOR.POSITION_AFTER_END :
+ CKEDITOR.POSITION_BEFORE_START );
return true;
}
// Non-editable non-inline elements are to be bypassed, getting the next one.
if ( CKEDITOR.dtd.$empty[ el.getName() ] )
- el = el.getNext( nonWhitespaceOrBookmarkEval );
+ el = el[ isMoveToEnd ? 'getPrevious' : 'getNext' ]( nonWhitespaceOrBookmarkEval );
else
- el = el.getFirst( nonWhitespaceOrBookmarkEval );
+ el = el[ isMoveToEnd ? 'getLast' : 'getFirst' ]( nonWhitespaceOrBookmarkEval );
// Stop immediately if we've found a text node.
if ( el && el.type == CKEDITOR.NODE_TEXT )
{
- this.moveToPosition( el, CKEDITOR.POSITION_BEFORE_START );
+ this.moveToPosition( el, isMoveToEnd ?
+ CKEDITOR.POSITION_AFTER_END :
+ CKEDITOR.POSITION_BEFORE_START );
return true;
}
}
@@ -1647,6 +1655,22 @@ CKEDITOR.dom.range = function( document )
},
/**
+ *@see {CKEDITOR.dom.range.moveToElementEditablePosition}
+ */
+ moveToElementEditStart : function( target )
+ {
+ return this.moveToElementEditablePosition( target );
+ },
+
+ /**
+ *@see {CKEDITOR.dom.range.moveToElementEditablePosition}
+ */
+ moveToElementEditEnd : function( target )
+ {
+ return this.moveToElementEditablePosition( target, true );
+ },
+
+ /**
* Get the single node enclosed within the range if there's one.
*/
getEnclosedNode : function()