mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🎨 Update av
This commit is contained in:
parent
b0dc75b3c4
commit
4bc4684163
2 changed files with 7 additions and 3 deletions
|
|
@ -35,6 +35,7 @@ import (
|
||||||
type AttributeView struct {
|
type AttributeView struct {
|
||||||
Spec int `json:"spec"`
|
Spec int `json:"spec"`
|
||||||
ID string `json:"id"` // 属性视图 ID
|
ID string `json:"id"` // 属性视图 ID
|
||||||
|
Name string `json:"name"` // 属性视图名称
|
||||||
Columns []*Column `json:"columns"` // 表格列名
|
Columns []*Column `json:"columns"` // 表格列名
|
||||||
Rows []*Row `json:"rows"` // 表格行记录
|
Rows []*Row `json:"rows"` // 表格行记录
|
||||||
|
|
||||||
|
|
@ -55,6 +56,7 @@ func NewAttributeView(id string) *AttributeView {
|
||||||
return &AttributeView{
|
return &AttributeView{
|
||||||
Spec: 0,
|
Spec: 0,
|
||||||
ID: id,
|
ID: id,
|
||||||
|
Name: "Table",
|
||||||
Columns: []*Column{{ID: ast.NewNodeID(), Name: "Block", Type: ColumnTypeBlock}},
|
Columns: []*Column{{ID: ast.NewNodeID(), Name: "Block", Type: ColumnTypeBlock}},
|
||||||
Rows: []*Row{},
|
Rows: []*Row{},
|
||||||
Type: AttributeViewTypeTable,
|
Type: AttributeViewTypeTable,
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ func (tx *Transaction) doUpdateAttrViewCell(operation *Operation) (ret *TxErr) {
|
||||||
|
|
||||||
c.Value = parseCellData(operation.Data, av.ColumnType(operation.Typ))
|
c.Value = parseCellData(operation.Data, av.ColumnType(operation.Typ))
|
||||||
attrs := parse.IAL2Map(node.KramdownIAL)
|
attrs := parse.IAL2Map(node.KramdownIAL)
|
||||||
attrs["av"+c.ID] = c.Value
|
attrs[NodeAttrNamePrefixAvCol+c.ID] = c.Value
|
||||||
if err = setNodeAttrsWithTx(tx, node, tree, attrs); nil != err {
|
if err = setNodeAttrsWithTx(tx, node, tree, attrs); nil != err {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -279,8 +279,8 @@ func addAttributeViewBlock(blockID, avID string, tree *parse.Tree, tx *Transacti
|
||||||
if 1 < len(ret.Columns) {
|
if 1 < len(ret.Columns) {
|
||||||
attrs := parse.IAL2Map(node.KramdownIAL)
|
attrs := parse.IAL2Map(node.KramdownIAL)
|
||||||
for _, col := range ret.Columns[1:] {
|
for _, col := range ret.Columns[1:] {
|
||||||
attrs["av"+col.ID] = "" // 将列作为属性添加到块中
|
attrs[NodeAttrNamePrefixAvCol+col.ID] = "" // 将列作为属性添加到块中
|
||||||
row.Cells = append(row.Cells, &av.Cell{ID: ast.NewNodeID(), Value: ""})
|
row.Cells = append(row.Cells, &av.Cell{ID: ast.NewNodeID()})
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = setNodeAttrsWithTx(tx, node, tree, attrs); nil != err {
|
if err = setNodeAttrsWithTx(tx, node, tree, attrs); nil != err {
|
||||||
|
|
@ -300,3 +300,5 @@ func parseCellData(data interface{}, colType av.ColumnType) string {
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const NodeAttrNamePrefixAvCol = "av-col-"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue