一:插件的目錄結(jié)構(gòu)
插件目錄的名稱必須和插件的名稱一樣,而且目錄里面必須包含一個fckplugin.js文件。可選包含一個lang目錄用來實現(xiàn)界面的國際化。每一個文件定義一種語言,文件名不包含.js,用FCKConfig.Plugins.Add()注冊。如果實現(xiàn)的插件命令沒有界面,也可以不需要支持任何語言。
比如:findreplace插件的目錄結(jié)構(gòu)如下:
/editor/plugins/findreplace/fckplugin.js
/editor/plugins/findreplace/lang/en.js
/editor/plugins/findreplace/lang/zh.js
在fckplugin.js文件中定義你的插件,同時也應(yīng)該注冊改命令,以及創(chuàng)建一個工具欄按鈕。
注冊代碼說明:
復(fù)制代碼 代碼如下:
//注冊命令,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)) ;
//創(chuàng)建工具欄按鈕,現(xiàn)創(chuàng)建,再注冊。
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、先確定按鈕在工具欄的位置
最好在定制的配置文件中,新寫一個工具欄來包含新的插件。
定制配置文件:
復(fù)制代碼 代碼如下:
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方法里面的第三個參數(shù)指定插件所在的位置。
//代碼分析:
引用內(nèi)容
復(fù)制代碼 代碼如下:
FCKConfig.Plugins.Add( pluginName, availableLanguages, pathToPlugin )
pluginName: 插件名稱或者插件目錄名稱.
availableLanguages: 逗號分割的可用語言列表.
pathToPlugin: 絕對路徑,指插件的所占目錄,包括插件本身一層目錄
在默認位置添加插件
引用內(nèi)容
復(fù)制代碼 代碼如下:
FCKConfig.Plugins.Add( 'findreplace', 'en,it' ) ;
在其他位置添加插件,在add方法傳遞插件的絕對路徑。
引用內(nèi)容
復(fù)制代碼 代碼如下:
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 ) ;
https://www.jb51.net/article/18660.htm
您可能感興趣的文章:- 手把手教你 CKEDITOR 4 擴展插件制作
- FCKeditor .NET的配置、擴展與安全性經(jīng)驗交流
- FCKeditor 插件開發(fā) 示例(詳細版本)
- ckeditor自定義插件使用方法詳解
- CKEditor 附插入代碼的插件
- 添加FCKeditor插件需要注意的地方
- fckeditor 修改記錄添加行距功能插件
- ckeditor插件開發(fā)簡單實例
- fckeditor 插件實例 制作步驟
- CKEditor中加入syntaxhighlighter代碼高亮插件
- CKEDITOR二次開發(fā)之插件開發(fā)方法
- CKEditor擴展插件:自動排版功能autoformat插件實現(xiàn)方法詳解