mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-09-19 01:58:00 +08:00
markdown编辑器增加cherryMarkdown
* 使用cherryMarkdown替换editorMd * 支持历史&边栏 * 优化代码&支持html格式渲染为预览格式&保存主题配置 * 修复drawio异常 * 优化drawio异常改法 * 自定义提示面板主题颜色 * drawio增加样式,并且更新到最新版本 * 增加代码块复制功能&&修复drawio渲染图片过大&&drawio生成图片背景改为透明 * 恢复原有markdown编辑器,新增cherry markdown编辑器 * 修复复制功能异常 * 修复drawio偶尔无法编辑 --------- Co-authored-by: zhangsheng.93 <zhangsheng.93@bytedance.com>
This commit is contained in:
@@ -188,13 +188,15 @@ func (c *DocumentController) Read() {
|
||||
|
||||
if c.IsAjax() {
|
||||
var data struct {
|
||||
DocId int `json:"doc_id"`
|
||||
DocIdentify string `json:"doc_identify"`
|
||||
DocTitle string `json:"doc_title"`
|
||||
Body string `json:"body"`
|
||||
Title string `json:"title"`
|
||||
Version int64 `json:"version"`
|
||||
ViewCount int `json:"view_count"`
|
||||
DocId int `json:"doc_id"`
|
||||
DocIdentify string `json:"doc_identify"`
|
||||
DocTitle string `json:"doc_title"`
|
||||
Body string `json:"body"`
|
||||
Title string `json:"title"`
|
||||
Version int64 `json:"version"`
|
||||
ViewCount int `json:"view_count"`
|
||||
MarkdownTheme string `json:"markdown_theme"`
|
||||
IsMarkdown bool `json:"is_markdown"`
|
||||
}
|
||||
data.DocId = doc.DocumentId
|
||||
data.DocIdentify = doc.Identify
|
||||
@@ -203,7 +205,10 @@ func (c *DocumentController) Read() {
|
||||
data.Title = doc.DocumentName + " - Powered by MinDoc"
|
||||
data.Version = doc.Version
|
||||
data.ViewCount = doc.ViewCount
|
||||
|
||||
data.MarkdownTheme = doc.MarkdownTheme
|
||||
if bookResult.Editor == EditorCherryMarkdown {
|
||||
data.IsMarkdown = true
|
||||
}
|
||||
c.JsonResult(0, "ok", data)
|
||||
} else {
|
||||
c.Data["DocumentId"] = doc.DocumentId
|
||||
@@ -232,6 +237,9 @@ func (c *DocumentController) Read() {
|
||||
c.Data["Content"] = template.HTML(doc.Release)
|
||||
c.Data["ViewCount"] = doc.ViewCount
|
||||
c.Data["FoldSetting"] = "closed"
|
||||
if bookResult.Editor == EditorCherryMarkdown {
|
||||
c.Data["MarkdownTheme"] = doc.MarkdownTheme
|
||||
}
|
||||
if doc.IsOpen == 1 {
|
||||
c.Data["FoldSetting"] = "open"
|
||||
} else if doc.IsOpen == 2 {
|
||||
@@ -276,16 +284,7 @@ func (c *DocumentController) Edit() {
|
||||
}
|
||||
}
|
||||
|
||||
// 根据不同编辑器类型加载编辑器
|
||||
if bookResult.Editor == "markdown" {
|
||||
c.TplName = "document/markdown_edit_template.tpl"
|
||||
} else if bookResult.Editor == "html" {
|
||||
c.TplName = "document/html_edit_template.tpl"
|
||||
} else if bookResult.Editor == "new_html" {
|
||||
c.TplName = "document/new_html_edit_template.tpl"
|
||||
} else {
|
||||
c.TplName = "document/" + bookResult.Editor + "_edit_template.tpl"
|
||||
}
|
||||
c.TplName = fmt.Sprintf("document/%s_edit_template.tpl", bookResult.Editor)
|
||||
|
||||
c.Data["Model"] = bookResult
|
||||
|
||||
@@ -774,6 +773,7 @@ func (c *DocumentController) Content() {
|
||||
if c.Ctx.Input.IsPost() {
|
||||
markdown := strings.TrimSpace(c.GetString("markdown", ""))
|
||||
content := c.GetString("html")
|
||||
markdownTheme := c.GetString("markdown_theme", "theme__light")
|
||||
version, _ := c.GetInt64("version", 0)
|
||||
isCover := c.GetString("cover")
|
||||
|
||||
@@ -808,6 +808,7 @@ func (c *DocumentController) Content() {
|
||||
doc.Markdown = content
|
||||
} else {
|
||||
doc.Markdown = markdown
|
||||
doc.MarkdownTheme = markdownTheme
|
||||
}
|
||||
|
||||
doc.Version = time.Now().Unix()
|
||||
@@ -902,8 +903,8 @@ func (c *DocumentController) Export() {
|
||||
bookResult.Cover = conf.URLForWithCdnImage(bookResult.Cover)
|
||||
}
|
||||
|
||||
if output == "markdown" {
|
||||
if bookResult.Editor != "markdown" {
|
||||
if output == Markdown {
|
||||
if bookResult.Editor != EditorMarkdown && bookResult.Editor != EditorCherryMarkdown {
|
||||
c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.cur_project_not_support_md"))
|
||||
}
|
||||
p, err := bookResult.ExportMarkdown(c.CruSession.SessionID(context.TODO()))
|
||||
@@ -1222,7 +1223,7 @@ func (c *DocumentController) Compare() {
|
||||
identify := c.Ctx.Input.Param(":key")
|
||||
|
||||
bookId := 0
|
||||
editor := "markdown"
|
||||
editor := EditorMarkdown
|
||||
|
||||
// 如果是超级管理员则忽略权限判断
|
||||
if c.Member.IsAdministrator() {
|
||||
@@ -1268,7 +1269,7 @@ func (c *DocumentController) Compare() {
|
||||
c.Data["HistoryId"] = historyId
|
||||
c.Data["DocumentId"] = doc.DocumentId
|
||||
|
||||
if editor == "markdown" {
|
||||
if editor == EditorMarkdown || editor == EditorCherryMarkdown {
|
||||
c.Data["HistoryContent"] = history.Markdown
|
||||
c.Data["Content"] = doc.Markdown
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user