phpcms 文章一鍵排版

來源:互聯網
上載者:User

標籤:phpcms   文章   一鍵排版   

  1. phpcms/libs/classes/form.class.php找[‘Maximize‘],在它下面添加[‘autoformat‘]

    650) this.width=650;" src="https://s5.51cto.com/wyfs02/M01/93/41/wKioL1kJnTWAHxXNAABo1CptwzI055.png-wh_500x0-wm_3-wmp_4-s_3808775440.png" title="QQ20170503170410.png" alt="wKioL1kJnTWAHxXNAABo1CptwzI055.png-wh_50" />

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

    config.extraPlugins = ‘capture,autoformat‘;650) this.width=650;" src="https://s4.51cto.com/wyfs02/M02/93/41/wKioL1kJne3D6H1zAAC_HtnweM8622.png-wh_500x0-wm_3-wmp_4-s_73541246.png" title="QQ20170503170739.png" alt="wKioL1kJne3D6H1zAAC_HtnweM8622.png-wh_50" />

  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);                }            }        }    };})();

phpcms 文章一鍵排版

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.