Index: /MediaWiki/trunk/FCKeditor.body.php
===================================================================
--- /MediaWiki/trunk/FCKeditor.body.php	(revision 2075)
+++ /MediaWiki/trunk/FCKeditor.body.php	(revision 2076)
@@ -386,4 +386,130 @@
 		// Hide the default toolbar.
 		document.getElementById('toolbar').style.cssText = 'display:none;' ;
+		// do things with CharInsert for example
+
+		var edittools_markup = document.getElementById ('editpage-specialchars') ;
+		if (edittools_markup) {
+			edittools_markup.style.display = 'none' ;
+		}
+		insertTags = function (tagOpen, tagClose, sampleText)
+		{
+			var txtarea;
+
+			if ( !(typeof(FCK) == "undefined") && !(typeof(FCK.EditingArea) == "undefined") )
+			{
+				txtarea = FCK.EditingArea.Textarea ;
+			}
+			else if (document.editform)
+			{
+				// if we have FCK enabled, behave differently...
+				FCKarea = document.getElementById( oFCKeditor.InstanceName ) ;
+				if ( FCKarea.style.display == 'none' )
+				{
+					SRCiframe = document.getElementById ('wpTextbox1___Frame') ;
+					if ( SRCiframe )
+					{
+						if (window.frames[SRCiframe])
+							SRCdoc = window.frames[SRCiframe].document ;
+						else
+							SRCdoc = SRCiframe.contentDocument ;
+							
+						var SRCarea = SRCdoc.getElementById ('xEditingArea').firstChild ;
+						
+						if (SRCarea)
+							txtarea = SRCarea ;
+						else
+							return false ;
+							
+					} 
+					else 
+					{
+						return false ;
+					}
+				}
+				else
+				{
+					txtarea = document.editform.wpTextbox1 ;
+				}
+			}
+			else
+			{
+				// some alternate form? take the first one we can find
+				var areas = document.getElementsByTagName( 'textarea' ) ;
+				txtarea = areas[0] ;
+			}
+
+			var selText, isSample = false ;
+
+			if ( document.selection  && document.selection.createRange ) 
+			{ // IE/Opera
+
+				//save window scroll position
+				if ( document.documentElement && document.documentElement.scrollTop )
+					var winScroll = document.documentElement.scrollTop ;
+				else if ( document.body )
+					var winScroll = document.body.scrollTop ;
+
+				//get current selection
+				txtarea.focus() ;
+				var range = document.selection.createRange() ;
+				selText = range.text ;
+				//insert tags
+				checkSelectedText() ;
+				range.text = tagOpen + selText + tagClose ;
+				//mark sample text as selected
+				if ( isSample && range.moveStart )
+				{
+					if (window.opera)
+						tagClose = tagClose.replace(/\\n/g,'') ; //check it out one more time
+					range.moveStart('character', - tagClose.length - selText.length) ;
+					range.moveEnd('character', - tagClose.length) ;
+				}
+				range.select();
+				//restore window scroll position
+				if ( document.documentElement && document.documentElement.scrollTop )
+					document.documentElement.scrollTop = winScroll ;
+				else if ( document.body )
+					document.body.scrollTop = winScroll ;
+
+			} 
+			else if ( txtarea.selectionStart || txtarea.selectionStart == '0' ) 
+			{ // Mozilla
+
+				//save textarea scroll position
+				var textScroll = txtarea.scrollTop ;
+				//get current selection
+				txtarea.focus() ;
+				var startPos = txtarea.selectionStart ;
+				var endPos = txtarea.selectionEnd ;
+				selText = txtarea.value.substring( startPos, endPos ) ;
+				
+				//insert tags
+				if (!selText) 
+				{
+					selText = sampleText ;
+					isSample = true ;
+				} 
+				else if (selText.charAt(selText.length - 1) == ' ')
+				{ //exclude ending space char
+					selText = selText.substring(0, selText.length - 1) ;
+					tagClose += ' ' ;
+				}
+				txtarea.value = txtarea.value.substring(0, startPos) + tagOpen + selText + tagClose + 
+								txtarea.value.substring(endPos, txtarea.value.length) ;
+				//set new selection
+				if (isSample) 
+				{
+					txtarea.selectionStart = startPos + tagOpen.length ;
+					txtarea.selectionEnd = startPos + tagOpen.length + selText.length ;
+				} 
+				else 
+				{
+					txtarea.selectionStart = startPos + tagOpen.length + selText.length + tagClose.length ;
+					txtarea.selectionEnd = txtarea.selectionStart;
+				}
+				//restore textarea scroll position
+				txtarea.scrollTop = textScroll;
+			}
+		}
 	}
 }
Index: /MediaWiki/trunk/plugins/mediawiki/fckplugin.js
===================================================================
--- /MediaWiki/trunk/plugins/mediawiki/fckplugin.js	(revision 2075)
+++ /MediaWiki/trunk/plugins/mediawiki/fckplugin.js	(revision 2076)
@@ -57,4 +57,51 @@
 FCKCommands.RegisterCommand( 'Image', new FCKDialogCommand( 'Image', FCKLang.DlgImgTitle, FCKConfig.PluginsPath + 'mediawiki/dialogs/image.html', 450, 300 ) ) ;
 
+FCKToolbarItems.OldGetItem = FCKToolbarItems.GetItem;
+
+FCKToolbarItems.GetItem = function( itemName )
+{
+	var oItem = FCKToolbarItems.LoadedItems[ itemName ] ;
+
+	if ( oItem )
+		return oItem ;
+
+	switch ( itemName )
+	{
+		case 'Bold'			: oItem = new FCKToolbarButton( 'Bold'          , FCKLang.Bold, null, null, true, true, 20 ) ; break ;
+		case 'Italic'		: oItem = new FCKToolbarButton( 'Italic'        , FCKLang.Italic, null, null, true, true, 21 ) ; break ;
+		case 'Underline'	: oItem = new FCKToolbarButton( 'Underline'     , FCKLang.Underline, null, null, true, true, 22 ) ; break ;
+		case 'StrikeThrough': oItem = new FCKToolbarButton( 'StrikeThrough' , FCKLang.StrikeThrough, null, null, true, true, 23 ) ; break ;
+		case 'Link'			: oItem = new FCKToolbarButton( 'Link'          , FCKLang.InsertLinkLbl, FCKLang.InsertLink, null, true, true, 34 ) ; break ;
+
+		default:
+			return FCKToolbarItems.OldGetItem( itemName );
+	}
+
+	FCKToolbarItems.LoadedItems[ itemName ] = oItem ;
+
+	return oItem ;
+}
+
+FCKToolbarButton.prototype.Click = function() 
+{
+	var oToolbarButton = this._ToolbarButton || this ;
+	
+	// for some buttons, do something else instead...
+	var CMode = false ;
+	if ( oToolbarButton.SourceView && (FCK_EDITMODE_SOURCE == FCK.EditMode) )
+	{
+		switch (oToolbarButton.CommandName) 
+		{
+			case 'Bold' 		: window.parent.insertTags ('\'\'\'', '\'\'\'', 'Bold text') ; CMode = true ; break ;
+			case 'Italic' 		: window.parent.insertTags ('\'\'', '\'\'', 'Italic text') ; CMode = true ; break ;
+			case 'Underline' 	: window.parent.insertTags ('<u>', '</u>', 'Underlined text') ; CMode = true ; break ;
+			case 'StrikeThrough': window.parent.insertTags ('<strike>', '</strike>', 'Strikethrough text') ; CMode = true ; break ;
+			case 'Link' 		: window.parent.insertTags ('[[', ']]', 'Internal link') ; CMode = true ; break ;
+		}
+	}
+	
+	if ( !CMode )
+		FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( oToolbarButton.CommandName ).Execute() ;
+}
 
 // MediaWiki Wikitext Data Processor implementation.
@@ -704,4 +751,5 @@
 			original.apply( FCK, args ) ;
 		}
+		var edittools_markup = parent.document.getElementById ('editpage-specialchars') ;
 
 		if ( FCK.EditMode == FCK_EDITMODE_SOURCE )
@@ -716,4 +764,8 @@
 //			loading.style.backgroundColor = '#ff0000' ;
 			FCK.EditingArea.Textarea.parentNode.appendChild( loading, FCK.EditingArea.Textarea ) ;
+			// if we have a standard Edittools div, hide the one containing wikimarkup
+			if (edittools_markup) {			
+				edittools_markup.style.display = 'none' ;
+			}	
 
 			// Use Ajax to transform the Wikitext to HTML.
@@ -721,6 +773,10 @@
 			window.parent.sajax_do_call( 'wfSajaxWikiToHTML', [FCK.EditingArea.Textarea.value], loadHTMLFromAjax ) ;
 		}
-		else
+		else {
 			original.apply( FCK, args ) ;
+			if (edittools_markup) {
+				edittools_markup.style.display = '' ;
+			}
+		}
 	}
 })() ;
