An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Keep database block layouts aligned with selected views https://github.com/siyuan-note/siyuan/issues/18515
Daniel98a94845a526
diff --git a/docs/SY-FORMAT.md b/docs/SY-FORMAT.mdindex 89094e292e..5cf99f4365 100644--- a/docs/SY-FORMAT.md+++ b/docs/SY-FORMAT.md@@ -396,8 +396,8 @@ Notes:- **Has no `Children`.**- `AttributeViewID` points to the AV table data (stored in a separate `.json` — **don't** fabricate this ID).-- `AttributeViewType`: `table` / `kanban` / `gallery`, etc.-- Optional `custom-sy-av-view` records the current view ID; it may be absent when no explicit current view is stored.+- `AttributeViewType`: `table` / `kanban` / `gallery`, etc. This value is derived from the layout of the view bound to the block and is not an independent view selector.+- Optional `custom-sy-av-view` records the current view ID. When it is absent or does not identify a view in the referenced AttributeView, the AttributeView's current view or first available view is used as the fallback.> AI is advised **not to create new AttributeView blocks**, since the table data is not in the `.sy` — it requires accompanying files.diff --git a/docs/SY-FORMAT.zh-CN.md b/docs/SY-FORMAT.zh-CN.mdindex a0dd30c4ad..429e1e04bc 100644--- a/docs/SY-FORMAT.zh-CN.md+++ b/docs/SY-FORMAT.zh-CN.md@@ -397,8 +397,8 @@ NodeList NodeList- **没有 Children**。- `AttributeViewID` 指向 AV 表数据,该数据存放在单独的 `.json` 中;**不要**凭空构造此 ID。-- `AttributeViewType`:`table` / `kanban` / `gallery` 等。-- 可选的 `custom-sy-av-view` 记录当前视图 ID;没有显式保存当前视图时可以缺失。+- `AttributeViewType`:`table` / `kanban` / `gallery` 等。该值由载体绑定视图的布局派生,不是独立的视图选择器。+- 可选的 `custom-sy-av-view` 记录当前视图 ID。缺失或未指向所引用 AttributeView 中的视图时,回退到 AttributeView 的当前视图或首个可用视图。> 建议 AI **不要创建新的 AttributeView 块**,因为表数据不在 `.sy` 中,还需要配套文件。diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex e547ef5106..33a6bfcce3 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -2342,6 +2342,70 @@ func SetDatabaseBlockView(blockID, avID, viewID string) (err error) {return}+// normalizeDatabaseBlockView 使数据库载体绑定的视图和布局保持一致,不修改数据库顶层当前视图。+func normalizeDatabaseBlockView(node *ast.Node, attrView *av.AttributeView) (changed bool) {+ if nil == node || nil == attrView || ast.NodeAttributeView != node.Type {+ return+ }++ viewID := node.IALAttr(av.NodeAttrView)+ var view *av.View+ if "" != viewID {+ view = attrView.GetView(viewID)+ }+ if nil == view {+ view, _ = attrView.GetCurrentView("")+ }+ if nil == view {+ return+ }++ layout := string(view.LayoutType)+ if layout != node.AttributeViewType {+ node.AttributeViewType = layout+ changed = true+ }+ if view.ID != viewID {+ node.SetIALAttr(av.NodeAttrView, view.ID)+ changed = true+ }+ return+}++func normalizeDatabaseBlockViews(node *ast.Node, boxID string, attrViews map[string]*av.AttributeView) (changed bool) {+ ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus {+ if !entering || ast.NodeAttributeView != n.Type {+ return ast.WalkContinue+ }++ attrView := cachedAttributeViewForBox(n.AttributeViewID, boxID, attrViews)+ if normalizeDatabaseBlockView(n, attrView) {+ changed = true+ }+ return ast.WalkContinue+ })+ return+}++func cachedAttributeViewForBox(avID, boxID string, attrViews map[string]*av.AttributeView) (ret *av.AttributeView) {+ cacheKey := boxID + "\x00" + avID+ if ret, ok := attrViews[cacheKey]; ok {+ return ret+ }++ var err error+ if IsEncryptedBox(boxID) {+ ret, err = av.ParseAttributeViewInBox(avID, boxID)+ } else {+ ret, err = av.ParseAttributeView(avID)+ }+ if nil != err {+ ret = nil+ }+ attrViews[cacheKey] = ret+ return+}+func GetAttributeViewPrimaryKeyValues(avID, keyword string, blockIDs []string, page, pageSize int) (attributeViewName string, databaseBlockIDs []string, keyValues *av.KeyValues, total int, err error) {waitForSyncingStorages()diff --git a/kernel/model/attribute_view_block_view_test.go b/kernel/model/attribute_view_block_view_test.gonew file mode 100644index 0000000000..7f390474cd--- /dev/null+++ b/kernel/model/attribute_view_block_view_test.go@@ -0,0 +1,409 @@+// SiYuan - Refactor your thinking+// Copyright (c) 2020-present, b3log.org+//+// This program is free software: you can redistribute it and/or modify+// it under the terms of the GNU Affero General Public License as published by+// the Free Software Foundation, either version 3 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU Affero General Public License for more details.+//+// You should have received a copy of the GNU Affero General Public License+// along with this program. If not, see <https://www.gnu.org/licenses/>.++package model++import (+ "path/filepath"+ "testing"++ "github.com/88250/lute/ast"+ "github.com/88250/lute/parse"+ "github.com/siyuan-note/siyuan/kernel/av"+ "github.com/siyuan-note/siyuan/kernel/cache"+ "github.com/siyuan-note/siyuan/kernel/filesys"+ "github.com/siyuan-note/siyuan/kernel/treenode"+ "github.com/siyuan-note/siyuan/kernel/util"+)++func TestNormalizeDatabaseBlockView(t *testing.T) {+ tests := []struct {+ name string+ blockViewID string+ currentViewID string+ views []*av.View+ initialLayout string+ expectedViewID string+ expectedLayout string+ expectedCurrent string+ expectedChanged bool+ }{+ {+ name: "valid block view takes precedence",+ blockViewID: "gallery-view",+ currentViewID: "table-view",+ views: []*av.View{+ {ID: "table-view", LayoutType: av.LayoutTypeTable},+ {ID: "gallery-view", LayoutType: av.LayoutTypeGallery},+ },+ initialLayout: string(av.LayoutTypeTable),+ expectedViewID: "gallery-view",+ expectedLayout: string(av.LayoutTypeGallery),+ expectedCurrent: "table-view",+ expectedChanged: true,+ },+ {+ name: "missing block view uses current view",+ currentViewID: "gallery-view",+ views: []*av.View{+ {ID: "table-view", LayoutType: av.LayoutTypeTable},+ {ID: "gallery-view", LayoutType: av.LayoutTypeGallery},+ },+ initialLayout: string(av.LayoutTypeTable),+ expectedViewID: "gallery-view",+ expectedLayout: string(av.LayoutTypeGallery),+ expectedCurrent: "gallery-view",+ expectedChanged: true,+ },+ {+ name: "invalid block view uses current view",+ blockViewID: "missing-view",+ currentViewID: "table-view",+ views: []*av.View{+ {ID: "table-view", LayoutType: av.LayoutTypeTable},+ {ID: "gallery-view", LayoutType: av.LayoutTypeGallery},+ },+ initialLayout: string(av.LayoutTypeGallery),+ expectedViewID: "table-view",+ expectedLayout: string(av.LayoutTypeTable),+ expectedCurrent: "table-view",+ expectedChanged: true,+ },+ {+ name: "invalid current view uses first view",+ blockViewID: "missing-block-view",+ currentViewID: "missing-current-view",+ views: []*av.View{+ {ID: "table-view", LayoutType: av.LayoutTypeTable},+ {ID: "gallery-view", LayoutType: av.LayoutTypeGallery},+ },+ initialLayout: string(av.LayoutTypeGallery),+ expectedViewID: "table-view",+ expectedLayout: string(av.LayoutTypeTable),+ expectedCurrent: "missing-current-view",+ expectedChanged: true,+ },+ {+ name: "view ID distinguishes views with the same layout",+ blockViewID: "second-table-view",+ currentViewID: "first-table-view",+ views: []*av.View{+ {ID: "first-table-view", LayoutType: av.LayoutTypeTable},+ {ID: "second-table-view", LayoutType: av.LayoutTypeTable},+ },+ initialLayout: string(av.LayoutTypeGallery),+ expectedViewID: "second-table-view",+ expectedLayout: string(av.LayoutTypeTable),+ expectedCurrent: "first-table-view",+ expectedChanged: true,+ },+ {+ name: "missing views keep block unchanged",+ blockViewID: "missing-view",+ currentViewID: "missing-current-view",+ initialLayout: string(av.LayoutTypeGallery),+ expectedViewID: "missing-view",+ expectedLayout: string(av.LayoutTypeGallery),+ expectedCurrent: "missing-current-view",+ },+ {+ name: "normalized block stays unchanged",+ blockViewID: "gallery-view",+ currentViewID: "table-view",+ views: []*av.View{+ {ID: "table-view", LayoutType: av.LayoutTypeTable},+ {ID: "gallery-view", LayoutType: av.LayoutTypeGallery},+ },+ initialLayout: string(av.LayoutTypeGallery),+ expectedViewID: "gallery-view",+ expectedLayout: string(av.LayoutTypeGallery),+ expectedCurrent: "table-view",+ },+ }++ for _, test := range tests {+ t.Run(test.name, func(t *testing.T) {+ node := &ast.Node{Type: ast.NodeAttributeView, AttributeViewType: test.initialLayout}+ if "" != test.blockViewID {+ node.SetIALAttr(av.NodeAttrView, test.blockViewID)+ }+ attrView := &av.AttributeView{ViewID: test.currentViewID, Views: test.views}++ changed := normalizeDatabaseBlockView(node, attrView)++ if test.expectedViewID != node.IALAttr(av.NodeAttrView) {+ t.Fatalf("unexpected block view ID: %s", node.IALAttr(av.NodeAttrView))+ }+ if test.expectedLayout != node.AttributeViewType {+ t.Fatalf("unexpected block layout: %s", node.AttributeViewType)+ }+ if test.expectedCurrent != attrView.ViewID {+ t.Fatalf("attribute view current view changed: %s", attrView.ViewID)+ }+ if test.expectedChanged != changed {+ t.Fatalf("unexpected normalization result: %t", changed)+ }+ })+ }+}++func TestNormalizeDatabaseBlockViewsUsesStoredBlockView(t *testing.T) {+ setupAttributeViewValidationTest(t)++ attrView := av.NewAttributeView("20260803090000-blockvw")+ tableView := attrView.Views[0]+ galleryView := &av.View{ID: ast.NewNodeID(), LayoutType: av.LayoutTypeGallery}+ attrView.Views = append(attrView.Views, galleryView)+ attrView.ViewID = tableView.ID+ if err := av.SaveAttributeView(attrView); nil != err {+ t.Fatalf("save attribute view failed: %s", err)+ }++ node := &ast.Node{+ Type: ast.NodeAttributeView,+ AttributeViewID: attrView.ID,+ AttributeViewType: string(av.LayoutTypeTable),+ }+ node.SetIALAttr(av.NodeAttrView, galleryView.ID)+ secondNode := &ast.Node{+ Type: ast.NodeAttributeView,+ AttributeViewID: attrView.ID,+ AttributeViewType: string(av.LayoutTypeTable),+ }+ secondNode.SetIALAttr(av.NodeAttrView, galleryView.ID)+ root := &ast.Node{Type: ast.NodeDocument}+ root.AppendChild(node)+ root.AppendChild(secondNode)+ attrViews := map[string]*av.AttributeView{}++ changed := normalizeDatabaseBlockViews(root, "", attrViews)++ if galleryView.ID != node.IALAttr(av.NodeAttrView) {+ t.Fatalf("unexpected block view ID: %s", node.IALAttr(av.NodeAttrView))+ }+ if string(av.LayoutTypeGallery) != node.AttributeViewType {+ t.Fatalf("unexpected block layout: %s", node.AttributeViewType)+ }+ if string(av.LayoutTypeGallery) != secondNode.AttributeViewType {+ t.Fatalf("unexpected second block layout: %s", secondNode.AttributeViewType)+ }+ if 1 != len(attrViews) {+ t.Fatalf("attribute view should be parsed once, cache size: %d", len(attrViews))+ }+ parsed, err := av.ParseAttributeView(attrView.ID)+ if nil != err {+ t.Fatalf("parse attribute view failed: %s", err)+ }+ if tableView.ID != parsed.ViewID {+ t.Fatalf("attribute view current view changed: %s", parsed.ViewID)+ }+ if !changed {+ t.Fatal("stored block view should normalize the block")+ }+}++func TestNormalizeDatabaseBlockViewsKeepsMissingAttributeViewLayout(t *testing.T) {+ setupAttributeViewValidationTest(t)++ node := &ast.Node{+ Type: ast.NodeAttributeView,+ AttributeViewID: "20260803090001-missing",+ AttributeViewType: string(av.LayoutTypeGallery),+ }+ node.SetIALAttr(av.NodeAttrView, "missing-view")++ changed := normalizeDatabaseBlockViews(node, "", map[string]*av.AttributeView{})++ if "missing-view" != node.IALAttr(av.NodeAttrView) {+ t.Fatalf("unexpected block view ID: %s", node.IALAttr(av.NodeAttrView))+ }+ if string(av.LayoutTypeGallery) != node.AttributeViewType {+ t.Fatalf("unexpected block layout: %s", node.AttributeViewType)+ }+ if changed {+ t.Fatal("missing attribute view should keep the block unchanged")+ }+}++func TestDatabaseBlockTransactionNormalization(t *testing.T) {+ tests := []struct {+ name string+ initialDatabase bool+ run func(*Transaction, *Operation, *parse.Tree) *TxErr+ }{+ {+ name: "insert",+ run: func(tx *Transaction, operation *Operation, tree *parse.Tree) *TxErr {+ operation.NextID = "20260803091002-anchor0"+ return tx.doInsert0(operation, tree)+ },+ },+ {+ name: "appendInsert",+ run: func(tx *Transaction, operation *Operation, tree *parse.Tree) *TxErr {+ operation.ParentID = tree.Root.ID+ return tx.doAppendInsert(operation)+ },+ },+ {+ name: "prependInsert",+ run: func(tx *Transaction, operation *Operation, tree *parse.Tree) *TxErr {+ operation.ParentID = tree.Root.ID+ return tx.doPrependInsert(operation)+ },+ },+ {+ name: "update",+ initialDatabase: true,+ run: func(tx *Transaction, operation *Operation, tree *parse.Tree) *TxErr {+ operation.ID = "20260803091003-avblock"+ return tx.doUpdate(operation)+ },+ },+ }++ for _, test := range tests {+ t.Run(test.name, func(t *testing.T) {+ fixture := setupDatabaseBlockTransactionTest(t, test.initialDatabase)+ operation := &Operation{+ Action: test.name,+ Data: databaseBlockTestDOM(+ "20260803091003-avblock", fixture.attrView.ID, fixture.galleryView.ID, av.LayoutTypeTable),+ }+ tx := &Transaction{+ trees: map[string]*parse.Tree{},+ nodes: map[string]*ast.Node{},+ luteEngine: util.NewLute(),+ }++ if txErr := test.run(tx, operation, fixture.tree); nil != txErr {+ t.Fatal(txErr)+ }++ resultTree := fixture.tree+ if loaded := tx.trees[fixture.tree.ID]; nil != loaded {+ resultTree = loaded+ }+ assertNormalizedDatabaseBlock(t, resultTree, operation, fixture)+ })+ }+}++type databaseBlockTransactionTestFixture struct {+ tree *parse.Tree+ attrView *av.AttributeView+ tableView *av.View+ galleryView *av.View+}++func setupDatabaseBlockTransactionTest(t *testing.T, initialDatabase bool) *databaseBlockTransactionTestFixture {+ t.Helper()+ setupAttributeViewValidationTest(t)++ oldBlockTreeDBPath := util.BlockTreeDBPath+ util.BlockTreeDBPath = filepath.Join(util.DataDir, "blocktree.db")+ treenode.InitBlockTree(true)+ var tree *parse.Tree+ t.Cleanup(func() {+ if nil != tree {+ cache.RemoveTreeDataInBox(tree.ID, tree.Box)+ cache.RemoveDocIALInBox(tree.Path, tree.Box)+ }+ treenode.CloseDatabase()+ util.BlockTreeDBPath = oldBlockTreeDBPath+ if "" != oldBlockTreeDBPath {+ treenode.InitBlockTree(false)+ }+ })++ attrView := av.NewAttributeView("20260803091000-avdata0")+ tableView := attrView.Views[0]+ galleryView := &av.View{ID: ast.NewNodeID(), LayoutType: av.LayoutTypeGallery}+ attrView.Views = append(attrView.Views, galleryView)+ attrView.ViewID = tableView.ID+ if err := av.SaveAttributeView(attrView); nil != err {+ t.Fatalf("save attribute view failed: %s", err)+ }++ tree = treenode.NewTree(+ "20260803091001-box0000", "/20260803091001-doc0000.sy", "/Test", "Test")+ tree.Root.FirstChild.Unlink()+ if initialDatabase {+ data := databaseBlockTestDOM(+ "20260803091003-avblock", attrView.ID, tableView.ID, av.LayoutTypeTable)+ node := util.NewLute().BlockDOM2Tree(data).Root.FirstChild+ tree.Root.AppendChild(node)+ } else {+ anchor := treenode.NewParagraph("")+ anchor.ID = "20260803091002-anchor0"+ anchor.SetIALAttr("id", anchor.ID)+ tree.Root.AppendChild(anchor)+ }+ if _, err := filesys.WriteTree(tree); nil != err {+ t.Fatalf("write test tree failed: %s", err)+ }+ treenode.UpsertBlockTree(tree)++ return &databaseBlockTransactionTestFixture{+ tree: tree, attrView: attrView, tableView: tableView, galleryView: galleryView,+ }+}++func databaseBlockTestDOM(blockID, avID, viewID string, layout av.LayoutType) string {+ return `<div class="av" data-node-id="` + blockID + `" data-av-id="` + avID ++ `" data-type="NodeAttributeView" data-av-type="` + string(layout) ++ `" custom-sy-av-view="` + viewID + `"></div>`+}++func assertNormalizedDatabaseBlock(+ t *testing.T, tree *parse.Tree, operation *Operation, fixture *databaseBlockTransactionTestFixture,+) {+ t.Helper()+ const blockID = "20260803091003-avblock"++ node := treenode.GetNodeInTree(tree, blockID)+ if nil == node {+ t.Fatal("database block was not written to the target tree")+ }+ if fixture.galleryView.ID != node.IALAttr(av.NodeAttrView) ||+ string(av.LayoutTypeGallery) != node.AttributeViewType {+ t.Fatalf("unexpected persisted database block view: %s, %s",+ node.IALAttr(av.NodeAttrView), node.AttributeViewType)+ }++ data, ok := operation.Data.(string)+ if !ok {+ t.Fatalf("unexpected operation data: %#v", operation.Data)+ }+ operationTree := util.NewLute().BlockDOM2Tree(data)+ operationNode := treenode.GetNodeInTree(operationTree, blockID)+ if nil == operationNode {+ t.Fatal("normalized operation data does not contain the database block")+ }+ if fixture.galleryView.ID != operationNode.IALAttr(av.NodeAttrView) ||+ string(av.LayoutTypeGallery) != operationNode.AttributeViewType {+ t.Fatalf("unexpected operation database block view: %s, %s",+ operationNode.IALAttr(av.NodeAttrView), operationNode.AttributeViewType)+ }++ parsed, err := av.ParseAttributeView(fixture.attrView.ID)+ if nil != err {+ t.Fatalf("parse attribute view failed: %s", err)+ }+ if fixture.tableView.ID != parsed.ViewID {+ t.Fatalf("attribute view current view changed: %s", parsed.ViewID)+ }+}diff --git a/kernel/model/transaction.go b/kernel/model/transaction.goindex 72f9537aa7..7cead58b3a 100644--- a/kernel/model/transaction.go+++ b/kernel/model/transaction.go@@ -829,6 +829,10 @@ func (tx *Transaction) doPrependInsert(operation *Operation) (ret *TxErr) {toInserts = append(toInserts, toInsert)}}+ attrViews := map[string]*av.AttributeView{}+ if normalizeDatabaseBlockViews(subTree.Root, tree.Box, attrViews) {+ operation.Data = tx.luteEngine.Tree2BlockDOM(subTree, tx.luteEngine.RenderOptions, tx.luteEngine.ParseOptions)+ }node := treenode.GetNodeInTree(tree, operation.ParentID)if nil == node {@@ -928,6 +932,10 @@ func (tx *Transaction) doAppendInsert(operation *Operation) (ret *TxErr) {toInserts = append(toInserts, toInsert)}}+ attrViews := map[string]*av.AttributeView{}+ if normalizeDatabaseBlockViews(subTree.Root, tree.Box, attrViews) {+ operation.Data = tx.luteEngine.Tree2BlockDOM(subTree, tx.luteEngine.RenderOptions, tx.luteEngine.ParseOptions)+ }node := treenode.GetNodeInTree(tree, operation.ParentID)if nil == node {@@ -1431,6 +1439,10 @@ func (tx *Transaction) doInsert0(operation *Operation, tree *parse.Tree) (ret *TinsertedNode.AttributeViewID = ast.NewNodeID()}}+ attrViews := map[string]*av.AttributeView{}+ if normalizeDatabaseBlockViews(subTree.Root, tree.Box, attrViews) {+ operation.Data = tx.luteEngine.Tree2BlockDOM(subTree, tx.luteEngine.RenderOptions, tx.luteEngine.ParseOptions)+ }var node *ast.NodenextID := operation.NextID@@ -1536,28 +1548,13 @@ func (tx *Transaction) doInsert0(operation *Operation, tree *parse.Tree) (ret *Tif ast.NodeAttributeView == insertedNode.Type {// 插入数据库块时需要重新绑定其中已经存在的块// 比如剪切操作时,会先进行 delete 数据库解绑块,这里需要重新绑定 https://github.com/siyuan-note/siyuan/issues/13031- attrView, parseErr := av.ParseAttributeView(insertedNode.AttributeViewID)- if nil == parseErr {+ attrView := cachedAttributeViewForBox(insertedNode.AttributeViewID, tree.Box, attrViews)+ if nil != attrView {trees, toBindNodes := tx.getAttrViewBoundNodes(attrView)for _, toBindNode := range toBindNodes {t := trees[toBindNode.ID]bindBlockAv0(tx, insertedNode.AttributeViewID, toBindNode, t)}-- // 设置视图 https://github.com/siyuan-note/siyuan/issues/15279- v := attrView.GetView(attrView.ViewID)- if nil != v {- insertedNode.AttributeViewType = string(v.LayoutType)- attrs := parse.IAL2Map(insertedNode.KramdownIAL)- if "" == attrs[av.NodeAttrView] {- attrs[av.NodeAttrView] = v.ID- err := setNodeAttrs(insertedNode, tree, attrs)- if err != nil {- logging.LogWarnf("set node [%s] attrs failed: %s", operation.BlockID, err)- return- }- }- }}}@@ -1650,6 +1647,11 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {logging.LogError(err.Error())return &TxErr{code: TxErrCodePushMsg, msg: err.Error(), id: id}}+ attrViews := map[string]*av.AttributeView{}+ if normalizeDatabaseBlockViews(updatedNode, tree.Box, attrViews) {+ data = tx.luteEngine.Tree2BlockDOM(subTree, tx.luteEngine.RenderOptions, tx.luteEngine.ParseOptions)+ operation.Data = data+ }// 收集引用的定义块 IDoldDefIDs := getRefDefIDs(oldNode)@@ -1793,25 +1795,6 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {upsertAvBlockRel(updatedNode)- if ast.NodeAttributeView == updatedNode.Type {- // 设置视图 https://github.com/siyuan-note/siyuan/issues/15279- attrView, parseErr := av.ParseAttributeView(updatedNode.AttributeViewID)- if nil == parseErr {- v := attrView.GetView(attrView.ViewID)- if nil != v {- updatedNode.AttributeViewType = string(v.LayoutType)- attrs := parse.IAL2Map(updatedNode.KramdownIAL)- if "" == attrs[av.NodeAttrView] {- attrs[av.NodeAttrView] = v.ID- err = setNodeAttrs(updatedNode, tree, attrs)- if err != nil {- logging.LogWarnf("set node [%s] attrs failed: %s", operation.BlockID, err)- return &TxErr{code: TxErrCodeBlockNotFound, id: id}- }- }- }- }- }return}