🎨 Use ID when block ref anchor text is empty https://github.com/siyuan-note/siyuan/issues/13606

This commit is contained in:
Daniel 2024-12-25 17:38:54 +08:00
parent 929d079bc3
commit e4fb91d56f
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 5 additions and 2 deletions

View file

@ -354,7 +354,7 @@ func RenderTemplate(p, id string, preview bool) (tree *parse.Tree, dom string, e
// 块引缺失锚文本情况下自动补全 https://github.com/siyuan-note/siyuan/issues/6087
if n.IsTextMarkType("block-ref") {
if refText := n.Text(); "" == refText {
refText = sql.GetRefText(n.TextMarkBlockRefID)
refText = strings.TrimSpace(sql.GetRefText(n.TextMarkBlockRefID))
if "" != refText {
treenode.SetDynamicBlockRefText(n, refText)
} else {

View file

@ -1619,7 +1619,10 @@ func updateRefText(refNode *ast.Node, changedDefNodes map[string]*ast.Node) (cha
changed = true
if "d" == subtype {
refText = getNodeRefText(defNode)
refText = strings.TrimSpace(getNodeRefText(defNode))
if "" == refText {
refText = n.TextMarkBlockRefID
}
treenode.SetDynamicBlockRefText(n, refText)
}
defNodes = append(defNodes, &changedDefNode{id: defID, refText: refText, refType: "ref-" + subtype})