mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-03 00:00:38 +08:00
🎨 The database primary key field displays the icon of the bound doc https://github.com/siyuan-note/siyuan/issues/13378
This commit is contained in:
parent
dbdf3c15a9
commit
807f0df86f
@ -371,6 +371,7 @@ func (value *Value) GetValByType(typ KeyType) (ret interface{}) {
|
|||||||
|
|
||||||
type ValueBlock struct {
|
type ValueBlock struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
|
Icon string `json:"icon"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
Created int64 `json:"created"`
|
Created int64 `json:"created"`
|
||||||
Updated int64 `json:"updated"`
|
Updated int64 `json:"updated"`
|
||||||
|
@ -1980,8 +1980,9 @@ func addAttributeViewBlock(now int64, avID, blockID, previousBlockID, addingBloc
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var blockIcon string
|
||||||
if !isDetached {
|
if !isDetached {
|
||||||
addingBlockContent = getNodeAvBlockText(node)
|
blockIcon, addingBlockContent = getNodeAvBlockText(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否重复添加相同的块
|
// 检查是否重复添加相同的块
|
||||||
@ -1992,6 +1993,7 @@ func addAttributeViewBlock(now int64, avID, blockID, previousBlockID, addingBloc
|
|||||||
// 重复绑定一下,比如剪切数据库块、取消绑定块后再次添加的场景需要
|
// 重复绑定一下,比如剪切数据库块、取消绑定块后再次添加的场景需要
|
||||||
bindBlockAv0(tx, avID, node, tree)
|
bindBlockAv0(tx, avID, node, tree)
|
||||||
blockValue.IsDetached = isDetached
|
blockValue.IsDetached = isDetached
|
||||||
|
blockValue.Block.Icon = blockIcon
|
||||||
blockValue.Block.Content = addingBlockContent
|
blockValue.Block.Content = addingBlockContent
|
||||||
blockValue.UpdatedAt = now
|
blockValue.UpdatedAt = now
|
||||||
err = av.SaveAttributeView(attrView)
|
err = av.SaveAttributeView(attrView)
|
||||||
@ -2936,7 +2938,7 @@ func replaceAttributeViewBlock(operation *Operation, tx *Transaction) (err error
|
|||||||
if !operation.IsDetached {
|
if !operation.IsDetached {
|
||||||
bindBlockAv0(tx, operation.AvID, node, tree)
|
bindBlockAv0(tx, operation.AvID, node, tree)
|
||||||
value.IsDetached = false
|
value.IsDetached = false
|
||||||
value.Block.Content = getNodeAvBlockText(node)
|
value.Block.Icon, value.Block.Content = getNodeAvBlockText(node)
|
||||||
value.UpdatedAt = now
|
value.UpdatedAt = now
|
||||||
err = av.SaveAttributeView(attrView)
|
err = av.SaveAttributeView(attrView)
|
||||||
}
|
}
|
||||||
@ -2973,7 +2975,7 @@ func replaceAttributeViewBlock(operation *Operation, tx *Transaction) (err error
|
|||||||
value.Block.ID = operation.NextID
|
value.Block.ID = operation.NextID
|
||||||
value.IsDetached = operation.IsDetached
|
value.IsDetached = operation.IsDetached
|
||||||
if !operation.IsDetached {
|
if !operation.IsDetached {
|
||||||
value.Block.Content = getNodeAvBlockText(node)
|
value.Block.Icon, value.Block.Content = getNodeAvBlockText(node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,22 +268,19 @@ func getNodeRefText(node *ast.Node) string {
|
|||||||
return getNodeRefText0(node, Conf.Editor.BlockRefDynamicAnchorTextMaxLen)
|
return getNodeRefText0(node, Conf.Editor.BlockRefDynamicAnchorTextMaxLen)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getNodeAvBlockText(node *ast.Node) (ret string) {
|
func getNodeAvBlockText(node *ast.Node) (icon, content string) {
|
||||||
if nil == node {
|
if nil == node {
|
||||||
return ""
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
icon = node.IALAttr("icon")
|
||||||
if name := node.IALAttr("name"); "" != name {
|
if name := node.IALAttr("name"); "" != name {
|
||||||
name = strings.TrimSpace(name)
|
name = strings.TrimSpace(name)
|
||||||
name = util.EscapeHTML(name)
|
name = util.EscapeHTML(name)
|
||||||
ret = name
|
content = name
|
||||||
} else {
|
} else {
|
||||||
ret = getNodeRefText0(node, 1024)
|
content = getNodeRefText0(node, 1024)
|
||||||
}
|
}
|
||||||
|
|
||||||
//if icon := node.IALAttr("icon"); "" != icon {
|
|
||||||
// ret = icon + " " + ret
|
|
||||||
//}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +269,11 @@ func refreshDynamicRefTexts(updatedDefNodes map[string]*ast.Node, updatedTrees m
|
|||||||
|
|
||||||
for _, blockValue := range blockValues.Values {
|
for _, blockValue := range blockValues.Values {
|
||||||
if blockValue.Block.ID == updatedDefNode.ID {
|
if blockValue.Block.ID == updatedDefNode.ID {
|
||||||
newContent := getNodeAvBlockText(updatedDefNode)
|
newIcon, newContent := getNodeAvBlockText(updatedDefNode)
|
||||||
|
if newIcon != blockValue.Block.Icon {
|
||||||
|
blockValue.Block.Icon = newIcon
|
||||||
|
changedAv = true
|
||||||
|
}
|
||||||
if newContent != blockValue.Block.Content {
|
if newContent != blockValue.Block.Content {
|
||||||
blockValue.Block.Content = newContent
|
blockValue.Block.Content = newContent
|
||||||
changedAv = true
|
changedAv = true
|
||||||
|
Loading…
Reference in New Issue
Block a user