Index: /CKEditor/branches/prototype/_samples/sample01.html
===================================================================
--- /CKEditor/branches/prototype/_samples/sample01.html	(revision 2116)
+++ /CKEditor/branches/prototype/_samples/sample01.html	(revision 2117)
@@ -1,3 +1,3 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <!--
  * CKEditor - The text editor for Internet - http://ckeditor.com
Index: /CKEditor/branches/prototype/_source/core/ckeditor_base.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/ckeditor_base.js	(revision 2116)
+++ /CKEditor/branches/prototype/_source/core/ckeditor_base.js	(revision 2117)
@@ -24,5 +24,5 @@
 // ckeditor.js and ckeditor_basic.js files.
 
-// if (!window.CKEDITOR){window.CKEDITOR=(function(){return {status:'unloaded',basePath:(function(){var A='';var B=document.getElementsByTagName('script');for (var i=0;i<B.length;i++){var C=B[i].src.match(/(^|.*[\\\/])ckeditor(?:_basic)?.js(?:\?.*)?$/i);if (C){A=C[1];break;}};if (A.indexOf('://')==-1){if (A.indexOf('/')==0) A=location.href.match(/^.*?:\/\/[^\/]*/)[0]+A;else A=location.href.match(/^[^\?]*\//)[0]+A;};return A;})()};})();};
+// if (!window.CKEDITOR){window.CKEDITOR=(function(){return {_:{},status:'unloaded',basePath:(function(){var A='';var B=document.getElementsByTagName('script');for (var i=0;i<B.length;i++){var C=B[i].src.match(/(^|.*[\\\/])ckeditor(?:_basic)?.js(?:\?.*)?$/i);if (C){A=C[1];break;}};if (A.indexOf('://')==-1){if (A.indexOf('/')==0) A=location.href.match(/^.*?:\/\/[^\/]*/)[0]+A;else A=location.href.match(/^[^\?]*\//)[0]+A;};return A;})()};})();};
 
 // #### Raw code
@@ -41,4 +41,12 @@
 		/** @lends CKEDITOR */
 		return {
+			/**
+			 * Private object used to hold core stuff. It should not be used out of
+			 * the API code as properties defined here may change at any time
+			 * without notice.
+			 * @private
+			 */
+			_ : {},
+
 			/**
 			 * Indicates the API loading status:
Index: /CKEditor/branches/prototype/_source/core/config.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/config.js	(revision 2116)
+++ /CKEditor/branches/prototype/_source/core/config.js	(revision 2117)
@@ -41,5 +41,5 @@
 	corePlugins : '',
 
-	plugins : '',
+	plugins : 'editingblock,elementspath,sourcearea,toolbar,wysiwygarea',
 
 	/**
@@ -48,4 +48,8 @@
 	 * @default 'default'
 	 */
-	theme : 'default'
+	theme : 'default',
+	
+	toolbarLocation : 'top',
+	
+	startupMode : 'wysiwyg'
 };
Index: /CKEditor/branches/prototype/_source/core/dom/element.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/dom/element.js	(revision 2116)
+++ /CKEditor/branches/prototype/_source/core/dom/element.js	(revision 2117)
@@ -37,4 +37,10 @@
 };
 
+CKEDITOR.dom.element.getById = function( id )
+{
+	var $ = document.getElementById( id );
+	return $ ? new CKEDITOR.dom.element( $ ) : null;
+};
+
 CKEDITOR.dom.element.getHead = function()
 {
@@ -42,4 +48,11 @@
 	return new CKEDITOR.dom.element( head );
 };
+
+CKEDITOR.dom.element.createFromHtml = function( html )
+{
+	var temp = document.createElement( 'div' );
+	temp.innerHTML = html;
+	return new CKEDITOR.dom.element( temp.firstChild );
+}
 
 CKEDITOR.dom.element.prototype =
@@ -63,4 +76,13 @@
 	{
 		element.$.parentNode.insertBefore( this.$, element.$ );
+	},
+	
+	insertHtmlAfter : function( html )
+	{
+		var temp = new CKEDITOR.dom.element( 'div' );
+		temp.setHtml( html );
+		
+		docFrag.innerHTML = html;
+		
 	},
 
Index: /CKEditor/branches/prototype/_source/core/editor.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/editor.js	(revision 2116)
+++ /CKEditor/branches/prototype/_source/core/editor.js	(revision 2117)
@@ -144,8 +144,8 @@
 					if ( plugin && plugin.init )
 						plugin.init( editor, CKEDITOR.plugins.getPath( pluginName ) );
+				}
 					
-					// Load the editor theme.
-					loadTheme( editor );
-				}
+				// Load the editor theme.
+				loadTheme( editor );
 			});
 	};
@@ -162,4 +162,6 @@
 	return function( element, instanceConfig )
 	{
+		this._ = {};
+
 		// Call the base constructor.
 		CKEDITOR.event.call( this );
@@ -193,5 +195,5 @@
 	{
 		return CKEDITOR.event.prototype.fireOnce.call( this, eventName, data, this );
-	}
+	}	
 };
 
Index: /CKEditor/branches/prototype/_source/core/event.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/event.js	(revision 2116)
+++ /CKEditor/branches/prototype/_source/core/event.js	(revision 2117)
@@ -28,5 +28,5 @@
 CKEDITOR.event = function()
 {
-	this._events = {};
+	( this._ || ( this._ = {} ) ).events = {};
 };
 
@@ -69,5 +69,5 @@
 		{
 			// Get the event entry (create it if needed).
-			var event = this._events[ eventName ] || ( this._events[ eventName ] = new eventEntry( eventName ) );
+			var event = this._.events[ eventName ] || ( this._.events[ eventName ] = new eventEntry( eventName ) );
 
 			if ( event.getListenerIndex( listenerFunction ) < 0 )
@@ -141,5 +141,5 @@
 
 			// Get the event entry.
-			var event = this._events[ eventName ];
+			var event = this._.events[ eventName ];
 
 			if ( event )
@@ -149,5 +149,8 @@
 				{
 					// Call the listener, passing the event data.
-					data = listeners[i].call( this, editor, data, stopEvent, cancelEvent );
+					var retData = listeners[i].call( this, editor, data, stopEvent, cancelEvent );
+
+					if ( typeof retData != 'undefined' )
+						data = retData;
 
 					// No further calls is stopped or cancelled.
@@ -162,6 +165,6 @@
 		fireOnce : function( eventName, data, editor )
 		{
-			var ret = this.fire( eventName, editor, data );
-			delete this._events[ eventName ];
+			var ret = this.fire( eventName, data, editor );
+			delete this._.events[ eventName ];
 			return ret;
 		},
@@ -170,5 +173,5 @@
 		{
 			// Get the event entry.
-			var event = this._events[ eventName ];
+			var event = this._.events[ eventName ];
 
 			if ( event )
Index: /CKEditor/branches/prototype/_source/core/resourcemanager.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/resourcemanager.js	(revision 2116)
+++ /CKEditor/branches/prototype/_source/core/resourcemanager.js	(revision 2117)
@@ -59,5 +59,5 @@
 	},
 	
-	import : function( name, path )
+	addExternal : function( name, path )
 	{
 		if ( this.registered[ name ] || this.externals[ name ] )
@@ -128,6 +128,6 @@
 							// Check all callbacks that were waiting for this
 							// resource.
-							for ( var j = 0 ; j < waitingList[ name ].length ; j++ )
-								loadCheck( waitingList[ name ][ j ] );
+							for ( var j = 0 ; j < waitingInfo.length ; j++ )
+								loadCheck( waitingInfo[ j ] );
 
 							delete waitingList[ name ];
Index: /CKEditor/branches/prototype/_source/plugins/editingblock/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/editingblock/plugin.js	(revision 2117)
+++ /CKEditor/branches/prototype/_source/plugins/editingblock/plugin.js	(revision 2117)
@@ -0,0 +1,76 @@
+﻿/*
+ * CKEditor - The text editor for Internet - http://ckeditor.com
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ *
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ *
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+
+CKEDITOR.plugins.add( 'editingblock',
+{
+	init : function( editor, pluginPath )
+	{
+		editor.on( 'themespace', function( event )
+			{
+				if ( event.data.space == 'middle' )
+					event.data.html += '<br>';
+			});
+
+		editor.on( 'themeloaded', function()
+			{
+				editor.fireOnce( 'editingblockready' );
+			});
+		
+		editor.on( 'uiready', function()
+			{
+				editor.setMode( CKEDITOR.config.startupMode );
+			});
+	}
+});
+
+(function()
+{
+	var getMode = function( editor, mode )
+	{
+		return editor._.modes && editor._.modes[ mode ];
+	};
+
+	CKEDITOR.editor.prototype.mode = '';
+
+	CKEDITOR.editor.prototype.addMode = function( mode, modeEditor )
+	{
+		modeEditor.name = mode;
+		( this._.modes || ( this._.modes = {} ) )[ mode ] = modeEditor;
+	};
+
+	CKEDITOR.editor.prototype.setMode = function( mode )
+	{
+		var holderElement = this.getThemeSpace( 'middle' );
+
+		// Unload previous mode.
+		if ( this.mode )
+			getMode( this, this.mode ).unload( holderElement );
+
+		// Load required mode.
+		var modeEditor = getMode( this, mode );
+		if ( !modeEditor )
+			throw '[CKEDITOR.editor.setMode] Unknown mode "' + mode + '".';
+
+		this.mode = mode;
+
+		modeEditor.load( holderElement );
+	};
+})();
Index: /CKEditor/branches/prototype/_source/plugins/elementspath/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/elementspath/plugin.js	(revision 2117)
+++ /CKEditor/branches/prototype/_source/plugins/elementspath/plugin.js	(revision 2117)
@@ -0,0 +1,33 @@
+﻿/*
+ * CKEditor - The text editor for Internet - http://ckeditor.com
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ *
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ *
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+ 
+CKEDITOR.plugins.add( 'elementspath',
+{
+	init : function( editor, pluginPath )
+	{
+		editor.on( 'themespace', function( event )
+			{
+				if ( event.data.space == 'bottom' )
+					event.data.html += 
+						'<div>Elements Path!</div>';
+			});
+	}
+});
Index: /CKEditor/branches/prototype/_source/plugins/sourcearea/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/sourcearea/plugin.js	(revision 2117)
+++ /CKEditor/branches/prototype/_source/plugins/sourcearea/plugin.js	(revision 2117)
@@ -0,0 +1,42 @@
+﻿/*
+ * CKEditor - The text editor for Internet - http://ckeditor.com
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ *
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ *
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+
+CKEDITOR.plugins.add( 'sourcearea',
+{
+	init : function( editor, pluginPath )
+	{
+		editor.on( 'editingblockready', function()
+			{
+				editor.addMode( 'source',
+					{
+						load : function( holderElement )
+						{
+							holderElement.setHtml( '<pre>Source Editor</pre>' );
+						},
+
+						unload : function( holderElement )
+						{
+							holderElement.setHtml( '' );
+						}
+					});
+			});
+	}
+});
Index: /CKEditor/branches/prototype/_source/plugins/toolbar/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/toolbar/plugin.js	(revision 2117)
+++ /CKEditor/branches/prototype/_source/plugins/toolbar/plugin.js	(revision 2117)
@@ -0,0 +1,33 @@
+﻿/*
+ * CKEditor - The text editor for Internet - http://ckeditor.com
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ *
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ *
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+ 
+CKEDITOR.plugins.add( 'toolbar',
+{
+	init : function( editor, pluginPath )
+	{
+		editor.on( 'themespace', function( event )
+			{
+				if ( event.data.space == editor.config.toolbarLocation )
+					event.data.html += 
+						'<div>Toolbar!</div>';
+			});
+	}
+});
Index: /CKEditor/branches/prototype/_source/plugins/wysiwygarea/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/wysiwygarea/plugin.js	(revision 2117)
+++ /CKEditor/branches/prototype/_source/plugins/wysiwygarea/plugin.js	(revision 2117)
@@ -0,0 +1,42 @@
+﻿/*
+ * CKEditor - The text editor for Internet - http://ckeditor.com
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ *
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ *
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+
+CKEDITOR.plugins.add( 'wysiwygarea',
+{
+	init : function( editor, pluginPath )
+	{
+		editor.on( 'editingblockready', function()
+			{
+				editor.addMode( 'wysiwyg',
+					{
+						load : function( holderElement )
+						{
+							holderElement.setHtml( '<b>WYSIWYG Editor</b>' );
+						},
+
+						unload : function( holderElement )
+						{
+							holderElement.setHtml( '' );
+						}
+					});
+			});
+	}
+});
Index: /CKEditor/branches/prototype/_source/themes/default/theme.js
===================================================================
--- /CKEditor/branches/prototype/_source/themes/default/theme.js	(revision 2116)
+++ /CKEditor/branches/prototype/_source/themes/default/theme.js	(revision 2117)
@@ -19,5 +19,5 @@
  * == END LICENSE ==
  */
- 
+
 CKEDITOR.themes.add( 'default',
 {
@@ -26,7 +26,29 @@
 		editor.element.hide();
 
-		var div = new CKEDITOR.dom.element( 'div' );
-		div.setHtml( 'Theme init for "' + editor.name + '" from "' + themePath + '".' );
-		div.insertAfter( editor.element );
+		var name = editor.name;
+		
+		var topHtml		= editor.fire( 'themespace', { space : 'top', html : '' } ).html;
+		var middleHtml	= editor.fire( 'themespace', { space : 'middle', html : '' } ).html;
+		var bottomHtml	= editor.fireOnce( 'themespace', { space : 'bottom', html : '' } ).html;
+
+		var table = CKEDITOR.dom.element.createFromHtml( [
+			'<table id="cke_', name, '" class="cke_editor" border="1" cellspacing="0" cellpadding="0"><tbody>' +
+				'<tr', topHtml		? '' : ' style="display:none"', '><td id="cke_top_'		, name, '" class="cke_top">'	, topHtml	, '</td></tr>' +
+				'<tr', middleHtml	? '' : ' style="display:none"', '><td id="cke_middle_'	, name, '" class="cke_middle">'	, middleHtml, '</td></tr>' +
+				'<tr', bottomHtml	? '' : ' style="display:none"', '><td id="cke_bottom'	, name, '" class="cke_bottom">'	, bottomHtml, '</td></tr>' +
+			'</tbody></table>' ].join('') );
+
+		table.insertAfter( editor.element );
+
+		editor.fireOnce( 'themeloaded' );
+		editor.fireOnce( 'uiready' );
 	}
 });
+
+CKEDITOR.editor.prototype.getThemeSpace = function( spaceName )
+{
+	var spacePrefix = 'cke_' + spaceName;
+	var space = this._[ spacePrefix ] || 
+		( this._[ spacePrefix ] = new CKEDITOR.dom.element.getById( spacePrefix + '_' + this.name ) );
+	return space;
+};
Index: /CKEditor/branches/prototype/ckeditor.js
===================================================================
--- /CKEditor/branches/prototype/ckeditor.js	(revision 2116)
+++ /CKEditor/branches/prototype/ckeditor.js	(revision 2117)
@@ -21,5 +21,5 @@
 
 // Compressed version of core/ckeditor_base.js. See original for instructions.
-if (!window.CKEDITOR){window.CKEDITOR=(function(){return {status:'unloaded',basePath:(function(){var A='';var B=document.getElementsByTagName('script');for (var i=0;i<B.length;i++){var C=B[i].src.match(/(^|.*[\\\/])ckeditor(?:_basic)?.js(?:\?.*)?$/i);if (C){A=C[1];break;}};if (A.indexOf('://')==-1){if (A.indexOf('/')==0) A=location.href.match(/^.*?:\/\/[^\/]*/)[0]+A;else A=location.href.match(/^[^\?]*\//)[0]+A;};return A;})()};})();};
+if (!window.CKEDITOR){window.CKEDITOR=(function(){return {_:{},status:'unloaded',basePath:(function(){var A='';var B=document.getElementsByTagName('script');for (var i=0;i<B.length;i++){var C=B[i].src.match(/(^|.*[\\\/])ckeditor(?:_basic)?.js(?:\?.*)?$/i);if (C){A=C[1];break;}};if (A.indexOf('://')==-1){if (A.indexOf('/')==0) A=location.href.match(/^.*?:\/\/[^\/]*/)[0]+A;else A=location.href.match(/^[^\?]*\//)[0]+A;};return A;})()};})();};
 
 if ( CKEDITOR.loader )
Index: /CKEditor/branches/prototype/ckeditor_basic.js
===================================================================
--- /CKEditor/branches/prototype/ckeditor_basic.js	(revision 2116)
+++ /CKEditor/branches/prototype/ckeditor_basic.js	(revision 2117)
@@ -21,5 +21,5 @@
 
 // Compressed version of core/ckeditor_base.js. See original for instructions.
-if (!window.CKEDITOR){window.CKEDITOR=(function(){return {status:'unloaded',basePath:(function(){var A='';var B=document.getElementsByTagName('script');for (var i=0;i<B.length;i++){var C=B[i].src.match(/(^|.*[\\\/])ckeditor(?:_basic)?.js(?:\?.*)?$/i);if (C){A=C[1];break;}};if (A.indexOf('://')==-1){if (A.indexOf('/')==0) A=location.href.match(/^.*?:\/\/[^\/]*/)[0]+A;else A=location.href.match(/^[^\?]*\//)[0]+A;};return A;})()};})();};
+if (!window.CKEDITOR){window.CKEDITOR=(function(){return {_:{},status:'unloaded',basePath:(function(){var A='';var B=document.getElementsByTagName('script');for (var i=0;i<B.length;i++){var C=B[i].src.match(/(^|.*[\\\/])ckeditor(?:_basic)?.js(?:\?.*)?$/i);if (C){A=C[1];break;}};if (A.indexOf('://')==-1){if (A.indexOf('/')==0) A=location.href.match(/^.*?:\/\/[^\/]*/)[0]+A;else A=location.href.match(/^[^\?]*\//)[0]+A;};return A;})()};})();};
 
 // Set the script name to be loaded by the loader.
