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

作者:懒羊 来源:懒羊的技术窝 时间:2008-08-18 21:09:00 

因些朋友发来邮件讲根据文章修改后无效,懒羊再次检查后发现在工具栏中并无添加,所以还得做一下下面步骤,再此给大家造成的不便还请多多谅解!

因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就可以使用行距。整个代码以及测试成功,我一直再用,只是没有时间看官方介绍,所以一直也未真正搞明白。

标签:FCKeditor,编辑器,功能
0
投稿

猜你喜欢

  • 实用301转向到另一域名相应页面的asp代码

    2011-04-18 10:42:00
  • Linux环境MySQL服务器级优化讲解

    2008-12-04 17:21:00
  • asp 过滤尖括号内所有内容的正则代码

    2011-04-03 10:40:00
  • SQL Server数据库备份多种方法

    2008-11-24 15:27:00
  • Sql Server 索引使用情况及优化的相关Sql语句分享

    2012-06-06 19:49:36
  • Dreamweaver处理word文档有妙招

    2008-05-23 13:00:00
  • 将后台数据从Berkeley的文件DB转到MySQL

    2009-01-04 13:31:00
  • 带你轻松接触MySQL数据库的出错代码列表

    2008-12-31 15:06:00
  • 多列复合索引的使用 绕过微软sql server的一个缺陷

    2012-08-21 10:37:36
  • SQL Server 数据库备份和还原认识和总结 (一)

    2012-10-07 10:52:54
  • ASP判断一个字符串中只包含字母和数字

    2008-08-08 12:12:00
  • 一个导航的前端实现

    2008-11-13 12:41:00
  • asp如何让页面背景五彩缤纷?

    2010-05-13 16:38:00
  • PHP+MYSQL不恶补十句话

    2009-12-02 10:09:00
  • AJAX概述

    2007-11-03 13:41:00
  • 简洁js的隔行变色代码

    2008-06-18 18:17:00
  • gchart:基于google图表API的jquery组件全攻略:1、入门

    2010-01-25 12:18:00
  • 10款实用的jQuery图片插件

    2011-01-25 12:28:00
  • CSS样式设计技巧十则

    2008-06-04 12:18:00
  • 段正淳的css笔记(1)分类之间的横竖线

    2007-11-01 21:47:00
  • asp之家 网络编程 m.aspxhome.com