Skip to content

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

:art: Display the database title on the block superscript https://github.com/siyuan-note/siyuan/issues/10545

Danielc61d412fea2e
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index 22856d95ae..790efb9061 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -1696,38 +1696,41 @@ func setAttributeViewName(operation *Operation) (err error) {
nodes := getAttrViewBoundNodes(attrView)
for _, node := range nodes {
oldAttrs := parse.IAL2Map(node.KramdownIAL)
- nodeAvIDsVal := oldAttrs[av.NodeAttrNameAvs]
- if "" == nodeAvIDsVal {
+ avNames := getNodeIALAvNames(node)
+ if "" == avNames {
continue
}
+ node.SetIALAttr("av-names", avNames)
+ pushBroadcastAttrTransactions(oldAttrs, node)
+ }
+ return
+}
- avNames := bytes.Buffer{}
- nodeAvIDs := strings.Split(nodeAvIDsVal, ",")
- for _, nodeAvID := range nodeAvIDs {
- var nodeAvName string
- var getErr error
- if nodeAvID == avID {
- nodeAvName = attrView.Name
- } else {
- nodeAvName, getErr = av.GetAttributeViewName(nodeAvID)
- if nil != getErr {
- continue
- }
- }
- if "" == nodeAvName {
- nodeAvName = "Untitled"
- }
+func getNodeIALAvNames(node *ast.Node) (ret string) {
+ avIDs := parse.IAL2Map(node.KramdownIAL)[av.NodeAttrNameAvs]
+ if "" == avIDs {
+ return
+ }
- tpl := strings.ReplaceAll(attrAvNameTpl, "${avID}", nodeAvID)
- tpl = strings.ReplaceAll(tpl, "${avName}", nodeAvName)
- avNames.WriteString(tpl)
- avNames.WriteString(" ")
+ avNames := bytes.Buffer{}
+ nodeAvIDs := strings.Split(avIDs, ",")
+ for _, nodeAvID := range nodeAvIDs {
+ nodeAvName, getErr := av.GetAttributeViewName(nodeAvID)
+ if nil != getErr {
+ continue
}
- if 0 < avNames.Len() {
- avNames.Truncate(avNames.Len() - 6)
- node.SetIALAttr("av-names", avNames.String())
- pushBroadcastAttrTransactions(oldAttrs, node)
+ if "" == nodeAvName {
+ nodeAvName = "Untitled"
}
+
+ tpl := strings.ReplaceAll(attrAvNameTpl, "${avID}", nodeAvID)
+ tpl = strings.ReplaceAll(tpl, "${avName}", nodeAvName)
+ avNames.WriteString(tpl)
+ avNames.WriteString("&nbsp;")
+ }
+ if 0 < avNames.Len() {
+ avNames.Truncate(avNames.Len() - 6)
+ ret = avNames.String()
}
return
}
@@ -2053,6 +2056,11 @@ func addAttributeViewBlock(avID, blockID, previousBlockID, addingBlockID string,
attrs[av.NodeAttrNameAvs] = strings.Join(avIDs, ",")
}
+ avNames := getNodeIALAvNames(node)
+ if "" != avNames {
+ attrs["av-names"] = avNames
+ }
+
if nil != tx {
if err = setNodeAttrsWithTx(tx, node, tree, attrs); nil != err {
return