🎨 当自定义排序时支持在文档上/下新建同级文档 https://github.com/siyuan-note/siyuan/issues/5098

This commit is contained in:
Liang Ding 2022-07-01 22:41:28 +08:00
parent d4602433c5
commit b40b460f0c
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 16 additions and 3 deletions

View file

@ -342,8 +342,15 @@ func createDoc(c *gin.Context) {
p := arg["path"].(string)
title := arg["title"].(string)
md := arg["md"].(string)
sortsArg := arg["sorts"]
var sorts []string
if nil != sortsArg {
for _, sort := range sortsArg.([]interface{}) {
sorts = append(sorts, sort.(string))
}
}
err := model.CreateDocByMd(notebook, p, title, md)
err := model.CreateDocByMd(notebook, p, title, md, sorts)
if nil != err {
ret.Code = -1
ret.Msg = err.Error()

View file

@ -920,7 +920,7 @@ func DuplicateDoc(rootID string) (err error) {
return
}
func CreateDocByMd(boxID, p, title, md string) (err error) {
func CreateDocByMd(boxID, p, title, md string, sorts []string) (err error) {
WaitForWritingFiles()
box := Conf.Box(boxID)
@ -930,7 +930,13 @@ func CreateDocByMd(boxID, p, title, md string) (err error) {
luteEngine := NewLute()
dom := luteEngine.Md2BlockDOM(md)
return createDoc(box.ID, p, title, dom)
err = createDoc(box.ID, p, title, dom)
if nil != err {
return
}
ChangeFileTreeSort(box.ID, sorts)
return
}
func CreateWithMarkdown(boxID, hPath, md string) (id string, err error) {