wordpress ueditor編輯器的使用

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



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章