From 2197ccb9e9be64a3d7e51a377313f31fa3c7f8c4 Mon Sep 17 00:00:00 2001 From: fay Date: Tue, 24 Jul 2018 11:42:41 +0800 Subject: [PATCH 1/4] update --- src/case/richeditor/niceditor/niceditor.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/case/richeditor/niceditor/niceditor.js b/src/case/richeditor/niceditor/niceditor.js index 64dde7209..612dc46d0 100644 --- a/src/case/richeditor/niceditor/niceditor.js +++ b/src/case/richeditor/niceditor/niceditor.js @@ -60,13 +60,13 @@ selectCheck: function (e) { var t = e.target; var found = false; + this.instance.saveRng(); do { if (t.nodeName !== "svg" && t.className && t.className.indexOf(prefix) != -1) { return; // return false; } if (this.instance.checkToolbar(t)) { - this.instance.saveRng(); return; } } while (t = t.parentNode); @@ -85,8 +85,8 @@ }, setValue: function (v) { - v = v || ""; - v = v.startWith("
") ? v : "
" + v + "
"; + v = v || "
"; + v = v.startWith("

") ? v : "

" + v + "

"; this.instance.setContent(v); }, @@ -121,7 +121,7 @@ nicEditorInstance.superclass._init.apply(this, arguments); var o = this.options; var initValue = o.value || "
"; - initValue = initValue.startWith("
") ? initValue : "
" + initValue + "
"; + initValue = initValue.startWith("

") ? initValue : "

" + initValue + "

"; this.ne = this.options.ne; this.elm = BI.createWidget({ type: "bi.layout", @@ -281,7 +281,7 @@ keyDown: function (e, t) { if (e.keyCode === 8) { var html = this.elm.element.html().toLowerCase().trim(); - if (html === "

" || html === "
") { + if (html === "


" || html === "

") { e.preventDefault() return; } @@ -315,7 +315,7 @@ var newLine; var html = this.elm.element.html().toLowerCase().trim(); if (!html || html === '
') { - newLine = $("
"); + newLine = $("


"); this.elm.element.html(''); this.elm.element.append(newLine); this.setFocus(newLine[0]); @@ -418,7 +418,7 @@ // 新增一个空行 var html = last.html().toLowerCase(); var nodeName = last.nodeName; - if ((html !== "
" && html !== "") || nodeName !== "DIV") { + if ((html !== "
" && html !== "") || nodeName !== "P") { // 最后一个元素不是空行,添加一个空行,重新设置选区 el.append(newLineHtml); this.initSelection(); @@ -430,7 +430,7 @@ }, _getNewLine: function () { - return "

"; + return "


"; }, _isChildOf: function(child, parent) { From 2ee9764b163846f2dc3520318c00ab2de38a1866 Mon Sep 17 00:00:00 2001 From: fay Date: Tue, 24 Jul 2018 14:51:41 +0800 Subject: [PATCH 2/4] update --- src/case/richeditor/niceditor/niceditor.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/case/richeditor/niceditor/niceditor.js b/src/case/richeditor/niceditor/niceditor.js index 612dc46d0..d92fa3103 100644 --- a/src/case/richeditor/niceditor/niceditor.js +++ b/src/case/richeditor/niceditor/niceditor.js @@ -6,6 +6,12 @@ * @extends BI.Widget */ !(function () { + function isIE11Below () { + if (!BI.isIE()) { + return false; + } + return BI.getIEVersion() < 11; + } BI.NicEditor = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.NicEditor.superclass._defaultConfig.apply(this, arguments), { @@ -85,7 +91,7 @@ }, setValue: function (v) { - v = v || "
"; + v = v || ( isIE11Below() ? "" : "
"); v = v.startWith("

") ? v : "

" + v + "

"; this.instance.setContent(v); }, @@ -315,7 +321,7 @@ var newLine; var html = this.elm.element.html().toLowerCase().trim(); if (!html || html === '
') { - newLine = $("


"); + newLine = $(this._getNewLine()); this.elm.element.html(''); this.elm.element.append(newLine); this.setFocus(newLine[0]); @@ -430,7 +436,7 @@ }, _getNewLine: function () { - return "


"; + return isIE11Below() ? "

" : "


"; }, _isChildOf: function(child, parent) { @@ -447,11 +453,6 @@ return false; }, - _isIE11Below: function() { - if (!BI.isIE()) { - return false; - } - return BI.getIEVersion() < 11; - } + }); }()); From 697e9344ab44dbeeb2dd06874e67ace6542419f4 Mon Sep 17 00:00:00 2001 From: fay Date: Tue, 24 Jul 2018 15:54:37 +0800 Subject: [PATCH 3/4] update --- src/case/richeditor/niceditor/niceditor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/case/richeditor/niceditor/niceditor.js b/src/case/richeditor/niceditor/niceditor.js index d92fa3103..b5829ab50 100644 --- a/src/case/richeditor/niceditor/niceditor.js +++ b/src/case/richeditor/niceditor/niceditor.js @@ -92,7 +92,7 @@ setValue: function (v) { v = v || ( isIE11Below() ? "" : "
"); - v = v.startWith("

") ? v : "

" + v + "

"; + v = ($(v)[0] && $(v)[0].nodeName === "P") ? v : "

" + v + "

"; this.instance.setContent(v); }, From e6b5bfd5d31043fdbd6c2bc43e9fc7e5d688ffc4 Mon Sep 17 00:00:00 2001 From: fay Date: Tue, 24 Jul 2018 19:34:32 +0800 Subject: [PATCH 4/4] update --- src/case/richeditor/niceditor/niceditor.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/case/richeditor/niceditor/niceditor.js b/src/case/richeditor/niceditor/niceditor.js index b5829ab50..3a33a2aa1 100644 --- a/src/case/richeditor/niceditor/niceditor.js +++ b/src/case/richeditor/niceditor/niceditor.js @@ -65,14 +65,19 @@ selectCheck: function (e) { var t = e.target; + var self = this; var found = false; - this.instance.saveRng(); do { if (t.nodeName !== "svg" && t.className && t.className.indexOf(prefix) != -1) { return; // return false; } if (this.instance.checkToolbar(t)) { + this.instance.saveRng(); + // 如果是点击在toolbar内恢复选取(IE中出现的问题) + BI.defer(function () { + self.instance.restoreRng(); + }); return; } } while (t = t.parentNode);