Index: /FCKeditor/trunk/editor/_source/classes/fckw3crange.js
===================================================================
--- /FCKeditor/trunk/editor/_source/classes/fckw3crange.js	(revision 47)
+++ /FCKeditor/trunk/editor/_source/classes/fckw3crange.js	(revision 47)
@@ -0,0 +1,177 @@
+﻿/* @Packager.Header
+<FileDescription>
+	This class partially implements the W3C DOM Range for browser that don't
+	support the standards (like IE):
+	http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html
+</FileDescription>
+<Author name="Frederico Caldeira Knabben" email="www.fckeditor.net" />
+*/
+
+var FCKW3CRange = function( parentDocument )
+{
+	this._Document = parentDocument ;
+
+	this.startContainer	= null ;
+	this.startOffset	= null ;
+	this.endContainer	= null ;
+	this.endOffset		= null ;
+	this.collapsed		= true ;
+}
+
+FCKW3CRange.CreateRange = function( parentDocument )
+{
+	// We could opt to use the Range implentation of the browsers. The problem
+	// is that every browser have different bugs on their implementations,
+	// mostly related to different interpretations of the W3C specifications.
+	// So, for now, let's use our implementation and pray for browsers fixings
+	// soon. Otherwise will go crazy on trying to find out workarounds.
+	/*
+	// Get the browser implementation of the range, if available.
+	if ( parentDocument.createRange )
+	{
+		var range = parentDocument.createRange() ;
+		if ( typeof( range.startContainer ) != 'undefined' )
+			return range ;
+	}
+	*/
+	return new FCKW3CRange( parentDocument ) ;
+}
+
+FCKW3CRange.prototype = 
+{
+	TypeName : 'FCKW3CRange',		// @Packager.RemoveLine
+
+	_UpdateCollapsed : function()
+	{
+      this.collapsed = ( this.startContainer == this.endContainer && this.startOffset == this.endOffset ) ;
+	},
+
+	setStart : function( refNode, offset )
+	{
+		this.startContainer	= refNode ;
+		this.startOffset	= offset ;
+		
+		if ( !this.endContainer )
+		{
+			this.endContainer	= refNode ;
+			this.endOffset		= offset ;
+		}
+
+		this._UpdateCollapsed() ;
+	},
+	
+	setEnd : function( refNode, offset )
+	{
+		this.endContainer	= refNode ;
+		this.endOffset		= offset ;
+		
+		if ( !this.startContainer )
+		{
+			this.startContainer	= refNode ;
+			this.startOffset	= offset ;
+		}
+
+		this._UpdateCollapsed() ;
+	},
+
+	setStartAfter : function( refNode )
+	{
+		this.setStart( refNode.parentNode, FCKDomTools.GetIndexOf( refNode ) + 1 ) ;
+	},
+
+	setStartBefore : function( refNode )
+	{
+		this.setStart( refNode.parentNode, FCKDomTools.GetIndexOf( refNode ) ) ;
+	},
+
+	setEndAfter : function( refNode )
+	{
+		this.setEnd( refNode.parentNode, FCKDomTools.GetIndexOf( refNode ) + 1 ) ;
+	},
+
+	setEndBefore : function( refNode )
+	{
+		this.setEnd( refNode.parentNode, FCKDomTools.GetIndexOf( refNode ) ) ;
+	},
+	
+	collapse : function( toStart )
+	{
+		if ( toStart )
+		{
+			this.endContainer	= this.startContainer ;
+			this.endOffset		= this.startOffset ;
+		}
+		else
+		{
+			this.startContainer	= this.endContainer ;
+			this.startOffset	= this.endOffset ;
+		}
+		
+		this.collapsed = true ;
+	},
+
+	selectNodeContents : function( refNode )
+	{
+		this.setStart( refNode, 0 ) ;
+		this.setEnd( refNode, refNode.nodeType == 3 ? refNode.data.length : refNode.childNodes.length ) ;
+	},
+
+	insertNode : function( newNode )
+	{
+		var startContainer = this.startContainer ;
+		var startOffset = this.startOffset ;
+		
+		// If we are in a text node.
+		if ( startContainer.nodeType == 3 )
+		{
+			startContainer.splitText( startOffset ) ;
+
+			// Check if it is necessary to update the end boundary.
+			if ( startContainer == this.endContainer )
+				this.setEnd( startContainer.nextSibling, this.endOffset - this.startOffset ) ;
+			
+			// Insert the new node it after the text node.
+			FCKDomTools.InsertAfterNode( startContainer, newNode ) ;
+	
+			return ;
+		}
+		else
+		{
+			// Simply insert the new node before the current start node.
+			startContainer.insertBefore( newNode, startContainer.childNodes[ startOffset ] ) ;
+
+			// Check if it is necessary to update the end boundary.
+			if ( startContainer == this.endContainer )
+			{
+				this.endOffset++ ;
+				this.collapsed = false ;
+			}
+		}
+	},
+
+	cloneContents : function()
+	{
+	},
+
+	deleteContents : function()
+	{
+		if ( this.collapsed )
+			return ;
+		
+		var startParents	= FCKDomTools.GetParents( this.startBoundary ) ;
+		var endParents		= FCKDomTools.GetParents( this.endBoundary ) ;
+	},
+
+	extractContents : function()
+	{
+	},
+
+	cloneRange : function()
+	{
+		return FCKTools.CloneObject( this ) ;
+	},
+
+	toString : function()
+	{
+	}
+} ;
Index: /FCKeditor/trunk/editor/_source/fckscriptloader.js
===================================================================
--- /FCKeditor/trunk/editor/_source/fckscriptloader.js	(revision 46)
+++ /FCKeditor/trunk/editor/_source/fckscriptloader.js	(revision 47)
@@ -78,4 +78,6 @@
 FCKScriptLoader.AddScript( 'FCKJSCoreExtensions' ) ;
 FCKScriptLoader.AddScript( 'FCKBrowserInfo'		, 'internals/'	, ['FCKJSCoreExtensions'] ) ;
+FCKScriptLoader.AddScript( 'FCKConfig'			, 'internals/' ) ;
+FCKScriptLoader.AddScript( 'FCKDebug'			, 'internals/'	, ['FCKConfig'] ) ;
 FCKScriptLoader.AddScript( 'FCKDomTools'		, 'internals/'	, ['FCKJSCoreExtensions'], FCK_GENERIC ) ;
 FCKScriptLoader.AddScript( 'FCKTools'			, 'internals/'	, ['FCKJSCoreExtensions','FCKBrowserInfo'], FCK_GENERIC_SPECIFIC ) ;
@@ -86,4 +88,5 @@
 FCKScriptLoader.AddScript( 'FCKKeystrokeHandler', 'classes/'	, ['FCKConstants','FCKBrowserInfo','FCKTools'], FCK_GENERIC ) ;
 FCKScriptLoader.AddScript( 'FCKListHandler'		, 'internals/'	, ['FCKJSCoreExtensions','FCKDomTools','FCKTools'], FCK_GENERIC ) ;
+FCKScriptLoader.AddScript( 'FCKW3CRange'		, 'classes/'	, ['FCKDomTools','FCKTools'], FCK_GENERIC ) ;
 
 // ####################################
Index: /FCKeditor/trunk/editor/_source/internals/fckdomtools.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fckdomtools.js	(revision 46)
+++ /FCKeditor/trunk/editor/_source/internals/fckdomtools.js	(revision 47)
@@ -205,4 +205,35 @@
 	{
 		existingNode.parentNode.insertBefore( newNode, existingNode.nextSibling ) ;
+	},
+	
+	GetParents : function( node )
+	{
+		var parents = new Array() ;
+		
+		while ( node )
+		{
+			parents.splice( 0, 0, node ) ;
+			node = node.parentNode ;
+		}
+		
+		return parents ;
+	},
+	
+	GetIndexOf : function( node )
+	{
+		var currentNode = node.parentNode.firstChild ;
+		var currentIndex = -1 ;
+		
+		while ( currentNode )
+		{
+			currentIndex++ ;
+			
+			if ( currentNode == node )
+				return currentIndex ;
+				
+			currentNode = currentNode.nextSibling ;
+		}
+		
+		return -1 ;
 	}
 }
