From 1a482150765ca5dd31f9f8537158bebfd21840c4 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 4 Dec 2024 22:53:36 +0800 Subject: [PATCH 1/3] :art: Improve document tag adding interaction https://github.com/siyuan-note/siyuan/issues/13311 --- kernel/model/blockial.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/model/blockial.go b/kernel/model/blockial.go index bd43d3718db..8af83a68924 100644 --- a/kernel/model/blockial.go +++ b/kernel/model/blockial.go @@ -216,7 +216,10 @@ func setNodeAttrs0(node *ast.Node, nameValues map[string]string) (oldAttrs map[s } for name, value := range nameValues { - if "" == strings.TrimSpace(value) { + value = util.RemoveInvalid(value) + value = strings.TrimSpace(value) + value = strings.TrimSuffix(value, ",") + if "" == value { node.RemoveIALAttr(name) } else { node.SetIALAttr(name, value) From a1c21e9261350c136190c8a576f1c241739cb01b Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 4 Dec 2024 23:19:36 +0800 Subject: [PATCH 2/3] :art: Simplify document block paths in block ref search list https://github.com/siyuan-note/siyuan/issues/13364 --- kernel/model/block.go | 4 ++++ kernel/model/search.go | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/kernel/model/block.go b/kernel/model/block.go index 417cbf19356..bf0bd7a20ff 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 8033f0d30ac..7cbed3c2499 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 { From 4a1960516f15b68c4156e3fe80a1798c5e664520 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 4 Dec 2024 23:19:36 +0800 Subject: [PATCH 3/3] :art: Simplify document block paths in search results https://github.com/siyuan-note/siyuan/issues/13364 --- kernel/model/search.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/kernel/model/search.go b/kernel/model/search.go index 7cbed3c2499..dbbeb973074 100644 --- a/kernel/model/search.go +++ b/kernel/model/search.go @@ -360,8 +360,8 @@ func SearchRefBlock(id, rootID, keyword string, beforeLen int, isSquareBrackets, ret = []*Block{} } - // 在 hPath 中加入笔记本名 Show notebooks in hpath of block ref search list results https://github.com/siyuan-note/siyuan/issues/9378 prependNotebookNameInHPath(ret) + filterSelfHPath(ret) return } @@ -423,15 +423,15 @@ func SearchRefBlock(id, rootID, keyword string, beforeLen int, isSquareBrackets, newDoc = true } - // 在 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) { + // 简化搜索结果列表中的文档块路径 Simplify document block paths in search results https://github.com/siyuan-note/siyuan/issues/13364 + // 文档块不显示自己的路径(最后一层) + for _, b := range blocks { if b.IsDoc() { b.HPath = strings.TrimSuffix(b.HPath, path.Base(b.HPath)) @@ -440,6 +440,8 @@ func filterSelfHPath(blocks []*Block) { } func prependNotebookNameInHPath(blocks []*Block) { + // 在 hPath 中加入笔记本名 Show notebooks in hpath of block ref search list results https://github.com/siyuan-note/siyuan/issues/9378 + var boxIDs []string for _, b := range blocks { boxIDs = append(boxIDs, b.Box) @@ -1121,6 +1123,8 @@ func FullTextSearchBlock(query string, boxes, paths []string, types map[string]b if 1 > len(ret) { ret = []*Block{} } + + filterSelfHPath(ret) return }