From 00e6891ea0f4ea15532245e97a57ceba7fe1b4b6 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 10 Oct 2025 10:58:32 +0800 Subject: [PATCH 1/8] :art: https://github.com/siyuan-note/siyuan/issues/16030 Signed-off-by: Daniel <845765@qq.com> --- kernel/av/filter.go | 62 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/kernel/av/filter.go b/kernel/av/filter.go index 9acb813ce..31f2834ef 100644 --- a/kernel/av/filter.go +++ b/kernel/av/filter.go @@ -146,11 +146,13 @@ func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, itemID s return true } - switch filter.Operator { - case FilterOperatorIsEmpty: - return value.IsEmpty() - case FilterOperatorIsNotEmpty: - return !value.IsEmpty() + if "" == filter.Qualifier { + switch filter.Operator { + case FilterOperatorIsEmpty: + return value.IsEmpty() + case FilterOperatorIsNotEmpty: + return !value.IsEmpty() + } } // 单独处理汇总 @@ -194,12 +196,30 @@ func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, itemID s switch filter.Qualifier { case FilterQuantifierUndefined, FilterQuantifierAny: + if len(value.Rollup.Contents) < len(relVal.Relation.Contents) { // 说明汇总的目标字段存在空值 + if FilterOperatorIsEmpty == filter.Operator { + return true + } else if FilterOperatorIsNotEmpty == filter.Operator { + return false + } + } + for _, content := range value.Rollup.Contents { if content.filter(filter.Value.Rollup.Contents[0], filter.RelativeDate, filter.RelativeDate2, filter.Operator) { return true } } case FilterQuantifierAll: + if len(value.Rollup.Contents) < len(relVal.Relation.Contents) { + if FilterOperatorIsEmpty == filter.Operator { + if 1 > len(value.Rollup.Contents) { + return true + } + } else if FilterOperatorIsNotEmpty == filter.Operator { + return false + } + } + for _, content := range value.Rollup.Contents { if !content.filter(filter.Value.Rollup.Contents[0], filter.RelativeDate, filter.RelativeDate2, filter.Operator) { return false @@ -207,6 +227,14 @@ func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, itemID s } return true case FilterQuantifierNone: + if len(value.Rollup.Contents) < len(relVal.Relation.Contents) { + if FilterOperatorIsEmpty == filter.Operator { + return false + } else if FilterOperatorIsNotEmpty == filter.Operator { + return true + } + } + for _, content := range value.Rollup.Contents { if content.filter(filter.Value.Rollup.Contents[0], filter.RelativeDate, filter.RelativeDate2, filter.Operator) { return false @@ -265,6 +293,14 @@ func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, itemID s switch filter.Qualifier { case FilterQuantifierUndefined, FilterQuantifierAny: + if 1 > len(value.MAsset) { // 说明资源字段为空 + if FilterOperatorIsEmpty == filter.Operator { + return true + } else if FilterOperatorIsNotEmpty == filter.Operator { + return false + } + } + for _, asset := range value.MAsset { switch asset.Type { case AssetTypeFile: @@ -279,6 +315,14 @@ func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, itemID s } } case FilterQuantifierAll: + if 1 > len(value.MAsset) { + if FilterOperatorIsEmpty == filter.Operator { + return true + } else if FilterOperatorIsNotEmpty == filter.Operator { + return false + } + } + for _, asset := range value.MAsset { switch asset.Type { case AssetTypeFile: @@ -294,6 +338,14 @@ func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, itemID s } return true case FilterQuantifierNone: + if 1 > len(value.MAsset) { + if FilterOperatorIsEmpty == filter.Operator { + return false + } else if FilterOperatorIsNotEmpty == filter.Operator { + return true + } + } + for _, asset := range value.MAsset { switch asset.Type { case AssetTypeFile: From 9372119bc31f332c790040c2062f804bd6493c0a Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 10 Oct 2025 10:58:42 +0800 Subject: [PATCH 2/8] :art: Clean code Signed-off-by: Daniel <845765@qq.com> --- kernel/model/attribute_view.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index 2795fb0c9..6901ed88b 100644 --- a/kernel/model/attribute_view.go +++ b/kernel/model/attribute_view.go @@ -1959,7 +1959,7 @@ func genAttrViewGroups(view *av.View, attrView *av.AttributeView) { // 过去 30 天、过去 7 天、昨天、今天、明天、未来 7 天、未来 30 天 // 未来 30 天之后的按月分组 if contentTime.Before(todayStart.AddDate(0, 0, -30)) { - groupVal = contentTime.Format("2006-01") // 开头的数字用于排序,下同 + groupVal = contentTime.Format("2006-01") // 开头的数字用于排序 } else if contentTime.Before(todayStart.AddDate(0, 0, -7)) { groupVal = groupValueLast30Days } else if contentTime.Before(todayStart.AddDate(0, 0, -1)) { From 6acd0d3f27898327c0a8b5cb4e05fbde0097c076 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 10 Oct 2025 11:20:22 +0800 Subject: [PATCH 3/8] :art: Improve fold heading editing https://github.com/siyuan-note/siyuan/issues/15989 Signed-off-by: Daniel <845765@qq.com> --- kernel/model/transaction.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index f768c045d..0e0a1ea76 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -912,8 +912,12 @@ func (tx *Transaction) doDelete(operation *Operation) (ret *TxErr) { node.Next.Unlink() } + next := node.Next node.Unlink() + parentFoldedHeading := treenode.GetParentFoldedHeading(next) + unfoldHeading(parentFoldedHeading) + if nil != parent && ast.NodeListItem == parent.Type && nil == parent.FirstChild { needAppendEmptyListItem := true for _, op := range tx.DoOperations { From b3a4068ceaa7444672cdf453a47edf633489e929 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 10 Oct 2025 11:52:23 +0800 Subject: [PATCH 4/8] :art: https://github.com/siyuan-note/siyuan/issues/16050 Signed-off-by: Daniel <845765@qq.com> --- kernel/api/filetree.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/kernel/api/filetree.go b/kernel/api/filetree.go index a8bb81b8a..cd02b1c94 100644 --- a/kernel/api/filetree.go +++ b/kernel/api/filetree.go @@ -114,11 +114,11 @@ func listDocTree(c *gin.Context) { ids := map[string]bool{} for _, entry := range dir { - if entry.IsDir() { - if strings.HasPrefix(entry.Name(), ".") { - continue - } + if strings.HasPrefix(entry.Name(), ".") { + continue + } + if entry.IsDir() { if !ast.IsNodeIDPattern(entry.Name()) { continue } @@ -134,7 +134,12 @@ func listDocTree(c *gin.Context) { return } } else { - doc := &DocFile{ID: strings.TrimSuffix(entry.Name(), ".sy")} + id := strings.TrimSuffix(entry.Name(), ".sy") + if !ast.IsNodeIDPattern(id) { + continue + } + + doc := &DocFile{ID: id} if !ids[doc.ID] { doctree = append(doctree, doc) } From 60c49dbfe9a75b166424d44bb3a150bafbf06319 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 10 Oct 2025 12:43:01 +0800 Subject: [PATCH 5/8] :bug: https://github.com/siyuan-note/siyuan/issues/16042 Signed-off-by: Daniel <845765@qq.com> --- kernel/model/export.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/model/export.go b/kernel/model/export.go index d5e2f87c1..6fa0c2a0d 100644 --- a/kernel/model/export.go +++ b/kernel/model/export.go @@ -2162,9 +2162,11 @@ func exportMarkdownContent0(id string, tree *parse.Tree, cloudAssetsBase string, href = "#" + defID } } - href = strings.TrimPrefix(href, currentDocDir) + newHref := strings.TrimPrefix(href, currentDocDir) + if !strings.HasPrefix(newHref, ".md") { + href = newHref + } href = util.FilterFilePath(href) - href = strings.TrimPrefix(href, "/") blockRefLink := &ast.Node{Type: ast.NodeTextMark, TextMarkType: "a", TextMarkTextContent: linkText, TextMarkAHref: href} blockRefLink.KramdownIAL = n.KramdownIAL n.InsertBefore(blockRefLink) From af43929b7a234a53099bc10a0403e857a3b81de7 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 10 Oct 2025 12:48:40 +0800 Subject: [PATCH 6/8] :art: https://github.com/siyuan-note/siyuan/issues/16046 Signed-off-by: Daniel <845765@qq.com> --- kernel/model/conf.go | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/model/conf.go b/kernel/model/conf.go index 89930c322..76897e7e7 100644 --- a/kernel/model/conf.go +++ b/kernel/model/conf.go @@ -1131,6 +1131,7 @@ func closeUserGuide() { unindex(boxID) + sql.FlushQueue() if removeErr := filelock.Remove(boxDirPath); nil != removeErr { logging.LogErrorf("remove corrupted user guide box [%s] failed: %s", boxDirPath, removeErr) } From 4f39f2a29e77998ba9ba564679ac61ea5bc068a4 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 10 Oct 2025 12:53:37 +0800 Subject: [PATCH 7/8] :art: https://github.com/siyuan-note/siyuan/issues/16046 Signed-off-by: Daniel <845765@qq.com> --- kernel/model/box.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/kernel/model/box.go b/kernel/model/box.go index 16768373c..ffcf8bdcb 100644 --- a/kernel/model/box.go +++ b/kernel/model/box.go @@ -102,17 +102,22 @@ func ListNotebooks() (ret []*Box, err error) { continue } - if !ast.IsNodeIDPattern(dir.Name()) { + id := dir.Name() + if !ast.IsNodeIDPattern(id) { continue } boxConf := conf.NewBoxConf() - boxDirPath := filepath.Join(util.DataDir, dir.Name()) + boxDirPath := filepath.Join(util.DataDir, id) boxConfPath := filepath.Join(boxDirPath, ".siyuan", "conf.json") isExistConf := filelock.IsExist(boxConfPath) if !isExistConf { - // 数据同步时展开文档树操作可能导致数据丢失 https://github.com/siyuan-note/siyuan/issues/7129 - logging.LogWarnf("found a corrupted box [%s]", boxDirPath) + if !IsUserGuide(id) { + // 数据同步时展开文档树操作可能导致数据丢失 https://github.com/siyuan-note/siyuan/issues/7129 + logging.LogWarnf("found a corrupted box [%s]", boxDirPath) + } else { + continue + } } else { data, readErr := filelock.ReadFile(boxConfPath) if nil != readErr { @@ -126,7 +131,6 @@ func ListNotebooks() (ret []*Box, err error) { } } - id := dir.Name() icon := boxConf.Icon if strings.Contains(icon, ".") { // 说明是自定义图标 // XSS through emoji name https://github.com/siyuan-note/siyuan/issues/15034 From 30a960ef1f77030b27e70080a2cd9bd0395799dd Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 10 Oct 2025 13:04:29 +0800 Subject: [PATCH 8/8] :art: https://github.com/siyuan-note/siyuan/issues/16048 Signed-off-by: Daniel <845765@qq.com> --- kernel/model/block.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/model/block.go b/kernel/model/block.go index 248b13797..97a4f0ebf 100644 --- a/kernel/model/block.go +++ b/kernel/model/block.go @@ -786,6 +786,11 @@ func GetBlockDOMs(ids []string) (ret map[string]string) { if nil == node { continue } + + if parentFoldedHeading := treenode.GetParentFoldedHeading(node); nil != parentFoldedHeading { + node.SetIALAttr("parent-heading", parentFoldedHeading.ID) + } + ret[id] = luteEngine.RenderNodeBlockDOM(node) } return