您好,登錄后才能下訂單哦!
phpcms/libs/classes/form.class.php找['Maximize'],在它下面添加['autoformat']
statics/js/ckeditor/config.js找到config.extraPlugins修改為
config.extraPlugins = 'capture,autoformat';
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); } } } }; })();
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。