。下载FCKEditor插件
下载2种文件
1.下载FCKeditor_2.6.6,fckeditor应用程序相关文件。
2.下载FCKeditor.Net_2.6.3,asp.net程序需要的dll文件。
然后创建一个web项目,将下载压缩文件解压。将fckeditor文件,夹拷贝到项目,删除多余的文件,只保留 editor文件夹,fckconfig.js,fckeditor.js,fckstyles.xml,fcktemplate.xml文件。
创建一个新的文件夹取名叫userfiles用于存储本地上传到服务器的文件,也是fckeditor浏览服务器文件的位置(文件夹位置和名称可以自己命名)。
接下来进行fckeditor项目配置
1.引入FredCK.FCKeditorV2.dll文件,该文件位于Fckeditor.net_2.6.3/bin/release/2.0 /下。
2.在工具栏引用fckeditor控件,工具栏中右键-选择项-.net framework组件-浏览-选择刚才引用的FredCK.FCKeditorV2.dll文件(最好引用项目下 FredCK.FCKeditorV2.dll文件)。
3.将控件拖到页面产生如下代码:
<FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server" BasePath="~/fckeditor/" Width="800px" Height="300px"></FCKeditorV2:FCKeditor>
注意:BasePath属性不是自动生成,需要自己手动添加fckeditor应用程序文件夹路径,该路径可以配置在web.config中,文件夹所在项目位置不同,路径配置也不同根据实际情况而定,
如果路径配置不正确页面将无法显示编辑器。
4.配置userfiles用于存储本地上传到服务器的文件,即fckeditor浏览服务器文件夹的位置代码如下:
<appSettings>
<add key="FCKeditor:UserFilesPath" value="/fckeditor/userfiles/"/>
</appSettings>
5.配置fckconfig.js中 FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/default/' ;用设置fckeditor编辑器的皮肤
6.配置fckconfig.js中 FCKConfig.DefaultLanguage 将默认值 en 改为 zh-cn。
代码如下:FCKConfig.DefaultLanguage = 'zh-cn' ;
7.配置fckconfig.js中var _FileBrowserLanguage 和 var _QuickUploadLanguage 将默认值 php 改为 aspx
代码如下:var _FileBrowserLanguage = 'aspx' ;var _QuickUploadLanguage = 'aspx' ;
8.配置fckeditor/filemanager/connectors/asp/config.ascx文件,
private bool CheckAuthentication()
{
// WARNING : DO NOT simply return "true". By doing so, you are allowing
// "anyone" to upload and list the files in your server. You must implement
// some kind of session validation here. Even something very simple as...
//
// return ( Session[ "IsAuthorized" ] != null && (bool)Session[ "IsAuthorized" ] == true );
//
// ... where Session[ "IsAuthorized" ] is set to "true" as soon as the
// user logs in your system.
// return false;
return true;
}
该方法用于验证用户是否具有上传文件的权限,默认return false,这里我们将false改为true。
9.配置config.ascx文件中的SetConfig方法中: UserFilesPath = "/fckeditor/userfiles/";该方法也是设置上传的文件夹路径,最好与web.config中设置相同。
10.如果使用时候出现,例如具有现在危险Request.Form的值,已从客户端侦测。
请加入页面page标签中加入 ValidateRuqest=false;
代码如下:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="FCKEditor._Default" ValidateRequest="false" %>
删除一些没用的文件
1、临时文件及文件夹删除:从根目录下开始删除一切以“_”开头的文件及文件夹,因为他们为临时文件和文件夹。删除这类临时文件及文件夹之后,我们还要删除一些根目录下的多余文件,根目录下我们只保留fckconfig.js(配置文件)、fckeditor.js(js方式调用文件)、fckeditor.php(fckeditor_php4.php(php4的调用文件)、fckeditor_php5.php(php5的调用文件))、fckstyles.xml(样式)、fcktemplates.xml(模板)文件和editor文件夹。
2、editor/lang目录:存放的是多语言配置文件,因为我们只可能用到en和zh-cn(简体中文)所以,根据我的选择,我删掉其他的语言配置文件。
3、editor/skins界面目录:默认带有三个界面(default:默认界面,加载速度相对较快;office2003:相对pp的界面,不过速度确实要慢些;silver:银白色界面,加载速度也相对较快),可以自行决定是否删除其中一两个。
4、editor/filemanager/browser/default/connectors目录:存放编辑器所支持的Web动态语言,我们以php为例所以保留php目录,test.html文件可以帮助你查看某语言下的上传设置等(具体上传设置我将在后面的配置作较为详细讲解),可以自行决定是否删除。
5、editor/filemanager/upload目录:同理。
一些工具条的删除:
在FCKeditor的根目录下打开fckconfig.js,修改如下内容:
FCKConfig.ToolbarSets["Default"] = [
['Source','DocProps','-','Save','NewPage','Preview','-','Templates'],
['Cut','Copy','Paste','PasteText','PasteWord','-','Print','SpellCheck'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'],
'/',
['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
['OrderedList','UnorderedList','-','Outdent','Indent'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
['Link','Unlink','Anchor'],
['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak','UniversalKey'],
'/',
['Style','FontFormat','FontName','FontSize'],
['TextColor','BGColor'],
['FitWindow','-','About']
] ;
不需要的删除即可。
1、设置表情所在路径
FCKConfig.SmileyPath = FCKConfig.BasePath + 'images/smiley/msn/' ;
2、设置表情路径下的哪些图片要显示,图片名称数组
FCKConfig.SmileyImages = ['regular_smile.gif','sad_smile.gif','wink_smile.gif','teeth_smile.gif','confused_smile.gif','tounge_smile.gif','embaressed_smile.gif','omg_smile.gif','whatchutalkingabout_smile.gif','angry_smile.gif','angel_smile.gif','shades_smile.gif','devil_smile.gif','cry_smile.gif','lightbulb.gif','thumbs_down.gif','thumbs_up.gif','heart.gif','broken_heart.gif','kiss.gif','envelope.gif'] ;
3、设置每行表情数目
FCKConfig.SmileyColumns = 8 ;
4、设置表情窗口宽和高
FCKConfig.SmileyWindowWidth = 320 ;
FCKConfig.SmileyWindowHeight = 210 ;
5、如果之前设置的宽和高不起作用,需要修改表情页面js代码。进入fckeditoreditordialog,fck_smiley.html文件是前台表情调用页面
window.onload = function ()
{
// First of all, translate the dialog box texts
oEditor.FCKLanguageManager.TranslatePage(document) ;
//dialog.SetAutoSize( true ) ;//将自动适应尺寸方法注释掉,即可根据配置文件设置的宽和高显示页面
}
<body style="overflow: hidden"> 将overflow:hidden 改为overflow:auto,在尺寸不够时出现滚动条