Kaynağa Gözat

Merge remote-tracking branch 'origin/dev' into dev

Vanessa 1 yıl önce
ebeveyn
işleme
92856c1c8c
2 değiştirilmiş dosya ile 6 ekleme ve 29 silme
  1. 3 8
      kernel/model/attribute_view.go
  2. 3 21
      kernel/model/file.go

+ 3 - 8
kernel/model/attribute_view.go

@@ -1695,23 +1695,18 @@ func setAttributeViewName(operation *Operation) (err error) {
 
 	nodes := getAttrViewBoundNodes(attrView)
 	for _, node := range nodes {
+		avNames := getAvNames(node.IALAttr(av.NodeAttrNameAvs))
 		oldAttrs := parse.IAL2Map(node.KramdownIAL)
-		avNames := getNodeIALAvNames(node)
-		if "" == avNames {
-			continue
-		}
 		node.SetIALAttr("av-names", avNames)
 		pushBroadcastAttrTransactions(oldAttrs, node)
 	}
 	return
 }
 
-func getNodeIALAvNames(node *ast.Node) (ret string) {
-	avIDs := parse.IAL2Map(node.KramdownIAL)[av.NodeAttrNameAvs]
+func getAvNames(avIDs string) (ret string) {
 	if "" == avIDs {
 		return
 	}
-
 	avNames := bytes.Buffer{}
 	nodeAvIDs := strings.Split(avIDs, ",")
 	for _, nodeAvID := range nodeAvIDs {
@@ -2056,7 +2051,7 @@ func addAttributeViewBlock(avID, blockID, previousBlockID, addingBlockID string,
 			attrs[av.NodeAttrNameAvs] = strings.Join(avIDs, ",")
 		}
 
-		avNames := getNodeIALAvNames(node)
+		avNames := getAvNames(attrs[av.NodeAttrNameAvs])
 		if "" != avNames {
 			attrs["av-names"] = avNames
 		}

+ 3 - 21
kernel/model/file.go

@@ -17,7 +17,6 @@
 package model
 
 import (
-	"bytes"
 	"errors"
 	"fmt"
 	"os"
@@ -735,26 +734,9 @@ func GetDoc(startID, endID, id string, index int, query string, queryTypes map[s
 
 			if avs := n.IALAttr(av.NodeAttrNameAvs); "" != avs {
 				// 填充属性视图角标 Display the database title on the block superscript https://github.com/siyuan-note/siyuan/issues/10545
-				avNames := bytes.Buffer{}
-				avIDs := strings.Split(avs, ",")
-				for _, avID := range avIDs {
-					avName, getErr := av.GetAttributeViewName(avID)
-					if nil != getErr {
-						continue
-					}
-
-					if "" == avName {
-						avName = "Untitled"
-					}
-
-					tpl := strings.ReplaceAll(attrAvNameTpl, "${avID}", avID)
-					tpl = strings.ReplaceAll(tpl, "${avName}", avName)
-					avNames.WriteString(tpl)
-					avNames.WriteString(" ")
-				}
-				if 0 < avNames.Len() {
-					avNames.Truncate(avNames.Len() - 6)
-					n.SetIALAttr("av-names", avNames.String())
+				avNames := getAvNames(n.IALAttr(av.NodeAttrNameAvs))
+				if "" != avNames {
+					n.SetIALAttr("av-names", avNames)
 				}
 			}