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: 持久化属性视图 https://github.com/siyuan-note/siyuan/issues/2829
Liang Ding86fbb759ed9a
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex 413e11138a..bf9e2ccf1f 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -17,6 +17,7 @@package modelimport (+ "github.com/88250/lute/parse""github.com/siyuan-note/siyuan/kernel/av""github.com/siyuan-note/siyuan/kernel/sql""github.com/siyuan-note/siyuan/kernel/treenode"@@ -45,11 +46,18 @@ func AddBlockToAttributeView(blockID, avID string) (err error) {return}+ attrs := parse.IAL2Map(node.KramdownIAL)var row []av.Cellrow = append(row, av.NewCellBlock(block.ID))- for _, col := range attrView.Columns[1:] {- // TODO 为块添加列对应的属性- _ = col+ if 1 < len(attrView.Columns) {+ for _, col := range attrView.Columns[1:] {+ colName := col.Name()+ attrs[colName] = ""+ }++ if err = setNodeAttrs(node, tree, attrs); nil != err {+ return+ }}attrView.Rows = append(attrView.Rows, row)diff --git a/kernel/model/blockial.go b/kernel/model/blockial.goindex 08e56d4951..6a05998435 100644--- a/kernel/model/blockial.go+++ b/kernel/model/blockial.go@@ -19,13 +19,13 @@ package modelimport ("errors""fmt"+ "github.com/88250/lute/parse""time""github.com/88250/gulu""github.com/88250/lute/ast""github.com/88250/lute/html""github.com/88250/lute/lex"- "github.com/88250/lute/parse""github.com/araddon/dateparse""github.com/siyuan-note/siyuan/kernel/cache""github.com/siyuan-note/siyuan/kernel/treenode"@@ -105,12 +105,17 @@ func SetBlockAttrs(id string, nameValues map[string]string) (err error) {return errors.New(fmt.Sprintf(Conf.Language(15), id))}+ err = setNodeAttrs(node, tree, nameValues)+ return+}++func setNodeAttrs(node *ast.Node, tree *parse.Tree, nameValues map[string]string) (err error) {oldAttrs := parse.IAL2Map(node.KramdownIAL)for name := range nameValues {for i := 0; i < len(name); i++ {if !lex.IsASCIILetterNumHyphen(name[i]) {- return errors.New(fmt.Sprintf(Conf.Language(25), id))+ return errors.New(fmt.Sprintf(Conf.Language(25), node.ID))}}}@@ -135,10 +140,10 @@ func SetBlockAttrs(id string, nameValues map[string]string) (err error) {}IncSync()- cache.PutBlockIAL(id, parse.IAL2Map(node.KramdownIAL))+ cache.PutBlockIAL(node.ID, parse.IAL2Map(node.KramdownIAL))newAttrs := parse.IAL2Map(node.KramdownIAL)- doOp := &Operation{Action: "updateAttrs", Data: map[string]interface{}{"old": oldAttrs, "new": newAttrs}, ID: id}+ doOp := &Operation{Action: "updateAttrs", Data: map[string]interface{}{"old": oldAttrs, "new": newAttrs}, ID: node.ID}trans := []*Transaction{{DoOperations: []*Operation{doOp},UndoOperations: []*Operation{},