An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Update av
Daniel42f9c6e65749
diff --git a/kernel/av/cell.go b/kernel/av/cell.goindex 9a25334884..8eac479f08 100644--- a/kernel/av/cell.go+++ b/kernel/av/cell.go@@ -17,14 +17,21 @@package avtype Cell struct {- ID string `json:"id"`- Value *CellValue `json:"value"`- RenderValue interface{} `json:"renderValue"`- Color string `json:"color"`- BgColor string `json:"bgColor"`+ ID string `json:"id"`+ Value *CellValue `json:"value"`+ Color string `json:"color"`+ BgColor string `json:"bgColor"`}type CellValue struct {- Type ColumnType `json:"type"`- Value interface{} `json:"value"`+ Type ColumnType `json:"type"`+ Data interface{} `json:"data"`+}++func (v *CellValue) String() string {+ switch v.Type {+ case ColumnTypeText:+ return v.Data.(string)+ }+ return v.Data.(string)}diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex a5896847cb..1737d1a712 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -56,7 +56,7 @@ func (tx *Transaction) doUpdateAttrViewCell(operation *Operation) (ret *TxErr) {continue}- blockID = row.Cells[0].Value+ blockID = row.Cells[0].Value.String()for _, cell := range row.Cells[1:] {if cell.ID == operation.ID {c = cell@@ -80,9 +80,9 @@ func (tx *Transaction) doUpdateAttrViewCell(operation *Operation) (ret *TxErr) {return}- c.Value = parseCellData(operation.Data, av.ColumnType(operation.Typ))+ c.Value.Data = operation.Dataattrs := parse.IAL2Map(node.KramdownIAL)- attrs[NodeAttrNamePrefixAvCol+c.ID] = c.Value+ attrs[NodeAttrNamePrefixAvCol+c.ID] = c.Value.String()if err = setNodeAttrsWithTx(tx, node, tree, attrs); nil != err {return}@@ -183,7 +183,7 @@ func addAttributeViewColumn(name string, typ string, avID string) (err error) {col := &av.Column{ID: "av" + ast.NewNodeID(), Name: name, Type: colType}attrView.Columns = append(attrView.Columns, col)for _, row := range attrView.Rows {- row.Cells = append(row.Cells, &av.Cell{ID: ast.NewNodeID()})+ row.Cells = append(row.Cells, &av.Cell{ID: ast.NewNodeID(), Value: &av.CellValue{Type: colType}})}default:msg := fmt.Sprintf("invalid column type [%s]", typ)@@ -233,7 +233,7 @@ func removeAttributeViewBlock(blockID, avID string, tree *parse.Tree) (ret *av.A}for i, row := range ret.Rows {- if row.Cells[0].Value == blockID {+ if row.Cells[0].Value.String() == blockID {// 从行中移除,但是不移除属性ret.Rows = append(ret.Rows[:i], ret.Rows[i+1:]...)break@@ -269,18 +269,18 @@ func addAttributeViewBlock(blockID, avID string, tree *parse.Tree, tx *Transacti// 不允许重复添加相同的块到属性视图中for _, row := range ret.Rows {- if row.Cells[0].Value == blockID {+ if row.Cells[0].Value.String() == blockID {return}}row := av.NewRow()- row.Cells = append(row.Cells, &av.Cell{ID: ast.NewNodeID(), Value: blockID})+ row.Cells = append(row.Cells, &av.Cell{ID: ast.NewNodeID(), Value: &av.CellValue{Type: av.ColumnTypeBlock, Data: blockID}})if 1 < len(ret.Columns) {attrs := parse.IAL2Map(node.KramdownIAL)for _, col := range ret.Columns[1:] {attrs[NodeAttrNamePrefixAvCol+col.ID] = "" // 将列作为属性添加到块中- row.Cells = append(row.Cells, &av.Cell{ID: ast.NewNodeID()})+ row.Cells = append(row.Cells, &av.Cell{ID: ast.NewNodeID(), Value: &av.CellValue{Type: col.Type}})}if err = setNodeAttrsWithTx(tx, node, tree, attrs); nil != err {