diff --git a/build/MDEditor.min.js b/build/MDEditor.min.js index 8f93e70..859898b 100644 --- a/build/MDEditor.min.js +++ b/build/MDEditor.min.js @@ -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); diff --git a/lib/MDEditor.js b/lib/MDEditor.js index 0df2bc1..a2c1ecd 100644 --- a/lib/MDEditor.js +++ b/lib/MDEditor.js @@ -118,7 +118,7 @@ id:"#mdeditor", minheight:200, maxheight:500, - value:"", + value:"",//markdown themes:"" }; @@ -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) {