Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve database exporting for asset field https://github.com/siyuan-note/siyuan/issues/12484

Daniel7e19a77ccbc8
diff --git a/kernel/model/export.go b/kernel/model/export.go
index 5a1b8138ed..5048ccb304 100644
--- a/kernel/model/export.go
+++ b/kernel/model/export.go
@@ -2341,7 +2341,7 @@ func exportTree(tree *parse.Tree, wysiwyg, keepFold, avHiddenCol bool,
}
} else if av.KeyTypeMAsset == cell.Value.Type {
if nil != cell.Value.MAsset {
- for _, a := range cell.Value.MAsset {
+ for i, a := range cell.Value.MAsset {
if av.AssetTypeImage == a.Type {
img := &ast.Node{Type: ast.NodeImage}
img.AppendChild(&ast.Node{Type: ast.NodeBang})
@@ -2355,13 +2355,20 @@ func exportTree(tree *parse.Tree, wysiwyg, keepFold, avHiddenCol bool,
} else if av.AssetTypeFile == a.Type {
file := &ast.Node{Type: ast.NodeLink}
file.AppendChild(&ast.Node{Type: ast.NodeOpenBracket})
- file.AppendChild(&ast.Node{Type: ast.NodeLinkText, Tokens: []byte(a.Name)})
+ linkText := strings.TrimSpace(a.Name)
+ if "" == linkText {
+ linkText = a.Content
+ }
+ file.AppendChild(&ast.Node{Type: ast.NodeLinkText, Tokens: []byte(linkText)})
file.AppendChild(&ast.Node{Type: ast.NodeCloseBracket})
file.AppendChild(&ast.Node{Type: ast.NodeOpenParen})
file.AppendChild(&ast.Node{Type: ast.NodeLinkDest, Tokens: []byte(a.Content)})
file.AppendChild(&ast.Node{Type: ast.NodeCloseParen})
mdTableCell.AppendChild(file)
}
+ if i < len(cell.Value.MAsset)-1 {
+ mdTableCell.AppendChild(&ast.Node{Type: ast.NodeText, Tokens: []byte(" ")})
+ }
}
continue
}