Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: The backlink panel no longer displays child-block references https://github.com/siyuan-note/siyuan/issues/12861

Danieldd256bbaec75
diff --git a/kernel/api/ref.go b/kernel/api/ref.go
index 075a75c5c4..24939b7e9a 100644
--- a/kernel/api/ref.go
+++ b/kernel/api/ref.go
@@ -51,7 +51,7 @@ func getBackmentionDoc(c *gin.Context) {
defID := arg["defID"].(string)
refTreeID := arg["refTreeID"].(string)
keyword := arg["keyword"].(string)
- containChildren := true
+ containChildren := false
if val, ok := arg["containChildren"]; ok {
containChildren = val.(bool)
}
@@ -73,7 +73,7 @@ func getBacklinkDoc(c *gin.Context) {
defID := arg["defID"].(string)
refTreeID := arg["refTreeID"].(string)
keyword := arg["keyword"].(string)
- containChildren := true
+ containChildren := false
if val, ok := arg["containChildren"]; ok {
containChildren = val.(bool)
}
@@ -109,7 +109,11 @@ func getBacklink2(c *gin.Context) {
if nil != mentionSortArg {
mentionSort, _ = strconv.Atoi(mentionSortArg.(string))
}
- boxID, backlinks, backmentions, linkRefsCount, mentionsCount := model.GetBacklink2(id, keyword, mentionKeyword, sort, mentionSort)
+ containChildren := false
+ if val, ok := arg["containChildren"]; ok {
+ containChildren = val.(bool)
+ }
+ boxID, backlinks, backmentions, linkRefsCount, mentionsCount := model.GetBacklink2(id, keyword, mentionKeyword, sort, mentionSort, containChildren)
ret.Data = map[string]interface{}{
"backlinks": backlinks,
"linkRefsCount": linkRefsCount,
@@ -141,7 +145,11 @@ func getBacklink(c *gin.Context) {
if nil != arg["beforeLen"] {
beforeLen = int(arg["beforeLen"].(float64))
}
- boxID, backlinks, backmentions, linkRefsCount, mentionsCount := model.GetBacklink(id, keyword, mentionKeyword, beforeLen)
+ containChildren := false
+ if val, ok := arg["containChildren"]; ok {
+ containChildren = val.(bool)
+ }
+ boxID, backlinks, backmentions, linkRefsCount, mentionsCount := model.GetBacklink(id, keyword, mentionKeyword, beforeLen, containChildren)
ret.Data = map[string]interface{}{
"backlinks": backlinks,
"linkRefsCount": linkRefsCount,
diff --git a/kernel/model/backlink.go b/kernel/model/backlink.go
index efe5536326..f9bdaf9d2a 100644
--- a/kernel/model/backlink.go
+++ b/kernel/model/backlink.go
@@ -230,7 +230,7 @@ func getBacklinkRenderNodes(n *ast.Node) (ret []*ast.Node, expand bool) {
return
}
-func GetBacklink2(id, keyword, mentionKeyword string, sortMode, mentionSortMode int) (boxID string, backlinks, backmentions []*Path, linkRefsCount, mentionsCount int) {
+func GetBacklink2(id, keyword, mentionKeyword string, sortMode, mentionSortMode int, containChildren bool) (boxID string, backlinks, backmentions []*Path, linkRefsCount, mentionsCount int) {
keyword = strings.TrimSpace(keyword)
mentionKeyword = strings.TrimSpace(mentionKeyword)
backlinks, backmentions = []*Path{}, []*Path{}
@@ -242,7 +242,7 @@ func GetBacklink2(id, keyword, mentionKeyword string, sortMode, mentionSortMode
rootID := sqlBlock.RootID
boxID = sqlBlock.Box
- refs := sql.QueryRefsByDefID(id, false)
+ refs := sql.QueryRefsByDefID(id, containChildren)
refs = removeDuplicatedRefs(refs)
linkRefs, linkRefsCount, excludeBacklinkIDs := buildLinkRefs(rootID, refs, keyword)
@@ -328,7 +328,7 @@ func GetBacklink2(id, keyword, mentionKeyword string, sortMode, mentionSortMode
return
}
-func GetBacklink(id, keyword, mentionKeyword string, beforeLen int) (boxID string, linkPaths, mentionPaths []*Path, linkRefsCount, mentionsCount int) {
+func GetBacklink(id, keyword, mentionKeyword string, beforeLen int, containChildren bool) (boxID string, linkPaths, mentionPaths []*Path, linkRefsCount, mentionsCount int) {
linkPaths = []*Path{}
mentionPaths = []*Path{}
@@ -340,7 +340,7 @@ func GetBacklink(id, keyword, mentionKeyword string, beforeLen int) (boxID strin
boxID = sqlBlock.Box
var links []*Block
- refs := sql.QueryRefsByDefID(id, false)
+ refs := sql.QueryRefsByDefID(id, containChildren)
refs = removeDuplicatedRefs(refs)
// 为了减少查询,组装好 IDs 后一次查出