在Grails中使用CKEditor

[url]http://grails.org/plugin/ckeditor[/url]

Grails的插件系统让引入一个新框架需要做的工作简单到爆。

1. 在IDEA中右键点击Plugins(插件),就会列出可用的插件,打勾就安装成功。

2. 在GSP中加入
[quote]<head>
....
[color=red]<ckeditor:resources/>[/color]
....
</head>
<body>
....
<form>
[color=red] <ckeditor:editor name="myeditor" height="400px" width="80%">
${initialValue}
</ckeditor:editor>[/color]
</form>
....
</body>[/quote]

3. 要不要太简单,哈哈
[img]http://dl.iteye.com/upload/attachment/0078/8225/ad6109c5-7bae-361b-ba9d-c11b556b0ef2.png[/img]


[size=large]注意事项[/size]
1. 在GSP显示富文本的时候,如果用
<g:fieldValue bean="${companyInstance}" field="content"/>
会将HTML标签也作为文本输出。需要使用
${companyInstance.content}
才能正确显示

2. 对于使用了layout的gsp,需要保证在layout页里有
<g:layoutHead/>
原因很简单,看前面的第2步就知道了。我当时遇到这个问题,开始还以为是css导致的,排查了半天才找到症结。。。

[size=large]高级-自定义工具栏[/size]
<ckeditor:config var="toolbar_bar01">
[
['PasteText','-','Undo','Redo','SelectAll','RemoveFormat'],['Preview','Source','ShowBlocks'],
'/',
['TextColor','BGColor','-','Bold','Italic','Underline','Strike'],['NumberedList','BulletedList','-','Outdent','Indent' ],['Link','Unlink'],['Table','HorizontalRule']
]
</ckeditor:config>
<ckeditor:editor name="comment" height="200px" width="90%" toolbar="bar01">
Please write down some comment
</ckeditor:editor>

[size=large]高级-回车换行模式[/size]
默认是回车=P,shift回车=BR,但这很不方便,交换一下就合理很多。
<ckeditor:config enterMode="CKEDITOR.ENTER_BR" shiftEnterMode="CKEDITOR.ENTER_P"/>


[url]http://stefanogualdi.github.com/grails-ckeditor/docs/ref/Tags/config.html[/url]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值