I. directory structure of the plug-in
The plug-in directory name must be the same as the plug-in name, and the directory must contain a fckplugin. js file. Optional. contains an Lang directory to internationalize the interface. Each file defines a language with a file name that does not contain. js and is registered with fckconfig. plugins. Add. If the implemented plug-in command has no interface, you do not need to support any language.
For example, the directory structure of the findreplace plug-in is as follows:
/Editor/plugins/findreplace/fckplugin. js
/Editor/plugins/findreplace/lang/en. js
/Editor/plugins/findreplace/lang/Zh. js
Define your plug-in the fckplugin. js file, and register and modify commands and create a toolbar button.
RegisterCodeNote:
Copy code The Code is as follows: // register the command, registercommand (command name, command)
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 ));
// Create a toolbar button, which is now created and then registered.
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 );
Ii. Install the plug-in:
Copy the decompressed package to the editor/Plugins directory before installation, and perform the following steps:
1. First, determine the position of the button on the toolbar.
It is best to write a new toolbar in the custom configuration file to include the new plug-in.
Custom configuration file:Copy codeThe Code is as follows: fckconfig. toolbarsets ['inteintest'] = [
['Source'],
['Holder'],
['My _ Find ', 'My _ replace'],
['Table ','-',
'Tableinsertrow', 'tabledeleterows ',
'Tableinsertcolumn', 'tabledeletecolumns ',
'Tableinsertcel', 'tabledeletecells ',
'Tablemergecells ', 'tablesplitcell'
],
['Bold ', 'italic', '-', 'orderedlist', 'unorderedlist', '-', 'link', 'unlink ','-', 'about']
];
2: Add a plug-in. You can add a plug-in directly to the custom file. You can directly place the plug-in the default directory, or specify the location of the plug-in by using the third parameter in the fckconfig. plugins. Add method.
// Code analysis:
Reference contentCopy codeThe Code is as follows: fckconfig. plugins. Add (pluginname, availablelanguages, pathtoplugin)
Pluginname: plug-in name or plug-in directory name.
Availablelanguages: list of available languages separated by commas.
Pathtoplugin: absolute path, which indicates the directory occupied by the plug-in, including the directory of the plug-in itself.
Add a plug-in to the default location
Reference contentCopy codeThe Code is as follows: fckconfig. plugins. Add ('findreplace', 'en, it ');
Add the plug-in elsewhere and pass the absolute path of the plug-in the add method.
Reference contentCopy codeThe Code is as follows: 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 );
Http://www.jb51.net/article/18660.htm