mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Display the database title on the block superscript https://github.com/siyuan-note/siyuan/issues/10545
This commit is contained in:
parent
09b23754db
commit
c61d412fea
1 changed files with 34 additions and 26 deletions
|
|
@ -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(" ")
|
||||
}
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue