论坛首页 Web前端技术论坛

fckeditor的两个疑问:多配置和焦点管理

浏览 8319 次
精华帖 (0) :: 良好帖 (1) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2007-02-16  
现在web页面上的html编辑器,选择用fckeditor的越来越多了。我自己也很喜欢用这款编辑器,可是用的过程中,有两个问题一直让我有点不爽:

1. fckeditor的配置主要是在一个fckconfig.js中完成的。假设一个应用中有多个地方用到了fckeditor,并且这些地方要求不同的配置。比如有的地方要求工具条默认直接显示,有的地方则要求工具条默认折叠起来。当然,有一种方案是在应用中按照不同的配置,预置好几套完整的编辑器。然后在应用的不同地方,通过引入不同的js文件,来达到这种效果。如下就分别引入了两个不同位置的fckeditor。
    <script type="text/javascript" src="<%=request.getContextPath()%>/FCKeditor_01/fckeditor.js"></script>

或者
    <script type="text/javascript" src="<%=request.getContextPath()%>/FCKeditor_02/fckeditor.js"></script>

但是这种方法的一大弱点就是会有很大的文件数量的冗余。

不知道有没有一种方法,可以轻松让fckeditor的实例可以有不同的配置信息呢?

2. fckeditor的编辑区域一般都是一个iframe,有时还是iframe中嵌iframe,那么控制focus就成了一个问题。比如要用tab键在页面中的textfield和fckeditor中切换,就很难做到。再比如想在页面加载的时候,让fckeditor自动获得焦点,也不是很容易的事情。(fckconfig.js中确实有个FCKConfig.StartupFocus的配置项可以控制获得焦点的,但是如上面第一个问题所述,很不灵活)
不知道有没有什么好办法?
   发表时间:2007-02-16  
fckconfig是一个类,
fckeditor使用的是其一个实例,
你当然可以自己new 一个实例出来  ,
在默认实例的基础上 ,
覆盖你需要改动的属性 ,
配置文件 只是一个默认的配置
0 请登录后投票
   发表时间:2007-02-16  
jianfeng008cn 写道
fckconfig是一个类,
fckeditor使用的是其一个实例,
你当然可以自己new 一个实例出来  ,
在默认实例的基础上 ,
覆盖你需要改动的属性 ,
配置文件 只是一个默认的配置


在代码中的每一个fckeditor都是一个类FCKeditor,我通常这么用,先new出一个FCKeditor的实例,传递需要替换的textarea的id;然后设置大小,用到的工具条;最后执行ReplaceTextarea方法进行替换。如下代码:
var oFCKeditor ; 
window.onload = function()
{
	var sBasePath = '<%=request.getContextPath()%>/FCKeditor/';
	oFCKeditor = new FCKeditor('txtArea01');
	oFCKeditor.BasePath	= sBasePath ;
	oFCKeditor.ToolbarSet='Default';
	oFCKeditor.Height = 300;
	oFCKeditor.Width = 800;
	oFCKeditor.ReplaceTextarea() ;
};


在FCKeditor这个类中,好像没有看到设置不同的config的函数呢,如下:
var FCKeditor = function( instanceName, width, height, toolbarSet, value )
{
	// Properties
	this.InstanceName	= instanceName ;
	this.Width			= width			|| '100%' ;
	this.Height			= height		|| '200' ;
	this.ToolbarSet		= toolbarSet	|| 'Default' ;
	this.Value			= value			|| '' ;
	this.BasePath		= '/fckeditor/' ;
	this.CheckBrowser	= true ;
	this.DisplayErrors	= true ;
	this.EnableSafari	= false ;		// This is a temporary property, while Safari support is under development.
	this.EnableOpera	= false ;		// This is a temporary property, while Opera support is under development.

	this.Config			= new Object() ;

	// Events
	this.OnError		= null ;	// function( source, errorNumber, errorDescription )
}


难道是Config这个属性 ?
可是我用oFCKeditor.Config.property01=value1,没有效果呢。
0 请登录后投票
   发表时间:2007-02-16  
var FCKConfig = FCK.Config = new Object();

从这句看,FCKConfig其实并不是一个类,而只是一个变量。
0 请登录后投票
   发表时间:2007-02-16  
因为fckeditor替换了textarea之后,其实是用的一个iframe。而这个iframe的src是fckeditor.html,再加上目标textarea的id。
在fckeditor.html这个页面,先后导入了
fckeditorcode_ie.js
fckconfig.js
这两个javascript文件。
在第1个js文件中,定义了两个对象。其中第2个对象存放了配置信息。
var FCK = new Object();
var FCKConfig = FCK.Config = new Object();

0 请登录后投票
   发表时间:2007-02-16  
对fckeditor的研究还不够深入,提点想法。

这种JavaScript在线编辑器,都是调用Web Browser内置的编辑器,所以非得内嵌iframe,把这个iframe的document.desingmode换成on。

结果就是只能在Web Browser里面腾挪变换,局限性很大。都想给Browser写个plugin了。
0 请登录后投票
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics