|
@@ -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.AttributeViewID
|
|
|
if "" == 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
|
|
|
})
|