Skip to content

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

:art: Improve av https://github.com/siyuan-note/siyuan/issues/15644

Daniel2899e3851d71
diff --git a/kernel/av/value.go b/kernel/av/value.go
index fcf76c617d..d080ad1884 100644
--- a/kernel/av/value.go
+++ b/kernel/av/value.go
@@ -978,6 +978,8 @@ func GetAttributeViewDefaultValue(valueID, keyID, blockID string, typ KeyType) (
}
switch typ {
+ case KeyTypeBlock:
+ ret.Block = &ValueBlock{Created: ret.CreatedAt, Updated: ret.UpdatedAt}
case KeyTypeText:
ret.Text = &ValueText{}
case KeyTypeNumber:
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index 4b2e80d7b0..d2971250b9 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -215,7 +215,32 @@ func getAttrViewAddingBlockDefaultValues(attrView *av.AttributeView, view, group
return
}
- if nil != newValue && !filterKeyIDs[groupKey.ID] /* 命中了过滤条件的话就不重复处理了 */ {
+ if nil == nearItem && !filterKeyIDs[groupKey.ID] {
+ // 没有临近项并且分组字段和过滤字段不同时,使用分组值
+ newValue = av.GetAttributeViewDefaultValue(ast.NewNodeID(), groupKey.ID, addingItemID, groupKey.Type)
+ if av.KeyTypeText == groupView.GroupVal.Type {
+ content := groupView.GroupVal.Text.Content
+ switch newValue.Type {
+ case av.KeyTypeBlock:
+ newValue.Block.Content = content
+ case av.KeyTypeText:
+ newValue.Text.Content = content
+ case av.KeyTypeURL:
+ newValue.URL.Content = content
+ case av.KeyTypeEmail:
+ newValue.Email.Content = content
+ case av.KeyTypePhone:
+ newValue.Phone.Content = content
+ case av.KeyTypeCheckbox:
+ newValue.Checkbox.Checked = "" != content
+ }
+ }
+
+ ret[groupKey.ID] = newValue
+ return
+ }
+
+ if nil != newValue && !filterKeyIDs[groupKey.ID] {
ret[groupKey.ID] = newValue
}
return