ckEditor使用方法
2011-07-31 21:33
399 查看
原帖地址
灵活的调用方式——JS代码调用:<script type="text/javascript" src="../../ckeditor/ckeditor.js"></script> <!--此行为导入ckeditor.js文件,要注意目录是否正确。--> <textarea cols="80" id="editor1" name="editor1" rows="10"></textarea> <script type="text/javascript"> CKEDITOR.replace( 'editor1' ); <!--此行就是用ckeditor替换文本域textarea 这里editor1可以是文本域的id或者name--></script>
其实很简单,包含Ckeditor的js文件,生成textarea,然后用语句替换。js替换,可以进行更为详细的配置,下文将做详细说明。
二、Ckeditor工具栏自定义设置
在ckeditor目录下,有个Config.js
未配置的内容如下:
CKEDITOR.editorConfig = function( config ){// Define changes to default configuration here. For example:// config.language = 'fr';// config.uiColor = '#AADC6E';
//可以在此处进行配置,配置后调用后就能呈现相应的显示效果,详细内容如下。};
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 配置文件Config.js的一些具体配置信息
三、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'
});
相关文章推荐
- CKEditor使用方法记录一(简单的操作)
- CKeditor在ASP.NET中的使用方法
- ckeditor:基本使用方法
- HTML编辑器CKEditor的使用方法
- ckeditor插件的使用方法和一些需要注意的地方。
- django轻松使用富文本编辑器CKEditor的方法
- 使用bootstrap框架的模态框与ckeditor产生冲突,ckeditor的弹出窗不可用时的解决方法
- YII使用ckeditor的方法
- ASP.NET笔记之CKEditor的使用方法
- CKEditor使用方法
- CKEditor 4使用方法,来自http://docs.ckeditor.com/#!/guide/dev_ckeditor_js_load官网地址
- ckeditor_4.0使用方法
- CKEditor的使用方法
- asp.net ckeditor编辑器的使用方法
- CKeditor在ASP.NET中的使用方法
- CKEditor的使用方法
- 初次使用CKeditor replace使用方法
- laravel 文章发布功能----ckeditor使用(附带post处理方法)
- [置顶] ckeditor 的几种使用方法总结(附演示工程文件,并且解决几个常见错误)
- CKEditor的使用方法