FCKeditor+添加行距功能

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

FCKeditor 添加行距功能
一直苦恼编辑器不能设置行距,文字设置大了就重叠在一起,终于找到解决办法了:
因FCKeditor已出现2.6.2版本,建议大家去下载,以下文章同样适用于此版本。

在js文件夹中有fckeditor code_gecko.js文件修改方式与ie这个文件相同,这个文件主要控制非IE的浏览器的使用。

FCKCONFIG.JS中104行FCKConfig.ToolbarSets中设定工具栏得加上LineHeight
一、首先为FCKeditor添加外部插件
在fckeditor\editor\plugins文件夹下建立新文件夹lineHeight,并在其中创建fckplugin.js文件,在其文件中办輸入代码:
FCKCommands.RegisterCommand('LineHeight',new FCKLineHeightCommand());
FCKToolbarItems.RegisterItem( 'LineHeight', new FCKToolbarLineHeightCombo( null, FCK_TOOLBARITE M_ONLYTEXT ) ) ;
二、建立此下拉框相应事件
在文件fckeditor\editor\js\fckeditorcode_ie.js76行添加代码如下:
var FCKLineHeightCommand=function(){};FCKLineHeightCommand.prototype={Name:'LineHeight',Execute:F CKStyleCommand.prototype.Execute,GetState:FCKFormatBlockCommand.prototype.GetState};
98行添加代码(FCKToolbarItems那一行的switch 语句中):
case 'LineHeight':B=new FCKLineHeightCommand();break;
111行处:
var FCKToolbarLineHeightCombo=function(A,B){mandName='LineHeight';bel=this.GetLabel(); this.Tooltip=A?A:bel;this.Style=B?B:2;this.DefaultLabel=FCKConfig.DefaultFontLabel||'';};FCKToolbarLi neHeightCombo.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 wa s 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);bel=F;B[F]=G;};return B;};FCKToolbarLineHeightCombo.prototype.RefreshAct iveItems=FCKToolbarStyleCombo.prototype.RefreshActiveItems;FCKToolbarLineHeightCombo.prototype.Style Combo_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.CheckActi ve(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' ” 让它在面板上显示出来.。

相关文档
最新文档