Skip to content

Commit

Permalink
默认插入内容,在有滚动的情况编辑器高度为设置中的最大值
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jul 4, 2015
1 parent f62ab3e commit 285b0d3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions build/MDEditor.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 4 additions & 0 deletions lib/MDEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@
});

css(self.preview,{'height':self.textarea.offsetHeight + "px"});

//实时监听输入框值变化 HTML5事件
addEvent(self.textarea,'input', function(event) {
if(this.scrollHeight<self.opts.maxheight){
css(self.textarea,{
Expand Down Expand Up @@ -197,6 +199,8 @@
*/
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;
}

Expand Down

0 comments on commit 285b0d3

Please sign in to comment.