diff --git a/kernel/conf/editor.go b/kernel/conf/editor.go index 2ea54e7d0..f7ec00378 100644 --- a/kernel/conf/editor.go +++ b/kernel/conf/editor.go @@ -50,6 +50,11 @@ type Editor struct { BackmentionExpandCount int `json:"backmentionExpandCount"` // 反链提及默认展开数量 } +const ( + MinDynamicLoadBlocks = 48 + MaxDynamicLoadBlocks = 1024 +) + func NewEditor() *Editor { return &Editor{ FontSize: 16, diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index a4c84a66f..b99c67e45 100644 --- a/kernel/model/attribute_view.go +++ b/kernel/model/attribute_view.go @@ -2943,12 +2943,12 @@ func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID, cellID string, // 将游离行绑定到新建的块上 bindBlockAv(tx, avID, rowID) } - } else { // 之前绑定了块 + } else { // 之前绑定了块 if isUpdatingBlockKey { // 正在更新主键 if val.IsDetached { // 现在是游离行 // 将绑定的块从属性视图中移除 unbindBlockAv(tx, avID, rowID) - } else { // 现在绑定了块 + } else { // 现在绑定了块 if oldBoundBlockID != val.BlockID { // 之前绑定的块和现在绑定的块不一样 // 换绑块 unbindBlockAv(tx, avID, oldBoundBlockID) @@ -3251,6 +3251,7 @@ func updateAttributeViewColumnOption(operation *Operation) (err error) { } } + // 如果存在选项对应的值,需要更新值中的选项 for _, keyValues := range attrView.KeyValues { if keyValues.Key.ID != operation.ID { continue @@ -3272,6 +3273,30 @@ func updateAttributeViewColumnOption(operation *Operation) (err error) { break } + // 如果存在选项对应的过滤器,需要更新过滤器中设置的选项值 + // Database select field filters follow option editing changes https://github.com/siyuan-note/siyuan/issues/10881 + for _, view := range attrView.Views { + switch view.LayoutType { + case av.LayoutTypeTable: + table := view.Table + for _, filter := range table.Filters { + if filter.Column != key.ID { + continue + } + + if nil != filter.Value && (av.KeyTypeSelect == filter.Value.Type || av.KeyTypeMSelect == filter.Value.Type) { + for i, opt := range filter.Value.MSelect { + if oldName == opt.Content { + filter.Value.MSelect[i].Content = newName + filter.Value.MSelect[i].Color = newColor + break + } + } + } + } + } + } + err = av.SaveAttributeView(attrView) return } diff --git a/kernel/model/blockinfo.go b/kernel/model/blockinfo.go index aabb5b91e..4f773cc89 100644 --- a/kernel/model/blockinfo.go +++ b/kernel/model/blockinfo.go @@ -365,7 +365,7 @@ func buildBlockBreadcrumb(node *ast.Node, excludeTypes []string) (ret []*BlockPa if ast.NodeDocument == parent.Type { name = box.Name + hPath } else if ast.NodeAttributeView == parent.Type { - name = treenode.GetAttributeViewName(parent.AttributeViewID) + name, _ = av.GetAttributeViewName(parent.AttributeViewID) } else { if "" == name { if ast.NodeListItem == parent.Type { diff --git a/kernel/model/conf.go b/kernel/model/conf.go index a7a6fb1bc..d5b27a56f 100644 --- a/kernel/model/conf.go +++ b/kernel/model/conf.go @@ -242,11 +242,11 @@ func InitConf() { if 1 > Conf.Editor.HistoryRetentionDays { Conf.Editor.HistoryRetentionDays = 30 } - if 48 > Conf.Editor.DynamicLoadBlocks { - Conf.Editor.DynamicLoadBlocks = 48 + if conf.MinDynamicLoadBlocks > Conf.Editor.DynamicLoadBlocks { + Conf.Editor.DynamicLoadBlocks = conf.MinDynamicLoadBlocks } - if 1024 < Conf.Editor.DynamicLoadBlocks { - Conf.Editor.DynamicLoadBlocks = 1024 + if conf.MaxDynamicLoadBlocks < Conf.Editor.DynamicLoadBlocks { + Conf.Editor.DynamicLoadBlocks = conf.MaxDynamicLoadBlocks } if 0 > Conf.Editor.BacklinkExpandCount { Conf.Editor.BacklinkExpandCount = 0 diff --git a/kernel/model/file.go b/kernel/model/file.go index 90ce4656f..71def8279 100644 --- a/kernel/model/file.go +++ b/kernel/model/file.go @@ -42,6 +42,7 @@ import ( "github.com/siyuan-note/riff" "github.com/siyuan-note/siyuan/kernel/av" "github.com/siyuan-note/siyuan/kernel/cache" + "github.com/siyuan-note/siyuan/kernel/conf" "github.com/siyuan-note/siyuan/kernel/filesys" "github.com/siyuan-note/siyuan/kernel/search" "github.com/siyuan-note/siyuan/kernel/sql" @@ -665,7 +666,7 @@ func GetDoc(startID, endID, id string, index int, query string, queryTypes map[s childCount += treenode.CountBlockNodes(n) } - if childCount > Conf.Editor.DynamicLoadBlocks { + if childCount > Conf.Editor.DynamicLoadBlocks && blockCount > conf.MinDynamicLoadBlocks { scroll = true return ast.WalkStop } diff --git a/kernel/treenode/node.go b/kernel/treenode/node.go index edf07ae12..295fc3292 100644 --- a/kernel/treenode/node.go +++ b/kernel/treenode/node.go @@ -342,7 +342,7 @@ func FirstLeafBlock(node *ast.Node) (ret *ast.Node) { func CountBlockNodes(node *ast.Node) (ret int) { ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus { - if !entering || !n.IsBlock() || ast.NodeList == n.Type || ast.NodeBlockquote == n.Type || ast.NodeSuperBlock == n.Type { + if !entering || !n.IsBlock() || ast.NodeList == n.Type || ast.NodeListItem == n.Type || ast.NodeBlockquote == n.Type || ast.NodeSuperBlock == n.Type { return ast.WalkContinue } @@ -546,27 +546,6 @@ func IsChartCodeBlockCode(code *ast.Node) bool { return render.NoHighlight(language) } -func GetAttributeViewName(avID string) (name string) { - if "" == avID { - return - } - - attrView, err := av.ParseAttributeView(avID) - if nil != err { - logging.LogErrorf("parse attribute view [%s] failed: %s", avID, err) - return - } - - buf := bytes.Buffer{} - for _, v := range attrView.Views { - buf.WriteString(v.Name) - buf.WriteByte(' ') - } - - name = strings.TrimSpace(buf.String()) - return -} - func getAttributeViewContent(avID string) (content string) { if "" == avID { return