Skip to content

Commit

Permalink
add froala (#945)
Browse files Browse the repository at this point in the history
* update images upload

* modify js res.url

* add froala

* froala-editor.js
  • Loading branch information
3xxx authored Jun 5, 2024
1 parent db620be commit 0ce6c5b
Show file tree
Hide file tree
Showing 6 changed files with 837 additions and 6 deletions.
3 changes: 2 additions & 1 deletion controllers/BookController.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
23 changes: 18 additions & 5 deletions controllers/DocumentController.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand All @@ -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()
Expand Down Expand Up @@ -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()
}

Expand Down
1 change: 1 addition & 0 deletions controllers/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ const (
EditorCherryMarkdown = "cherry_markdown"
EditorHtml = "html"
EditorNewHtml = "new_html"
EditorFroala = "froala"
)
Loading

0 comments on commit 0ce6c5b

Please sign in to comment.