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: Improve floating window backlink https://github.com/siyuan-note/siyuan/issues/13371
Daniel04a4a90721b9
diff --git a/kernel/api/block.go b/kernel/api/block.goindex 209cff5871..def886c0b5 100644--- a/kernel/api/block.go+++ b/kernel/api/block.go@@ -412,7 +412,7 @@ func getRefIDs(c *gin.Context) {}id := arg["id"].(string)- refIDs, refTexts, defIDs := model.GetBlockRefs(id)+ refIDs, refTexts, defIDs := model.GetBlockRefs(id, true)ret.Data = map[string][]string{"refIDs": refIDs,"refTexts": refTexts,diff --git a/kernel/model/blockinfo.go b/kernel/model/blockinfo.goindex fb2c43b22f..7b844d6d96 100644--- a/kernel/model/blockinfo.go+++ b/kernel/model/blockinfo.go@@ -91,6 +91,7 @@ func GetDocInfo(blockID string) (ret *BlockInfo) {}ret.RefIDs, _ = sql.QueryRefIDsByDefID(blockID, false)+ buildBacklinkListItemRefs(&ret.RefIDs)ret.RefCount = len(ret.RefIDs) // 填充块引计数// 填充属性视图角标 Display the database title on the block superscript https://github.com/siyuan-note/siyuan/issues/10545@@ -316,7 +317,7 @@ func getNodeRefText0(node *ast.Node, maxLen int) string {return ret}-func GetBlockRefs(defID string) (refIDs, refTexts, defIDs []string) {+func GetBlockRefs(defID string, isBacklink bool) (refIDs, refTexts, defIDs []string) {refIDs = []string{}refTexts = []string{}defIDs = []string{}@@ -332,6 +333,10 @@ func GetBlockRefs(defID string) (refIDs, refTexts, defIDs []string) {} else {defIDs = append(defIDs, defID)}++ if isBacklink {+ buildBacklinkListItemRefs(&refIDs)+ }return}@@ -548,3 +553,17 @@ func buildBlockBreadcrumb(node *ast.Node, excludeTypes []string, isEmbedBlock bo}return}++func buildBacklinkListItemRefs(refIDs *[]string) {+ refBts := treenode.GetBlockTrees(*refIDs)+ for i, refID := range *refIDs {+ if bt := refBts[refID]; nil != bt {+ if "p" == bt.Type {+ if parent := treenode.GetBlockTree(bt.ParentID); nil != parent && "i" == parent.Type {+ // 引用计数浮窗请求,需要按照反链逻辑组装 https://github.com/siyuan-note/siyuan/issues/6853+ (*refIDs)[i] = parent.ID+ }+ }+ }+ }+}diff --git a/kernel/model/file.go b/kernel/model/file.goindex 0f477e44ed..b7c96fe650 100644--- a/kernel/model/file.go+++ b/kernel/model/file.go@@ -634,14 +634,6 @@ func GetDoc(startID, endID, id string, index int, query string, queryTypes map[s}}- if isBacklink { // 引用计数浮窗请求,需要按照反链逻辑组装 https://github.com/siyuan-note/siyuan/issues/6853- if ast.NodeParagraph == node.Type {- if nil != node.Parent && ast.NodeListItem == node.Parent.Type {- node = node.Parent- }- }- }-located := falseisDoc := ast.NodeDocument == node.TypeisHeading := ast.NodeHeading == node.Typediff --git a/kernel/model/push_reload.go b/kernel/model/push_reload.goindex 35a270f3b2..bc54bc0b34 100644--- a/kernel/model/push_reload.go+++ b/kernel/model/push_reload.go@@ -157,7 +157,7 @@ func refreshRefCount(rootID, blockID string) {for _, count := range refCounts {rootRefCount += count}- refIDs, _, _ := GetBlockRefs(blockID)+ refIDs, _, _ := GetBlockRefs(blockID, false)util.PushSetDefRefCount(rootID, blockID, refIDs, refCount, rootRefCount)}