This commit is contained in:
Liang Ding 2023-03-03 10:49:45 +08:00
parent d3f8da753b
commit a78f0d4b78
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
11 changed files with 28 additions and 184 deletions

View file

@ -20,6 +20,7 @@ import (
"errors"
"fmt"
"github.com/88250/lute/ast"
"github.com/88250/lute/parse"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/av"
@ -69,7 +70,7 @@ func AddAttributeViewColumn(name string, typ string, columnIndex int, avID strin
switch av.ColumnType(typ) {
case av.ColumnTypeText:
attrView.InsertColumn(columnIndex, av.NewColumnText(name))
attrView.InsertColumn(columnIndex, &av.Column{ID: ast.NewNodeID(), Name: name, Type: av.ColumnTypeText})
default:
msg := fmt.Sprintf("invalid column type [%s]", typ)
logging.LogErrorf(msg)
@ -94,7 +95,7 @@ func removeAttributeViewBlock(blockID, avID string, tree *parse.Tree) (err error
}
for i, row := range attrView.Rows {
if row.Cells[0].(*av.Cell).Value == blockID {
if row.Cells[0].Value == blockID {
attrView.Rows = append(attrView.Rows[:i], attrView.Rows[i+1:]...)
break
}
@ -124,18 +125,18 @@ func addAttributeViewBlock(blockID, avID string, tree *parse.Tree) (err error) {
// 不允许重复添加相同的块到属性视图中
for _, row := range attrView.Rows {
if row.Cells[0].(*av.Cell).Value == blockID {
if row.Cells[0].Value == blockID {
return
}
}
row := av.NewRow()
row.Cells = append(row.Cells, av.NewCellBlock(block.ID))
row.Cells = append(row.Cells, &av.Cell{Value: blockID})
if 1 < len(attrView.Columns) {
attrs := parse.IAL2Map(node.KramdownIAL)
for _, col := range attrView.Columns[1:] {
colName := col.(*av.Column).Name
colName := col.Name
attrs[colName] = ""
}