Customize CKeditor toolbar and make it work with jQuery

CKeditor 是一个非常好用的web编辑器,javaEye 上也又很多介绍,有兴趣的同学可以继续围观: http://ckeditor.com/

 

这里主要讲如何定制 ckeditor 的toolbar,以及让 ckeditor 和 jQuery 协同工作。

 

1. 在确保 jQuery 能正常工作后,引入 ckeditor, 在 <head> 区添加。

 

<script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/ckeditor/adapters/jquery.js"></script>
 

2. At this point, any textarea, p or div element can be transformed into a rich text editor by simply using the ckeditor() method:

 

 $( 'textarea.editor' ).ckeditor();

 

3. 定制 toolbar。

 

 

<script>
	$(document).ready(function(){
				
		//customize ckeditor toolbar.
		var config = {
				toolbar:
				[
					['Source','Preview','-','Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink','-','TextColor','BGColor'],
					['UIColor','-','Image']
				]
			};
					

		//fire ckeditor	
		$("#text").ckeditor(config);

	});
</script>

 

定制后的 toolbar 如下图:

 

References:

http://ckeditor.com/blog/CKEditor_for_jQuery

CKEditor Toolbar: http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Toolbar

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值