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 <zhangsheng.93@bytedance.com>
pull/914/head
张胜 2023-11-20 17:31:45 +08:00 committed by GitHub
parent 18b6ead94d
commit 77fccc637a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 8 deletions

View File

@ -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: |

View File

@ -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

View File

@ -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 = 作者

View File

@ -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"

View File

@ -548,12 +548,13 @@ iframe.cherry-dialog-iframe {
margin-right: 50px; margin-right: 50px;
} }
.markdown-article-body { @media screen and (min-width: 840px) {
margin-right: 200px !important; .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;
}
}

View File

@ -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>")
} }
} }