X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fdom%2Frange.js;h=4c0067b856558a04050cf8eae0b6ed0c54cb3f88;hb=refs%2Ftags%2Fv3.5.3;hp=fedbfb97e45684a2612f0d548a5921c3e1fe1fe6;hpb=48b1db88210b4160dce439c6e3e32e14af8c106b;p=ckeditor.git
diff --git a/_source/core/dom/range.js b/_source/core/dom/range.js
index fedbfb9..4c0067b 100644
--- a/_source/core/dom/range.js
+++ b/_source/core/dom/range.js
@@ -4,16 +4,87 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
- * @class
+ * Creates a CKEDITOR.dom.range instance that can be used inside a specific
+ * DOM Document.
+ * @class Represents a delimited piece of content in a DOM Document.
+ * It is contiguous in the sense that it can be characterized as selecting all
+ * of the content between a pair of boundary-points.
+ *
+ * This class shares much of the W3C
+ * Document Object Model Range
+ * ideas and features, adding several range manipulation tools to it, but it's
+ * not intended to be compatible with it.
+ * @param {CKEDITOR.dom.document} document The document into which the range
+ * features will be available.
+ * @example
+ * // Create a range for the entire contents of the editor document body.
+ * var range = new CKEDITOR.dom.range( editor.document );
+ * range.selectNodeContents( editor.document.getBody() );
+ * // Delete the contents.
+ * range.deleteContents();
*/
CKEDITOR.dom.range = function( document )
{
+ /**
+ * Node within which the range begins.
+ * @type {CKEDITOR.NODE_ELEMENT|CKEDITOR.NODE_TEXT}
+ * @example
+ * var range = new CKEDITOR.dom.range( editor.document );
+ * range.selectNodeContents( editor.document.getBody() );
+ * alert( range.startContainer.getName() ); // "body"
+ */
this.startContainer = null;
+
+ /**
+ * Offset within the starting node of the range.
+ * @type {Number}
+ * @example
+ * var range = new CKEDITOR.dom.range( editor.document );
+ * range.selectNodeContents( editor.document.getBody() );
+ * alert( range.startOffset ); // "0"
+ */
this.startOffset = null;
+
+ /**
+ * Node within which the range ends.
+ * @type {CKEDITOR.NODE_ELEMENT|CKEDITOR.NODE_TEXT}
+ * @example
+ * var range = new CKEDITOR.dom.range( editor.document );
+ * range.selectNodeContents( editor.document.getBody() );
+ * alert( range.endContainer.getName() ); // "body"
+ */
this.endContainer = null;
+
+ /**
+ * Offset within the ending node of the range.
+ * @type {Number}
+ * @example
+ * var range = new CKEDITOR.dom.range( editor.document );
+ * range.selectNodeContents( editor.document.getBody() );
+ * alert( range.endOffset ); // == editor.document.getBody().getChildCount()
+ */
this.endOffset = null;
+
+ /**
+ * Indicates that this is a collapsed range. A collapsed range has it's
+ * start and end boudaries at the very same point so nothing is contained
+ * in it.
+ * @example
+ * var range = new CKEDITOR.dom.range( editor.document );
+ * range.selectNodeContents( editor.document.getBody() );
+ * alert( range.collapsed ); // "false"
+ * range.collapse();
+ * alert( range.collapsed ); // "true"
+ */
this.collapsed = true;
+ /**
+ * The document within which the range can be used.
+ * @type {CKEDITOR.dom.document}
+ * @example
+ * // Selects the body contents of the range document.
+ * range.selectNodeContents( range.document.getBody() );
+ */
this.document = document;
};
@@ -518,6 +589,10 @@ CKEDITOR.dom.range = function( document )
startContainer = child;
startOffset = 0;
}
+
+ // Get the normalized offset.
+ if ( child && child.type == CKEDITOR.NODE_ELEMENT )
+ startOffset = child.getIndex( 1 );
}
// Normalize the start.
@@ -546,6 +621,10 @@ CKEDITOR.dom.range = function( document )
endContainer = child;
endOffset = 0;
}
+
+ // Get the normalized offset.
+ if ( child && child.type == CKEDITOR.NODE_ELEMENT )
+ endOffset = child.getIndex( 1 );
}
// Normalize the end.