mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-29 11:46:09 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
8dc6420bee
3 changed files with 50 additions and 33 deletions
|
|
@ -410,7 +410,22 @@ func exportMdContent(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
hPath, content := model.ExportMarkdownContent(id)
|
||||
refMode := model.Conf.Export.BlockRefMode
|
||||
if nil != arg["refMode"] {
|
||||
refMode = arg["refMode"].(int)
|
||||
}
|
||||
|
||||
embedMode := model.Conf.Export.BlockEmbedMode
|
||||
if nil != arg["embedMode"] {
|
||||
embedMode = arg["embedMode"].(int)
|
||||
}
|
||||
|
||||
yfm := true
|
||||
if nil != arg["yfm"] {
|
||||
yfm = arg["yfm"].(bool)
|
||||
}
|
||||
|
||||
hPath, content := model.ExportMarkdownContent(id, refMode, embedMode, yfm)
|
||||
ret.Data = map[string]interface{}{
|
||||
"hPath": hPath,
|
||||
"content": content,
|
||||
|
|
|
|||
|
|
@ -695,16 +695,8 @@ func createDoc(c *gin.Context) {
|
|||
}
|
||||
|
||||
model.FlushTxQueue()
|
||||
|
||||
pushCreateEvt := false
|
||||
pushCreateEvtArg := arg["pushCreateEvt"]
|
||||
if nil != pushCreateEvtArg {
|
||||
pushCreateEvt = pushCreateEvtArg.(bool)
|
||||
}
|
||||
if pushCreateEvt {
|
||||
box := model.Conf.Box(notebook)
|
||||
pushCreate(box, p, arg)
|
||||
}
|
||||
box := model.Conf.Box(notebook)
|
||||
pushCreate(box, p, arg)
|
||||
|
||||
ret.Data = map[string]interface{}{
|
||||
"id": tree.Root.ID,
|
||||
|
|
@ -752,14 +744,9 @@ func createDailyNote(c *gin.Context) {
|
|||
}
|
||||
evt := util.NewCmdResult("createdailynote", 0, util.PushModeBroadcast)
|
||||
evt.AppId = app
|
||||
name := path.Base(p)
|
||||
files, _, _ := model.ListDocTree(box.ID, path.Dir(p), util.SortModeUnassigned, false, false, model.Conf.FileTree.MaxListCount)
|
||||
evt.Data = map[string]interface{}{
|
||||
"box": box,
|
||||
"path": p,
|
||||
"files": files,
|
||||
"name": name,
|
||||
"id": tree.Root.ID,
|
||||
"box": box,
|
||||
"path": p,
|
||||
}
|
||||
evt.Callback = arg["callback"]
|
||||
util.PushEvent(evt)
|
||||
|
|
@ -837,17 +824,9 @@ func createDocWithMd(c *gin.Context) {
|
|||
ret.Data = id
|
||||
|
||||
model.FlushTxQueue()
|
||||
|
||||
pushCreateEvt := false
|
||||
pushCreateEvtArg := arg["pushCreateEvt"]
|
||||
if nil != pushCreateEvtArg {
|
||||
pushCreateEvt = pushCreateEvtArg.(bool)
|
||||
}
|
||||
if pushCreateEvt {
|
||||
box := model.Conf.Box(notebook)
|
||||
b, _ := model.GetBlock(id, nil)
|
||||
pushCreate(box, b.Path, arg)
|
||||
}
|
||||
box := model.Conf.Box(notebook)
|
||||
b, _ := model.GetBlock(id, nil)
|
||||
pushCreate(box, b.Path, arg)
|
||||
}
|
||||
|
||||
func getDocCreateSavePath(c *gin.Context) {
|
||||
|
|
@ -1157,9 +1136,16 @@ func getDoc(c *gin.Context) {
|
|||
|
||||
func pushCreate(box *model.Box, p string, arg map[string]interface{}) {
|
||||
evt := util.NewCmdResult("create", 0, util.PushModeBroadcast)
|
||||
listDocTree := false
|
||||
listDocTreeArg := arg["listDocTree"]
|
||||
if nil != listDocTreeArg {
|
||||
listDocTree = listDocTreeArg.(bool)
|
||||
}
|
||||
|
||||
evt.Data = map[string]interface{}{
|
||||
"box": box,
|
||||
"path": p,
|
||||
"box": box,
|
||||
"path": p,
|
||||
"listDocTree": listDocTree,
|
||||
}
|
||||
evt.Callback = arg["callback"]
|
||||
util.PushEvent(evt)
|
||||
|
|
|
|||
|
|
@ -1925,8 +1925,24 @@ func walkRelationAvs(avID string, exportAvIDs *hashset.Set) {
|
|||
}
|
||||
}
|
||||
|
||||
func ExportMarkdownContent(id string) (hPath, exportedMd string) {
|
||||
return exportMarkdownContent(id, ".md", Conf.Export.BlockRefMode, nil, true, &map[string]*parse.Tree{})
|
||||
func ExportMarkdownContent(id string, refMode, embedMode int, addYfm bool) (hPath, exportedMd string) {
|
||||
bt := treenode.GetBlockTree(id)
|
||||
if nil == bt {
|
||||
return
|
||||
}
|
||||
|
||||
tree := prepareExportTree(bt)
|
||||
hPath = tree.HPath
|
||||
exportedMd = exportMarkdownContent0(tree, "", false,
|
||||
".md", refMode, embedMode, Conf.Export.FileAnnotationRefMode,
|
||||
Conf.Export.TagOpenMarker, Conf.Export.TagCloseMarker,
|
||||
Conf.Export.BlockRefTextLeft, Conf.Export.BlockRefTextRight,
|
||||
Conf.Export.AddTitle, nil, true, &map[string]*parse.Tree{})
|
||||
docIAL := parse.IAL2Map(tree.Root.KramdownIAL)
|
||||
if addYfm {
|
||||
exportedMd = yfm(docIAL) + exportedMd
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func exportMarkdownContent(id, ext string, exportRefMode int, defBlockIDs []string, singleFile bool, treeCache *map[string]*parse.Tree) (hPath, exportedMd string) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue