Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2025-02-09 12:04:54 +08:00
commit 834e42d330
4 changed files with 29 additions and 43 deletions

View file

@ -231,24 +231,12 @@ func heading2Doc(c *gin.Context) {
}
model.FlushTxQueue()
luteEngine := util.NewLute()
tree, err := filesys.LoadTree(targetNotebook, targetPath, luteEngine)
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
return
}
name := path.Base(targetPath)
box := model.Conf.Box(targetNotebook)
files, _, _ := model.ListDocTree(targetNotebook, path.Dir(targetPath), util.SortModeUnassigned, false, false, model.Conf.FileTree.MaxListCount)
evt := util.NewCmdResult("heading2doc", 0, util.PushModeBroadcast)
evt.Data = map[string]interface{}{
"box": box,
"path": targetPath,
"files": files,
"name": name,
"id": tree.Root.ID,
"srcRootBlockID": srcRootBlockID,
}
evt.Callback = arg["callback"]
@ -283,24 +271,12 @@ func li2Doc(c *gin.Context) {
}
model.FlushTxQueue()
luteEngine := util.NewLute()
tree, err := filesys.LoadTree(targetNotebook, targetPath, luteEngine)
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
return
}
name := path.Base(targetPath)
box := model.Conf.Box(targetNotebook)
files, _, _ := model.ListDocTree(targetNotebook, path.Dir(targetPath), util.SortModeUnassigned, false, false, model.Conf.FileTree.MaxListCount)
evt := util.NewCmdResult("li2doc", 0, util.PushModeBroadcast)
evt.Data = map[string]interface{}{
"box": box,
"path": targetPath,
"files": files,
"name": name,
"id": tree.Root.ID,
"srcRootBlockID": srcRootBlockID,
}
evt.Callback = arg["callback"]
@ -679,7 +655,7 @@ func duplicateDoc(c *gin.Context) {
notebook := tree.Box
box := model.Conf.Box(notebook)
model.DuplicateDoc(tree)
pushCreate(box, tree.Path, tree.ID, arg)
pushCreate(box, tree.Path, arg)
ret.Data = map[string]interface{}{
"id": tree.Root.ID,
@ -719,8 +695,16 @@ func createDoc(c *gin.Context) {
}
model.FlushTxQueue()
box := model.Conf.Box(notebook)
pushCreate(box, p, tree.Root.ID, arg)
pushCreateEvt := true
pushCreateEvtArg := arg["pushCreateEvt"]
if nil != pushCreateEvtArg {
pushCreateEvt = pushCreateEvtArg.(bool)
}
if pushCreateEvt {
box := model.Conf.Box(notebook)
pushCreate(box, p, arg)
}
ret.Data = map[string]interface{}{
"id": tree.Root.ID,
@ -853,10 +837,17 @@ func createDocWithMd(c *gin.Context) {
ret.Data = id
model.FlushTxQueue()
box := model.Conf.Box(notebook)
b, _ := model.GetBlock(id, nil)
p := b.Path
pushCreate(box, p, id, arg)
pushCreateEvt := true
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)
}
}
func getDocCreateSavePath(c *gin.Context) {
@ -1164,16 +1155,11 @@ func getDoc(c *gin.Context) {
}
}
func pushCreate(box *model.Box, p, treeID string, arg map[string]interface{}) {
func pushCreate(box *model.Box, p string, arg map[string]interface{}) {
evt := util.NewCmdResult("create", 0, util.PushModeBroadcast)
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": treeID,
"box": box,
"path": p,
}
evt.Callback = arg["callback"]
util.PushEvent(evt)

View file

@ -709,7 +709,7 @@ func NewLute() (ret *lute.Lute) {
return
}
func EnableLuteInlineSyntax(luteEngine *lute.Lute) {
func enableLuteInlineSyntax(luteEngine *lute.Lute) {
luteEngine.SetInlineAsterisk(true)
luteEngine.SetInlineUnderscore(true)
luteEngine.SetSup(true)

View file

@ -576,11 +576,11 @@ func Preview(id string) (retStdHTML string) {
tree, _ := LoadTreeByBlockID(id)
tree = exportTree(tree, false, false, true,
blockRefMode, Conf.Export.BlockEmbedMode, Conf.Export.FileAnnotationRefMode,
Conf.Export.TagOpenMarker, Conf.Export.TagCloseMarker,
"#", "#", // 这里固定使用 # 包裹标签,否则无法正确解析标签 https://github.com/siyuan-note/siyuan/issues/13857
Conf.Export.BlockRefTextLeft, Conf.Export.BlockRefTextRight,
Conf.Export.AddTitle, true, true, &map[string]*parse.Tree{})
luteEngine := NewLute()
EnableLuteInlineSyntax(luteEngine)
enableLuteInlineSyntax(luteEngine)
luteEngine.SetFootnotes(true)
addBlockIALNodes(tree, false)
md := treenode.FormatNode(tree.Root, luteEngine)

View file

@ -1036,7 +1036,7 @@ func CreateWithMarkdown(tags, boxID, hPath, md, parentID, id string, withMath bo
luteEngine.SetHTMLTag2TextMark(true)
if strings.HasPrefix(clippingHref, "https://ld246.com/article/") || strings.HasPrefix(clippingHref, "https://liuyun.io/article/") {
// 改进链滴剪藏 https://github.com/siyuan-note/siyuan/issues/13117
EnableLuteInlineSyntax(luteEngine)
enableLuteInlineSyntax(luteEngine)
}
dom := luteEngine.Md2BlockDOM(md, false)
retID, err = createDocsByHPath(box.ID, hPath, dom, parentID, id)