From f8c298cc5b835418af50300a8779067e88f2ac3a Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Sat, 4 Jul 2015 14:38:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BC=96=E8=BE=91=E5=99=A8?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=98=BE=E7=A4=BA=E5=86=85=E5=AE=B9=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/MDEditor.min.js | 6 ++++-- lib/MDEditor.js | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) 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) {