DWZ(J-UI)整合百度编辑器(UEditor)

DWZ(J-UI)整合百度编辑器(UEditor)

首先,在dwz.ui.js中找到

if($.fn.xheditor){
$(“textarea.editor”,$p).each(function(){
var $this=$(this);
var op={html5Upload:false,skin:’vista’,tools:$this.attr(“tools”)||’full’};
var upAttrs=[[“upLinkUrl”,”upLinkExt”,”zip,rar,txt”],[“upImgUrl”,”upImgExt”,”jpg,jpeg,gif,png”],[“upFlashUrl”,”upFlashExt”,”swf”],[“upMediaUrl”,”upMediaExt”,”avi”]];
$(upAttrs).each(function(i){
var urlAttr=upAttrs[i][0];
var extAttr=upAttrs[i][1];
if($this.attr(urlAttr)){
op[urlAttr]=$this.attr(urlAttr);
op[extAttr]=$this.attr(extAttr)||upAttrs[i][2];}});
$this.xheditor(op);});}

注释掉,然后添加以下代码

//百度编辑器
if ($(“textarea.editor”, $p).length>0) {
var module = $(“textarea.editor”, $p).attr(‘module’);
ueditor_loader[module]={};
$(“textarea.editor”, $p).each(function(i){
var $this = $(this);
var module=$this.attr(‘module’);
var thisid= module+’_’+i;
$this.attr(‘id’,thisid);
var uplink=$this.attr(‘upLink’);
var session=$this.attr(‘session’);
var ifheight=$this.attr(‘height’)?$this.attr(‘height’):320;
//var thisname=$this.attr(‘name’);
ueditor_loader[module][i]= new baidu.editor.ui.Editor({
minFrameHeight:ifheight
,imageUrl:uplink+’image_upload’
//,snapscreenServerUrl:uplink+’image_upload’
,fileUrl:uplink+’file_upload?’+session
,catcherUrl:uplink+’get_remote_image’
,imageManagerUrl:uplink+’image_manager’
,wordImageUrl:uplink+’image_upload’
,getMovieUrl:uplink+’get_movie’
//,textarea:thisname
});
ueditor_loader[module][i].render( $this[0] );
});
}
//百度编辑器

在首页文件index.html中加入以下代码

<script type=”text/javascript”>
var UEDITOR_HOME_URL=’__PUBLIC__/ueditor/’,ueditor_loader={};
//编辑器同步
function editorSyn(ename){
$.each(ueditor_loader[ename],function(i){
this.sync();
});
}
</script>

然后引入ueditor.min.css、ueditor.config.js和ueditor.all.min.js

<link rel=”stylesheet” type=”text/css” href=”__PUBLIC__/ueditor/themes/default/css/ueditor.min.css”/>
<script type=”text/javascript” charset=”utf-8″ src=”__PUBLIC__/ueditor/ueditor.config.js”></script>
<script type=”text/javascript” charset=”utf-8″ src=”__PUBLIC__/ueditor/ueditor.all.min.js”></script>

然后在百度编辑器就可以使用了

Comments are closed.