Skip to content

Commit

Permalink
🎨 Improve database exporting for asset field #12484
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Sep 15, 2024
1 parent 6d8319b commit 7e19a77
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions kernel/model/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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
}
Expand Down

0 comments on commit 7e19a77

Please sign in to comment.