🎨 Improve database exporting for asset field https://github.com/siyuan-note/siyuan/issues/12484
This commit is contained in:
parent
7e19a77ccb
commit
53d5423770
1 changed files with 27 additions and 8 deletions
|
@ -2339,6 +2339,20 @@ func exportTree(tree *parse.Tree, wysiwyg, keepFold, avHiddenCol bool,
|
|||
if nil != cell.Value.Updated {
|
||||
cell.Value.Updated = av.NewFormattedValueUpdated(cell.Value.Updated.Content, 0, av.UpdatedFormatNone)
|
||||
}
|
||||
} else if av.KeyTypeURL == cell.Value.Type {
|
||||
if nil != cell.Value.URL {
|
||||
if "" != strings.TrimSpace(cell.Value.URL.Content) {
|
||||
link := &ast.Node{Type: ast.NodeLink}
|
||||
link.AppendChild(&ast.Node{Type: ast.NodeOpenBracket})
|
||||
link.AppendChild(&ast.Node{Type: ast.NodeLinkText, Tokens: []byte(cell.Value.URL.Content)})
|
||||
link.AppendChild(&ast.Node{Type: ast.NodeCloseBracket})
|
||||
link.AppendChild(&ast.Node{Type: ast.NodeOpenParen})
|
||||
link.AppendChild(&ast.Node{Type: ast.NodeLinkDest, Tokens: []byte(cell.Value.URL.Content)})
|
||||
link.AppendChild(&ast.Node{Type: ast.NodeCloseParen})
|
||||
mdTableCell.AppendChild(link)
|
||||
}
|
||||
continue
|
||||
}
|
||||
} else if av.KeyTypeMAsset == cell.Value.Type {
|
||||
if nil != cell.Value.MAsset {
|
||||
for i, a := range cell.Value.MAsset {
|
||||
|
@ -2353,18 +2367,23 @@ func exportTree(tree *parse.Tree, wysiwyg, keepFold, avHiddenCol bool,
|
|||
img.AppendChild(&ast.Node{Type: ast.NodeCloseParen})
|
||||
mdTableCell.AppendChild(img)
|
||||
} else if av.AssetTypeFile == a.Type {
|
||||
file := &ast.Node{Type: ast.NodeLink}
|
||||
file.AppendChild(&ast.Node{Type: ast.NodeOpenBracket})
|
||||
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 "" != strings.TrimSpace(a.Content) {
|
||||
file := &ast.Node{Type: ast.NodeLink}
|
||||
file.AppendChild(&ast.Node{Type: ast.NodeOpenBracket})
|
||||
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)
|
||||
} else {
|
||||
mdTableCell.AppendChild(&ast.Node{Type: ast.NodeText, Tokens: []byte(linkText)})
|
||||
}
|
||||
}
|
||||
if i < len(cell.Value.MAsset)-1 {
|
||||
mdTableCell.AppendChild(&ast.Node{Type: ast.NodeText, Tokens: []byte(" ")})
|
||||
|
|
Loading…
Add table
Reference in a new issue