FCKeditor的工具条设置

上一章讲了配置部分,有关完整的配置选项的信息会在最后以附录的形式给出。

Toolbar  工具条

Toolbar Configuration   工具条的配置

It's quite easy to customize the toolbar buttons to your needs. Just edit the configuration file and modify or add new items to the "FCKConfig.ToolbarSets" configuration entry or create this entry in your custom Configuration File.
要自定义工具条的按钮是很容易的事情,只需要在配置文件中 修改或添加新的按钮的名称到 FCKConfig.ToolbarSets 的数组成员中即可。或者在自己的配置文件中新建一个 ToolbarSets 的数组成员作为新的工具集。

Take a look at the fckconfig.js file to see these two sample toolbarsets definitions: 下面是fckconfig.js文件中两款编辑器按钮工具集的编程形式:

FCKConfig.ToolbarSets["Default"] = [
['Source','DocProps','-','Save','NewPage','Preview','-','Templates'],
['Cut','Copy','Paste','PasteText','PasteWord','-','Print','SpellCheck'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'],
'/',
['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
['Link','Unlink','Anchor'],
['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak'],
'/',
['Style','FontFormat','FontName','FontSize'],
['TextColor','BGColor'],
['FitWindow','ShowBlocks','-','About'] // No comma for the last row. 注意最后一行没有逗号
] ;
FCKConfig.ToolbarSets["Basic"] = [
['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink','-','About']
] ;

Toolbar Bands   "工具条带"

Every ToolBarSet is composed of a series of "toolbar bands" that are grouped in the final toolbar layout. The bands items move together on new rows when resizing the editor. 每个工具集都由一系列的 "工具条带" 组成,如果工具集是一个团,那么每个"工具条带"就是团里的连,属于基本的战斗单位,当编辑器的大小发生改变时,工具条带里的按钮会一起移动到新行。

As you can see in the above toolbarsets definitions, every toolbar band is defined as a separated JavaScript array of strings. Every string corresponds to an available toolbar item defined in the editor code or in a plugin. If the toolbar item doesn't exist, a message is displayed when loading the editor.  正如你所看到的,在上面的工具集的定义中,每个工具条带被定义为一个Javascript的字符串形式的数组 比如:

['Source','DocProps','-','Save','NewPage','Preview','-','Templates']

等,其中的每个字符串 像'Source' 之类(除了'-'字符,这个字符后面会提到)的都对应一个在编辑器的代码中或在插件中定义过的按钮(在插件中如何定义一个按钮,后面的章节会提到)。如果对应的按钮没有被定义过,那么在加载编辑器的时候就会出现一条警告信息。
You can also include a separator in the toolbar band by including the "-" string on it.  在刚才的那个字符串数组中有个很特别的字符 '-' 字符,这个字符是工具条带中的分隔符,可以使界面的显示层次更加的分明。

Forcing Row Break   强制换行符

Looking at the "Default" ToolBarSet you will note that in one of the rows you have a "/" string instead of an array. This slash can be used to tell the editor that you want to force the next bands to be rendered in a new row and not following the previous one.  在前面的Default工具集的定义中 有个很特别的字符串 "/" ,这里使用的是 反斜线 而不是一个数组,这样做的目的是为了告诉编辑器,在显示的时候,反斜线以后的工具条带会另起一行,从而与前面的工具条带分开。

Custom ToolBarSets   自定义一个工具集

The editor comes with the "Default" and "Basic" ToolBarSets already defined in the fckconfig.js file. You can modify them, but you can also create new customized ones. For example, to create a toolbarset named "MyToolbar", just include the following in the configuration file or in your custom Configuration File:    编辑器的配置文件中提供了 "Default" 和 "Basic" 两个工具集。你可以修改它们,当然你也可以自己定义一个新的工具集。例如,创建一个名为 "MyToolbar" 的工具集,只需在主配置文件或你自定义的配置文件中包含如下的代码(也就是给 ToolbarSets数组添加一个新的成员):

FCKConfig.ToolbarSets["MyToolbar"] = [
['Cut','Copy','Paste','PasteText','PasteWord'],
['Undo','Redo','-','Bold','Italic','Underline','StrikeThrough'],
'/',
['OrderedList','UnorderedList','-','Outdent','Indent'],
['Link','Unlink','Anchor'],
'/',
['Style'],
['Table','Image','Flash','Rule','SpecialChar'],
['About']
] ;

Now you just need to set your ToolBarSet when creating an editor instance. Below you will find examples how to do it in different server side languages:  现在,你就可以在创建编辑器的实例时 设置你的工具集了,下面通过不同的编程语言来说明如何实现这个操作:

posted @ 2010-09-04 06:53  夜壶  阅读(986)  评论(0编辑  收藏  举报