From 285b0d373cee9c24c84b56f91ddc279bb1069163 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Sat, 4 Jul 2015 22:20:47 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=8F=92=E5=85=A5=E5=86=85?= =?UTF-8?q?=E5=AE=B9=EF=BC=8C=E5=9C=A8=E6=9C=89=E6=BB=9A=E5=8A=A8=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5=E7=BC=96=E8=BE=91=E5=99=A8=E9=AB=98=E5=BA=A6?= =?UTF-8?q?=E4=B8=BA=E8=AE=BE=E7=BD=AE=E4=B8=AD=E7=9A=84=E6=9C=80=E5=A4=A7?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/MDEditor.min.js | 1 + lib/MDEditor.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/build/MDEditor.min.js b/build/MDEditor.min.js index ace96c6..af12062 100644 --- a/build/MDEditor.min.js +++ b/build/MDEditor.min.js @@ -937,6 +937,7 @@ }; MDEditor.prototype.setMD = function(val) { if (marked) this.textarea.value = val ? val : this.opts.value; + if (this.textarea.scrollHeight > this.opts.maxheight) this.textarea.style.height = this.opts.maxheight + "px"; return this; }; MDEditor.prototype.getHTML = function() { diff --git a/lib/MDEditor.js b/lib/MDEditor.js index a7233f1..8d41049 100644 --- a/lib/MDEditor.js +++ b/lib/MDEditor.js @@ -166,6 +166,8 @@ }); css(self.preview,{'height':self.textarea.offsetHeight + "px"}); + + //实时监听输入框值变化 HTML5事件 addEvent(self.textarea,'input', function(event) { if(this.scrollHeightthis.opts.maxheight) + this.textarea.style.height = this.opts.maxheight + 'px'; return this; }