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/15659

Daniel920291d52bd8
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index 6b7051e969..fc93843c64 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -3032,7 +3032,7 @@ func addAttributeViewBlock(now int64, avID, dbBlockID, groupID, previousItemID,
var blockIcon string
if !isDetached {
- blockIcon, addingBlockContent = getNodeAvBlockText(node)
+ blockIcon, addingBlockContent = getNodeAvBlockText(node, "")
addingBlockContent = util.UnescapeHTML(addingBlockContent)
}
@@ -4278,7 +4278,7 @@ func replaceAttributeViewBlock0(attrView *av.AttributeView, oldBlockID, newBlock
if !isDetached && blockVal.Block.ID == newBlockID && nil != node && nil != tree {
bindBlockAv0(tx, avID, node, tree)
blockVal.IsDetached = false
- icon, content := getNodeAvBlockText(node)
+ icon, content := getNodeAvBlockText(node, "")
content = util.UnescapeHTML(content)
blockVal.Block.Icon, blockVal.Block.Content = icon, content
blockVal.UpdatedAt = now
@@ -4302,7 +4302,7 @@ func replaceAttributeViewBlock0(attrView *av.AttributeView, oldBlockID, newBlock
bindBlockAv(tx, avID, newBlockID)
blockVal.Block.ID = newBlockID
- icon, content := getNodeAvBlockText(node)
+ icon, content := getNodeAvBlockText(node, "")
content = util.UnescapeHTML(content)
blockVal.Block.Icon, blockVal.Block.Content = icon, content
@@ -4539,7 +4539,7 @@ func updateAttributeViewValue(tx *Transaction, attrView *av.AttributeView, keyID
} else { // 之前绑定的块和现在绑定的块一样
content := strings.TrimSpace(val.Block.Content)
node, tree, _ := getNodeByBlockID(tx, val.Block.ID)
- _, blockText := getNodeAvBlockText(node)
+ _, blockText := getNodeAvBlockText(node, "")
if "" == content {
// 使用动态锚文本
val.Block.Content = util.UnescapeHTML(blockText)
diff --git a/kernel/model/blockinfo.go b/kernel/model/blockinfo.go
index 859ef3caf1..365f2e32c4 100644
--- a/kernel/model/blockinfo.go
+++ b/kernel/model/blockinfo.go
@@ -288,7 +288,7 @@ func getNodeRefText(node *ast.Node) string {
return getNodeRefText0(node, Conf.Editor.BlockRefDynamicAnchorTextMaxLen, true)
}
-func getNodeAvBlockText(node *ast.Node) (icon, content string) {
+func getNodeAvBlockText(node *ast.Node, avID string) (icon, content string) {
if nil == node {
return
}
@@ -303,6 +303,11 @@ func getNodeAvBlockText(node *ast.Node) (icon, content string) {
}
content = strings.TrimSpace(content)
+ if "" != avID {
+ if staticText := node.IALAttr(av.NodeAttrViewStaticText + "-" + avID); "" != staticText {
+ content = staticText
+ }
+ }
if "" == content {
content = Conf.language(105)
}
diff --git a/kernel/model/push_reload.go b/kernel/model/push_reload.go
index 0b26c71066..384a18be94 100644
--- a/kernel/model/push_reload.go
+++ b/kernel/model/push_reload.go
@@ -310,7 +310,7 @@ func updateAttributeViewBlockText(updatedDefNodes map[string]*ast.Node) {
for _, blockValue := range blockValues.Values {
if blockValue.Block.ID == updatedDefNode.ID {
- newIcon, newContent := getNodeAvBlockText(updatedDefNode)
+ newIcon, newContent := getNodeAvBlockText(updatedDefNode, avID)
if newIcon != blockValue.Block.Icon {
blockValue.Block.Icon = newIcon
changedAv = true