PHP网页制作中ckEditor的使用方法
点击次数: 发布时间:2015-12-24 09:34:23
一、ckEditor的调用方式——JS代码调用:
Ckeditor的初始化内容,作为textarea的value值. You are using CKEditor.
CKEDITOR.replace( 'editor1' );
其实很简单,包含Ckeditor的js文件,生成textarea,用就是语句替换。js预计替换,可以进行更为详细的配置,下文将做详细说明。
二、Ckeditor工具栏自定义设置
1.在Ckeditor根目录的config.js中设置:
config.toolbar = 'Full';
config.toolbar_Full =
[
['Source','-','Save','NewPage','Preview','-','Templates'],
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
'/',
['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
['Link','Unlink','Anchor'],
['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
'/',
['Styles','Format','Font','FontSize'],
['TextColor','BGColor'],
['Maximize', 'ShowBlocks','-','About']
];
config.toolbar_Basic =
[
['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink','-','About']
];
上述代码中第一行,即为设定默认工具栏的,可以改写为:
config.toolbar = 'Basic';
2.在用js代码调用Ckeditor时设置:
CKEDITOR.replace( 'editor1',
{
toolbar :
[
['Styles', 'Format'],
['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', '-', 'About']
]
});
3.以上两种方法的综合:
在Ckeditor根目录下的config.js文件中设置好多组toolbar,如方法1示
例代码去掉第一行;调用Ckeditor时的代码如下:
CKEDITOR.replace( 'editor1',
{
toolbar : 'Full'
});
CKEDITOR.replace( 'editor2',
{
toolbar : 'Basic'
});
三、Ckeditor语言、字体及皮肤样式自定义
Ckeditor支持多国语言,并提供三种皮肤样式:kama、office2003和v2,可以在Ckeditor根目录下的config.js文件中进行设置:
config.language = 'zh-cn' ;
config.skin = 'office2003';
也可以在js调用Ckeditor时设置:
CKEDITOR.replace( 'editor1',
{
toolbar : 'Full',
language : 'zh-cn',
skin : 'office2003'
});
CKEDITOR.replace( 'editor2',
{
toolbar : 'Basic',
language : 'zh-cn';
skin : 'kama'
});
四、Ckeditor添加中文字体
1.在Ckeditor根目录下的config.js文件中添加:
config.font_names = '宋体;黑体;隶书;楷体_GB2312;Arial;Comic Sans MS';
2.在用js代码调用Ckeditor时添加:
CKEDITOR.replace( 'editor1',
{
toolbar : 'Full',
language : 'zh-cn',
skin : 'office2003',
config.font_names : '宋体;黑体;隶书;楷体_GB2312;Arial;Comic Sans MS'