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
Daniel54799578d7c4
diff --git a/kernel/av/av.go b/kernel/av/av.goindex 53dd76358a..72970b8d0d 100644--- a/kernel/av/av.go+++ b/kernel/av/av.go@@ -202,6 +202,5 @@ func RebuildAttributeViewTable(tx *sql.Tx, av *AttributeView) (err error) {return}}-return}diff --git a/kernel/av/cell.go b/kernel/av/cell.goindex e7dd26c34c..c7c06c567f 100644--- a/kernel/av/cell.go+++ b/kernel/av/cell.go@@ -17,8 +17,9 @@package avtype Cell struct {- ID string `json:"id"`- Value string `json:"value"`- Color string `json:"color"`- BgColor string `json:"bgColor"`+ ID string `json:"id"`+ Value string `json:"value"`+ RenderValue interface{} `json:"renderValue"`+ Color string `json:"color"`+ BgColor string `json:"bgColor"`}diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex cf0e2a85d8..8696a51801 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -39,6 +39,60 @@ func RenderAttributeView(avID string) (ret *av.AttributeView, err error) {return}+func (tx *Transaction) doUpdateAttrViewCell(operation *Operation) (ret *TxErr) {+ avID := operation.ParentID+ view, err := av.ParseAttributeView(avID)+ if nil != err {+ logging.LogErrorf("parse attribute view [%s] failed: %s", avID, err)+ return &TxErr{code: TxErrCodeBlockNotFound, id: avID, msg: err.Error()}+ }++ var c *av.Cell+ var blockID string+ for _, row := range view.Rows {+ if row.ID != operation.RowID {+ continue+ }++ blockID = row.Cells[0].Value+ for _, cell := range row.Cells[1:] {+ if cell.ID == operation.ID {+ c = cell+ break+ }+ }+ break+ }++ if nil == c {+ return+ }++ tree, err := tx.loadTree(blockID)+ if nil != err {+ return+ }++ node := treenode.GetNodeInTree(tree, blockID)+ if nil == node {+ return+ }++ c.Value = parseCellData(operation.Data, av.ColumnType(operation.Typ))+ attrs := parse.IAL2Map(node.KramdownIAL)+ attrs["av"+c.ID] = c.Value+ if err = setNodeAttrsWithTx(tx, node, tree, attrs); nil != err {+ return+ }++ if err = av.SaveAttributeView(view); nil != err {+ return+ }++ sql.RebuildAttributeViewQueue(view)+ return+}+func (tx *Transaction) doInsertAttrViewBlock(operation *Operation) (ret *TxErr) {firstSrcID := operation.SrcIDs[0]tree, err := tx.loadTree(firstSrcID)@@ -224,3 +278,11 @@ func addAttributeViewBlock(blockID, avID string, tree *parse.Tree, tx *Transactierr = av.SaveAttributeView(ret)return}++func parseCellData(data interface{}, colType av.ColumnType) string {+ switch colType {+ case av.ColumnTypeText:+ return data.(string)+ }+ return ""+}diff --git a/kernel/model/transaction.go b/kernel/model/transaction.goindex 9ceda2f83b..954cbc3440 100644--- a/kernel/model/transaction.go+++ b/kernel/model/transaction.go@@ -224,6 +224,8 @@ func performTx(tx *Transaction) (ret *TxErr) {ret = tx.doAddAttrViewColumn(op)case "removeAttrViewCol":ret = tx.doRemoveAttrViewColumn(op)+ case "updateAttrViewCell":+ ret = tx.doUpdateAttrViewCell(op)}if nil != ret {@@ -1026,6 +1028,7 @@ type Operation struct {SrcIDs []string `json:"srcIDs"` // 用于将块拖拽到属性视图中Name string `json:"name"` // 用于属性视图列名Typ string `json:"type"` // 用于属性视图列类型+ RowID string `json:"rowID"` // 用于属性视图行 IDdiscard bool // 用于标识是否在事务合并中丢弃}