kindeditor编辑器

一:官网

http://kindeditor.net/doc3.php

二:引用

<!-- kindeditor --> 
   <script charset="utf-8" src="plug-in/kindeditor/kindeditor-all.js"></script>
    <script charset="utf-8" src="plug-in/kindeditor/lang/zh-CN.js"></script>
   <script charset="utf-8" src="plug-in/kindeditor/plugins/code/prettify.js"></script> <link rel="stylesheet" href="plug-in/kindeditor/themes/default/default.css" /> <link rel="stylesheet" href="plug-in/kindeditor/plugins/code/prettify.css" />

三:功能

(1)上传图片

  上传图片需要设置三个初始化参数:uploadJson, fileManagerJson ,allowFileManager 。

      KindEditor.ready(function(K) {
                           window.editor = K.create('#content',{
                 uploadJson : 'plug-in/kindeditor/jsp/upload_json.jsp',
                fileManagerJson : 'plug-in/kindeditor/jsp/file_manager_json.jsp',
                allowFileManager : true,
         urlType:"domain",
        });
      });

var html = editor.html();
$("#content").val(html);

获取编辑器内容,并赋给绑定的textarea。

urlType
改变站内本地URL,可设置空、relative、absolute、domain。空为不修改URL,relative为相对路径,absolute为绝对路径,domain为带域名的绝对路径。
数据类型:String
默认值:空
注: 3.4版本开始支持,3.4.1版本开始默认值为空。

(2)textarea增加字数限制

 KindEditor.ready(function(K) {
                     window.editor = K.create('#content',{
                     afterChange : function() {    
                       K('.word_count').html(this.count('text'));
                       K('#wordcount').val(this.count('text'));
                    }       
        });
      });

  您当前输入了 <span class="word_count">0</span>个文字。
  <input id="wordcount" datatype="n1-4" errormsg="须10000字以内" style="40px"
  ignore="ignore" type="hidden" class="word_count" value="0"/>

原文地址:https://www.cnblogs.com/fdzfd/p/5711994.html