From 60e3b9446adb48f8c9ca7464d5202f18d98a4fd8 Mon Sep 17 00:00:00 2001 From: lealife Date: Sat, 17 Oct 2015 15:51:21 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A9=BA=E7=99=BD=E7=AC=94=E8=AE=B0=E5=89=8D?= =?UTF-8?q?=E6=9C=89=E4=B8=80=E4=B8=AA=E7=A9=BA=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/common.js | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/public/js/common.js b/public/js/common.js index be30ac1..394cd2a 100644 --- a/public/js/common.js +++ b/public/js/common.js @@ -388,7 +388,6 @@ function switchEditor(isMarkdown) { } - // editor 设置内容 // 可能是tinymce还没有渲染成功 var previewToken = "
FORTOKEN
" @@ -411,27 +410,12 @@ function setEditorContent(content, isMarkdown, preview, callback) { } } */ - - $("#editorContent").html(content); + // $("#editorContent").html(content); + // 不能先setHtml, 因为在tinymce的setContent前要获取之前的content, destory ACE if(typeof tinymce != "undefined" && tinymce.activeEditor) { var editor = tinymce.activeEditor; - // console.log('set content'); - LEA.s4 = new Date(); - LEA.s4_1 = LEA.s4.getTime()-LEA.s1.getTime(); editor.setContent(content); callback && callback(); - /* - if(LeaAce.canAce() && LeaAce.isAce) { - try { - LeaAce.initAceFromContent(editor); - } catch(e) { - log(e); - } - } else { - // 为了在firefox下有正常的显示 - $("#editorContent pre").removeClass("ace-tomorrow ace_editor"); - } - */ editor.undoManager.clear(); // 4-7修复BUG } else { // 等下再设置 @@ -464,8 +448,6 @@ function setEditorContent(content, isMarkdown, preview, callback) { if(MD) { MD.setContent(content); callback && callback(); - LEA.s4 = new Date(); - LEA.s4_1 = LEA.s4.getTime()-LEA.s1.getTime() } else { clearIntervalForSetContent = setTimeout(function() { setEditorContent(content, true, false, callback); @@ -491,7 +473,16 @@ function isAceError(val) { } // 有tinymce得到的content有包围 +// 总会出现

 

, 原因, setContent('


') 会设置成


+// 所以, 要在getContent时, 当是


, 返回


function getEditorContent(isMarkdown) { + var content = _getEditorContent(isMarkdown); + if (content === '


') { + return '


'; + } + return content; +} +function _getEditorContent(isMarkdown) { if(!isMarkdown) { var editor = tinymce.activeEditor; if(editor) { @@ -1359,4 +1350,4 @@ var trimTitle = function(title) { } return title.replace(//g, ">"); // return title.replace(/<.*?script.*?>/g, ''); -}; \ No newline at end of file +};