Skip to content

Commit

Permalink
🎨 Simplify document block paths in block ref search list #13364
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Dec 4, 2024
1 parent 1a48215 commit a1c21e9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kernel/model/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions kernel/model/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a1c21e9

Please sign in to comment.