当前位置:网站首页>Ueeditor automatically appends P tags to rich text.br tags always wrap.br tag solutions

Ueeditor automatically appends P tags to rich text.br tags always wrap.br tag solutions

2022-06-26 04:16:00 Never bow

to update ::

I found these problems unsolved

Reprint :http://www.bomiw.com/news/useknowledge-377.html

Here's the content


UEditor It is a very good text editor developed by Baidu , But in use , The default is to automatically append each time p label . But in many cases , I don't need this p label , This is very annoying . Is there any way to eliminate the automatic addition p What about the label ?


The method is as follows :

First : open ueditor.all.js( or ueditor.all.min.js).

1、 Change the search to false:allowDivTransToP: false


2、 Search and modify the following :

// Editor cannot be empty 
if (domUtils.isEmptyNode(me.body)) {
    me.body.innerHTML = '';
}

3、 Search for “/ Give text or inline Node sleeve p label ”, And replace the following

// Give text or inline Node sleeve p label 
if (me.options.enterTag == 'p') {
  var child = this.body.firstChild, tmpNode;
  if (!child || child.nodeType == 1 &&
    (dtd.$cdata[child.tagName] || isCdataDiv(child) ||
      domUtils.isCustomeNode(child)
      )
    && child === this.body.lastChild) {
    this.body.innerHTML = '' + this.body.innerHTML;
  } else {
    var p = me.document.createElement('div');
    while (child) {
      while (child && (child.nodeType == 3 || child.nodeType == 1 && dtd.p[child.tagName] && !dtd.$cdata[child.tagName])) {
        tmpNode = child.nextSibling;
        p.appendChild(child);
        child = tmpNode;
      }
      if (p.firstChild) {
        if (!child) {
          me.body.appendChild(p);
          break;
        } else {
          child.parentNode.insertBefore(p, child);
          p = me.document.createElement('div');
        }
      }
      child = child.nextSibling;
    }
  }
}

4、 Search for “ Enter the editor's li Must set p label ”, This should also be noted out


5、 Look at this :

node.className = utils.trim(node.className.replace(/list-paddingleft-\w+/,'')) + ' list-paddingleft-' + type;

6、 Finally look away :

li.style.cssText && (li.style.cssText = '');

Perfect solution , The above is the whole process , However, some browsing needs to empty the cache to work .

原网站

版权声明
本文为[Never bow]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202180536199193.html