导航

为FCKeditor2.6添加行距功能(最新修改)

Posted on 2011-12-05 11:45  爱依然  阅读(203)  评论(0)    收藏  举报
撒花庆祝3334名博主获11月CSDN博客“持之以恒”勋章!                                          点击了解英特尔云计算
11月热门下载资源TOP100强力推荐!                                                                          “我的2011”博客频道跨年征文活动火爆上线!

为FCKeditor2.6添加行距功能(最新修改)

分类: DoNet笔记 2060人阅读 评论(9) 收藏 举报
因些朋友发来邮件讲根据文章修改后无效,懒羊再次检查后发现在工具栏中并无添加,所以还得做一下下面步骤,再此给大家造成的不便还请多多谅解!
因FCKeditor已出现2.6.2版本,建议大家去下载,以下文章同样适用于此版本。在js文件夹中有fckeditorcode_gecko.js文件修改方式与ie这个文件相同,这个文件主要控制非IE的浏览器的使用。
 
FCKCONFIG.JS中104行FCKConfig.ToolbarSets中设定工具栏得加上LineHeight
 
一、首先为FCKeditor添加外部插件
在fckeditor/editor/plugins文件夹下建立新文件夹lineHeight,并在其中创建fckplugin.js文件,在其文件中办輸入代码:
FCKToolbarItems.RegisterItem( 'LineHeight'       , new FCKToolbarLineHeightCombo( null, FCK_TOOLBARITEM_ONLYTEXT ) ) ;
 
二、建立此下拉框相应事件
 
在文件fckeditor/editor/js/fckeditorcode_ie.js76行添加代码如下:
var FCKLineHeightCommand=function(){};FCKLineHeightCommand.prototype={Name:'LineHeight',Execute:FCKStyleCommand.prototype.Execute,GetState:FCKFormatBlockCommand.prototype.GetState};
 
98行添加代码:
case 'LineHeight':B=new FCKLineHeightCommand();break;
 
121行处:
var FCKToolbarLineHeightCombo=function(A,B){this.CommandName=&apos;LineHeight&apos;;this.Label=this.GetLabel();this.Tooltip=A?A:this.Label;this.Style=B?B:2;this.DefaultLabel=FCKConfig.DefaultFontLabel||&apos;&apos;;};FCKToolbarLineHeightCombo.prototype=new FCKToolbarFontFormatCombo(false);FCKToolbarLineHeightCombo.prototype.GetLabel=function(){return FCKLang.LineHeight;};FCKToolbarLineHeightCombo.prototype.GetStyles=function(){var A=FCKStyles.GetStyle(&apos;_FCK_LineHeight&apos;);if (!A){alert("The FCKConfig.CoreStyles[&apos;Size&apos;] setting was not found. Please check the fckconfig.js file");return {};};var B={};var C=FCKConfig.LineHeights.split(&apos;;&apos;);for (var i=0;i<C.length;i++){var D=C[i].split(&apos;/&apos;);var E=D[0];var F=D[1]||E;var G=FCKTools.CloneObject(A);G.SetVariable(&apos;Font&apos;,E);G.Label=F;B[F]=G;};return B;};FCKToolbarLineHeightCombo.prototype.RefreshActiveItems=FCKToolbarStyleCombo.prototype.RefreshActiveItems;FCKToolbarLineHeightCombo.prototype.StyleCombo_OnBeforeClick=function(A){A.DeselectAll();var B=FCKSelection.GetBoundaryParentElement(true);if (B){var C=new FCKElementPath(B);for (var i in A.Items){var D=A.Items[i];var E=D.Style;if (E.CheckActive(C)){A.SelectItem(D);return;}}}};
 
 
在文件fckeditor/editor/lang/zh-cn.js的117行添加代码如下:
LineHeight:"行距",
//此处主要是添加资源代码,这里只针对于中文,所以只修改了zh-cn.js文件
 
在fckconfig.js文件夹的98行添加:
FCKConfig.Plugins.Add( &apos;lineHeight&apos; ) ;
 
153行处:
FCKConfig.LineHeights = &apos;50%;100%;150%;200%&apos; ; //.net dll得相应变化 A处
 
 
247行处:
&apos;LineHeight&apos; :
       {
              Element          : &apos;span&apos;,
              Styles             : { &apos;line-height&apos; : &apos;#("Font")&apos; },
              Overrides       : [ { Element : &apos;font&apos;, Attributes : { &apos;size&apos; : null } } ]
       },
 
 
 
由于我这里使用的是.NET,所以还必须修改.NET DLL项目,我这里用的是2.5版本。
修改DLL 项目中的FCKeditor.cs文件,在293行处添加
        [Category("Configurations")]
        public string LineHeights
        {
            set { this.Config["LineHeights"] = value; }
        }
 
这里的LineHeights与A处相呼应
 
重新编译项目,这样我们的fckeditor就可以使用行距。整个代码以及测试成功,我一直再用,只是没有时间看官方介绍,所以一直也未真正搞明白。