|
|
|
@ -83377,6 +83377,8 @@ BI.shortcut("bi.rich_editor_text_toolbar", BI.RichEditorTextToolbar);/**
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
setValue: function (v) { |
|
|
|
|
v = v || ""; |
|
|
|
|
v = v.startWith("<div>") ? v : "<div>" + v + "</div>"; |
|
|
|
|
this.instance.setContent(v); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -83400,6 +83402,7 @@ BI.shortcut("bi.rich_editor_text_toolbar", BI.RichEditorTextToolbar);/**
|
|
|
|
|
BI.NicEditor.EVENT_BLUR = "blur"; |
|
|
|
|
BI.NicEditor.EVENT_FOCUS = "focus"; |
|
|
|
|
BI.NicEditor.EVENT_KEYDOWN = "keydown"; |
|
|
|
|
BI.NicEditor.EVENT_KEYUP = "keyup"; |
|
|
|
|
BI.shortcut("bi.nic_editor", BI.NicEditor); |
|
|
|
|
|
|
|
|
|
var prefix = "niceditor-"; |
|
|
|
@ -83409,6 +83412,8 @@ BI.shortcut("bi.rich_editor_text_toolbar", BI.RichEditorTextToolbar);/**
|
|
|
|
|
_init: function () { |
|
|
|
|
nicEditorInstance.superclass._init.apply(this, arguments); |
|
|
|
|
var o = this.options; |
|
|
|
|
var initValue = o.value || "<br>"; |
|
|
|
|
initValue = initValue.startWith("<div>") ? initValue : "<div>" + initValue + "</div>"; |
|
|
|
|
this.ne = this.options.ne; |
|
|
|
|
this.elm = BI.createWidget({ |
|
|
|
|
type: "bi.layout", |
|
|
|
@ -83418,8 +83423,9 @@ BI.shortcut("bi.rich_editor_text_toolbar", BI.RichEditorTextToolbar);/**
|
|
|
|
|
this.elm.element.css({ |
|
|
|
|
minHeight: BI.isNumber(o.height) ? (o.height - 8) + "px" : o.height, |
|
|
|
|
outline: "none", |
|
|
|
|
padding: "0 10px" |
|
|
|
|
}).html(o.value); |
|
|
|
|
padding: "0 10px", |
|
|
|
|
wordWrap: "break-word" |
|
|
|
|
}).html(initValue); |
|
|
|
|
|
|
|
|
|
if(o.readOnly) { |
|
|
|
|
this.elm.element.attr("contentEditable", false); |
|
|
|
@ -83453,8 +83459,7 @@ BI.shortcut("bi.rich_editor_text_toolbar", BI.RichEditorTextToolbar);/**
|
|
|
|
|
} |
|
|
|
|
this.instanceDoc = document.defaultView; |
|
|
|
|
this.elm.element.on("mousedown", BI.bind(this.selected, this)); |
|
|
|
|
this.elm.element.on("keyup", BI.bind(this.keyDown, this)); |
|
|
|
|
// this.elm.element.on("keydown", BI.bind(this.keyDown, this));
|
|
|
|
|
this.elm.element.on("keydown", BI.bind(this.keyDown, this)); |
|
|
|
|
this.elm.element.on("focus", BI.bind(this.selected, this)); |
|
|
|
|
this.elm.element.on("blur", BI.bind(this.blur, this)); |
|
|
|
|
this.elm.element.on("keyup", BI.bind(this.selected, this)); |
|
|
|
@ -83566,6 +83571,13 @@ BI.shortcut("bi.rich_editor_text_toolbar", BI.RichEditorTextToolbar);/**
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
keyDown: function (e, t) { |
|
|
|
|
if (e.keyCode === 8) { |
|
|
|
|
var html = this.elm.element.html().toLowerCase().trim(); |
|
|
|
|
if (html === "<div><br></div>" || html === "<div></div>") { |
|
|
|
|
e.preventDefault() |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.ne.fireEvent("keydown", e); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -83587,6 +83599,19 @@ BI.shortcut("bi.rich_editor_text_toolbar", BI.RichEditorTextToolbar);/**
|
|
|
|
|
this.isFocused = true; |
|
|
|
|
this.elm.element.addClass(prefix + "selected"); |
|
|
|
|
} |
|
|
|
|
this.ne.fireEvent("keyup", e); |
|
|
|
|
|
|
|
|
|
if (e.keyCode !== 8) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
var newLine; |
|
|
|
|
var html = this.elm.element.html().toLowerCase().trim(); |
|
|
|
|
if (!html || html === '<br>') { |
|
|
|
|
newLine = $("<div></div>"); |
|
|
|
|
this.elm.element.html(''); |
|
|
|
|
this.elm.element.append(newLine); |
|
|
|
|
this.setFocus(newLine[0]); |
|
|
|
|
} |
|
|
|
|
// return false;
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -83668,6 +83693,38 @@ BI.shortcut("bi.rich_editor_text_toolbar", BI.RichEditorTextToolbar);/**
|
|
|
|
|
document.execCommand(cmd, false, args); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
initSelection: function (newLine) { |
|
|
|
|
var newLineHtml = this._getNewLine(); |
|
|
|
|
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 !== "DIV") { |
|
|
|
|
// 最后一个元素不是空行,添加一个空行,重新设置选区
|
|
|
|
|
el.append(newLineHtml); |
|
|
|
|
this.initSelection(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.setFocus(last[0]); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
_getNewLine: function () { |
|
|
|
|
return "<div><br></div>"; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
_isChildOf: function(child, parent) { |
|
|
|
|
var parentNode; |
|
|
|
|
if(child && parent) { |
|
|
|
@ -83680,6 +83737,13 @@ BI.shortcut("bi.rich_editor_text_toolbar", BI.RichEditorTextToolbar);/**
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
_isIE11Below: function() { |
|
|
|
|
if (!BI.isIE()) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return BI.getIEVersion() < 11; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}()); |
|
|
|
|