This commit is contained in:
Daniel 2025-08-23 18:31:28 +08:00
parent 39e2b7adf6
commit 920291d52b
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 11 additions and 6 deletions

View file

@ -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)

View file

@ -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)
}

View file

@ -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