温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

phpcms 文章一键排版

发布时间:2020-06-27 14:09:19 来源:网络 阅读:753 作者:菜鸟不菜么 栏目:web开发
  1. phpcms/libs/classes/form.class.php找['Maximize'],在它下面添加['autoformat']

    phpcms 文章一键排版

  2. statics/js/ckeditor/config.js找到config.extraPlugins修改为

    config.extraPlugins = 'capture,autoformat';phpcms 文章一键排版

  3. statics\js\ckeditor\plugins 新建文件夹autoformat并新建文件plugin.js


  4. (function() {     CKEDITOR.plugins.add('autoformat', {         requires: ['styles', 'button'],         init: function(a) {             a.addCommand('autoformat', CKEDITOR.plugins.autoformat.commands.autoformat);             a.ui.addButton('autoformat', {                 label: "清除格式,一键排版",                 command: 'autoformat',                 //这个autoformat.gif是你的插件图标,放在同目录下                  icon: this.path + "autoformat.gif"             });         }     });     CKEDITOR.plugins.autoformat = {         commands: {             autoformat: {                 exec: function(a) {                     var _html = a.getData();                     //清除样式代码                      _html = _html.replace(/<div/ig, '<p');                     _html = _html.replace(/<\/div>/ig, '</p>');                     _html = _html.replace(/<strong[^>]*>/ig, '');                     _html = _html.replace(/<\/strong>/ig, '');                     _html = _html.replace(/<em[^>]*>/ig, '');                     _html = _html.replace(/<\/em>/ig, '');                     _html = _html.replace(/<u[^>]*>/ig, '');                     _html = _html.replace(/<\/u>/, '');                     _html = _html.replace(/<li[^>]*>/ig, '');                     _html = _html.replace(/<\/li>/ig, '');                     _html = _html.replace(/<span[^>]*>/ig, '');                     _html = _html.replace(/<\/span>/ig, '');                     _html = _html.replace(/&nbsp;/ig, '');                     _html = _html.replace(/ /ig, '');                     _html = _html.replace(/<p><\/p>/ig, '');                     _html = _html.replace(/<a/ig, '<a rel="nofollow"');                     //将p标签替换成<br />                      _html = _html.replace(/<p[^>]*>/ig, '');                     _html = _html.replace(/<\/p>/ig, '<br />');                     _html = _html.replace(/<br \/><br \/>/ig, '<br />');                     _html = _html.replace(/[\n]/ig, '');                     //按<br />分组,将换行<br>全部替换成p标签                      bb = _html.split("<br />");                     aa = '';                     for (var i = 0; i < bb.length; i++) {                         aa = aa + '<p>' + bb[i] + '</p>';                     }                     //首行缩进                      _html = aa.replace(/<p[^>]*>/ig, '<p>  ');                     _html = _html.replace(/<p>  <\/p>/ig, '');                     _html = _html.replace(/<p><\/p>/ig, '');                     //在这里执行你将_html中的空行替换掉的操作                      a.setData(_html);                 }             }         }     }; })();
附件:http://down.51cto.com/data/2366632
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI