您现在的位置是:网站首页>列表内容

FCKeditor 源代码分析附中文注释_网页播放器_

2023-05-27 23:25:26 235人已围观

简介 FCKeditor 源代码分析附中文注释_网页播放器_

这几天都在研究FCKeditor的源代码 (FCKeditor就是网络中应用比较广泛的网页编辑器)  这里需要感谢nileaderblog的辛苦翻译。

几乎搜遍了Internet,似乎对于fckconfig.js这个文件讲解的很多,但对于fckeditor.js这个FCK的核心类文件的资料几乎为0.

所以,花了整整一天的时间,以挤牙膏的方式,对fckeditor.js这个fck核心类文件作了自己力所能及的注释,供同样学习fck的网友一个参考。

鉴于笔者水平有限,在此,请广大高手指出我的注释中不妥之处,以免误导他人 。谢谢。

建议copy到自己的IDE中查看 或者
注:本文基于FCKeditor2.6.5
更多权威资料,请参见 FCK 官方Developers Guide
复制代码 代码如下:

/**
*
* ***********CopyRight**************
*-------Annotated by nileader-----
*-----Version 1.00 2009-10-18-----
*-----Once copied, marked http://www.nileader.cn
*
* FCKeditor 类 annotated by nileader
* @param {Object} instanceName 编辑器的唯一名称(相当于ID) 是不可省参数,
* width,height,toolbarset,value 都是 可选参数
*/
var FCKeditor = function( instanceName, width, height, toolbarSet, value )
{
//编辑器的基本属性 注意:这些东西优先于FCKConfig.js中的配置

this.InstanceName = instanceName ; //编辑器的唯一名称(相当于ID)(必须有!)
this.Width = width || '100%' ; //宽度 默认是100%
this.Height = height || '200' ; //宽度 默认是200
this.ToolbarSet = toolbarSet || 'Default' ;//工具集名称,默认值是Default
this.Value = value || '' ; //初始化编辑器的HTML代码,默认值为空
//编辑器初始化的时候默认的根路径, 其作用是编写fck中,凡是用到的路径,均从FCKeditor.BasePath目录开始 默认为/Fckeditor/
this.BasePath = FCKeditor.BasePath ;
this.CheckBrowser = true ; //是否在显示编辑器前检查浏览器兼容性,默认为true
this.DisplayErrors = true ; //是否显示提示错误,默为true
this.Config = new Object() ;
// Events
this.OnError = null ; // function( source, errorNumber, errorDescription )自定义的错误处理函数
}
FCKeditor.BasePath = '/fckeditor/' ; // fck默认的根目录
FCKeditor.MinHeight = 200 ; //高和宽的限制
FCKeditor.MinWidth = 750 ;
FCKeditor.prototype.Version = '2.6.5' ; //版本号
FCKeditor.prototype.VersionBuild = '23959' ;
/**
* 调用CreateHtml()来生成编辑器的html代码并在页面上输出编辑器
*/
FCKeditor.prototype.Create = function()
{
//调用createhtml()方法
document.write( this.CreateHtml() ) ;
}
/**
* @return sHtml 用于生成编辑器的html代码
*/
FCKeditor.prototype.CreateHtml = function()
{
// 检查有无InstanceName 如果没有则不生成html代码
if ( !this.InstanceName || this.InstanceName.length == 0 )
{
this._ThrowError( 701, 'You must specify an instance name.' ) ;
return '' ;
}
//函数的返回值
var sHtml = '' ;
/*
* 当用户的浏览器符合预设的几种浏览器时,
* 生成一个id="this.instancename" name="this.instancename"的文本框,事实上的内容储存器
*/
if ( !this.CheckBrowser || this._IsCompatibleBrowser() )
{
//将此时FCK初始值通过转义之后放入这个input
sHtml += '' ;
//生成一个隐藏的INPUT来放置this.config中的内容
sHtml += this._GetConfigHtml() ;
//生成编辑器的iframe的代码
sHtml += this._GetIFrameHtml() ;
}
/**
* 如果用户的浏览器不兼容FCK默认的几种浏览器
* 只能有传统的textarea了
*/
else
{
var sWidth = this.Width.toString().indexOf('%') > 0 ? this.Width : this.Width + 'px' ;
var sHeight = this.Height.toString().indexOf('%') > 0 ? this.Height : this.Height + 'px' ;
sHtml += '