diff --git a/controllers/BookController.go b/controllers/BookController.go index 56a234c7..10ee03b1 100644 --- a/controllers/BookController.go +++ b/controllers/BookController.go @@ -164,7 +164,8 @@ func (c *BookController) SaveBook() { if !models.NewItemsets().Exist(itemId) { c.JsonResult(6006, i18n.Tr(c.Lang, "message.project_space_not_exist")) } - if editor != EditorMarkdown && editor != EditorCherryMarkdown && editor != EditorHtml && editor != EditorNewHtml { + // if editor != EditorMarkdown && editor != EditorCherryMarkdown && editor != EditorHtml && editor != EditorNewHtml { + if editor != EditorMarkdown && editor != EditorCherryMarkdown && editor != EditorHtml && editor != EditorNewHtml && editor != EditorFroala { editor = EditorMarkdown } diff --git a/controllers/DocumentController.go b/controllers/DocumentController.go index bdfcd1ee..087c5751 100644 --- a/controllers/DocumentController.go +++ b/controllers/DocumentController.go @@ -503,8 +503,15 @@ func (c *DocumentController) Upload() { name = "editormd-image-file" files, err = c.GetFiles(name) if err == http.ErrMissingFile { - c.JsonResult(6003, i18n.Tr(c.Lang, "message.upload_file_empty")) - return + // c.JsonResult(6003, i18n.Tr(c.Lang, "message.upload_file_empty")) + // return + name = "file" + files, err = c.GetFiles(name) + // logs.Info(files) + if err == http.ErrMissingFile { + c.JsonResult(6003, i18n.Tr(c.Lang, "message.upload_file_empty")) + return + } } } @@ -515,6 +522,7 @@ func (c *DocumentController) Upload() { // jMap := make(map[string]interface{}) // s := []map[int]interface{}{} result2 := []map[string]interface{}{} + var result map[string]interface{} for i, _ := range files { //for each fileheader, get a handle to the actual file file, err := files[i].Open() @@ -680,19 +688,24 @@ func (c *DocumentController) Upload() { c.JsonResult(6005, i18n.Tr(c.Lang, "message.failed")) } } - result := map[string]interface{}{ + result = map[string]interface{}{ "errcode": 0, "success": 1, "message": "ok", "url": attachment.HttpPath, + "link": attachment.HttpPath, "alt": attachment.FileName, "is_attach": isAttach, "attach": attachment, } result2 = append(result2, result) } - - c.Ctx.Output.JSON(result2, true, false) + if name == "file" { + // froala单图片上传 + c.Ctx.Output.JSON(result, true, false) + } else { + c.Ctx.Output.JSON(result2, true, false) + } c.StopRun() } diff --git a/controllers/const.go b/controllers/const.go index 83b664e3..95e9322b 100644 --- a/controllers/const.go +++ b/controllers/const.go @@ -6,4 +6,5 @@ const ( EditorCherryMarkdown = "cherry_markdown" EditorHtml = "html" EditorNewHtml = "new_html" + EditorFroala = "froala" ) diff --git a/views/book/setting.tpl b/views/book/setting.tpl index 8f926074..5d8e6113 100644 --- a/views/book/setting.tpl +++ b/views/book/setting.tpl @@ -97,6 +97,10 @@ + +
diff --git a/views/document/froala_edit_template.tpl b/views/document/froala_edit_template.tpl new file mode 100644 index 00000000..8b2068be --- /dev/null +++ b/views/document/froala_edit_template.tpl @@ -0,0 +1,316 @@ + + + + + + + + {{i18n .Lang "doc.edit_doc"}} - Powered by MinDoc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+ + + +
+
+ +
+
+
+
+
+
+
0 {{i18n .Lang "doc.attachments"}}
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file