MVCFckEditor一些小问题

用到MVCfckeditor发现在一些小问题,网上找了资料,解决了,在这里我一并贴出来方便查找;

第一:MVCFckeditor在IE9上无法上传图片

解决办法:

原因是IE9不支持var $=document.getElementById;这样的写法了。
 打开下面这个文件
 fckeditor/editor/js/fckeditorcode_ie.js
 找到第38行的这个方法:FCKTools.RegisterDollarFunction
 将原来的
 FCKTools.RegisterDollarFunction=function(A){A.$=A.document.getElementById;};
 修改方法为:
 FCKTools.RegisterDollarFunction=function(A){A.$=function(v){return A.document.getElementById(v);}};

来自:http://www.2cto.com/kf/201201/117220.html

第二问题:修改字体与字体大小

解决办法:

1. 在fckconfig.js文件中找到FCKConfig.FontNames ,在字体中加入想要的字体就行了。

FCKConfig.FontNames= '宋体;黑体;隶书;幼圆;仿宋_GB2312;楷体_GB2312;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;然后在editor/css/fck_editorarea.css的43行修改font-family: 宋体,黑体,楷体,仿宋,Arial, Verdana, sans-serif;


FCKConfig.FontSizes= '12px;14px;16px;18px;24px;26px;28px;32px;' ;//这个是修改字体大小

来自:http://blog.csdn.net/shaobingj126/article/details/5566537 

第三问题:添加行距功能:

解决办法:

 1、FCKCONFIG.JS中104行FCKConfig.ToolbarSets中设定工具栏得加上LineHeight

2、在fckeditor\editor\plugins文件夹下建立新文件夹lineHeight,并在其中创建fckplugin.js文件,在其文件中办输入代码:
FCKCommands.RegisterCommand('LineHeight',new FCKLineHeightCommand());
FCKToolbarItems.RegisterItem( 'LineHeight', new FCKToolbarLineHeightCombo( null, FCK_TOOLBARITEM_ONLYTEXT ) ) ;

 3、在文件fckeditor\editor\js\fckeditorcode_ie.js

76行添加代码如下:
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;}}}};

4、在文件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 } } ]
       },

注:上面所添加的就直接拷贝。
来自:http://www.docin.com/p-244016521.html

 第四个问题

其实这也不是什么问题,只是操作方式不一样

解决fckeditor回车间距过大问题

CKeditor文字换行问题 FCKeditor Enter(回车键)换行时间距过大。
按住Shift+Enter换行时(间距会小)也就是说它默认直接敲回车是一个键,而按Shift+回车则是键。
那一般人的习惯都是直接就敲回车的了,查看了下它的配置文件发现是可以解决的。
还有二种方法
一,修改fckconfig.js FCKConfig.EnterMode = 'p' ; // p | div | br FCKConfig.ShiftEnterMode = 'br' ; // p | div | br 将ShiftEnterMode与EnterMode的值换一下,EnterMode=br SHIFTENTERMODE=P 就可以解决了。
 
二,在fckconfig.js文件中查找UseBROnCarriageReturn。把FCKConfig.UseBROnCarriageReturn = false ; 改为FCKConfig.UseBROnCarriageReturn = true ; 不过这方式可能只有IE支持,不建议使用。 我也很想告诉百度管理员,让他也来看看这篇文章,百度空间的编辑器正是fckeditor,也是如些,真的很不方便。
原文地址:https://www.cnblogs.com/KimhillZhang/p/2482416.html