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 fa651ff commit f8c298c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions build/MDEditor.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -890,8 +890,10 @@
}
MDEditor.prototype.load = function() {
var self = this, box = self.obj[0], index = 0;
if (self.obj.length > 0) box.appendChild(self.preview), box.appendChild(self.tools),
box.appendChild(self.textarea);
if (box) {
if (box.innerHTML !== "") self.opts.value = box.innerHTML, box.innerHTML = "";
box.appendChild(self.preview), box.appendChild(self.tools), box.appendChild(self.textarea);
}
self.setMD();
addEvent(self.btn_preview, "click", function(event) {
index = parseInt(self.preview.style.zIndex);
Expand Down
9 changes: 6 additions & 3 deletions lib/MDEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
id:"#mdeditor",
minheight:200,
maxheight:500,
value:"",
value:"",//markdown
themes:""
};

Expand All @@ -143,10 +143,13 @@
MDEditor.prototype.load = function(){
var self = this,box = self.obj[0],index=0;

if(self.obj.length>0) box.appendChild(self.preview),
if(box) {
if(box.innerHTML!=="") self.opts.value = box.innerHTML,
box.innerHTML='';
box.appendChild(self.preview),
box.appendChild(self.tools),
box.appendChild(self.textarea);

}
self.setMD();

addEvent(self.btn_preview,'click', function(event) {
Expand Down

0 comments on commit f8c298c

Please sign in to comment.