您好,登錄后才能下訂單哦!
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', //這個(gè)autoformat.gif是你的插件圖標(biāo),放在同目錄下 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標(biāo)簽替換成<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標(biāo)簽 bb = _html.split("<br />"); aa = ''; for (var i = 0; i < bb.length; i++) { aa = aa + '<p>' + bb[i] + '</p>'; } //首行縮進(jìn) _html = aa.replace(/<p[^>]*>/ig, '<p> '); _html = _html.replace(/<p> <\/p>/ig, ''); _html = _html.replace(/<p><\/p>/ig, ''); //在這里執(zhí)行你將_html中的空行替換掉的操作 a.setData(_html); } } } }; })();
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。