KindEditor

KindEditor是用JavaScript编写的HTML可视化编辑器,在CMS、论坛、博客、电子邮件等互联网应用上得到广泛使用。 2006年7月首次发布2.0以来,KindEditor依靠出色的用户体验和领先的技术不断扩大编辑器市场占有率,目前在国内已经成为轻量级编辑器的首选。

主要特点

程序演示

http://kindsoft.net/demo.php

  • 代码量少,加载速度快。
  • 内置自定义range,完美地支持span标记。
  • 所有功能都是插件,增加自定义功能非常简单。
  • 编辑器风格定义在一个CSS文件里。
  • 支持大部分浏览器,比如IE、Firefox、Safari、Chrome、Opera。

 


程序下载

http://kindeditor.googlecode.com/files/kindeditor-3.3.1.zip

 

使用方法

<script type="text/javascript" charset="utf-8" src="./kindeditor.js"></script>
<script type="text/javascript">
    KE.show({
        id : 'your_editor_id',
        width : '700px',
        height : '400px'
    });
</script>
<textarea id="your_editor_id" name="content" cols="100" rows="8"></textarea>
编辑器调用方法
  1. 下载KindEditor最新版本。打开下载页面
  2. 解压zip文件,并把所有文件上传到您的网站程序目录下。例如:http://你的域名/editor/
  3. 要显示编辑器的位置添加TEXTAREA输入框。如果已经有TEXTAREA,属性里添加ID即可。
    <textarea id="content_1" name="content" style="width:700px;height:300px;"></textarea>
              
    <textarea id="content_1" name="content" cols="100" rows="8"></textarea>
              
  4. 该页面添加以下代码。
    <script type="text/javascript" charset="utf-8" src="/editor/kindeditor.js"></script>
    <script type="text/javascript">
        KE.show({
            id : 'content_1' //TEXTAREA输入框的ID
        });
    </script>
              
    除id之外可以设置其它的属性,具体属性请参考编辑器属性

编辑器属性

调用KE.showKE.init时可以设置以下参数。

  1. id TEXTAREA输入框的ID,必须设置。 数据类型:String
  2. items 配置编辑器的工具栏,工具栏遇到"-"会换行。 数据类型:Array 默认值:
    ['source', 'preview', 'fullscreen', 'undo', 'redo', 'print', 'cut', 'copy', 'paste',
    'plainpaste', 'wordpaste', 'justifyleft', 'justifycenter', 'justifyright',
    'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
    'superscript', 'date', 'time', '-',
    'title', 'fontname', 'fontsize', 'textcolor', 'bgcolor', 'bold',
    'italic', 'underline', 'strikethrough', 'removeformat', 'selectall', 'image',
    'flash', 'media', 'layer', 'table', 'specialchar', 'hr',
    'emoticons', 'link', 'unlink', 'about']
              
  3. width
    编辑器的宽度,可以设置px或%,比TEXTAREA输入框样式表宽度优先度高。
    数据类型:String
    默认值:TEXTAREA输入框的宽度
    注: 3.2版本开始支持。
  4. height
    编辑器的高度,只能设置px,比TEXTAREA输入框样式表高度优先度高。
    数据类型:String
    默认值:TEXTAREA输入框的高度
    注: 3.2版本开始支持。
  5. minWidth
    数据类型:Int
    指定编辑器最小宽度,单位为px。
    默认值:200
  6. minHeight
    数据类型:Int
    指定编辑器最小高度,单位为px。
    默认值:100
  7. filterMode
    数据类型:Boolean
    true时过滤HTML代码,false时允许输入任何代码。
    默认值:true
  8. htmlTags
    指定要保留的HTML标记和属性。哈希数组的key为HTML标签名,value为HTML属性数组,"."开始的属性表示style属性。
    数据类型:Object
    默认值:
    {
        font : ['color', 'size', 'face', '.background-color'],
        span : [
            '.color', '.background-color', '.font-size', '.font-family',
            '.font-weight', '.font-style', '.text-decoration', '.vertical-align'
        ],
        div : [
            'class', 'align', '.border', '.margin', '.padding', '.text-align', '.color',
            '.background-color', '.font-size', '.font-family', '.font-weight',
            '.font-style', '.text-decoration', '.vertical-align'
        ],
        table: [
            'class', 'border', 'cellspacing', 'cellpadding', 'width', 'height', 'align',
            '.padding', '.margin', '.border', 'bgcolor', '.text-align', '.color', '.background-color',
            '.font-size', '.font-family', '.font-weight', '.font-style', '.text-decoration'
        ],
        'td,th': [
            'class', 'align', 'valign', 'width', 'height', 'colspan', 'rowspan', 'bgcolor',
            '.text-align', '.color', '.background-color', '.font-size', '.font-family', '.font-weight',
            '.font-style', '.text-decoration', '.vertical-align'
        ],
        a : ['class', 'href', 'target', 'name'],
        embed : ['src', 'type', 'loop', 'autostart', 'quality', '.width', '.height', '/'],
        img : ['src', 'width', 'height', 'border', 'alt', 'title', '.width', '.height', '/'],
        hr : ['class', '/'],
        br : ['/'],
        'p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : [
            'align', '.text-align', '.color', '.background-color', '.font-size', '.font-family',
            '.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.text-indent'
        ],
        'tbody,tr,strong,b,sub,sup,em,i,u,strike' : []
    }
              
    注:filterMode为true时有效。
  9. resizeMode
    2或1或0,2时可以拖动改变宽度和高度,1时只能改变高度,0时不能拖动。
    数据类型:Int
    默认值:2
  10. skinType
    风格类型,default或tinymce,目前暂时只支持这两种。
    数据类型:String
    默认值:default
  11. wyswygMode
    可视化模式或代码模式
    数据类型:Boolean
    默认值:true
  12. autoOnsubmitMode
    true时form的onsubmit事件里自动添加KE.util.setData函数,自动完成把编辑器内容设置到textarea的处理。
    数据类型:Boolean
    默认值:true
  13. cssPath
    指定编辑器iframe document的CSS,用于设置可视化区域的样式。
    数据类型:String
    默认值:空
  14. skinsPath
    指定编辑器的skins目录,skins目录存放风格的css文件和gif图片。
    数据类型:String
    默认值:KE.scriptPath + 'skins/'
  15. pluginsPath
    指定编辑器的plugins目录。
    数据类型:String
    默认值:KE.scriptPath + 'plugins/'
  16. minChangeSize
    undo/redo文字输入最小变化长度,当输入的文字变化小于这个长度时不会添加到undo堆栈里。
    数据类型:Int
    默认值:5
  17. tagLineMode
    true时显示P,DIV等TAG的轮廓。
    数据类型:Boolean
    默认值:false
    注: 3.2版本开始支持。
  18. siteDomains
    指定多个网站域名,该域名的URL都会变成相对路径。例如:siteDomains = ['yourdomain.com', 'www.yourdomain.com'];
    数据类型:Array
    默认值:[]
    注: 3.3版本开始自动识别域名,无需设置这个属性,已废弃。
参数设置例子:
KE.show({
    id : "content_1",
    width : "70%", //编辑器的宽度为70%
    height : "200px", //编辑器的高度为100px
    filterMode : false, //不会过滤HTML代码
    resizeMode : 1 //编辑器只能调整高度
});

具体设置:http://kindsoft.net/doc.php

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值