Skip to content

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

:art: Simplify document block paths in block ref search list https://github.com/siyuan-note/siyuan/issues/13364

Daniela1c21e926135
diff --git a/kernel/model/block.go b/kernel/model/block.go
index 417cbf1935..bf0bd7a20f 100644
--- a/kernel/model/block.go
+++ b/kernel/model/block.go
@@ -101,6 +101,10 @@ func (block *Block) IsContainerBlock() bool {
return false
}
+func (block *Block) IsDoc() bool {
+ return "NodeDocument" == block.Type
+}
+
type Path struct {
ID string `json:"id"` // 块 ID
Box string `json:"box"` // 块 Box
diff --git a/kernel/model/search.go b/kernel/model/search.go
index 8033f0d30a..7cbed3c249 100644
--- a/kernel/model/search.go
+++ b/kernel/model/search.go
@@ -425,9 +425,20 @@ func SearchRefBlock(id, rootID, keyword string, beforeLen int, isSquareBrackets,
// 在 hPath 中加入笔记本名 Show notebooks in hpath of block ref search list results https://github.com/siyuan-note/siyuan/issues/9378
prependNotebookNameInHPath(ret)
+ // 简化块引搜索列表中的文档块路径 Simplify document block paths in block ref search list https://github.com/siyuan-note/siyuan/issues/13364
+ // 文档块不显示自己的路径(最后一层)
+ filterSelfHPath(ret)
return
}
+func filterSelfHPath(blocks []*Block) {
+ for _, b := range blocks {
+ if b.IsDoc() {
+ b.HPath = strings.TrimSuffix(b.HPath, path.Base(b.HPath))
+ }
+ }
+}
+
func prependNotebookNameInHPath(blocks []*Block) {
var boxIDs []string
for _, b := range blocks {