mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-21 19:41:05 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
cad51d7554
@ -109,6 +109,33 @@ type Value struct {
|
|||||||
Phone *ValuePhone `json:"phone,omitempty"`
|
Phone *ValuePhone `json:"phone,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (value *Value) String() string {
|
||||||
|
switch value.Type {
|
||||||
|
case KeyTypeBlock:
|
||||||
|
return value.Block.Content
|
||||||
|
case KeyTypeText:
|
||||||
|
return value.Text.Content
|
||||||
|
case KeyTypeNumber:
|
||||||
|
return value.Number.FormattedContent
|
||||||
|
case KeyTypeDate:
|
||||||
|
return value.Date.FormattedContent
|
||||||
|
case KeyTypeMSelect:
|
||||||
|
var ret []string
|
||||||
|
for _, v := range value.MSelect {
|
||||||
|
ret = append(ret, v.Content)
|
||||||
|
}
|
||||||
|
return strings.Join(ret, " ")
|
||||||
|
case KeyTypeURL:
|
||||||
|
return value.URL.Content
|
||||||
|
case KeyTypeEmail:
|
||||||
|
return value.Email.Content
|
||||||
|
case KeyTypePhone:
|
||||||
|
return value.Phone.Content
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (value *Value) ToJSONString() string {
|
func (value *Value) ToJSONString() string {
|
||||||
data, err := gulu.JSON.MarshalJSON(value)
|
data, err := gulu.JSON.MarshalJSON(value)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
|
@ -46,6 +46,7 @@ import (
|
|||||||
"github.com/siyuan-note/filelock"
|
"github.com/siyuan-note/filelock"
|
||||||
"github.com/siyuan-note/httpclient"
|
"github.com/siyuan-note/httpclient"
|
||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
|
"github.com/siyuan-note/siyuan/kernel/av"
|
||||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
"github.com/siyuan-note/siyuan/kernel/filesys"
|
||||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||||
@ -1786,6 +1787,86 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros, keepFold bool,
|
|||||||
for _, emptyParagraph := range emptyParagraphs {
|
for _, emptyParagraph := range emptyParagraphs {
|
||||||
emptyParagraph.AppendChild(&ast.Node{Type: ast.NodeText, Tokens: []byte(editor.Zwj)})
|
emptyParagraph.AppendChild(&ast.Node{Type: ast.NodeText, Tokens: []byte(editor.Zwj)})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unlinks = nil
|
||||||
|
// Attribute View export https://github.com/siyuan-note/siyuan/issues/8710
|
||||||
|
ast.Walk(ret.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||||
|
if !entering {
|
||||||
|
return ast.WalkContinue
|
||||||
|
}
|
||||||
|
|
||||||
|
if ast.NodeAttributeView != n.Type {
|
||||||
|
return ast.WalkContinue
|
||||||
|
}
|
||||||
|
|
||||||
|
avID := n.AttributeViewID
|
||||||
|
if avJSONPath := av.GetAttributeViewDataPath(avID); !gulu.File.IsExist(avJSONPath) {
|
||||||
|
return ast.WalkContinue
|
||||||
|
}
|
||||||
|
|
||||||
|
attrView, err := av.ParseAttributeView(avID)
|
||||||
|
if nil != err {
|
||||||
|
logging.LogErrorf("parse attribute view [%s] failed: %s", avID, err)
|
||||||
|
return ast.WalkContinue
|
||||||
|
}
|
||||||
|
|
||||||
|
var view *av.View
|
||||||
|
if "" != attrView.ViewID {
|
||||||
|
for _, v := range attrView.Views {
|
||||||
|
if v.ID == attrView.ViewID {
|
||||||
|
view = v
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
view = attrView.Views[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
table, err := renderAttributeViewTable(attrView, view)
|
||||||
|
if nil != err {
|
||||||
|
logging.LogErrorf("render attribute view [%s] table failed: %s", avID, err)
|
||||||
|
return ast.WalkContinue
|
||||||
|
}
|
||||||
|
|
||||||
|
var aligns []int
|
||||||
|
for range table.Columns {
|
||||||
|
aligns = append(aligns, 0)
|
||||||
|
}
|
||||||
|
mdTable := &ast.Node{Type: ast.NodeTable, TableAligns: aligns}
|
||||||
|
mdTableHead := &ast.Node{Type: ast.NodeTableHead}
|
||||||
|
mdTable.AppendChild(mdTableHead)
|
||||||
|
mdTableHeadRow := &ast.Node{Type: ast.NodeTableRow, TableAligns: aligns}
|
||||||
|
mdTableHead.AppendChild(mdTableHeadRow)
|
||||||
|
for _, col := range table.Columns {
|
||||||
|
cell := &ast.Node{Type: ast.NodeTableCell}
|
||||||
|
cell.AppendChild(&ast.Node{Type: ast.NodeText, Tokens: []byte(col.Name)})
|
||||||
|
mdTableHeadRow.AppendChild(cell)
|
||||||
|
}
|
||||||
|
for _, row := range table.Rows {
|
||||||
|
mdTableRow := &ast.Node{Type: ast.NodeTableRow, TableAligns: aligns}
|
||||||
|
mdTable.AppendChild(mdTableRow)
|
||||||
|
for _, cell := range row.Cells {
|
||||||
|
mdTableCell := &ast.Node{Type: ast.NodeTableCell}
|
||||||
|
mdTableRow.AppendChild(mdTableCell)
|
||||||
|
var val string
|
||||||
|
if nil != cell.Value {
|
||||||
|
if av.KeyTypeDate == cell.Value.Type && nil != cell.Value.Date {
|
||||||
|
cell.Value.Date = av.NewFormattedValueDate(cell.Value.Date.Content, cell.Value.Date.Content2, av.DateFormatNone)
|
||||||
|
}
|
||||||
|
|
||||||
|
val = cell.Value.String()
|
||||||
|
}
|
||||||
|
mdTableCell.AppendChild(&ast.Node{Type: ast.NodeText, Tokens: []byte(val)})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
n.InsertBefore(mdTable)
|
||||||
|
unlinks = append(unlinks, n)
|
||||||
|
return ast.WalkContinue
|
||||||
|
})
|
||||||
|
for _, n := range unlinks {
|
||||||
|
n.Unlink()
|
||||||
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user