您的位置:首页 > 其它

FckEditor自定义按钮

2009-11-25 15:22 302 查看

目录

FckEditor自定义按钮 1
目录 2
修订历史纪录 3
1 FckEditor简介 4
2 使用FckEditor 4
3 添加自定义按钮 4

1 FckEditor简介

一款比较好的网页文本编辑器

2 使用FckEditor

1.将FCKeditor编辑器的文件夹复制到网站根目录下

2. 请设置文件夹的user用户的访问权限

3. 在web.config中添加

<appSettings>

<add key="FCKeditor:BasePath" value="~/FckEditorv2/"/>

</appSettings>

4.添加对FredCK.FCKeditorV2.dll的引用

5. 在要使用此编辑器的页面的最上方添加

<%@Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>



6. 在需要使用编辑器的地方添加

<fckeditorv2:fckeditor id="txtContent" runat="server" Height="100%">

</fckeditorv2:fckeditor>

3 添加自定义按钮

以添加上传附件按钮为例:

1.在fckconfig.js中添的FCKConfig.ToolbarSets["Default"]添加'InsertFile',这是在Default模式下的工具栏显示的按钮。如需要可添加到其他模式下。

2.在editor/lang/zh-cn.js文件最后添加InsertFile : "附件"

3.在editor/js/fckeditorcode_ie.js文件中查找InsertHorizontalRule,在|后添加InsertFile

4.还在此文件中查找default:if (FCKRegexLib,在其前边添加case 'InsertFile':B=new FCKDialogCommand

('InsertFile',FCKLang.InsertFile,'dialog/InsertFile/InsertFile.aspx',510,450);break;

第3个参数为打开窗口的相对路径

5.还在此文件中查找default:alert(FCKLang.UnknownToolbarItem 在其前面添加

case 'InsertFile':B = new FCKToolbarButton('InsertFile',FCKLang.InsertFile,FCKLang.InsertFile,FCK_TOOLBARITEM_ICONTEXT,false,true,4);break;

FCK_TOOLBARITEM_ICONTEXT参数使此按钮为文字和图片同时显示,最后一个参数为使用第几个图片图片,图片的路径为editor/skins/default/fck_strip.gif

这样工具栏上就多了一个添加附件的按钮

我照着上面做一个实例,我的不是点出来对话框,而是插入一个对象

var FCKInsertParaCommand=function(){this.Name='InsertPara';};FCKInsertParaCommand.prototype.Execute=function(){FCKUndo.SaveUndoStep();var e=FCK.EditorDocument.createElement('span');e.innerHTML='[收信人姓名]';var B=new FCKDomRange(FCK.EditorWindow);B.MoveToSelection();B.InsertNode(e);FCK.Events.FireEvent('OnSelectionChange');};FCKInsertParaCommand.prototype.GetState=function(){if (FCK.EditMode!=0) return -1;return 0;};

case 'InsertPara':B=new FCKInsertParaCommand();break;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: