From 8ef7fbb95c3f42e7f48a0a99e6b24b25c3c58bf6 Mon Sep 17 00:00:00 2001 From: yangrunkang Date: Wed, 22 Jun 2022 08:37:01 +0800 Subject: [PATCH] =?UTF-8?q?Feature:=20=E7=BC=96=E8=BE=91=E5=99=A8=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E5=A4=B1=E8=B4=A5=E5=8F=AF=E4=BB=A5=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E9=87=8D=E6=96=B0=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- upupor-web/src/main/resources/static/js/cv.js | 41 ++++++++++++------- .../resources/templates/editor/editor.html | 2 +- .../templates/fragments/comment.html | 15 ++++--- 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/upupor-web/src/main/resources/static/js/cv.js b/upupor-web/src/main/resources/static/js/cv.js index 91367ad5..54c34554 100644 --- a/upupor-web/src/main/resources/static/js/cv.js +++ b/upupor-web/src/main/resources/static/js/cv.js @@ -380,25 +380,38 @@ let cherryConfig = { * 加载不同的编辑器js,初始化是同一个 */ function initEditor(isComment){ - if(isComment){ - _height = '400px'; - _defaultModel = 'editOnly'; - } + try{ + $("#editor_load_failure").hide(); + $("#editor_loading").show(); - let config = Object.assign({}, cherryConfig); - window.editor = new Cherry(config); + if(isComment){ + _height = '400px'; + _defaultModel = 'editOnly'; + } - let mdValue = getElementValue("md_value"); - let htmlValue = getElementValue("html_value"); + let config = Object.assign({}, cherryConfig); + window.editor = new Cherry(config); - if(cvIsNull(mdValue) && !cvIsNull(htmlValue)){ - // 将html转为markdown - mdValue = window.editor.engine.makeMarkdown(htmlValue); - } + let mdValue = getElementValue("md_value"); + let htmlValue = getElementValue("html_value"); + + if(cvIsNull(mdValue) && !cvIsNull(htmlValue)){ + // 将html转为markdown + mdValue = window.editor.engine.makeMarkdown(htmlValue); + } - if(!cvIsNull(mdValue)){ - window.editor.setMarkdown(mdValue); + if(!cvIsNull(mdValue)){ + window.editor.setMarkdown(mdValue); + } + }catch (e) { + $("#editor_load_failure").show(); + $("#editor_loading").hide(); } + +} + +function reloadEditor(isComment) { + $.cvLoadBootstrapRichText(isComment) } diff --git a/upupor-web/src/main/resources/templates/editor/editor.html b/upupor-web/src/main/resources/templates/editor/editor.html index e367964e..09d5954c 100644 --- a/upupor-web/src/main/resources/templates/editor/editor.html +++ b/upupor-web/src/main/resources/templates/editor/editor.html @@ -70,7 +70,7 @@
-
+
diff --git a/upupor-web/src/main/resources/templates/fragments/comment.html b/upupor-web/src/main/resources/templates/fragments/comment.html index 4ebc929f..6b1afc86 100644 --- a/upupor-web/src/main/resources/templates/fragments/comment.html +++ b/upupor-web/src/main/resources/templates/fragments/comment.html @@ -30,17 +30,22 @@ xmlns:th="http://www.thymeleaf.org"> -
+
-
-

编辑器加载中...

-

注: 因最小维护成本需要(eg.最低带宽,无CDN等),编辑器加载可能需要15秒左右,请耐心等待

+
+
+

编辑器加载中...

+

注: 因最小维护成本需要(eg.最低带宽,无CDN等),编辑器加载可能需要15秒左右,请耐心等待

+
+
-
+