An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Export the binding block docs when exporting the doc where the database is located https://github.com/siyuan-note/siyuan/issues/11486 https://github.com/siyuan-note/siyuan/issues/11486
Daniel8901bd3abc0d
diff --git a/kernel/model/export.go b/kernel/model/export.goindex 00a008fd79..43aefb0b56 100644--- a/kernel/model/export.go+++ b/kernel/model/export.go@@ -2527,21 +2527,10 @@ type refAsFootnotes struct {func exportRefTrees(tree *parse.Tree) (ret map[string]*parse.Tree) {ret = map[string]*parse.Tree{}exportRefTrees0(tree, &ret)-- attrViewDefTrees := map[string]*parse.Tree{}- exportAttributeViewRefTrees0(tree, &attrViewDefTrees)- for _, t := range attrViewDefTrees {- if nil == ret[t.ID] {- ret[t.ID] = t- }- }return}-func exportAttributeViewRefTrees0(tree *parse.Tree, retTrees *map[string]*parse.Tree) {- // 导出数据库所在文档时一并导出绑定块所在文档- // Export the binding block docs when exporting the doc where the database is located https://github.com/siyuan-note/siyuan/issues/11486-+func exportRefTrees0(tree *parse.Tree, retTrees *map[string]*parse.Tree) {if nil != (*retTrees)[tree.ID] {return}@@ -2552,7 +2541,25 @@ func exportAttributeViewRefTrees0(tree *parse.Tree, retTrees *map[string]*parse.return ast.WalkContinue}- if ast.NodeAttributeView == n.Type {+ if treenode.IsBlockRef(n) {+ defID, _, _ := treenode.GetBlockRef(n)+ if "" == defID {+ return ast.WalkContinue+ }+ defBlock := treenode.GetBlockTree(defID)+ if nil == defBlock {+ return ast.WalkSkipChildren+ }+ defTree, err := LoadTreeByBlockID(defBlock.RootID)+ if nil != err {+ return ast.WalkSkipChildren+ }++ exportRefTrees0(defTree, retTrees)+ } else if ast.NodeAttributeView == n.Type {+ // 导出数据库所在文档时一并导出绑定块所在文档+ // Export the binding block docs when exporting the doc where the database is located https://github.com/siyuan-note/siyuan/issues/11486+avID := n.AttributeViewIDif "" == avID {return ast.WalkContinue@@ -2579,39 +2586,8 @@ func exportAttributeViewRefTrees0(tree *parse.Tree, retTrees *map[string]*parse.continue}- exportAttributeViewRefTrees0(defTree, retTrees)- }- }- return ast.WalkContinue- })-}--func exportRefTrees0(tree *parse.Tree, retTrees *map[string]*parse.Tree) {- if nil != (*retTrees)[tree.ID] {- return- }- (*retTrees)[tree.ID] = tree-- ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {- if !entering {- return ast.WalkContinue- }-- if treenode.IsBlockRef(n) {- defID, _, _ := treenode.GetBlockRef(n)- if "" == defID {- return ast.WalkContinue- }- defBlock := treenode.GetBlockTree(defID)- if nil == defBlock {- return ast.WalkSkipChildren+ exportRefTrees0(defTree, retTrees)}- defTree, err := LoadTreeByBlockID(defBlock.RootID)- if nil != err {- return ast.WalkSkipChildren- }-- exportRefTrees0(defTree, retTrees)}return ast.WalkContinue})