Kingeditor的使用笔记(配置、清除和设置值)

先下载Kingeditor的压缩包文件,解压后放在项目WebContent文件夹下,如图:

在这里插入图片描述
然后在需要放置插件的jsp文件中添加js代码,代码如下:

var editor;
KindEditor.ready(function(K) {
	editor = K.create('textarea[name="affcontent"]',{
		cssPath : '<%=path%>/kindeditor/plugins/code/prettify.css',
		uploadJson : '<%=path%>/kindeditor/jsp/upload_json.jsp',
		fileManagerJson : '<%=path%>/kindeditor/jsp/file_manager_json.jsp',
		allowFileManager : true,
		width:"100%",
		allowImageUpload:true,
		afterBlur:function(){this.sync();}
	 });
});

在需要放置插件的页面部分HTML代码如下:

<textarea id="affcontent" name="affcontent" style="width:100%;height:120px;" ></textarea>

当需要修改内容,并且要将之前在编辑器上写的数据重新显示在Kingeditor上,可以这样先移除原有的编辑器,然后在重新配置,并设置值。清除编辑器上原有的内容也可以采取这样的方法。

var editor;
KindEditor.remove('#content'); // 先移除之前创建的编辑器
editor = KindEditor.create('#content', {// 再重新创建编辑器
	 cssPath : '<%=path%>/kindeditor/plugins/code/prettify.css',
	 uploadJson:'<%=path%>/kindeditor/jsp/upload_json.jsp',
	 fileManagerJson: '<%=path%>/kindeditor/jsp/file_manager_json.jsp',
	 allowFileManager: true,
	 width:"100%",
	 allowImageUpload:true,
 	 afterBlur: function(){this.sync();}
});
editor.html(data);

Kingeditor下载地址:http://kindeditor.net/down.php

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值