FCKeditor 添加行距、字体功能 (转载)

一、首先为FCKeditor添加外部插件
在fckeditor/editor/plugins文件夹下建立新文件夹lineHeight,并在其中创建fckplugin.js文件,在其文件中办輸入代码:
FCKCommands.RegisterCommand('LineHeight',new FCKLineHeightCommand());
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行添加代码(FCKToolbarItems那一行的 switch 语句中):
case 'LineHeight':B=new FCKLineHeightCommand();break;
111行处:
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.FontSizes属性的后面,其实任何行都可以):
FCKConfig.LineHeights = '50%;100%;150%;200%' ; //.net dll得相应变化 A处
  
247行处(FCKConfig.CoreStyles属性中):
'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就可以使用行距。整个代码以及测试成功,我一直再用,只是没有时间看官方介绍,所以一直也未真正搞明白。
PS:
最后还要在 fckconfig.js 中的” FCKConfig.ToolbarSets["Default"] = “属性中添加“ 'LineHeight' ” 让它在面板上显示出来.

转自:http://blog.163.com/chao_zz/blog/static/1201678842012219112430521/

原文地址:https://www.cnblogs.com/694579350liuq/p/7844292.html