Browse Source

Merge pull request #530 in VISUAL/fineui from ~FAY/fineui:master to master

* commit '77b9af480ae580dfcaca3dedef87c362d3485a44':
  update
  update
  update
es6
Young 6 years ago
parent
commit
3cf6e912c7
  1. 35
      src/case/richeditor/niceditor/niceditor.js

35
src/case/richeditor/niceditor/niceditor.js

@ -376,6 +376,34 @@
document.execCommand(cmd, false, args); document.execCommand(cmd, false, args);
}, },
initSelection: function (newLine) {
var newLineHtml = this._isIE11Below() ? "<p></p>" : "<p><br></p>"
var el = this.elm.element;
var children = el.children();
if (!children.length) {
// 如果编辑器区域无内容,添加一个空行,重新设置选区
el.append(newLineHtml);
this.initSelection();
return;
}
var last = children.last();
if (newLine) {
// 新增一个空行
var html = last.html().toLowerCase();
var nodeName = last.nodeName;
if ((html !== "<br>" && html !== "<br\/>") || nodeName !== "P") {
// 最后一个元素不是空行,添加一个空行,重新设置选区
el.append(newLineHtml);
this.initSelection();
return;
}
}
this.setFocus(last[0]);
},
_isChildOf: function(child, parent) { _isChildOf: function(child, parent) {
var parentNode; var parentNode;
if(child && parent) { if(child && parent) {
@ -388,6 +416,13 @@
} }
} }
return false; return false;
},
_isIE11Below: function() {
if (!BI.isIE()) {
return false;
}
return BI.getIEVersion() < 11;
} }
}); });
}()); }());

Loading…
Cancel
Save