thinkphp整合kindeditor編輯器詳解

來源:互聯網
上載者:User

具體方法

本人使用 的是@version 4.1.2 現在應該有更新了KindEditor 4.1.4 已經發布

KindEditor主要特點
快速:體積小,載入速度快
開源:開放原始碼,高水平,高品質
底層:內建自訂 DOM 類庫,精確操作 DOM
擴充:基於外掛程式的設計,所有功能都是外掛程式,可根據需求增減功能
風格:修改編輯器風格非常容易,只需修改一個 CSS 檔案
相容:支援大部分主流瀏覽器,比如 IE、Firefox、Safari、Chrome、Opera

下面說一下kindeditor在thinkphp中的使用
步驟1:下載kindeditor編輯器http://www.kindsoft.net/

步驟2:檔案引入

 代碼如下 複製代碼

<link rel="stylesheet" href="__PUBLIC__/kindeditor/themes/default/default.css" />

<link rel="stylesheet" href="__PUBLIC__/kindeditor/plugins/code/prettify.css" />
<script charset="utf-8" src="__PUBLIC__/kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="__PUBLIC__/kindeditor/lang/zh_CN.js"></script>

步驟3:配置參數

 代碼如下 複製代碼

<script>
    KindEditor.ready(function(K) {
        var editor1 = K.create('textarea[name="content"]', {
            cssPath : '__PUBLIC__/kindeditor/plugins/code/prettify.css',
            uploadJson : '__PUBLIC__/kindeditor/php/upload_json.php',
            fileManagerJson : '__PUBLIC__/kindeditor/php/file_manager_json.php',
            allowFileManager : true,
            afterCreate : function() {
                var self = this;
                K.ctrl(document, 13, function() {
                    self.sync();
                    K('form[name=example]')[0].submit();
                });
                K.ctrl(self.edit.doc, 13, function() {
                    self.sync();
                    K('form[name=example]')[0].submit();
                });
            }
        });
        prettyPrint();
    });
</script>

<textarea name="content" style="width:700px;height:200px;visibility:hidden;"></textarea>

textarea 中的content和上面 紅色的content對應

 

kindeditor html代碼過濾不能儲存

這是因為編輯器預設開啟了過濾模式(filterMode:true)。當filterMode為true時,編輯器會根據htmlTags設定自動過濾HTML代碼,主要是為了產生乾淨的代碼。
如果想保留所有HTML,修改kindeditor.js,請將filterMode設定成false。如果想保留特定HTML,請將filterMode設定成true後,配置htmlTags屬性。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.