Browse Source

fix: cherry_markdown error (#908)

* fix: first open document, cherryMarkdown not have theme

* fix: modify prismjs style and improve image clarity

* update cherry-markdown

* optimiztion: cherry-markdown

* feat: cherry-markdown add auto-save and update icon

* fix: the mobile phone displays abnormally and Markdown does not allow conversion

---------

Co-authored-by: zhangsheng.93 <[email protected]>
张胜 1 year ago
parent
commit
77fccc637a

+ 1 - 1
.github/workflows/build.yml

@@ -32,7 +32,7 @@ jobs:
       - name: Set up Go
       - name: Set up Go
         uses: actions/setup-go@v3
         uses: actions/setup-go@v3
         with:
         with:
-          go-version: 1.18
+          go-version: 1.20.0
 
 
       - name: Build
       - name: Build
         run: |
         run: |

+ 2 - 1
conf/lang/en-us.ini

@@ -224,6 +224,7 @@ project_label_desc = Allows up to 10 labels, use ";" to separate multiple tags
 cannot_change_own_status = Cannot change own status
 cannot_change_own_status = Cannot change own status
 cannot_change_super_status = Cannot change super administrator status
 cannot_change_super_status = Cannot change super administrator status
 cannot_change_super_priv = Cannot change super administrator permissions
 cannot_change_super_priv = Cannot change super administrator permissions
+editors_not_compatible = two editors are not compatible
 
 
 [blog]
 [blog]
 author = Author
 author = Author
@@ -571,4 +572,4 @@ create_time = Create Time
 creator = Creator
 creator = Creator
 doc_amount = Number of Document
 doc_amount = Number of Document
 last_edit = Last Edit
 last_edit = Last Edit
-delete_project = Delete Project
+delete_project = Delete Project

+ 1 - 0
conf/lang/zh-cn.ini

@@ -224,6 +224,7 @@ project_label_desc = 最多允许添加10个标签,多个标签请用“;”
 cannot_change_own_status = 不能变更自己的状态
 cannot_change_own_status = 不能变更自己的状态
 cannot_change_super_status = 不能变更超级管理员的状态
 cannot_change_super_status = 不能变更超级管理员的状态
 cannot_change_super_priv = 不能变更超级管理员的权限
 cannot_change_super_priv = 不能变更超级管理员的权限
+editors_not_compatible = 两种编辑器不兼容
 
 
 [blog]
 [blog]
 author = 作者
 author = 作者

+ 3 - 0
controllers/BookController.go

@@ -173,6 +173,9 @@ func (c *BookController) SaveBook() {
 	book.CommentStatus = commentStatus
 	book.CommentStatus = commentStatus
 	book.Publisher = publisher
 	book.Publisher = publisher
 	//book.Label = tag
 	//book.Label = tag
+	if book.Editor == EditorMarkdown && editor == EditorCherryMarkdown || book.Editor == EditorCherryMarkdown && editor == EditorMarkdown {
+		c.JsonResult(6006, i18n.Tr(c.Lang, "message.editors_not_compatible"))
+	}
 	book.Editor = editor
 	book.Editor = editor
 	if editor == EditorCherryMarkdown {
 	if editor == EditorCherryMarkdown {
 		book.Theme = "cherry"
 		book.Theme = "cherry"

+ 11 - 4
static/css/markdown.css

@@ -548,12 +548,13 @@ iframe.cherry-dialog-iframe {
     margin-right: 50px;
     margin-right: 50px;
 }
 }
 
 
-.markdown-article-body {
-    margin-right: 200px !important;
+@media screen and (min-width: 840px) {
+    .markdown-article {
+        margin-right: 200px !important;
+    }
 }
 }
 
 
 .markdown-article-head {
 .markdown-article-head {
-    margin-right: 200px !important;
     width: unset !important;
     width: unset !important;
     padding: unset !important;
     padding: unset !important;
     padding-top: 10px !important;
     padding-top: 10px !important;
@@ -562,4 +563,10 @@ iframe.cherry-dialog-iframe {
 .markdown-title {
 .markdown-title {
     padding: unset !important;
     padding: unset !important;
     width: 100% !important;
     width: 100% !important;
-}
+}
+
+@media screen and (max-width: 839px) {
+  .toc {
+    display: none !important;
+  }
+}

+ 4 - 2
utils/html.go

@@ -34,7 +34,7 @@ func StripTags(s string) string {
 	return src
 	return src
 }
 }
 
 
-//自动提取文章摘要
+// 自动提取文章摘要
 func AutoSummary(body string, l int) string {
 func AutoSummary(body string, l int) string {
 
 
 	//匹配图片,如果图片语法是在代码块中,这里同样会处理
 	//匹配图片,如果图片语法是在代码块中,这里同样会处理
@@ -60,7 +60,7 @@ func AutoSummary(body string, l int) string {
 	return content
 	return content
 }
 }
 
 
-//安全处理HTML文档,过滤危险标签和属性.
+// 安全处理HTML文档,过滤危险标签和属性.
 func SafetyProcessor(html string) string {
 func SafetyProcessor(html string) string {
 
 
 	//安全过滤,移除危险标签和属性
 	//安全过滤,移除危险标签和属性
@@ -117,6 +117,8 @@ func SafetyProcessor(html string) string {
 		if selector := docQuery.Find("div.markdown-article").First(); selector.Size() <= 0 {
 		if selector := docQuery.Find("div.markdown-article").First(); selector.Size() <= 0 {
 			if selector := docQuery.Find("div.markdown-toc").First(); selector.Size() > 0 {
 			if selector := docQuery.Find("div.markdown-toc").First(); selector.Size() > 0 {
 				docQuery.Find("div.markdown-toc").NextAll().WrapAllHtml("<div class=\"markdown-article\"></div>")
 				docQuery.Find("div.markdown-toc").NextAll().WrapAllHtml("<div class=\"markdown-article\"></div>")
+			} else if selector := docQuery.Find("dir.toc").First(); selector.Size() > 0 {
+				docQuery.Find("dir.toc").NextAll().WrapAllHtml("<div class=\"markdown-article\"></div>")
 			}
 			}
 		}
 		}