天天看點

百度UEditor富文本編輯器去除自動追加p标簽

本篇文章還原了我在遇到這個問題時的解決過程:

找到ueditor.all.js檔案,搜尋 me.addInputRule(function(root){ 或者直接搜尋 //進入編輯器的li要套p标簽 

将utils.each完全注釋!

//進入編輯器的li要套p标簽
    me.addInputRule(function(root){
        //utils.each(root.getNodesByTagName('li'),function(li){
        //    var tmpP = UE.uNode.createElement('p');
        //    for(var i= 0,ci;ci=li.children[i];){
        //        if(ci.type == 'text' || dtd.p[ci.tagName]){
        //            tmpP.appendChild(ci);
        //        }else{
        //            if(tmpP.firstChild()){
        //                li.insertBefore(tmpP,ci);
        //                tmpP = UE.uNode.createElement('p');
        //                i = i + 2;
        //            }else{
        //                i++;
        //            }
 
        //        }
        //    }
        //    if(tmpP.firstChild() && !tmpP.parentNode || !li.firstChild()){
        //        li.appendChild(tmpP);
        //    }
        //    //trace:3357
        //    //p不能為空
        //    if (!tmpP.firstChild()) {
        //        tmpP.innerHTML(browser.ie ? '&nbsp;' : '<br/>')
        //    }
        //    //去掉末尾的空白
        //    var p = li.firstChild();
        //    var lastChild = p.lastChild();
        //    if(lastChild && lastChild.type == 'text' && /^\s*$/.test(lastChild.data)){
        //        p.removeChild(lastChild)
        //    }
        //});      
me.addInputRule(function(root){
      

轉載于:https://www.cnblogs.com/renhongwei/p/6141437.html