Index: typo3/sysext/rtehtmlarea/class.tx_rtehtmlarea_base.php
===================================================================
--- typo3/sysext/rtehtmlarea/class.tx_rtehtmlarea_base.php	(révision 4943)
+++ typo3/sysext/rtehtmlarea/class.tx_rtehtmlarea_base.php	(copie de travail)
@@ -76,7 +76,6 @@
 		// Conversion array: TYPO3 button names to htmlArea button names
 	var $convertToolbarForHtmlAreaArray = array (
 		'line'			=> 'InsertHorizontalRule',
-		'chMode'		=> 'HtmlMode',
 		'showhelp'		=> 'ShowHelp',
 		'textindicator'		=> 'TextIndicator',
 		'space'			=> 'space',
Index: typo3/sysext/rtehtmlarea/ext_localconf.php
===================================================================
--- typo3/sysext/rtehtmlarea/ext_localconf.php	(révision 4943)
+++ typo3/sysext/rtehtmlarea/ext_localconf.php	(copie de travail)
@@ -95,11 +95,12 @@
 
 	// Initialize plugin registration array
 $TYPO3_CONF_VARS['EXTCONF'][$_EXTKEY]['plugins'] = array();
-
 	// Status Bar configuration
 $TYPO3_CONF_VARS['EXTCONF'][$_EXTKEY]['plugins']['StatusBar'] = array();
 $TYPO3_CONF_VARS['EXTCONF'][$_EXTKEY]['plugins']['StatusBar']['objectReference'] = 'EXT:'.$_EXTKEY.'/extensions/StatusBar/class.tx_rtehtmlarea_statusbar.php:&tx_rtehtmlarea_statusbar';
-
+	// Editor Mode configuration
+$TYPO3_CONF_VARS['EXTCONF'][$_EXTKEY]['plugins']['EditorMode'] = array();
+$TYPO3_CONF_VARS['EXTCONF'][$_EXTKEY]['plugins']['EditorMode']['objectReference'] = 'EXT:'.$_EXTKEY.'/extensions/EditorMode/class.tx_rtehtmlarea_editormode.php:&tx_rtehtmlarea_editormode';
 	// Inline Elements configuration
 $TYPO3_CONF_VARS['EXTCONF'][$_EXTKEY]['plugins']['DefaultInline'] = array();
 $TYPO3_CONF_VARS['EXTCONF'][$_EXTKEY]['plugins']['DefaultInline']['objectReference'] = 'EXT:'.$_EXTKEY.'/extensions/DefaultInline/class.tx_rtehtmlarea_defaultinline.php:&tx_rtehtmlarea_defaultinline';
Index: typo3/sysext/rtehtmlarea/extensions/EditorMode/class.tx_rtehtmlarea_editormode.php
===================================================================
--- typo3/sysext/rtehtmlarea/extensions/EditorMode/class.tx_rtehtmlarea_editormode.php	(révision 0)
+++ typo3/sysext/rtehtmlarea/extensions/EditorMode/class.tx_rtehtmlarea_editormode.php	(révision 0)
@@ -0,0 +1,64 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009 Stanislas Rolland <typo3(arobas)sjbr.ca>
+*  All rights reserved
+*
+*  This script is part of the Typo3 project. The Typo3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+/**
+ * EditorMode plugin for htmlArea RTE
+ *
+ * @author Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *
+ * TYPO3 SVN ID: $Id: class.tx_rtehtmlarea_editormode.php $
+ *
+ */
+
+require_once(t3lib_extMgm::extPath('rtehtmlarea').'class.tx_rtehtmlareaapi.php');
+
+class tx_rtehtmlarea_editormode extends tx_rtehtmlareaapi {
+
+	protected $extensionKey = 'rtehtmlarea';	// The key of the extension that is extending htmlArea RTE
+	protected $pluginName = 'EditorMode';		// The name of the plugin registered by the extension
+	protected $relativePathToLocallangFile = '';	// Path to this main locallang file of the extension relative to the extension dir.
+	protected $relativePathToSkin = 'extensions/EditorMode/skin/htmlarea.css';		// Path to the skin (css) file relative to the extension dir.
+	protected $htmlAreaRTE;				// Reference to the invoking object
+	protected $thisConfig;				// Reference to RTE PageTSConfig
+	protected $toolbar;				// Reference to RTE toolbar array
+	protected $LOCAL_LANG; 				// Frontend language array
+
+	protected $pluginButtons = 'chMode';
+	protected $convertToolbarForHtmlAreaArray = array (
+		'chMode'	=> 'TextMode',
+		);
+		// Requiring itself so that it is always loaded.
+	protected $requiredPlugins = 'EditorMode';
+	
+	public function main($parentObject) {
+		parent::main($parentObject);
+			// Do not disable this plugin even if the chMode button is disabled
+		$this->pluginAddsButtons = false;
+		return true;
+	}
+}
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/HTMLEditor/class.tx_rtehtmlarea_editormode.php']) {
+	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/HTMLEditor/class.tx_rtehtmlarea_editormode.php']);
+}
+?>
\ No newline at end of file
Index: typo3/sysext/rtehtmlarea/extensions/EditorMode/skin/htmlarea.css
===================================================================
--- typo3/sysext/rtehtmlarea/extensions/EditorMode/skin/htmlarea.css	(révision 0)
+++ typo3/sysext/rtehtmlarea/extensions/EditorMode/skin/htmlarea.css	(révision 0)
@@ -0,0 +1,6 @@
+/* Selectors for the EditorMode plugin of htmlArea RTE */
+/* TYPO3 SVN ID: $Id: htmlarea.css 2862 2008-01-05 19:32:58Z stanrolland $ */
+
+.htmlarea .toolbar .TextMode {
+	background-image:url("images/ed_html.gif");
+}
Index: typo3/sysext/rtehtmlarea/extensions/EditorMode/skin/images/ed_html.gif
===================================================================
Impossible d'afficher : fichier considéré comme binaire.
svn:mime-type = application/octet-stream

Modification de propriétés sur typo3\sysext\rtehtmlarea\extensions\EditorMode\skin\images\ed_html.gif
___________________________________________________________________
Ajouté : svn:mime-type
   + application/octet-stream

Index: typo3/sysext/rtehtmlarea/htmlarea/htmlarea-gecko.js
===================================================================
--- typo3/sysext/rtehtmlarea/htmlarea/htmlarea-gecko.js	(révision 4943)
+++ typo3/sysext/rtehtmlarea/htmlarea/htmlarea-gecko.js	(copie de travail)
@@ -504,7 +504,7 @@
 		if (navigator.productSub > 20071127) {
 			styleEvent = (ev.attrName == "style");
 		}
-		if (target == nestedObj && editor._editMode == "wysiwyg" && styleEvent && (target.style.display == "" || target.style.display == "block")) {
+		if (target == nestedObj && editor.getMode() == "wysiwyg" && styleEvent && (target.style.display == "" || target.style.display == "block")) {
 				// Check if all affected nested elements are displayed (style.display!='none'):
 			if (HTMLArea.allElementsAreDisplayed(editor.nested.sorted)) {
 				window.setTimeout(function() {
Index: typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js
===================================================================
--- typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js	(révision 4943)
+++ typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js	(copie de travail)
@@ -49,7 +49,9 @@
 			else this.config = config;
 		this._htmlArea = null;
 		this._textArea = textarea;
-		this._editMode = "wysiwyg";
+		if (typeof(this._textArea) == "string") {
+			this._textArea = HTMLArea.getElementById("textarea", this._textArea);
+		}
 		this.plugins = {};
 		this._timerToolbar = null;
 		this.doctype = '';
@@ -305,7 +307,6 @@
 
 	this.btnList = {
 		InsertHorizontalRule:	["Horizontal Rule", "ed_hr.gif",false, function(editor) {editor.execCommand("InsertHorizontalRule");}],
-		HtmlMode:		["Toggle HTML Source", "ed_html.gif", true, function(editor) {editor.execCommand("HtmlMode");}],
 		SelectAll:		["SelectAll", "", true, function(editor) {editor.execCommand("SelectAll");}, null, true, false]
 	};
 		// Default hotkeys
@@ -792,10 +793,6 @@
 
 		// get the textarea and hide it
 	var textarea = this._textArea;
-	if (typeof(textarea) == "string") {
-		textarea = HTMLArea.getElementById("textarea", textarea);
-		this._textArea = textarea;
-	}
 	textarea.style.display = "none";
 
 		// create the editor framework and insert the editor before the textarea
@@ -1051,10 +1048,8 @@
 
 HTMLArea.prototype.stylesLoaded = function() {
 	var doc = this._doc;
-	var docWellFormed = true;
 
 		// check if the stylesheets have been loaded
-
 	if (this._stylesLoadedTimer) window.clearTimeout(this._stylesLoadedTimer);
 	var stylesAreLoaded = true;
 	var errorText = '';
@@ -1071,38 +1066,11 @@
 	}
 	HTMLArea._appendToLog("[HTMLArea::initIframe]: Stylesheets successfully loaded.");
 
-	if (!this.config.fullPage) {
-		doc.body.style.borderWidth = "0px";
-		doc.body.className = "htmlarea-content-body";
-		try {
-			doc.body.innerHTML = this._textArea.value;
-		} catch(e) {
-			HTMLArea._appendToLog("[HTMLArea::initIframe]: The HTML document is not well-formed.");
-			alert(HTMLArea.I18N.msg["HTML-document-not-well-formed"]);
-			docWellFormed = false;
-		}
-	}
+	doc.body.style.borderWidth = "0px";
+	doc.body.className = "htmlarea-content-body";
 
-		// Set contents editable
-	if (docWellFormed) {
-		if (HTMLArea.is_gecko && !HTMLArea.is_safari && !HTMLArea.is_opera && !this._initEditMode()) {
-			return false;
-		}
-		if (HTMLArea.is_ie || HTMLArea.is_safari) {
-			doc.body.contentEditable = true;
-		}
-		if (HTMLArea.is_opera || HTMLArea.is_safari) {
-			doc.designMode = "on";
-			if (this._doc.queryCommandEnabled("insertbronreturn")) this._doc.execCommand("insertbronreturn", false, this.config.disableEnterParagraphs);
-			if (this._doc.queryCommandEnabled("styleWithCSS")) this._doc.execCommand("styleWithCSS", false, this.config.useCSS);
-		}
-		this._editMode = "wysiwyg";
-		if (doc.body.contentEditable || doc.designMode == "on") HTMLArea._appendToLog("[HTMLArea::initIframe]: Design mode successfully set.");
-	} else {
-		this._editMode = "textmode";
-		this.setMode("docnotwellformedmode");
-		HTMLArea._appendToLog("[HTMLArea::initIframe]: Design mode could not be set.");
-	}
+		// Initialize editor mode
+	this.getPluginInstance("EditorMode").init();
 
 		// set editor number in iframe and document for retrieval in event handlers
 	doc._editorNo = this._editorNumber;
@@ -1168,7 +1136,7 @@
 	if(!ev) var ev = window.event;
 	var form = (ev.target) ? ev.target : ev.srcElement;
 	var editor = RTEarea[form._editorNumber]["editor"];
-	editor.setHTML(editor._textArea.value);
+	editor.getPluginInstance("EditorMode").setHTML(editor._textArea.value);
 	editor.updateToolbar();
 	var a = form.__msh_prevOnReset;
 		// call previous reset methods if they were there.
@@ -1192,7 +1160,7 @@
 			if (editor) {
 				RTEarea[editorNumber].editor = null;
 					// save the HTML content into the original textarea for submit, back/forward, etc.
-				editor._textArea.value = editor.getHTML();
+				editor._textArea.value = editor.getPluginInstance("EditorMode").getHTML();
 					// do final cleanup
 				HTMLArea.cleanup(editor);
 			}
@@ -1271,62 +1239,10 @@
 };
 
 /*
- * Switch editor mode; parameter can be "textmode" or "wysiwyg".
- *  If no parameter was passed, toggle between modes.
- */
-HTMLArea.prototype.setMode = function(mode) {
-	if (typeof(mode) == "undefined") var mode = (this._editMode == "textmode") ? "wysiwyg" : "textmode";
-	switch (mode) {
-		case "textmode":
-		case "docnotwellformedmode":
-			this._textArea.value = this.getHTML();
-			this._iframe.style.display = "none";
-			this._textArea.style.display = "block";
-			this._editMode = "textmode";
-			break;
-		case "wysiwyg":
-			if(HTMLArea.is_gecko && !HTMLArea.is_safari && !HTMLArea.is_opera) this._doc.designMode = "off";
-			try {
-				if(!this.config.fullPage) this._doc.body.innerHTML = this.getHTML();
-					else this.setFullHTML(this.getHTML());
-			} catch(e) {
-				alert(HTMLArea.I18N.msg["HTML-document-not-well-formed"]);
-				break;
-			}
-			this._textArea.style.display = "none";
-			this._iframe.style.display = "block";
-			if (HTMLArea.is_gecko && !HTMLArea.is_safari && !HTMLArea.is_opera) this._doc.designMode = "on";
-			this._editMode = "wysiwyg";
-				//set gecko options (if we can... raises exception in Firefox 3)
-			if (HTMLArea.is_gecko) {
-				try {
-					if (this._doc.queryCommandEnabled("insertbronreturn")) this._doc.execCommand("insertbronreturn", false, this.config.disableEnterParagraphs);
-					if (this._doc.queryCommandEnabled("enableObjectResizing")) this._doc.execCommand("enableObjectResizing", false, !this.config.disableObjectResizing);
-					if (this._doc.queryCommandEnabled("enableInlineTableEditing")) this._doc.execCommand("enableInlineTableEditing", false, (this.config.buttons.table && this.config.buttons.table.enableHandles) ? true : false);
-					if (this._doc.queryCommandEnabled("styleWithCSS")) this._doc.execCommand("styleWithCSS", false, this.config.useCSS);
-						else if (this._doc.queryCommandEnabled("useCSS")) this._doc.execCommand("useCSS", false, !this.config.useCSS);
-				} catch(e) {}
-			}
-			break;
-		default:
-			return false;
-	}
-	if (mode !== "docnotwellformedmode") this.focusEditor();
-	for (var pluginId in this.plugins) {
-		if (this.plugins.hasOwnProperty(pluginId)) {
-			var pluginInstance = this.plugins[pluginId].instance;
-			if (typeof(pluginInstance.onMode) === "function") {
-				pluginInstance.onMode(mode);
-			}
-		}
-	}
-};
-
-/*
  * Get editor mode
  */
 HTMLArea.prototype.getMode = function() {
-	return this._editMode;
+	return this.getPluginInstance("EditorMode").getEditorMode();
 };
 
 /*
@@ -1485,7 +1401,7 @@
  * Focus the editor iframe document or the textarea.
  */
 HTMLArea.prototype.focusEditor = function() {
-	switch (this._editMode) {
+	switch (this.getMode()) {
 		case "wysiwyg" :
 			try {
 				if (HTMLArea.is_safari) {
@@ -1586,9 +1502,6 @@
 						}
 					}
 					break;
-				case "HtmlMode":
-					btn.state("active", text);
-					break;
 				default:
 					break;
 			}
@@ -1804,10 +1717,7 @@
 HTMLArea.prototype.execCommand = function(cmdID, UI, param) {
 	this.focusEditor();
 	switch (cmdID) {
-		case "HtmlMode"	:
-			this.setMode();
-			break;
-		default		:
+		default:
 			try {
 				this._doc.execCommand(cmdID, UI, param);
 			} catch(e) {
@@ -1969,47 +1879,13 @@
 };
 
 /*
- * Retrieve the HTML
+ * Get the html content of the current editing mode
  */
 HTMLArea.prototype.getHTML = function() {
-	switch (this._editMode) {
-		case "wysiwyg":
-			return HTMLArea.getHTML(this._doc.body, false, this);
-		case "textmode":
-			return this._textArea.value;
-	}
-	return false;
+	return this.getPluginInstance("EditorMode").getHTML();
 };
 
 /*
- * Retrieve raw HTML
- */
-HTMLArea.prototype.getInnerHTML = function() {
-	switch (this._editMode) {
-		case "wysiwyg":
-			return this._doc.body.innerHTML;
-		case "textmode":
-			return this._textArea.value;
-	}
-	return false;
-};
-
-/*
- * Replace the HTML inside
- */
-HTMLArea.prototype.setHTML = function(html) {
-	switch (this._editMode) {
-		case "wysiwyg":
-			this._doc.body.innerHTML = html;
-			break;
-		case "textmode":
-			this._textArea.value = html;
-			break;
-	}
-	return false;
-};
-
-/*
  * Set the given doctype when config.fullPage is true
  */
 HTMLArea.prototype.setDoctype = function(doctype) {
@@ -2799,6 +2675,15 @@
 	},
 
 	/**
+	 * Returns a current editor mode
+	 *
+	 * @return	string		editor mode
+	 */
+	getEditorMode : function() {
+		return this.getPluginInstance("EditorMode").getEditorMode();
+	},
+
+	/**
 	 * Returns true if the button is enabled in the toolbar configuration
 	 *
 	 * @param	string		buttonId: identification of the button
Index: typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockElements/block-elements.js
===================================================================
--- typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockElements/block-elements.js	(révision 4943)
+++ typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockElements/block-elements.js	(copie de travail)
@@ -921,7 +921,7 @@
 	 * This function gets called when the toolbar is updated
 	 */
 	onUpdateToolbar : function () {
-		if (this.editor.getMode() === "textmode" || !this.editor.isEditable()) {
+		if (this.getEditorMode() === "textmode" || !this.editor.isEditable()) {
 			return false;
 		}
 		var statusBarSelection = this.editor.getPluginInstance("StatusBar") ? this.editor.getPluginInstance("StatusBar").getSelection() : null;
Index: typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockStyle/block-style.js
===================================================================
--- typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockStyle/block-style.js	(révision 4943)
+++ typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockStyle/block-style.js	(copie de travail)
@@ -221,7 +221,7 @@
 	 * This function gets called when the toolbar is being updated
 	 */
 	onUpdateToolbar : function() {
-		if (this.editor.getMode() === "wysiwyg") {
+		if (this.getEditorMode() === "wysiwyg") {
 			this.generate(this.editor, "BlockStyle");
 		}
 	},
@@ -230,7 +230,7 @@
 	 * This function gets called when the editor has changed its mode to "wysiwyg"
 	 */
 	onMode : function(mode) {
-		if (this.editor.getMode() === "wysiwyg") {
+		if (this.getEditorMode() === "wysiwyg") {
 			this.generate(this.editor, "BlockStyle");
 		}
 	},
@@ -240,7 +240,7 @@
 	 * Re-initiate the parsing of the style sheets, if not yet completed, and refresh our toolbar components
 	 */
 	generate : function(editor, dropDownId) {
-		if (this.cssLoaded && this.editor.getMode() === "wysiwyg" && this.editor.isEditable()) {
+		if (this.cssLoaded && this.getEditorMode() === "wysiwyg" && this.editor.isEditable()) {
 			this.updateValue(dropDownId);
 		} else {
 			if (this.cssTimeout) {
Index: typo3/sysext/rtehtmlarea/htmlarea/plugins/CopyPaste/copy-paste.js
===================================================================
--- typo3/sysext/rtehtmlarea/htmlarea/plugins/CopyPaste/copy-paste.js	(révision 4943)
+++ typo3/sysext/rtehtmlarea/htmlarea/plugins/CopyPaste/copy-paste.js	(copie de travail)
@@ -340,7 +340,7 @@
 	 * This function gets called when the toolbar is updated
 	 */
 	onUpdateToolbar : function () {
-		if (this.editor.getMode() === "wysiwyg" || this.editor.isEditable()) {
+		if (this.getEditorMode() === "wysiwyg" || this.editor.isEditable()) {
 			var buttonId = "Paste";
 			if (typeof(this.editor._toolbarObjects[buttonId]) !== "undefined") {
 				try {
Index: typo3/sysext/rtehtmlarea/htmlarea/plugins/DefinitionList/definition-list.js
===================================================================
--- typo3/sysext/rtehtmlarea/htmlarea/plugins/DefinitionList/definition-list.js	(révision 4943)
+++ typo3/sysext/rtehtmlarea/htmlarea/plugins/DefinitionList/definition-list.js	(copie de travail)
@@ -304,7 +304,7 @@
 	 * This function gets called when the toolbar is updated
 	 */
 	onUpdateToolbar : function () {
-		if (this.editor.getMode() === "textmode" || !this.editor.isEditable()) {
+		if (this.getEditorMode() === "textmode" || !this.editor.isEditable()) {
 			return false;
 		}
 		var statusBarSelection = this.editor.getPluginInstance("StatusBar") ? this.editor.getPluginInstance("StatusBar").getSelection() : null;
Index: typo3/sysext/rtehtmlarea/htmlarea/plugins/EditorMode/editor-mode.js
===================================================================
--- typo3/sysext/rtehtmlarea/htmlarea/plugins/EditorMode/editor-mode.js	(révision 0)
+++ typo3/sysext/rtehtmlarea/htmlarea/plugins/EditorMode/editor-mode.js	(révision 0)
@@ -0,0 +1,302 @@
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009 Stanislas Rolland <typo3(arobas)sjbr.ca>
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*  A copy is found in the textfile GPL.txt and important notices to the license
+*  from the author is found in LICENSE.txt distributed with these scripts.
+*
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+/*
+ * EditorMode Plugin for TYPO3 htmlArea RTE
+ *
+ * TYPO3 SVN ID: $Id: editor-mode.js $
+ */
+EditorMode = HTMLArea.Plugin.extend({
+
+	constructor : function(editor, pluginName) {
+		this.base(editor, pluginName);
+	},
+
+	/*
+	 * This function gets called by the class constructor
+	 */
+	configurePlugin : function (editor) {
+
+		/*
+		 * Registering plugin "About" information
+		 */
+		var pluginInformation = {
+			version		: "0.1",
+			developer	: "Stanislas Rolland",
+			developerUrl	: "http://www.sjbr.ca/",
+			copyrightOwner	: "Stanislas Rolland",
+			sponsor		: "SJBR",
+			sponsorUrl	: "http://www.sjbr.ca/",
+			license		: "GPL"
+		};
+		this.registerPluginInformation(pluginInformation);
+
+		/*
+		 * Registering the buttons
+		 */
+		var buttonList = this.buttonList, buttonId;
+		for (var i = 0, n = buttonList.length; i < n; ++i) {
+			var button = buttonList[i];
+			buttonId = button[0];
+			var buttonConfiguration = {
+				id		: buttonId,
+				tooltip		: this.localize(buttonId + "-Tooltip"),
+				action		: "onButtonPress",
+				context		: button[1],
+				textMode	: (buttonId == "TextMode")
+			};
+			this.registerButton(buttonConfiguration);
+		}
+		return true;
+	 },
+
+	/* The list of buttons added by this plugin */
+	buttonList : [
+		["TextMode", null]
+	],
+
+	/*
+	 * This function gets called during the editor generation and initializes the editor mode
+	 *
+	 * @return	void
+	 */
+	init : function () {
+		var doc = this.editor._doc;
+			// Catch error if html content is invalid
+		var documentIsWellFormed = true;
+		try {
+			doc.body.innerHTML = this.editor._textArea.value;
+		} catch(e) {
+			this.appendToLog("init", "The HTML document is not well-formed.");
+			alert(this.localize("HTML-document-not-well-formed"));
+			documentIsWellFormed = false;
+		}
+			// Set contents editable
+		if (documentIsWellFormed) {
+			if (HTMLArea.is_gecko && !HTMLArea.is_safari && !HTMLArea.is_opera && !this.editor._initEditMode()) {
+				return false;
+			}
+			if (HTMLArea.is_ie || HTMLArea.is_safari) {
+				doc.body.contentEditable = true;
+			}
+			if (HTMLArea.is_opera || HTMLArea.is_safari) {
+				doc.designMode = "on";
+				this.setGeckoOptions();
+			}
+			this.editorMode = "wysiwyg";
+			if (doc.body.contentEditable || doc.designMode == "on") {
+				this.appendToLog("init", "Design mode successfully set.");
+			}
+		} else {
+			this.editorMode = "textmode";
+			this.setEditorMode("docnotwellformedmode");
+			this.appendToLog("init", "Design mode could not be set.");
+		}
+	},
+
+	/*
+	 * This function gets called when the editor is generated
+	 *
+	 * @return 	void
+	 */
+	onGenerate : function () {
+			// Set some references
+		this.textArea = this.editor._textArea;
+		this.editorBody = this.editor._doc.body;
+	},
+
+	/*
+	 * This function gets called when a button was pressed.
+	 *
+	 * @param	object		editor: the editor instance
+	 * @param	string		id: the button id or the key
+	 *
+	 * @return	boolean		false if action is completed
+	 */
+	onButtonPress : function (editor, id, target) {
+			// Could be a button or its hotkey
+		var buttonId = this.translateHotKey(id);
+		buttonId = buttonId ? buttonId : id;
+		this.setEditorMode((this.getEditorMode() == buttonId.toLowerCase()) ? "wysiwyg" : buttonId.toLowerCase());
+		return false;
+	},
+
+	/*
+	 * Switch editor mode
+	 *
+	 * @param	string	"textmode" or "wysiwyg"; if no parameter was passed, toggle between modes.
+	 * @return	void
+	 */
+	setEditorMode : function (mode) {
+		var editor = this.editor;
+		switch (mode) {
+			case "textmode":
+			case "docnotwellformedmode":
+				this.textArea.value = this.getHTML();
+				editor._iframe.style.display = "none";
+				this.textArea.style.display = "block";
+				this.editorMode = "textmode";
+				break;
+			case "wysiwyg":
+				if (HTMLArea.is_gecko && !HTMLArea.is_safari && !HTMLArea.is_opera) {
+					editor._doc.designMode = "off";
+				}
+				try {
+					this.editorBody.innerHTML = this.getHTML();
+				} catch(e) {
+					alert(HTMLArea.I18N.msg["HTML-document-not-well-formed"]);
+					break;
+				}
+				this.textArea.style.display = "none";
+				editor._iframe.style.display = "block";
+				if (HTMLArea.is_gecko && !HTMLArea.is_safari && !HTMLArea.is_opera) {
+					editor._doc.designMode = "on";
+				}
+				this.editorMode = "wysiwyg";
+				this.setGeckoOptions();
+				break;
+			case "htmlmode":
+				this.editorMode = "htmlmode";
+				break;
+			default:
+				return false;
+		}
+		if (mode !== "docnotwellformedmode") {
+			editor.focusEditor();
+		}
+		for (var pluginId in editor.plugins) {
+			if (editor.plugins.hasOwnProperty(pluginId)) {
+				var pluginInstance = this.getPluginInstance(pluginId);
+				if (typeof(pluginInstance.onMode) === "function") {
+					pluginInstance.onMode(mode);
+				}
+			}
+		}
+	},
+
+	/*
+	 * Set gecko editing mode options (if we can... raises exception in Firefox 3)
+	 *
+	 * @return	void
+	 */
+	setGeckoOptions : function () {
+		if (HTMLArea.is_gecko) {
+			var doc = this.editor._doc;
+			var config = this.editor.config;
+			try {
+				if (doc.queryCommandEnabled("insertbronreturn")) {
+					doc.execCommand("insertbronreturn", false, config.disableEnterParagraphs);
+				}
+				if (doc.queryCommandEnabled("styleWithCSS")) {
+					doc.execCommand("styleWithCSS", false, config.useCSS);
+				} else if (!HTMLArea.is_opera && !HTMLArea.is_safari && doc.queryCommandEnabled("useCSS")) {
+					doc.execCommand("useCSS", false, !config.useCSS);
+				}
+				if (!HTMLArea.is_opera && !HTMLArea.is_safari) {
+					if (doc.queryCommandEnabled("enableObjectResizing")) {
+						doc.execCommand("enableObjectResizing", false, !config.disableObjectResizing);
+					}
+					if (doc.queryCommandEnabled("enableInlineTableEditing")) {
+						doc.execCommand("enableInlineTableEditing", false, (config.buttons.table && config.buttons.table.enableHandles) ? true : false);
+					}
+				}
+			} catch(e) {}
+		}
+	},
+
+	/*
+	 * Get editor mode
+	 *
+	 * @return	string	the current editor mode
+	 */
+	getEditorMode : function() {
+		return this.editorMode;
+	},
+
+	/*
+	 * This function gets called when the toolbar is updated
+	 *
+	 * @return	void
+	 */
+	onUpdateToolbar : function () {
+		var buttonList = this.buttonList, buttonId;
+		for (var i = 0, n = buttonList.length; i < n; ++i) {
+			buttonId = buttonList[i][0];
+			if (this.isButtonInToolbar(buttonId)) {
+				this.editor._toolbarObjects[buttonId].state("active", (this.getEditorMode() == buttonId.toLowerCase()));
+			}
+		}
+	},
+
+	/*
+	 * Retrieve the HTML
+	 * In the case of the wysiwyg mode, the html content is parsed
+	 *
+	 * @return	string	the textual html content from the current editing mode
+	 */
+	getHTML : function () {
+		switch (this.editorMode) {
+			case "wysiwyg":
+				return HTMLArea.getHTML(this.editorBody, false, this.editor);
+			case "textmode":
+				return this.textArea.value;
+		}
+		return "";
+	},
+
+	/*
+	 * Retrieve raw HTML
+	 *
+	 * @return	string	the textual html content from the current editing mode
+	 */
+	getInnerHTML : function () {
+		switch (this.editorMode) {
+			case "wysiwyg":
+				return this.editorBody.innerHTML;
+			case "textmode":
+				return this.textArea.value;
+		}
+		return "";
+	},
+
+	/*
+	 * Replace the HTML inside
+	 *
+	 * @param	string	html: the textual html
+	 * @return	boolean	false
+	 */
+	setHTML : function (html) {
+		switch (this.editorMode) {
+			case "wysiwyg":
+				this.editorBody.innerHTML = html;
+				break;
+			case "textmode":
+				this.textArea.value = html;
+				break;
+		}
+		return false;
+	}
+});
Index: typo3/sysext/rtehtmlarea/htmlarea/plugins/EditorMode/locallang.xml
===================================================================
--- typo3/sysext/rtehtmlarea/htmlarea/plugins/EditorMode/locallang.xml	(révision 0)
+++ typo3/sysext/rtehtmlarea/htmlarea/plugins/EditorMode/locallang.xml	(révision 0)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<T3locallang>
+	<meta type="array">
+		<description>Labels for Editor Mode plugin of htmlArea RTE</description>
+		<type>module</type>
+	</meta>
+	<data type="array">
+		<languageKey index="default" type="array">
+			<label index="TextMode-Tooltip">Toggle text mode</label>
+			<label index="HTMLMode-Tooltip">Toggle HTML mode</label>
+		</languageKey>
+	</data>
+	<orig_hash type="array">
+		<languageKey index="default" type="array">
+		</languageKey>
+	</orig_hash>
+	<orig_text type="array">
+		<languageKey index="default" type="array">
+		</languageKey>
+	</orig_text>
+</T3locallang>
\ No newline at end of file
Index: typo3/sysext/rtehtmlarea/htmlarea/plugins/InlineElements/inline-elements.js
===================================================================
--- typo3/sysext/rtehtmlarea/htmlarea/plugins/InlineElements/inline-elements.js	(révision 4943)
+++ typo3/sysext/rtehtmlarea/htmlarea/plugins/InlineElements/inline-elements.js	(copie de travail)
@@ -356,7 +356,7 @@
 	*/
 	onUpdateToolbar : function () {
 		var editor = this.editor;
-		if (editor.getMode() === "wysiwyg" && editor.isEditable()) {
+		if (this.getEditorMode() === "wysiwyg" && editor.isEditable()) {
 			var id, activeButton;
 			var tagName = false, endPointsInSameBlock = true, fullNodeSelected = false;
 			var sel = editor._getSelection();
Index: typo3/sysext/rtehtmlarea/htmlarea/plugins/Language/language.js
===================================================================
--- typo3/sysext/rtehtmlarea/htmlarea/plugins/Language/language.js	(révision 4943)
+++ typo3/sysext/rtehtmlarea/htmlarea/plugins/Language/language.js	(copie de travail)
@@ -368,7 +368,7 @@
 	 * This function gets called when the toolbar is updated
 	 */
 	onUpdateToolbar : function () {
-		if (this.editor.getMode() === "wysiwyg" && this.editor.isEditable()) {
+		if (this.getEditorMode() === "wysiwyg" && this.editor.isEditable()) {
 			var selection = this.editor._getSelection();
 			var statusBarSelection = this.editor.getPluginInstance("StatusBar") ? this.editor.getPluginInstance("StatusBar").getSelection() : null;
 			var range = this.editor._createRange(selection);
Index: typo3/sysext/rtehtmlarea/htmlarea/plugins/StatusBar/status-bar.js
===================================================================
--- typo3/sysext/rtehtmlarea/htmlarea/plugins/StatusBar/status-bar.js	(révision 4943)
+++ typo3/sysext/rtehtmlarea/htmlarea/plugins/StatusBar/status-bar.js	(copie de travail)
@@ -158,7 +158,7 @@
 	 * Update the status bar
 	 */
 	onUpdateToolbar : function() {
-		if (this.editor.getMode() == "wysiwyg" && !this.noUpdate) {
+		if (this.getEditorMode() == "wysiwyg" && !this.noUpdate) {
 			var text,
 				language,
 				languageObject = this.editor.getPluginInstance("Language"),
Index: typo3/sysext/rtehtmlarea/htmlarea/plugins/TableOperations/table-operations.js
===================================================================
--- typo3/sysext/rtehtmlarea/htmlarea/plugins/TableOperations/table-operations.js	(révision 4943)
+++ typo3/sysext/rtehtmlarea/htmlarea/plugins/TableOperations/table-operations.js	(copie de travail)
@@ -514,7 +514,7 @@
 	 * This function gets called when the toolbar is being updated
 	 */
 	onUpdateToolbar : function() {
-		if (this.editor.getMode() === "wysiwyg" && this.editor.isEditable() && this.isButtonInToolbar("TO-toggle-borders")) {
+		if (this.getEditorMode() === "wysiwyg" && this.editor.isEditable() && this.isButtonInToolbar("TO-toggle-borders")) {
 			this.editor._toolbarObjects["TO-toggle-borders"].state("active", HTMLArea._hasClass(this.editor._doc.body, 'htmlarea-showtableborders'));
 		}
 	},
Index: typo3/sysext/rtehtmlarea/htmlarea/plugins/TextStyle/text-style.js
===================================================================
--- typo3/sysext/rtehtmlarea/htmlarea/plugins/TextStyle/text-style.js	(révision 4943)
+++ typo3/sysext/rtehtmlarea/htmlarea/plugins/TextStyle/text-style.js	(copie de travail)
@@ -391,7 +391,7 @@
 	 * This function gets called when the toolbar is being updated
 	 */
 	onUpdateToolbar : function() {
-		if (this.editor.getMode() === "wysiwyg" && this.editor.isEditable()) {
+		if (this.getEditorMode() === "wysiwyg" && this.editor.isEditable()) {
 			this.generate(this.editor, "TextStyle");
 		}
 	},
@@ -401,7 +401,7 @@
 	*/
 	updateToolbar : function(dropDownId) {
 		var editor = this.editor;
-		if (this.editor.getMode() === "wysiwyg" && this.editor.isEditable()) {
+		if (this.getEditorMode() === "wysiwyg" && this.editor.isEditable()) {
 			var tagName = false, classNames = Array(), fullNodeSelected = false;
 			var selection = editor._getSelection();
 			var statusBarSelection = editor.getPluginInstance("StatusBar") ? editor.getPluginInstance("StatusBar").getSelection() : null;
Index: typo3/sysext/rtehtmlarea/htmlarea/plugins/TYPO3Color/typo3color.js
===================================================================
--- typo3/sysext/rtehtmlarea/htmlarea/plugins/TYPO3Color/typo3color.js	(révision 4943)
+++ typo3/sysext/rtehtmlarea/htmlarea/plugins/TYPO3Color/typo3color.js	(copie de travail)
@@ -376,7 +376,7 @@
 	 */
 	onUpdateToolbar : function () {
 		var editor = this.editor;
-		if (editor.getMode() === "wysiwyg" && editor.isEditable()) {
+		if (this.getEditorMode() === "wysiwyg" && editor.isEditable()) {
 			var buttonId;
 			var statusBarSelection = editor.getPluginInstance("StatusBar") ? editor.getPluginInstance("StatusBar").getSelection() : null;
 			var parentElement = statusBarSelection ? statusBarSelection : editor.getParentElement();
Index: typo3/sysext/rtehtmlarea/htmlarea/plugins/TYPO3HtmlParser/typo3html-parser.js
===================================================================
--- typo3/sysext/rtehtmlarea/htmlarea/plugins/TYPO3HtmlParser/typo3html-parser.js	(révision 4943)
+++ typo3/sysext/rtehtmlarea/htmlarea/plugins/TYPO3HtmlParser/typo3html-parser.js	(copie de travail)
@@ -97,12 +97,12 @@
 		var bookmark = editor.getBookmark(editor._createRange(editor._getSelection()));
 		var content = {
 			editorNo : this.editorNumber,
-			content	 : editor._doc.body.innerHTML
+			content	 : this.getPluginInstance("EditorMode").getInnerHTML()
 		};
 		this.postData(	this.parseHtmlModulePath,
 				content,
 				function(response) {
-					editor.setHTML(response);
+					editor.getPluginInstance("EditorMode").setHTML(response);
 					editor.selectRange(editor.moveToBookmark(bookmark));
 				}
 		);
Index: typo3/sysext/rtehtmlarea/htmlarea/plugins/UndoRedo/undo-redo.js
===================================================================
--- typo3/sysext/rtehtmlarea/htmlarea/plugins/UndoRedo/undo-redo.js	(révision 4943)
+++ typo3/sysext/rtehtmlarea/htmlarea/plugins/UndoRedo/undo-redo.js	(copie de travail)
@@ -132,7 +132,7 @@
 			newSnapshot = true;
 		}
 			// Get the html text
-		var text = this.editor.getInnerHTML();
+		var text = this.getPluginInstance("EditorMode").getInnerHTML();
 		
 		if (newSnapshot) {
 				// If previous slot contains the same text, a new one should not be used
@@ -178,7 +178,7 @@
 			}
 				// Get the bookmarked html text and remove the bookmark
 			if (bookmark) {
-				bookmarkedText = this.editor.getInnerHTML();
+				bookmarkedText = this.getPluginInstance("EditorMode").getInnerHTML();
 				var range = this.editor.moveToBookmark(bookmark);
 					// Restore Firefox selection
 				if (HTMLArea.is_gecko && !HTMLArea.is_opera && !HTMLArea.is_safari) {
@@ -188,7 +188,7 @@
 			}
 		}
 		return {
-			text		: this.editor.getInnerHTML(),
+			text		: this.getPluginInstance("EditorMode").getInnerHTML(),
 			bookmark	: bookmark,
 			bookmarkedText	: bookmarkedText
 		};
@@ -227,12 +227,12 @@
 	setContent : function (undoPosition) {
 		var bookmark = this.undoQueue[undoPosition].bookmark;
 		if (bookmark) {
-			this.editor.setHTML(this.undoQueue[undoPosition].bookmarkedText);
+			this.getPluginInstance("EditorMode").setHTML(this.undoQueue[undoPosition].bookmarkedText);
 			this.editor.focusEditor();
 			this.editor.selectRange(this.editor.moveToBookmark(bookmark));
 			this.editor.scrollToCaret();
 		} else {
-			this.editor.setHTML(this.undoQueue[undoPosition].text);
+			this.getPluginInstance("EditorMode").setHTML(this.undoQueue[undoPosition].text);
 		}
 	},
 	
Index: typo3/sysext/rtehtmlarea/htmlarea/skins/default/htmlarea.css
===================================================================
--- typo3/sysext/rtehtmlarea/htmlarea/skins/default/htmlarea.css	(révision 4943)
+++ typo3/sysext/rtehtmlarea/htmlarea/skins/default/htmlarea.css	(copie de travail)
@@ -113,7 +113,7 @@
 .htmlarea .toolbar .Acronym { background-image:url("images/Acronym/ed_acronym.gif"); }
 .htmlarea .toolbar .RemoveFormat { background-image:url("images/RemoveFormat/ed_clean.gif"); }
 .htmlarea .toolbar .SplitBlock {background-image:url("images/ed_splitblock.gif"); }
-.htmlarea .toolbar .HtmlMode { background-image:url("images/ed_html.gif"); }
+.htmlarea .toolbar .TextMode { background-image:url("images/ed_html.gif"); }
 .htmlarea .toolbar .Copy, .htmlarea-context-menu .Copy  { background-image:url("images/ed_copy.gif");}
 .htmlarea .toolbar .Cut, .htmlarea-context-menu .Cut  { background-image:url("images/ed_cut.gif");}
 .htmlarea .toolbar .Paste, .htmlarea-context-menu .Paste { background-image:url("images/ed_paste.gif");}
Index: typo3/sysext/t3skin/rtehtmlarea/htmlarea.css
===================================================================
--- typo3/sysext/t3skin/rtehtmlarea/htmlarea.css	(révision 4943)
+++ typo3/sysext/t3skin/rtehtmlarea/htmlarea.css	(copie de travail)
@@ -123,7 +123,7 @@
 .htmlarea .toolbar .Acronym {background-image:url("images/Acronym/ed_acronym.gif"); }
 .htmlarea .toolbar .RemoveFormat {background-image:url("images/RemoveFormat/ed_clean.gif"); }
 .htmlarea .toolbar .SplitBlock {background-image:url("images/ed_splitblock.gif"); }
-.htmlarea .toolbar .HtmlMode {background-image:url("images/ed_html.gif"); }
+.htmlarea .toolbar .TextMode {background-image:url("images/ed_html.gif"); }
 .htmlarea .toolbar .Copy, .htmlarea-context-menu .Copy  {background-image:url("images/ed_copy.gif");}
 .htmlarea .toolbar .Cut, .htmlarea-context-menu .Cut  {background-image:url("images/ed_cut.gif");}
 .htmlarea .toolbar .Paste, .htmlarea-context-menu .Paste {background-image:url("images/ed_paste.gif");}
