fay 7 years ago
parent
commit
2197ccb9e9
  1. 16
      src/case/richeditor/niceditor/niceditor.js

16
src/case/richeditor/niceditor/niceditor.js

@ -60,13 +60,13 @@
selectCheck: function (e) { selectCheck: function (e) {
var t = e.target; var t = e.target;
var found = false; var found = false;
this.instance.saveRng();
do { do {
if (t.nodeName !== "svg" && t.className && t.className.indexOf(prefix) != -1) { if (t.nodeName !== "svg" && t.className && t.className.indexOf(prefix) != -1) {
return; return;
// return false; // return false;
} }
if (this.instance.checkToolbar(t)) { if (this.instance.checkToolbar(t)) {
this.instance.saveRng();
return; return;
} }
} while (t = t.parentNode); } while (t = t.parentNode);
@ -85,8 +85,8 @@
}, },
setValue: function (v) { setValue: function (v) {
v = v || ""; v = v || "<br>";
v = v.startWith("<div>") ? v : "<div>" + v + "</div>"; v = v.startWith("<p>") ? v : "<p>" + v + "</p>";
this.instance.setContent(v); this.instance.setContent(v);
}, },
@ -121,7 +121,7 @@
nicEditorInstance.superclass._init.apply(this, arguments); nicEditorInstance.superclass._init.apply(this, arguments);
var o = this.options; var o = this.options;
var initValue = o.value || "<br>"; var initValue = o.value || "<br>";
initValue = initValue.startWith("<div>") ? initValue : "<div>" + initValue + "</div>"; initValue = initValue.startWith("<p>") ? initValue : "<p>" + initValue + "</p>";
this.ne = this.options.ne; this.ne = this.options.ne;
this.elm = BI.createWidget({ this.elm = BI.createWidget({
type: "bi.layout", type: "bi.layout",
@ -281,7 +281,7 @@
keyDown: function (e, t) { keyDown: function (e, t) {
if (e.keyCode === 8) { if (e.keyCode === 8) {
var html = this.elm.element.html().toLowerCase().trim(); var html = this.elm.element.html().toLowerCase().trim();
if (html === "<div><br></div>" || html === "<div></div>") { if (html === "<p><br></p>" || html === "<p></p>") {
e.preventDefault() e.preventDefault()
return; return;
} }
@ -315,7 +315,7 @@
var newLine; var newLine;
var html = this.elm.element.html().toLowerCase().trim(); var html = this.elm.element.html().toLowerCase().trim();
if (!html || html === '<br>') { if (!html || html === '<br>') {
newLine = $("<div></div>"); newLine = $("<p><br></p>");
this.elm.element.html(''); this.elm.element.html('');
this.elm.element.append(newLine); this.elm.element.append(newLine);
this.setFocus(newLine[0]); this.setFocus(newLine[0]);
@ -418,7 +418,7 @@
// 新增一个空行 // 新增一个空行
var html = last.html().toLowerCase(); var html = last.html().toLowerCase();
var nodeName = last.nodeName; var nodeName = last.nodeName;
if ((html !== "<br>" && html !== "<br\/>") || nodeName !== "DIV") { if ((html !== "<br>" && html !== "<br\/>") || nodeName !== "P") {
// 最后一个元素不是空行,添加一个空行,重新设置选区 // 最后一个元素不是空行,添加一个空行,重新设置选区
el.append(newLineHtml); el.append(newLineHtml);
this.initSelection(); this.initSelection();
@ -430,7 +430,7 @@
}, },
_getNewLine: function () { _getNewLine: function () {
return "<div><br></div>"; return "<p><br></p>";
}, },
_isChildOf: function(child, parent) { _isChildOf: function(child, parent) {

Loading…
Cancel
Save