Change or customize the Toolbars in FCKeditor

分类:Java 作者: 秋天 时间: 08-09-2007

标签分类 :

Since March 13, 2007, the FCKeditor has supported the new method setCustomConfigurationsPath(String url) that you can specify the url of the custom configuration .js file. You do not need to modify the fckconfig.js inside the fckez.jar any more. Please see FCKeditor Configurations File for details on what can be customized.So here is the new way to create a new toolbar set for the FCKeditor.

1. Create a JavaScript .js custom configuration file, say, myconfig.js under somewhere of your web path. For description convenience, this example would put it under root path; i.e. “/myconfig.js”.

2. Create a new toolbar set “Simple” inside the file (myconfig.js). e.g.

FCKConfig.ToolbarSets[”Simple”] = [
[’Bold’,'Italic’,'Underline’,'StrikeThrough’,'-’,'TextColor’,'BGColor’]
];

3. To use this /myconfig.js, you have to specify it in the <fckeditor> tag
<fckeditor customConfigurationsPath=”/myconfig.js” toolbarSet=”Simple”/>
or by Java methods
FCKeditor myFCKeditor = new FCKeditor();
myFCKeditor.setCustomConfigurationsPath(”/myconfig.js”);
myFCKeditor.setToolbarSet(”Simple”);
4. OK. You are done.

The following is the old way that needs you to modify the fckconfig.js inside the fckez.jar

To change a toolbar in FCKeditor or create a new one, the fckconfig.js file in the fckez.jar file will have to be modified.

1. make a backup copy of the fckez.jar file in case anything goes wrong.

2. rename the fckez.jar file to fckez.zip (jar files are just zip files, so this works)

3. unzip the fckez.zip file somewhere. A new directory is suggested.

4. find the fckconfig.js, and open it for editing. It should be at \web\js\ext\FCKeditor\fckconfig.js

5. find the toolbars section. The following is the Basic one.

FCKConfig.ToolbarSets[”Basic”] = [
[’Bold’,'Italic’,'-’,'OrderedList’,'UnorderedList’,'-’,'Link’,'Unlink’,'-’,'About’]
] ;
6. To create a new ToolbarSet, copy everything between the FCKConfig.ToolbarSets… to the semicolon ;

7. Paste it in following the semicolon, and change the name.
FCKConfig.ToolbarSets[”Simple”] = [
[’Bold’,'Italic’,'-’,'OrderedList’,'UnorderedList’,'-’,'Link’,'Unlink’,'-’,'About’]
] ;
8. Change the Toolset as you see fit. Buttons are defined in the single quotes. the ‘-’ is a toolbar separator. Lets remove the link and unlink buttons.
FCKConfig.ToolbarSets[”Simple”] = [
[’Bold’,'Italic’,'-’,'OrderedList’,'UnorderedList’,'-’,'About’]
] ;
9. Save the file and exit the editor program.

10. navigate up the dir tree till you get to web folder level, and place the whole tree into the zip file. (this will preserve the location of the modified file in the dir structure.)

11. rename the zip file back to fckez.jar, and put the jar file into the tomcat shared/lib directory with the other zk jar files.

12. change your code that calls the FCKeditor in you zk application to use the ‘Simple’ toolbarset.
FCKeditor myFCKeditor = new FCKeditor();
myFCKeditor.setToolbarSet(”Simple”);
13. start Tomcat, and use a browser to view your application. You should see your modified toolbar set in FCKeditor.

Leave a Reply


如果你喜欢本站,请加入你的收藏夹以便随时回来