phpcms/libs/classes/form.class.php找['Maximize'],在它下面添加['autoformat']
statics/js/ckeditor/config.js找到config.extraPlugins修改为
statics\js\ckeditor\plugins 新建文件夹autoformat并新建文件plugin.js
(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(/ /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); } } } }; })();
phpcms 文章一键排版
原创
©著作权归作者所有:来自51CTO博客作者菜鸟不菜么的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:phpcms 标签调用
下一篇:云人才网添加字段
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Excel一键导入导出-EasyPOI
EasyPOI是一个功能强大、易用的Java库,可以帮助开发者快速实现Excel文件的导入导出功能。
excel EasyPOI java -
公众号文章排版神器,Markdown一键排版,微信公号文章里代码的美化排版
自己经常在简书,掘金上面写一些技术文章,喜欢用Markdow
markdown 微信公众号 微信公众号排版 公号排版 代码排版 -
typora主题配置:公众号一键排版
typora是一个非常易用且免费的markdown编辑器,是我最常用的文
css markdown typora 排版 边距 -
用html+javascript打造公文一键排版系统7:落款排版
anvas.getContext().measureText().width来实现
html 前端 javascript 正则表达式 排版