源码网,源码论坛,源码之家,商业源码,游戏源码下载,discuz插件,棋牌源码下载,精品源码论坛

 找回密码
 立即注册
查看: 869|回复: 11

[网页编辑器] 比较不错的修改FCKEditor的修改方法

[复制链接]

7万

主题

861

回帖

32万

积分

论坛元老

Rank: 8Rank: 8

积分
329525
发表于 2007-11-4 12:50:56 | 显示全部楼层 |阅读模式
修改后的代码下载
[color=]http://www.cnblogs.com/Files/Truly/FCKeditor_Truly.rar

本地下载地址
由于项目需要,近期仔细研究了FCKEditor。发现一下bug,以及缺少的一些东西。
一、防止连续文本导致出现滚动条
        FCKEditor编辑器使用Iframe来处理编辑器内容,可惜不支持文本换行,假如你连续输入一段英文或数字等,将会出现滚动条,这时我们需要给其增加word-wrap样式为break-word;
添加方式有很多,我选择最便捷的修改方式:具体做法是修改fckeditor.html文件,给
.FCK__Media
{
border: darkgray 1px solid;
background-position: center center;
background-image: url(images/fck_medialogo.gif);
background-repeat: no-repeat;
width: 80px ;
height: 80px ;
}
.FCK__Realplay
{
border: darkgray 1px solid;
background-position: center center;
background-image: url(images/fck_realplaylogo.JPG);
background-repeat: no-repeat;
width: 80px ;
height: 80px ;
}
c。修改js,主要以realplay做示例
FCKeditor\editor\js\fckeditorcode_ie_1.js,在FCKDocumentProcessors.addItem(FCKFlashProcessor);后面增加
// Realplay begin
var FCKRealplayProcessor=new Object();
FCKRealplayProcessor.ProcessDocument=function(A){
    var B=A.getElementsByTagName('EMBED');
    var C;
    var i=B.length-1;
while (i>=0&&(C=B[i--])){
if (C.src.endsWith('.rm',true) || C.src.endsWith('.ram',true) || C.src.endsWith('.ra',true))
{var D=FCKDocumentProcessors_CreateFakeImage('FCK__Realplay',C.cloneNode(true));
D.setAttribute('_fckRealplay','true',0);
FCKRealplayProcessor.RefreshView(D,C);
C.parentNode.insertBefore(D,C);
C.parentNode.removeChild(C);
};
};
};
FCKRealplayProcessor.RefreshView=function(A,B){
    if (B.width>0) A.style.width=FCKTools.ConvertHtmlSizeToStyle(B.width);
    if (B.height>0) A.style.height=FCKTools.ConvertHtmlSizeToStyle(B.height);
};
FCKDocumentProcessors.addItem(FCKRealplayProcessor);
// Realplay end
var FCKMediaProcessor=new Object();
FCKMediaProcessor.ProcessDocument=function(A)
{
    var B=A.getElementsByTagName('EMBED');
    var C;
    var i=B.length-1;
    while (i>=0&&(C=B[i--]))
    {
        if (C.src.endsWith('.avi',true) || C.src.endsWith('.mpg',true) || C.src.endsWith('.mpeg',true))
        {
            var D=FCKDocumentProcessors_CreateFakeImage('FCK__Media',C.cloneNode(true));
            D.setAttribute('_fckmedia','true',0);FCKMediaProcessor.RefreshView(D,C);
            C.parentNode.insertBefore(D,C);C.parentNode.removeChild(C);
        };
    };
};
FCKMediaProcessor.RefreshView=function(A,B)
{
    if (B.width>0) A.style.width=FCKTools.ConvertHtmlSizeToStyle(B.width);
    if (B.height>0) A.style.height=FCKTools.ConvertHtmlSizeToStyle(B.height);
};
FCKDocumentProcessors.addItem(FCKMediaProcessor);
然后修改FCK.GetRealElement方法为下面代码,该方法为处理编辑器中width和height的调整
FCK.GetRealElement=function(A){
var e=FCKTempBin.Elements[A.getAttribute('_fckrealelement')];
if (A.getAttribute('_fckflash')|| A.getAttribute('_fckrealplay') || A.getAttribute('_fckmedia')){
    if (A.style.width.length>0) e.width=FCKTools.ConvertStyleSizeToHtml(A.style.width);
    if (A.style.height.length>0) e.height=FCKTools.ConvertStyleSizeToHtml(A.style.height);
};
return e;};
----------
FCKeditor\editor\js\fckeditorcode_ie_2.js
FCKCommands.GetCommand方法增加
case 'Media':B=new FCKDialogCommand('Media',FCKLang.DlgMediaTitle,'dialog/fck_Media.html',450,400);
break;
case 'Realplay':B=new FCKDialogCommand('Realplay',FCKLang.DlgMediaTitle,'dialog/fck_Realplay.html',450,400);
break;
FCKToolbarItems.GetItem方法增加
case 'Media':B=new FCKToolbarButton('Media',FCKLang.InsertMediaLbl,FCKLang.InsertMedia);
break;
case 'Realplay':B=new FCKToolbarButton('Realplay',FCKLang.InsertRealplayLbl,FCKLang.InsertRealplay);
break;
FCKContextMenu._GetGroup方法增加
case 'Media':return new FCKContextMenuGroup(true,this,'Media',FCKLang.MediaProperties,true);
case 'Realplay':return new FCKContextMenuGroup(true,this,'Realplay',FCKLang.RealplayProperties,true);   // truly
FCKContextMenu.RefreshState方法增加
if (this.Groups['Media'])   this.Groups['Media'].SetVisible(B=='IMG'&&A.getAttribute('_fckmedia'));
if (this.Groups['Realplay'])  this.Groups['Realplay'].SetVisible(B=='IMG'&&A.getAttribute('_fckrealplay'));
然后要增加'dialog/fck_Media.html'和'dialog/fck_Realplay.html'页面,具体我懒得再写了,自己到我的源码下载里看,我是在2。1的基础上改的,2.2要做一些调整!
fckconfig.js也有较多调整,但是这个文件非常简单,自己去看我的源码吧。
然后就是lang目录中对常量的定义,搜索一下就很容易得到,没什么可讲。
在然后就可以了,:)。
三、添加删除按钮列,类似sina的blog中的编辑控件
四、修改上传路径
        默认是根目录/UserFiles,有多种方式进行修改,先看一下它的源码:
protected string UserFilesPath
{
get
{
  if ( sUserFilesPath == null )
  {
   // Try to get from the "Application".
   sUserFilesPath = (string)Application["FCKeditor:UserFilesPath"] ;
   // Try to get from the "Session".
   if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )
   {
    sUserFilesPath = (string)Session["FCKeditor:UserFilesPath"] ;
    // Try to get from the Web.config file.
    if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )
    {
     sUserFilesPath = System.Configuration.ConfigurationSettings.AppSettings["FCKeditor:UserFilesPath"] ;
     // Otherwise use the default value.
     if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )
      sUserFilesPath = DEFAULT_USER_FILES_PATH ;
     // Try to get from the URL.
     if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )
     {
      sUserFilesPath = Request.QueryString["ServerPath"] ;
     }
    }
   }
   // Check that the user path ends with slash ("/")
   if ( ! sUserFilesPath.EndsWith("/") )
    sUserFilesPath += "/" ;
  }
  return sUserFilesPath ;
}
}
由此,可以在Global里或者程序任意位置(加载fckeditor前可以运行到的位置)设置Application["FCKeditor:UserFilesPath"] ,或者Session,或者Webconfig,或者action中的请求参数等。
to be continued...
附:js版FCKEditor下载:
[color=]http://prdownloads.sourceforge.net/fckeditor/FCKeditor_2.2.zip

.net版

[color=]http://prdownloads.sourceforge.net/fckeditor/FCKeditor.Net_2.2.zip

所有版本列表

[color=]http://prdownloads.sourceforge.net/fckeditor
回复

使用道具 举报

0

主题

1万

回帖

0

积分

中级会员

Rank: 3Rank: 3

积分
0
发表于 2022-8-18 21:26:50 | 显示全部楼层
强烈支持楼主ing……
回复 支持 反对

使用道具 举报

4

主题

1万

回帖

58

积分

注册会员

Rank: 2

积分
58
发表于 2022-8-24 18:19:15 | 显示全部楼层
看看看看
回复 支持 反对

使用道具 举报

0

主题

1万

回帖

0

积分

中级会员

Rank: 3Rank: 3

积分
0
发表于 2022-11-23 06:35:50 | 显示全部楼层
还有什么好东西没
回复 支持 反对

使用道具 举报

1

主题

1万

回帖

93

积分

注册会员

Rank: 2

积分
93
发表于 2022-12-20 03:35:47 | 显示全部楼层
iiguuubhuiuihu
回复 支持 反对

使用道具 举报

1

主题

1万

回帖

93

积分

注册会员

Rank: 2

积分
93
发表于 2023-1-4 04:16:17 | 显示全部楼层
2222222222222222
回复 支持 反对

使用道具 举报

0

主题

1万

回帖

0

积分

中级会员

Rank: 3Rank: 3

积分
0
发表于 2023-10-3 01:08:19 | 显示全部楼层
谢谢下载来看看
回复 支持 反对

使用道具 举报

7

主题

1万

回帖

398

积分

中级会员

Rank: 3Rank: 3

积分
398
发表于 2024-4-15 17:35:55 | 显示全部楼层
。。。。。。。。。。。。。。。
回复 支持 反对

使用道具 举报

0

主题

1万

回帖

0

积分

中级会员

Rank: 3Rank: 3

积分
0
发表于 2024-6-14 08:43:30 | 显示全部楼层
呵呵呵呵呵呵
回复 支持 反对

使用道具 举报

3

主题

1万

回帖

50

积分

注册会员

Rank: 2

积分
50
发表于 2024-6-30 21:35:38 | 显示全部楼层
来看看!!!
回复 支持 反对

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

手机版|小黑屋|网站地图|源码论坛 ( 海外版 )

GMT+8, 2024-9-20 01:03 , Processed in 0.205590 second(s), 26 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表