Click here to Skip to main content
15,884,986 members
Articles / Web Development / ASP.NET

HTMLEditor Provider - How to write a custom provider for ASP.NET 2.0

Rate me:
Please Sign up or sign in to vote.
4.75/5 (29 votes)
5 Sep 200614 min read 122.2K   2.4K   123  
A tutorial on how to use the Provider Templates to create your own provider.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--
 * FCKeditor - The text editor for internet
 * Copyright (C) 2003-2006 Frederico Caldeira Knabben
 * 
 * Licensed under the terms of the GNU Lesser General Public License:
 * 		http://www.opensource.org/licenses/lgpl-license.php
 * 
 * For further information visit:
 * 		http://www.fckeditor.net/
 * 
 * "Support Open Source software. What about a donation today?"
 * 
 * File Name: fckeditor.original.html
 * 	Main page that holds the editor.
 * 
 * File Authors:
 * 		Frederico Caldeira Knabben (fredck@fckeditor.net)
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>FCKeditor</title>
	<meta name="robots" content="noindex, nofollow" />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<!-- @Packager.RemoveLine
	<meta http-equiv="Cache-Control" content="public" />
	@Packager.RemoveLine -->
	<script type="text/javascript">

// Instead of loading scripts and CSSs using inline tags, all scripts are
// loaded by code. In this way we can guarantee the correct processing order,
// otherwise external scripts and inline scripts could be executed in an
// unwanted order (IE).

function LoadScript( url )
{
	document.write( '<script type="text/javascript" src="' + url + '" onerror="alert(\'Error loading \' + this.src);"><\/script>' ) ;
}

function LoadCss( url )
{
	document.write( '<link href="' + url + '" type="text/css" rel="stylesheet" onerror="alert(\'Error loading \' + this.src);" />' ) ;
}

// Main editor scripts.
var sSuffix = /msie/.test( navigator.userAgent.toLowerCase() ) ? 'ie' : 'gecko' ;

/* @Packager.RemoveLine
LoadScript( 'js/fckeditorcode_' + sSuffix + '.js' ) ;
@Packager.RemoveLine */
// @Packager.Remove.Start

LoadScript( '_source/fckconstants.js' ) ;
LoadScript( '_source/fckjscoreextensions.js' ) ;

if ( sSuffix == 'ie' )
	LoadScript( '_source/classes/fckiecleanup.js' ) ;

LoadScript( '_source/internals/fckbrowserinfo.js' ) ;
LoadScript( '_source/internals/fckurlparams.js' ) ;
LoadScript( '_source/internals/fck.js' ) ;
LoadScript( '_source/internals/fckconfig.js' ) ;

LoadScript( '_source/internals/fckdebug.js' ) ;
LoadScript( '_source/internals/fcktools.js' ) ;
LoadScript( '_source/internals/fcktools_' + sSuffix + '.js' ) ;
LoadScript( '_source/fckeditorapi.js' ) ;
LoadScript( '_source/internals/fckregexlib.js' ) ;
LoadScript( '_source/internals/fcklanguagemanager.js' ) ;
LoadScript( '_source/classes/fckevents.js' ) ;
LoadScript( '_source/internals/fckxhtmlentities.js' ) ;
LoadScript( '_source/internals/fckxhtml.js' ) ;
LoadScript( '_source/internals/fckxhtml_' + sSuffix + '.js' ) ;
LoadScript( '_source/internals/fckcodeformatter.js' ) ;
LoadScript( '_source/internals/fckundo_' + sSuffix + '.js' ) ;
LoadScript( '_source/classes/fckeditingarea.js' ) ;
LoadScript( '_source/internals/fckdocumentprocessor.js' ) ;
LoadScript( '_source/internals/fck_1.js' ) ;
LoadScript( '_source/internals/fck_1_' + sSuffix + '.js' ) ;
LoadScript( '_source/internals/fck_2.js' ) ;
LoadScript( '_source/internals/fck_2_' + sSuffix + '.js' ) ;
LoadScript( '_source/internals/fckselection.js' ) ;
LoadScript( '_source/internals/fckselection_' + sSuffix + '.js' ) ;

LoadScript( '_source/internals/fcktablehandler.js' ) ;
LoadScript( '_source/internals/fcktablehandler_' + sSuffix + '.js' ) ;
LoadScript( '_source/classes/fckxml_' + sSuffix + '.js' ) ;
LoadScript( '_source/classes/fckstyledef.js' ) ;
LoadScript( '_source/classes/fckstyledef_' + sSuffix + '.js' ) ;
LoadScript( '_source/classes/fckstylesloader.js' ) ;

LoadScript( '_source/commandclasses/fcknamedcommand.js' ) ;
LoadScript( '_source/commandclasses/fck_othercommands.js' ) ;
LoadScript( '_source/commandclasses/fckspellcheckcommand_' + sSuffix + '.js' ) ;
LoadScript( '_source/commandclasses/fcktextcolorcommand.js' ) ;
LoadScript( '_source/commandclasses/fckpasteplaintextcommand.js' ) ;
LoadScript( '_source/commandclasses/fckpastewordcommand.js' ) ;
LoadScript( '_source/commandclasses/fcktablecommand.js' ) ;
LoadScript( '_source/commandclasses/fckstylecommand.js' ) ;
LoadScript( '_source/commandclasses/fckfitwindow.js' ) ;
LoadScript( '_source/internals/fckcommands.js' ) ;

LoadScript( '_source/classes/fckpanel.js' ) ;
LoadScript( '_source/classes/fckicon.js' ) ;
LoadScript( '_source/classes/fcktoolbarbuttonui.js' ) ;
LoadScript( '_source/classes/fcktoolbarbutton.js' ) ;
LoadScript( '_source/classes/fckspecialcombo.js' ) ;
LoadScript( '_source/classes/fcktoolbarspecialcombo.js' ) ;
LoadScript( '_source/classes/fcktoolbarfontscombo.js' ) ;
LoadScript( '_source/classes/fcktoolbarfontsizecombo.js' ) ;
LoadScript( '_source/classes/fcktoolbarfontformatcombo.js' ) ;
LoadScript( '_source/classes/fcktoolbarstylecombo.js' ) ;
LoadScript( '_source/classes/fcktoolbarpanelbutton.js' ) ;
LoadScript( '_source/internals/fcktoolbaritems.js' ) ;
LoadScript( '_source/classes/fcktoolbar.js' ) ;
LoadScript( '_source/classes/fcktoolbarbreak_' + sSuffix + '.js' ) ;
LoadScript( '_source/internals/fcktoolbarset.js' ) ;
LoadScript( '_source/internals/fckdialog.js' ) ;
LoadScript( '_source/internals/fckdialog_' + sSuffix + '.js' ) ;
LoadScript( '_source/classes/fckmenuitem.js' ) ;
LoadScript( '_source/classes/fckmenublock.js' ) ;
LoadScript( '_source/classes/fckmenublockpanel.js' ) ;
LoadScript( '_source/classes/fckcontextmenu.js' ) ;
LoadScript( '_source/internals/fck_contextmenu.js' ) ;
LoadScript( '_source/classes/fckplugin.js' ) ;
LoadScript( '_source/internals/fckplugins.js' ) ;

// @Packager.Remove.End

// Base configuration file.
LoadScript( '../fckconfig.js' ) ;

	</script>
	<script type="text/javascript">

// Create the default cleanup object used by the editor.
if ( FCKBrowserInfo.IsIE )
{
	FCK.IECleanup = new FCKIECleanup( window ) ;
	FCK.IECleanup.AddItem( FCKTempBin, FCKTempBin.Reset ) ;
	FCK.IECleanup.AddItem( FCK, FCK_Cleanup ) ;
}

// The config hidden field is processed immediately, because
// CustomConfigurationsPath may be set in the page.
FCKConfig.ProcessHiddenField() ;

// Load the custom configurations file (if defined).
if ( FCKConfig.CustomConfigurationsPath.length > 0 )
	LoadScript( FCKConfig.CustomConfigurationsPath ) ;

	</script>
	<script type="text/javascript">

// Load configurations defined at page level.
FCKConfig_LoadPageConfig() ;

FCKConfig_PreProcess() ;

// Load the active skin CSS.
LoadCss( FCKConfig.SkinPath + 'fck_editor.css' ) ;

// Load the language file.
FCKLanguageManager.Initialize() ;
LoadScript( 'lang/' + FCKLanguageManager.ActiveLanguage.Code + '.js' ) ;

	</script>
	<script type="text/javascript">

// Initialize the editing area context menu.
FCK_ContextMenu_Init() ;

FCKPlugins.Load() ;

	</script>
	<script type="text/javascript">
	
// Set the editor interface direction.
window.document.dir = FCKLang.Dir ;

// Activate pasting operations.
if ( FCKConfig.ForcePasteAsPlainText || FCKConfig.AutoDetectPasteFromWord )
	FCK.Events.AttachEvent( "OnPaste", FCK.Paste ) ;

	</script>
	<script type="text/javascript">

window.onload = function()
{
	InitializeAPI() ;

	if ( FCKBrowserInfo.IsIE )
		FCK_PreloadImages() ;
	else
		LoadToolbarSetup() ;
}

function LoadToolbarSetup()
{
	FCKeditorAPI._FunctionQueue.Add( LoadToolbar ) ;
}

function LoadToolbar()
{
	var oToolbarSet = FCK.ToolbarSet = FCKToolbarSet_Create() ;
	
	if ( oToolbarSet.IsLoaded )
		StartEditor() ;
	else
	{
		oToolbarSet.OnLoad = StartEditor ;
		oToolbarSet.Load( FCKURLParams['Toolbar'] || 'Default' ) ;
	}
}

function StartEditor()
{
	// Remove the onload listener.
	FCK.ToolbarSet.OnLoad = null ;

	FCKeditorAPI._FunctionQueue.Remove( LoadToolbar ) ;

	FCK.Events.AttachEvent( 'OnStatusChange', WaitForActive ) ;

	// Start the editor.
	FCK.StartEditor() ;
}

function WaitForActive( editorInstance, newStatus )
{
	if ( newStatus == FCK_STATUS_ACTIVE )
	{
		if ( FCKBrowserInfo.IsGecko )
			FCKTools.RunFunction( window.onresize ) ;

		FCK.SetStatus( FCK_STATUS_COMPLETE ) ;

		// Call the special "FCKeditor_OnComplete" function that should be present in 
		// the HTML page where the editor is located.
		if ( typeof( window.parent.FCKeditor_OnComplete ) == 'function' )
			window.parent.FCKeditor_OnComplete( FCK ) ;	
	}
}

// Gecko browsers doens't calculate well that IFRAME size so we must
// recalculate it every time the window size changes.
if ( FCKBrowserInfo.IsGecko )
{
	function Window_OnResize()
	{
		if ( FCKBrowserInfo.IsOpera )
			return ;

		var oCell = document.getElementById( 'xEditingArea' ) ;

		var eInnerElement ;
		if ( eInnerElement = oCell.firstChild )
		{
			eInnerElement.style.height = 0 ;
			eInnerElement.style.height = oCell.scrollHeight - 2 ;
		}
	}
	window.onresize = Window_OnResize ;
}

	</script>
</head>
<body>
	<table width="100%" cellpadding="0" cellspacing="0" style="height: 100%; table-layout: fixed">
		<tr id="xToolbarRow" style="display: none">
			<td id="xToolbarSpace" style="overflow: hidden">
				<table width="100%" cellpadding="0" cellspacing="0">
					<tr id="xCollapsed" style="display: none">
						<td id="xExpandHandle" class="TB_Expand" colspan="3">
							<img class="TB_ExpandImg" alt="" src="images/spacer.gif" width="8" height="4" /></td>
					</tr>
					<tr id="xExpanded" style="display: none">
						<td id="xTBLeftBorder" class="TB_SideBorder" style="width: 1px; display: none;"></td>
						<td id="xCollapseHandle" style="display: none" class="TB_Collapse" valign="bottom">
							<img class="TB_CollapseImg" alt="" src="images/spacer.gif" width="8" height="4" /></td>
						<td id="xToolbar" class="TB_ToolbarSet"></td>
						<td class="TB_SideBorder" style="width: 1px"></td>
					</tr>
				</table>
			</td>
		</tr>
		<tr style="height: 100%">
			<td id="xEditingArea" valign="top"></td>
		</tr>
	</table>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Systems Engineer Virtual RadioLogic
United States United States
Todd Davis has been working in web and application development for several years, using Silverlight, ASP.NET, VB.NET, C#, C++ and Javascript, as well as a great deal of work with SQL server and IIS.

He currently works for Virtual Radiologic in Eden Prairie, MN, however he is better known for his varied work in the open source community, especially the DotNetNuke project for which he provided several world-renowned training videos and modules. A huge advocate of open source and open knowledge sharing, everything on his website (www.SeaburyDesign.com) is always offered for free.

Whenever he is not actively coding at his laptop (a rarity to be sure), he can be found woodworking, walking with his wife and kids, or motoring along the back roads of MN on his Harley Davidson Fatboy.

Comments and Discussions