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
Daniel18390572b58c
diff --git a/kernel/av/cell.go b/kernel/av/cell.goindex e97859722c..27cea27179 100644--- a/kernel/av/cell.go+++ b/kernel/av/cell.go@@ -19,24 +19,24 @@ package avimport ("github.com/88250/gulu""github.com/88250/lute/ast"+ "time")type Cell struct {- ID string `json:"id"`- Value *Value `json:"value"`- ValueType ColumnType `json:"valueType"`- RenderValue interface{} `json:"renderValue"`- Color string `json:"color"`- BgColor string `json:"bgColor"`+ ID string `json:"id"`+ Value *Value `json:"value"`+ ValueType ColumnType `json:"valueType"`+ Color string `json:"color"`+ BgColor string `json:"bgColor"`}type Value struct {- Block string `json:"block"`- Text string `json:"text"`- Number float64 `json:"number"`- Date string `json:"date"`- Select string `json:"select"`- MSelect []string `json:"mSelect"`+ Block *ValueBlock `json:"block"`+ Text *ValueText `json:"text"`+ Number *ValueNumber `json:"number"`+ Date *ValueDate `json:"date"`+ Select *ValueSelect `json:"select"`+ MSelect []*ValueSelect `json:"mSelect"`}func (value *Value) ToJSONString() string {@@ -49,10 +49,9 @@ func (value *Value) ToJSONString() string {func NewCellBlock(blockID, blockContent string) *Cell {return &Cell{- ID: ast.NewNodeID(),- Value: &Value{Block: blockID},- ValueType: ColumnTypeBlock,- RenderValue: &RenderValueBlock{ID: blockID, Content: blockContent},+ ID: ast.NewNodeID(),+ Value: &Value{Block: &ValueBlock{ID: blockID, Content: blockContent}},+ ValueType: ColumnTypeBlock,}}@@ -63,7 +62,23 @@ func NewCell(valueType ColumnType) *Cell {}}-type RenderValueBlock struct {+type ValueBlock struct {ID string `json:"id"`Content string `json:"content"`}++type ValueText struct {+ Content string `json:"content"`+}++type ValueNumber struct {+ Content float64 `json:"content"`+}++type ValueDate struct {+ Content time.Time `json:"content"`+}++type ValueSelect struct {+ Content string `json:"content"`+}diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex 7373b01eb2..491a140449 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -89,7 +89,7 @@ func (tx *Transaction) doUpdateAttrViewCell(operation *Operation) (ret *TxErr) {continue}- blockID = row.Cells[0].Value.Block+ blockID = row.Cells[0].Value.Block.IDfor _, cell := range row.Cells[1:] {if cell.ID == operation.ID {c = cell@@ -121,7 +121,6 @@ func (tx *Transaction) doUpdateAttrViewCell(operation *Operation) (ret *TxErr) {return}- c.RenderValue = operation.Dataattrs := parse.IAL2Map(node.KramdownIAL)attrs[NodeAttrNamePrefixAvCol+avID+"-"+c.ID] = c.Value.ToJSONString()if err = setNodeAttrsWithTx(tx, node, tree, attrs); nil != err {@@ -229,6 +228,14 @@ func (tx *Transaction) doSortAttrViewColumn(operation *Operation) (ret *TxErr) {return}+func (tx *Transaction) doSortAttrViewRow(operation *Operation) (ret *TxErr) {+ err := sortAttributeViewRow(operation.ID, operation.PreviousID, operation.ParentID)+ if nil != err {+ return &TxErr{code: TxErrWriteAttributeView, id: operation.ParentID, msg: err.Error()}+ }+ return+}+func addAttributeViewColumn(name string, typ string, avID string) (err error) {attrView, err := av.ParseAttributeView(avID)if nil != err {@@ -340,6 +347,35 @@ func sortAttributeViewColumn(columnID, previousColumnID, avID string) (err errorreturn}+func sortAttributeViewRow(rowID, previousRowID, avID string) (err error) {+ attrView, err := av.ParseAttributeView(avID)+ if nil != err {+ return+ }++ var row *av.Row+ var index, previousIndex int+ for i, r := range attrView.Rows {+ if r.ID == rowID {+ row = r+ index = i+ break+ }+ if r.ID == previousRowID {+ previousIndex = i+ }+ }+ if nil == row {+ return+ }++ attrView.Rows = append(attrView.Rows[:index], attrView.Rows[index+1:]...)+ attrView.Rows = append(attrView.Rows[:previousIndex], append([]*av.Row{row}, attrView.Rows[previousIndex:]...)...)++ err = av.SaveAttributeView(attrView)+ return+}+func removeAttributeViewBlock(blockID, avID string, tree *parse.Tree) (ret *av.AttributeView, err error) {node := treenode.GetNodeInTree(tree, blockID)if nil == node {@@ -353,7 +389,7 @@ func removeAttributeViewBlock(blockID, avID string, tree *parse.Tree) (ret *av.A}for i, row := range ret.Rows {- if row.Cells[0].Value.Block == blockID {+ if row.Cells[0].Value.Block.ID == blockID {// 从行中移除,但是不移除属性ret.Rows = append(ret.Rows[:i], ret.Rows[i+1:]...)break@@ -389,7 +425,7 @@ func addAttributeViewBlock(blockID, previousRowID, avID string, tree *parse.Tree// 不允许重复添加相同的块到属性视图中for _, row := range ret.Rows {- if row.Cells[0].Value.Block == blockID {+ if row.Cells[0].Value.Block.ID == blockID {return}}diff --git a/kernel/model/transaction.go b/kernel/model/transaction.goindex ab78b8331e..6e360bfb97 100644--- a/kernel/model/transaction.go+++ b/kernel/model/transaction.go@@ -230,6 +230,8 @@ func performTx(tx *Transaction) (ret *TxErr) {ret = tx.doSortAttrViewColumn(op)case "updateAttrViewCell":ret = tx.doUpdateAttrViewCell(op)+ case "sortAttrViewRow":+ ret = tx.doSortAttrViewRow(op)}if nil != ret {