mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 08:30:12 +01:00
🎨 Simplify document block paths in block ref search list https://github.com/siyuan-note/siyuan/issues/13364
This commit is contained in:
parent
1a48215076
commit
a1c21e9261
2 changed files with 15 additions and 0 deletions
|
|
@ -101,6 +101,10 @@ func (block *Block) IsContainerBlock() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (block *Block) IsDoc() bool {
|
||||||
|
return "NodeDocument" == block.Type
|
||||||
|
}
|
||||||
|
|
||||||
type Path struct {
|
type Path struct {
|
||||||
ID string `json:"id"` // 块 ID
|
ID string `json:"id"` // 块 ID
|
||||||
Box string `json:"box"` // 块 Box
|
Box string `json:"box"` // 块 Box
|
||||||
|
|
|
||||||
|
|
@ -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
|
// 在 hPath 中加入笔记本名 Show notebooks in hpath of block ref search list results https://github.com/siyuan-note/siyuan/issues/9378
|
||||||
prependNotebookNameInHPath(ret)
|
prependNotebookNameInHPath(ret)
|
||||||
|
// 简化块引搜索列表中的文档块路径 Simplify document block paths in block ref search list https://github.com/siyuan-note/siyuan/issues/13364
|
||||||
|
// 文档块不显示自己的路径(最后一层)
|
||||||
|
filterSelfHPath(ret)
|
||||||
return
|
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) {
|
func prependNotebookNameInHPath(blocks []*Block) {
|
||||||
var boxIDs []string
|
var boxIDs []string
|
||||||
for _, b := range blocks {
|
for _, b := range blocks {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue