wordpress ueditor编辑器的使用

来源:互联网 发布:惊天动地影评知乎 编辑:程序博客网 时间:2024/06/05 23:01

wordpress系统默认的编辑器功能不太完善,就改用百度编辑器ueditor插件。

要在其他页面上调用这个编辑器,就在当页加上ueditor相关的js和css。

<script charset="utf-8" src="<?php home_url();?>/wp-content/plugins/wp-ueditor2/ueditor/editor_config.js"></script><script charset="utf-8" src="<?php home_url();?>/wp-content/plugins/wp-ueditor2/ueditor/editor_all.js"></script><link rel="stylesheet" type="text/css" href="<?php home_url();?>/wp-content/plugins/wp-ueditor2/ueditor/themes/default/ueditor.css"/>

调用:

<pre name="code" class="javascript"><script type="text/javascript">var editor_a = new baidu.editor.ui.Editor({initialFrameWidth:660,initialFrameHeight:250});editor_a.render('info_content');</script>


<textarea name="info_content" id="info_content" style="width:660px;font-size:12px;margin-top: 5px;overflow: scroll-y;"></textarea>

获取内容:getContent();

设置内容:setContent();

//获取编辑器内容var content = editor_a.getContent();


编辑器会自动将<div>转成<p>,解决:

在ueditor.all.js里大约在9305行,'allowDivTransToP' : true 改为 false:

 me.setOpt({        'allowDivTransToP':false,        'disabledTableInTable':true    });

在9399行有个case ' div '全部注释掉。。


禁止编辑器高度自适应:

在ueditor.config.js里:

 //是否可以拉伸长高,默认true(当开启时,自动长高失效)        ,scaleEnabled:true
 ,initialFrameWidth:1081  //初始化编辑器宽度,默认1000        ,initialFrameHeight:320  //初始化编辑器高度,默认320



0 0
原创粉丝点击