phpcms编辑器添加一键排版控件

phpcms编辑器添加一键排版控件

CKEditor添加一键排版插件实例,大家都知道phpcms也是ckeditor编辑器,那么如果增加这个一键排版这个牛逼功能呢增加好了后,鲜花
">鲜花效果图是这样的废话不多说,直接说步骤第一步:config.js中statics\js\ckeditor\config.js中注册autoformat控件

  1. config.extraPlugins=‘capture,videoforpc,flashplayer,autoformat’;
第二步,在statics\js\ckeditor\plugins 新建文件夹autoformat第三步,在statics\js\ckeditor\plugins\autoformat新建文件plugin.js写入如下内容
  1. /Copyright©2015-11-17,程序员人生温良顺class=“alt”>(function(){CKEDITOR.plugins.add(‘autoformat’,{
  2. requires:[‘styles’,‘button’],init:function(a){
  3. a.addCommand(‘autoformat’,CKEDITOR.plugins.autoformat.commands.autoformat);a.ui.addButton(‘autoformat’,{
  4. label:“清除格式,一键排版”,command:‘autoformat’,
  5. icon:this.path+“autoformat.gif”//这个autoformat.gif是你的插件图标,放在同目录下});
  6. }});
  7. CKEDITOR.plugins.autoformat={commands:{
  8. autoformat:{exec:function(a){
  9. var_html=a.getData();//清除样式代码
  10. _html=_html.replace(/<div/ig,’<p’);_html=_html.replace(/</div>/ig,’</p>’);
  11. _html=_html.replace(/<strong[^>]>/ig,’’);_html=_html.replace(/</strong>/ig,’’);
  12. _html=_html.replace(/<em[^>]>/ig,’’);_html=_html.replace(/</em>/ig,’’);
  13. _html=_html.replace(/<u[^>]>/ig,’’);_html=_html.replace(/</u>/,’’);
  14. _html=_html.replace(/<li[^>]>/ig,’’);_html=_html.replace(/</li>/ig,’’);
  15. _html=_html.replace(/<span[^>]>/ig,’’);_html=_html.replace(/</span>/ig,’’);
  16. _html=_html.replace(/&nbsp;/ig,’’);_html=_html.replace(/ /ig,’’);
  17. _html=_html.replace(/<p></p>/ig,’’);_html=_html.replace(/<a/ig,’<arel=“nofollow”’);
  18. //将p标签替换成<br/>_html=_html.replace(/<p[^>]>/ig,’’);
  19. _html=_html.replace(/</p>/ig,’<br/>’);_html=_html.replace(/<br/><br/>/ig,’<br/>’);
  20. _html=_html.replace(/[\n]/ig,’’);
  21. //按<br/>分组,将换行<br>全部替换成p标签bb=_html.split("<br/>");
  22. aa=’’;for(vari=0;i<bb.length;i++){
  23. aa=aa+’<p>’+bb[i]+’</p>’;}
  24. //首行缩进
  25. _html=aa.replace(/<p[^>]>/ig,’<p>  ‘);_html=_html.replace(/<p>  </p>/ig,’’);
  26. _html=_html.replace(/<p></p>/ig,’’);
  27. //在这里执行你将_html中的空行替换掉的操作a.setData(_html);
  28. }}
  29. }};
  30. })();
写到这里,就完成啦,完成了CKEditor添加一键排版插件但是,到这里再phpcms里面,还是不能直接用的,在别的系统里面是可以的。因为phpcms的编辑器控件是需要单独选择的,还需要修改phpcms文件打开phpcms/libs/classes/form.class.php搜索[‘Maximize’] 在它的后面加上 [‘autoformat’],就可以了这样phpcms编辑器添加一键排版控件就完成啦,大家有什么疑问,欢迎留言,本文是站长手写代码,转载请说明出处,本文来自程序员人生

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值