当前位置: 移动技术网 > IT编程>脚本编程>编辑器 > fckeditor 插件开发参考文档

fckeditor 插件开发参考文档

2017年12月08日  | 移动技术网IT编程  | 我要评论

一:插件的目录结构
插件目录的名称必须和插件的名称一样,而且目录里面必须包含一个fckplugin.js文件。可选包含一个lang目录用来实现界面的国际化。每一个文件定义一种语言,文件名不包含.js,用fckconfig.plugins.add()注册。如果实现的插件命令没有界面,也可以不需要支持任何语言。
比如:findreplace插件的目录结构如下:
/editor/plugins/findreplace/fckplugin.js
/editor/plugins/findreplace/lang/en.js
/editor/plugins/findreplace/lang/zh.js
在fckplugin.js文件中定义你的插件,同时也应该注册改命令,以及创建一个工具栏按钮。
注册代码说明: 

复制代码 代码如下:

//注册命令,registercommand(命令名,命令)
fckcommands.registercommand(
'my_find',
new fckdialogcommand(
fcklang['dlgmyfindtitle'],
fcklang['dlgmyfindtitle'],
fckconfig.pluginspath + 'findreplace/find.html', 340, 170));

fckcommands.registercommand('my_replace',
new fckdialogcommand(
fcklang['dlgmyreplacetitle'],
fcklang['dlgmyreplacetitle'],
fckconfig.pluginspath + 'findreplace/replace.html', 340, 200)) ;

//创建工具栏按钮,现创建,再注册。
var ofinditem = new fcktoolbarbutton('my_find', fcklang['dlgmyfindtitle']);
ofinditem.iconpath = fckconfig.pluginspath + 'findreplace/find.gif' ;
fcktoolbaritems.registeritem( 'my_find', ofinditem ) ;

var oreplaceitem = new fcktoolbarbutton( 'my_replace', fcklang['dlgmyreplacetitle']);
oreplaceitem.iconpath = fckconfig.pluginspath + 'findreplace/replace.gif';
fcktoolbaritems.registeritem('my_replace', oreplaceitem);

二:安装插件:
安装前把解压的包拷贝到editor/plugins目录下,然后按下列步骤进行:
1、先确定按钮在工具栏的位置
最好在定制的配置文件中,新写一个工具栏来包含新的插件。

定制配置文件:
复制代码 代码如下:

fckconfig.toolbarsets['plugintest'] = [
['source'],
['placeholder'],
['my_find', 'my_replace'],
['table','-',
'tableinsertrow', 'tabledeleterows',
'tableinsertcolumn', 'tabledeletecolumns',
'tableinsertcell', 'tabledeletecells',
'tablemergecells', 'tablesplitcell'
],
['bold','italic','-','orderedlist','unorderedlist','-','link','unlink','-','about']
] ;

2:添加插件同样,可以直接在定制文件中添加插件。可以直接把插件放置到默认目录下,或者在fckconfig.plugins.add方法里面的第三个参数指定插件所在的位置。
//代码分析:
引用内容
复制代码 代码如下:

fckconfig.plugins.add( pluginname, availablelanguages, pathtoplugin )

pluginname: 插件名称或者插件目录名称.
availablelanguages: 逗号分割的可用语言列表.
pathtoplugin: 绝对路径,指插件的所占目录,包括插件本身一层目录

在默认位置添加插件
引用内容
复制代码 代码如下:

fckconfig.plugins.add( 'findreplace', 'en,it' ) ;

在其他位置添加插件,在add方法传递插件的绝对路径。
引用内容
复制代码 代码如下:

fckconfig.pluginspath = fckconfig.basepath.substr(0, fckconfig.basepath.length - 7) + '_samples/_plugins/' ;
var sotherpluginpath = fckconfig.basepath.substr(0, fckconfig.basepath.length - 7) + 'editor/plugins/' ;
fckconfig.plugins.add( 'placeholder', 'en,it', sotherpluginpath ) ;
fckconfig.plugins.add( 'tablecommands', null, sotherpluginpath ) ;


如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网