kindEditor PHP樣本

來源:互聯網
上載者:User

標籤:style   http   io   ar   os   for   sp   strong   檔案   

檔案自身調用

/*此處注意,上傳檔案是,請先建立對應的上傳檔案目錄,配置在upload_json.php中,建議同時修改file_manager_json.php中相關配置*/

/*擷取form表單傳值*/

<?php

    $htmlData = ‘‘;
    if (!empty($_POST[‘content‘])) {
        if (get_magic_quotes_gpc()) {
            $htmlData = stripslashes($_POST[‘content‘]);
        } else {
            $htmlData = $_POST[‘content‘];
        }
    }
    echo $htmlData;
?>

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>

    <script charset="utf-8" src="kindeditor-all-min.js"></script>
    <script charset="utf-8" src="zh-CN.js"></script>
    <script>
        var editor;
        KindEditor.ready(function(K) {
            editor = K.create(‘textarea[name="content"]‘, {
                cssPath : ‘./plugins/code/prettify.css‘,
                uploadJson : ‘./php/upload_json.php‘,
                fileManagerJson : ‘./php/file_manager_json.php‘,
                allowFileManager : true,
                afterCreate : function() {
                    var self = this;
                    K.ctrl(document, 13, function() {                <!--指定函數綁定到ctrl + [key]按鍵組合事件上-->
                        self.sync();
                        K(‘form[name=example]‘)[0].submit();
                    });
                    K.ctrl(self.edit.doc, 13, function() {
                        self.sync();
                        K(‘form[name=example]‘)[0].submit();
                    });
                }
            });
            <!--常方法-->
            K(‘input[name=getHtml]‘).click(function(e) {
                alert(editor.html());
            });
            K(‘input[name=isEmpty]‘).click(function(e) {
                alert(editor.isEmpty());
            });
            K(‘input[name=getText]‘).click(function(e) {
                alert(editor.text());
            });
            K(‘input[name=selectedHtml]‘).click(function(e) {
                alert(editor.selectedHtml());
            });
            K(‘input[name=setHtml]‘).click(function(e) {
                editor.html(‘<h3>Hello KindEditor</h3>‘);
            });
            K(‘input[name=setText]‘).click(function(e) {
                editor.text(‘<h3>Hello KindEditor</h3>‘);
            });
            K(‘input[name=insertHtml]‘).click(function(e) {
                editor.insertHtml(‘<strong>插入HTML</strong>‘);
            });
            K(‘input[name=appendHtml]‘).click(function(e) {
                editor.appendHtml(‘<strong>添加HTML</strong>‘);
            });
            K(‘input[name=clear]‘).click(function(e) {
                editor.html(‘‘);
            });
        });
    </script>
</head>
<body>
    <form action="kindeditor.php" name="example" method="post">
    <textarea id="editor_id" name="content" style="width:700px;height:300px;">
    </textarea>
    <p>
        <input type="button" name="getHtml" value="取得HTML" />
        <input type="button" name="isEmpty" value="判斷是否為空白" />
        <input type="button" name="getText" value="取得文本(包含img,embed)" />
        <input type="button" name="selectedHtml" value="取得選中HTML" />
        <br />
        <br />
        <input type="button" name="setHtml" value="設定HTML" />
        <input type="button" name="setText" value="設定文本" />
        <input type="button" name="insertHtml" value="插入HTML" />
        <input type="button" name="appendHtml" value="添加HTML" />
        <input type="button" name="clear" value="清空內容" />
        <input type="reset" name="reset" value="Reset" />
    </p>
    <input type="submit" name="button" value="提交內容" /> (提交快速鍵: Ctrl + Enter)
    </form>
</body>

</html>


更多協助資訊,參見http://kindeditor.net/docs/

kindEditor PHP樣本

聯繫我們

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