本手册由zengl开源网的站长提供 首页:www.zengl.com 上一章讲了配置部分,有关完整的配置选项的信息会在最后以附录的形式给出。 Toolbar  工具条 Toolbar Configuration   工具...

 本手册由zengl开源网的站长提供 首页:www.zengl.com

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

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:  现在,你就可以在创建编辑器的实例时 设置你的工具集了,下面通过不同的编程语言来说明如何实现这个操作:

#p#自定义工具集#e#

JavaScript  JAVAscript 语言的实现(下面的内容都看的懂,就不多啰嗦了):

<script type="text/javascript">

var oFCKeditor = new FCKeditor( 'FCKeditor1' ) ;

oFCKeditor.ToolbarSet = 'MyToolbar' ;

oFCKeditor.Create() ;

</script>

PHP

$oFCKeditor->ToolbarSet = 'MyToolbar';

JSP (Java)

<FCK:editor instanceName="EditorDefault" toolbarSet="MyToolbar" />

ASP

oFCKeditor.ToolbarSet = "MyToolbar"

ASP.NET

<FCKeditorV2:FCKeditor id="FCKeditor2" ToolbarSet="MyToolbar" runat="server" />

ColdFusion

fckEditor.toolbarSet = "MyToolbar";

Additional information  附加信息

  ● It's a common mistake when customizing the toolbar, to just remove some elements from the Default toolbar set, including the "About" item, leaving the last row terminating with a comma (","). So, remember that the last toolbar band doesn't have a comma after it.   在定义一个工具集的时候有个常犯的错误,比如当从 Default 工具集中删除一些元素时,假设把最后一个 "About" 元素删了,那么倒数第二行就会变成最后一行,但是此时,这一行最后的逗号也会遗留下来,但是这个逗号是不允许出现的,所以要记住工具集的最后一个工具条带 在定义后不要在后面留下逗号。

 ● Remember to clean up your browser's cache when making changes to the configuration file, otherwise you may not see your changes and will simply not understand why.   第二个要注意的地方 还是那个老问题,当对配置文件做了修改后要记得清理 浏览器的缓存。否则你可能看不到效果并且因此而感到困惑。

Toolbar Behavior   工具条的行为(最大化与最小化)

On start behavior   定义一开始的行为

You can easily determine how the toolbar will appear when the editor starts runing. The toolbar can appear expanded (in maximized mode) or collapsed (in minimized mode). If you want change the appearance of the toolbar you should look throughout ToolbarStartExpanded option or just insert the following code into the configuration file remembering that 'true' sets the toolbar to expanded mode and 'false' sets it to collapsed mode:   你可以定义当编辑器开始运行时,工具条应该如何出现。工具条可以以最大化形式展开,也可以 以最小化模式折叠起来。如果你想改变工具条的显示,可以通过 ToolbarStartExpanded 该链接查看该选项的相关信息或者 在配置文件中插入下面的代码,当 ToolbarStartExpanded 为true时 工具条就是展开模式,false 时 就是折叠模式:

FCKConfig.ToolbarStartExpanded = true ;

Toolbar Collapsing   定义工具条是否可被用户折叠

You can choose whether the user can collapse (minimize) the toolbar, during work with the editor, or not. Just see the ToolbarCanCollapse option or apply this entry in the configuration file remembering that 'true' gives the permission to collapse the toolbar and 'false' doesn't:  你可以通过 ToolbarCanCollapse 该链接查看该选项的相关信息,通过这个选项可以决定使用编辑器的用户是否可以在编辑器运行时 折叠工具条,当为true 时,允许折叠,false时,不允许折叠。

FCKConfig.ToolbarCanCollapse = false;

OK,工具条配置讲完,休息,休息哈。

如果本文有翻译不周的地方,或有其他方面的评论,可以到下方发表评论。

上下篇

下一篇: FCKeditor的样式设置

上一篇: FCKeditor编辑器的配置文件

相关文章

FCKeditor的安装

FCKeditor的样式设置

FCKeditor的皮肤设置

PHP脚本加载fckeditor编辑器

FCKeditor自定义插件

FCKeditor的开发精简