懒羊的技术窝[anchor]

以战养战[http://tech.swordyang.cn]

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

因些朋友发来邮件讲根据文章修改后无效,懒羊再次检查后发现在工具栏中并无添加,所以还得做一下下面步骤,再此给大家造成的不便还请多多谅解!
因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='LineHeight';this.Label=this.GetLabel();this.Tooltip=A?A:this.Label;this.Style=B?B:2;this.DefaultLabel=FCKConfig.DefaultFontLabel||'';};FCKToolbarLineHeightCombo.prototype=new FCKToolbarFontFormatCombo(false);FCKToolbarLineHeightCombo.prototype.GetLabel=function(){return FCKLang.LineHeight;};FCKToolbarLineHeightCombo.prototype.GetStyles=function(){var A=FCKStyles.GetStyle('_FCK_LineHeight');if (!A){alert("The FCKConfig.CoreStyles['Size'] setting was not found. Please check the fckconfig.js file");return {};};var B={};var C=FCKConfig.LineHeights.split(';');for (var i=0;i<C.length;i++){var D=C[i].split('/');var E=D[0];var F=D[1]||E;var G=FCKTools.CloneObject(A);G.SetVariable('Font',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( 'lineHeight' ) ;
 
153行处:
FCKConfig.LineHeights = '50%;100%;150%;200%' ; //.net dll得相应变化 A处
 
 
247行处:
'LineHeight' :
       {
              Element          : 'span',
              Styles             : { 'line-height' : '#("Font")' },
              Overrides       : [ { Element : 'font', Attributes : { 'size' : null } } ]
       },
 
 
 
由于我这里使用的是.NET,所以还必须修改.NET DLL项目,我这里用的是2.5版本。
修改DLL 项目中的FCKeditor.cs文件,在293行处添加
        [Category("Configurations")]
        public string LineHeights
        {
            set { this.Config["LineHeights"] = value; }
        }
 
这里的LineHeights与A处相呼应
 
重新编译项目,这样我们的fckeditor就可以使用行距。整个代码以及测试成功,我一直再用,只是没有时间看官方介绍,所以一直也未真正搞明白。

发表于 @ 2008年06月19日 14:55:00|评论(loading...)|收藏

新一篇: 送辆跑车给你开开[冲出迷宫游戏] | 旧一篇: 关于技术员

用户操作
[即时聊天] [发私信] [加为好友]
懒羊
订阅我的博客
XML聚合  FeedSky
懒羊的公告

懒羊技术群:13728793
Google
文章分类
收藏
    专家链接
    120个Web开发工具箱
    Dflying Chen
    JERRY
    MVP 周
    存档
    软件项目交易
    Csdn Blog version 3.1a
    Copyright © 懒羊