这些天弄那个fck编辑器,装了个flv播放器插件,可是问题出现什么”未知工具栏项目Insertplayer”,于是就找错,那顺便简单分析一下fck。


fckeditor.js
这个文件主要定义了FCKeditor这个类。
方法:


Create()创建fck编辑器,调用了CreateHtml()


CreateHtml() 创建fck编辑器的html,首先判断this.InstanceName不能为空。然后判断浏览器,调用了FCKeditor_IsCompatibleBrowser()。最终会返回
<input type=”hidden” id=”FCKeditor1″ name=”FCKeditor1″ value=”&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href=&quot;http://www.fckeditor.net/&quot;&gt;FCKeditor&lt;/a&gt;.&lt;/p&gt;” style=”display:none” />
<input type=”hidden” id=”FCKeditor1___Config” value=”CustomConfigurationsPath=http%3A%2F%2Fwww.abc.cn%2Fadmin%2F_samples%2Fmy_sample.config.js” style=”display:none” />
<iframe id=”FCKeditor1___Frame” src=”http://www.abc.cn/admin/_samples/editor/fckeditor.html?InstanceName=FCKeditor1&amp;Toolbar=PluginTest” width=”100%” height=”200″ frameborder=”0″ scrolling=”no”></iframe>


 


FCKeditor_IsCompatibleBrowser() 判断浏览器是否支持。


_GetConfigHtml() 生成一个隐藏域,里面的值是:CustomConfigurationsPath=http%3A%2F%2Fwww.abc.cn%2Fadmin%2F_samples%2Fmy_sample.config.js
这里的url经过了编码还原一下:
CustomConfigurationsPath=http://www.abc.cn/admin/_samples/my_sample.config.js
如果在页面上设置了oFCKeditor.Config[‘china’]=”great”那么那个url将变成http://www.abc.cn/admin/_samples/my_sample.config.js&china=great


_GetIFrameHtml()
返回下面这样的一个东西
<iframe id=”FCKeditor1___Frame” src=”http://www.abc.cn/admin/_samples/editor/fckeditor.html?InstanceName=FCKeditor1&amp;Toolbar=PluginTest” width=”100%” height=”200″ frameborder=”0″ scrolling=”no”></iframe>



http://www.abc.cn/admin/_samples/editor/fckeditor.html 会包含下面两个脚本文件
<script type=”text/javascript” src=”js/fckeditorcode_ie.js”></script>
<script type=”text/javascript” src=”../fckconfig.js”></script>
这些就是加载fck编辑器的工具栏和配置文件的。
js/fckeditorcode_ie.js 这个是文件有可能是js/fckeditorcode_gecko.js因为他是根据var sSuffix = ( /*@cc_on!@*/false ) ? ‘ie’ : ‘gecko’ ;这么句话来得到后缀,然后调用LoadScript()这个函数来把相应的js文件包含到页面上去。
关键就是那个js/fckeditorcode_ie.js,打开以后是个压缩之后的js,可以通过解压工具或在线解压js工具把它解开,解压后估计将近一万行


我用到了插件,所以用到了这些文件
<script type=”text/javascript” src=”js/fckeditorcode_ie.js”></script>
<script type=”text/javascript” src=”../fckconfig.js”></script>
<script type=”text/javascript” src=”http://www.zd.cn/admin/_samples/my_sample.config.js”></script>
<script type=”text/javascript” src=”lang/zh-cn.js”></script>
<script type=”text/javascript” src=”http://www.zd.cn/admin/_samples/editor/plugins/Insertplayer/fckplugin.js”></script>
<script type=”text/javascript” src=”http://www.zd.cn/admin/_samples/editor/plugins/placeholder/lang/de.js”></script>
<script type=”text/javascript” src=”http://www.zd.cn/admin/_samples/editor/plugins/placeholder/fckplugin.js”></script>
<script type=”text/javascript” src=”http://www.zd.cn/admin/_samples/editor/plugins/tablecommands/fckplugin.js”></script>
<script type=”text/javascript” src=”http://www.zd.cn/admin/_samples/editor/plugins/simplecommands/fckplugin.js”></script>


 


最终找到原因了,是fck根目录下的fckconfig.js里的一些配置出了问题,
FCKConfig.PluginsPath = FCKConfig.BasePath.substr(0, FCKConfig.BasePath.length – 7) + ‘editor/plugins/’ ;
就是这里,我设置错了,我把它设成其它路径了,这里改成你插件的路径就OK了。
编辑器显示页面上有这么一句话:
oFCKeditor.Config[‘CustomConfigurationsPath’] = sBasePath + ‘my_sample.config.js’ ;
以为他的配置文件就是那个my_sample.config.js,哪里知道fckeditor.js也需要相应的配置。
其实my_sample.config.js文件是从fck自带的例子里复制出来的,我只不过给它改了个名字,内容还是一样的。


FCKeditor要下载就去搜一下,多得是,支持asp,php,jsp,.net调用,不过.net调用需要附加相应的dll。

Comments are closed.

Post Navigation