diff --git a/build/MDEditor.min.js b/build/MDEditor.min.js index 95d4a3e..5ade662 100644 --- a/build/MDEditor.min.js +++ b/build/MDEditor.min.js @@ -913,10 +913,10 @@ css(self.preview, { height: self.textarea.offsetHeight + "px" }); - addEvent(self.textarea, "input", function(event) { - if (this.scrollHeight < self.opts.maxheight) { + valueChange = function(obj, event) { + if (obj.scrollHeight < self.opts.maxheight) { css(self.textarea, { - height: this.scrollHeight + "px", + height: obj.scrollHeight + "px", overflow: "hidden" }); } else { @@ -928,8 +928,14 @@ css(self.preview, { height: self.textarea.offsetHeight + "px" }); - self.opts.value = this.value; + self.opts.value = obj.value; self.callback(event, self.opts); + }; + addEvent(self.textarea, "input", function(event) { + valueChange(this, event); + }); + addEvent(self.textarea, "propertychange", function(event) { + valueChange(this, event); }); return this; }; diff --git a/lib/MDEditor.js b/lib/MDEditor.js index 886690c..9b05468 100644 --- a/lib/MDEditor.js +++ b/lib/MDEditor.js @@ -170,11 +170,10 @@ css(self.preview,{'height':self.textarea.offsetHeight + "px"}); - //实时监听输入框值变化 HTML5事件 - addEvent(self.textarea,'input', function(event) { - if(this.scrollHeight