Index: _source/tests/core/dom/range_shrink.html =================================================================== --- _source/tests/core/dom/range_shrink.html (revision 0) +++ _source/tests/core/dom/range_shrink.html (revision 0) @@ -0,0 +1,100 @@ + + +
+This is
+ Index: _source/plugins/selection/plugin.js =================================================================== --- _source/plugins/selection/plugin.js (revision 3418) +++ _source/plugins/selection/plugin.js (working copy) @@ -623,7 +623,7 @@ if ( !range.collapsed ) { range.optimize(); - + range.shrink(); node = range.startContainer; if ( node.type != CKEDITOR.NODE_ELEMENT ) Index: _source/core/dom/range.js =================================================================== --- _source/core/dom/range.js (revision 3418) +++ _source/core/dom/range.js (working copy) @@ -651,6 +651,24 @@ this.setEndAfter( container ); } }, + + /** + * Decrease the range content to exclude particial selected node which doesn't have visual impact. + * Note: It only affect the range start position. + * @example + * Original range as: + *This ^is^
+ * Will be transformed into the following: + *This ^is^
+ */ + shrink : function() + { + while( this.startOffset == ( this.startContainer.getChildCount ? + this.startContainer.getChildCount() : this.startContainer.getText().length ) ) + { + this.setStartAfter( this.startContainer ); + } + }, trim : function( ignoreStart, ignoreEnd ) { Index: _source/core/dom/node.js =================================================================== --- _source/core/dom/node.js (revision 3418) +++ _source/core/dom/node.js (working copy) @@ -221,33 +221,6 @@ }, /** - * Gets a DOM tree descendant under the current node. - * @param {Array|Number} indices The child index or array of child indices under the node. - * @returns {CKEDITOR.dom.node} The specified DOM child under the current node. Null if child does not exist. - * @example - * var strong = p.getChild(0); - */ - getChild : function( indices ) - { - var rawNode = this.$; - - if ( !indices.slice ) - rawNode = rawNode.childNodes[ indices ]; - else - { - while ( indices.length > 0 && rawNode ) - rawNode = rawNode.childNodes[ indices.shift() ]; - } - - return rawNode ? new CKEDITOR.dom.node( rawNode ) : null; - }, - - getChildCount : function() - { - return this.$.childNodes.length; - }, - - /** * Gets the document containing this element. * @returns {CKEDITOR.dom.document} The document. * @example Index: _source/core/dom/element.js =================================================================== --- _source/core/dom/element.js (revision 3418) +++ _source/core/dom/element.js (working copy) @@ -1311,5 +1311,32 @@ this.$.parentNode.replaceChild( newNode.$, this.$ ); newNode.$._cke_expando = this.$._cke_expando; this.$ = newNode.$; + }, + + /** + * Gets a DOM tree descendant under the current node. + * @param {Array|Number} indices The child index or array of child indices under the node. + * @returns {CKEDITOR.dom.node} The specified DOM child under the current node. Null if child does not exist. + * @example + * var strong = p.getChild(0); + */ + getChild : function( indices ) + { + var rawNode = this.$; + + if ( !indices.slice ) + rawNode = rawNode.childNodes[ indices ]; + else + { + while ( indices.length > 0 && rawNode ) + rawNode = rawNode.childNodes[ indices.shift() ]; + } + + return rawNode ? new CKEDITOR.dom.node( rawNode ) : null; + }, + + getChildCount : function() + { + return this.$.childNodes.length; } });