An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Support native Tabs and Mindmap operations in agents https://github.com/siyuan-note/siyuan/issues/20163
Daniel0e24004e7a0a
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20230304000547-ibldj1z/20260804171004-aiagt03.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20230304000547-ibldj1z/20260804171004-aiagt03.syindex 1dfc2e138a..87f6cbd88c 100644--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20230304000547-ibldj1z/20260804171004-aiagt03.sy+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20230304000547-ibldj1z/20260804171004-aiagt03.sy@@ -6,7 +6,7 @@"id": "20260804171004-aiagt03","title": "AI Agent","type": "doc",- "updated": "20260926163337"+ "updated": "20261007014930"},"Children": [{@@ -29,12 +29,12 @@"Type": "NodeParagraph","Properties": {"id": "20260804170024-uta8c8r",- "updated": "20260804180000"+ "updated": "20261007014930"},"Children": [{"Type": "NodeText",- "Data": "The AI agent can do more than answer questions. It can use SiYuan's built-in tools, skills, MCP services, and plugin capabilities to search, read, and operate on the knowledge base. It works through tasks step by step and requests confirmation before changing data."+ "Data": "The AI agent can do more than answer questions. It can use SiYuan's built-in tools, skills, MCP services, and plugin capabilities to search, read, and operate on the knowledge base. It works through tasks step by step and requests confirmation before changing data. The agent can create and edit native tabbed blocks and mind map blocks, add, move, or delete tabs and mind map nodes, and modify their content. For example, ask it to create study notes with several tabs or organize a topic into an editable mind map."}]},diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20230303235619-ex5l63e/20260804171000-aiagt01.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20230303235619-ex5l63e/20260804171000-aiagt01.syindex 03266d6113..74b75db1b9 100644--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20230303235619-ex5l63e/20260804171000-aiagt01.sy+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20230303235619-ex5l63e/20260804171000-aiagt01.sy@@ -6,7 +6,7 @@"id": "20260804171000-aiagt01","title": "AI 智能体","type": "doc",- "updated": "20260926163337"+ "updated": "20261007014930"},"Children": [{@@ -29,12 +29,12 @@"Type": "NodeParagraph","Properties": {"id": "20260804170024-gjy30mg",- "updated": "20260804180000"+ "updated": "20261007014930"},"Children": [{"Type": "NodeText",- "Data": "AI 智能体不仅可以回答问题,还可以调用思源内置工具、技能、MCP 服务和插件能力,搜索、读取并操作知识库。它会根据任务分步骤执行,并在需要修改数据时请求确认。"+ "Data": "AI 智能体不仅可以回答问题,还可以调用思源内置工具、技能、MCP 服务和插件能力,搜索、读取并操作知识库。它会根据任务分步骤执行,并在需要修改数据时请求确认。智能体支持创建和编辑原生页签块与思维导图块,可以添加、移动或删除页签和导图节点,并修改其中的内容。例如,可以让智能体创建包含多个页签的学习笔记,或将主题整理为可编辑的思维导图。"}]},diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20230304000829-9jwu3po/20260804171002-aiagt02.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20230304000829-9jwu3po/20260804171002-aiagt02.syindex 2d18b1327e..f3cfe11da7 100644--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20230304000829-9jwu3po/20260804171002-aiagt02.sy+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20230304000829-9jwu3po/20260804171002-aiagt02.sy@@ -6,7 +6,7 @@"id": "20260804171002-aiagt02","title": "AI 智能體","type": "doc",- "updated": "20260926163337"+ "updated": "20261007014930"},"Children": [{@@ -29,12 +29,12 @@"Type": "NodeParagraph","Properties": {"id": "20260804170024-ygqr86s",- "updated": "20260804180000"+ "updated": "20261007014930"},"Children": [{"Type": "NodeText",- "Data": "AI 智能體不僅可以回答問題,還可以呼叫思源內建工具、技能、MCP 服務和外掛能力,搜尋、讀取並操作知識庫。它會根據任務分步執行,並在需要修改資料時請求確認。"+ "Data": "AI 智能體不僅可以回答問題,還可以呼叫思源內建工具、技能、MCP 服務和外掛能力,搜尋、讀取並操作知識庫。它會根據任務分步執行,並在需要修改資料時請求確認。智能體支援建立和編輯原生頁籤區塊與心智圖區塊,可以新增、移動或刪除頁籤和心智圖節點,並修改其中的內容。例如,可以讓智能體建立包含多個頁籤的學習筆記,或將主題整理為可編輯的心智圖。"}]},diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-ei5t6tt/20260804171006-aiagt04.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-ei5t6tt/20260804171006-aiagt04.syindex db47c4629f..eab780b12a 100644--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-ei5t6tt/20260804171006-aiagt04.sy+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-ei5t6tt/20260804171006-aiagt04.sy@@ -6,7 +6,7 @@"id": "20260804171006-aiagt04","title": "AI エージェント","type": "doc",- "updated": "20260926163337"+ "updated": "20261007014930"},"Children": [{@@ -29,12 +29,12 @@"Type": "NodeParagraph","Properties": {"id": "20260804170024-9lvjy1x",- "updated": "20260804180000"+ "updated": "20261007014930"},"Children": [{"Type": "NodeText",- "Data": "AI エージェントは質問に答えるだけでなく、SiYuan の組み込みツール、スキル、MCP サービス、プラグイン機能を利用してナレッジベースを検索、読み取り、操作できます。タスクを段階的に実行し、データを変更する前に確認を求めます。"+ "Data": "AI エージェントは質問に答えるだけでなく、SiYuan の組み込みツール、スキル、MCP サービス、プラグイン機能を利用してナレッジベースを検索、読み取り、操作できます。タスクを段階的に実行し、データを変更する前に確認を求めます。エージェントはネイティブのタブブロックとマインドマップブロックを作成・編集し、タブやマインドマップのノードを追加・移動・削除したり、内容を変更したりできます。例えば、複数のタブを持つ学習ノートの作成や、トピックを編集可能なマインドマップに整理するよう依頼できます。"}]},diff --git a/kernel/agent/agent.go b/kernel/agent/agent.goindex e0c4a7bf9c..ed07486fe0 100644--- a/kernel/agent/agent.go+++ b/kernel/agent/agent.go@@ -49,7 +49,7 @@ const systemPrompt = `You are a SiYuan AI assistant. You help users manage their## Domain Concepts- Block: the fundamental unit. Everything is a block with a unique ID, including documents (a document block, type NodeDocument, is the root). Content blocks (headings, paragraphs, lists, code, tables) form a tree under a document block.-- Container blocks (can hold child blocks): document, blockquote, list, list-item, super-block, callout. Leaf blocks (cannot hold children): heading, paragraph, code-block, math-block, table, HTML-block, thematic-break, video, audio, widget, iframe, attribute-view, block-query-embed.+- Container blocks (can hold child blocks): document, blockquote, list, list-item, super-block, callout, tabs, tab-item, mindmap, mindmap-item. Leaf blocks (cannot hold children): heading, paragraph, code-block, math-block, table, HTML-block, thematic-break, video, audio, widget, iframe, attribute-view, block-query-embed.- Heading hierarchy: headings (h1-h6) are leaf blocks. Blocks that appear "under" a heading in the UI are its *following siblings* in the AST, not its children. To place a block below a heading, pass the heading's ID (or the ID of the last block currently below it) as previousID, not as parentID.- Nested lists: a list-item cannot directly contain another list-item. To nest lists, create a list (NodeList) as a child of the outer list-item, then add list-items to that inner list. The parent of a list-item must always be a list (NodeList).- Super-block layouts: despite the token names, "row" means a vertical layout with child blocks stacked top-to-bottom, while "col" means a horizontal layout with child blocks placed side-by-side. Never infer the visual direction from the English token alone.@@ -64,6 +64,27 @@ second paragraph}}}Use {{{row for a vertical super-block. Never use data-layout in raw block DOM. If raw DOM is unavoidable, the outer block must use data-type="NodeSuperBlock" and data-sb-layout="row" or data-sb-layout="col", and every child must be complete block DOM with an explicit data-type; otherwise content may become an HTML block.+- Tabs and Mindmap are native, editable SiYuan blocks supported by the block tool; do not substitute HTML widgets, Mermaid diagrams, or plugins unless requested.+- Tabs: NodeTabs contains only NodeTabItem; each item contains body blocks and may contain nested tabs. Create with block.insert/append/prepend and dataType="markdown":++::: tabs+@tab First++First body++@tab:active Second++Second body++:::++ The opening fence requires a space before tabs; never write :::tabs or :::tab. Nested groups require longer outer colon fences. To add tabs to an existing NodeTabs, pass a group containing only the new items; the tool inserts those items and preserves the target group's attributes. Use attr.set for tabs-position (top/left) and tabs-active-id (an existing direct item ID). Use block.move/delete on item IDs for reordering/removal, and edit body blocks individually.+- Mindmap: NodeMindmap contains only NodeMindmapItem. Each item contains content blocks and may contain a nested NodeMindmap for child branches; never put a plain NodeList, NodeListItem, or a bare NodeMindmapItem directly inside an item. Create with block.insert/append/prepend and dataType="dom", for example:++<div data-type="NodeMindmap" data-subtype="u" class="mindmap"><div data-type="NodeMindmapItem" data-subtype="u" data-marker="-" class="mindmap-item"><div data-type="NodeParagraph" class="p"><div contenteditable="true">Root</div></div><div data-type="NodeMindmap" data-subtype="u" class="mindmap"><div data-type="NodeMindmapItem" data-subtype="u" data-marker="-" class="mindmap-item"><div data-type="NodeParagraph" class="p"><div contenteditable="true">Child</div></div></div></div></div></div>++ Every block requires an explicit data-type; the tool generates IDs for new native DOM blocks that omit data-node-id. A mindmap code fence creates an ordinary code block, not a native mindmap. To add siblings to an existing NodeMindmap, pass a group containing only the new items; to add a child branch, insert a NodeMindmap under a NodeMindmapItem. Use block.move/delete on item IDs and edit their content blocks individually.+- Structural edits: block.get/get_kramdown/batch_kramdown return reading Markdown that flattens Tabs and renders Mindmap as ordinary lists. Before editing either container, call block.dom and preserve all existing data-node-id values and attributes, including active tabs and mindmap metadata. Use dataType="dom" and lockType=true for updates unless the user explicitly requests a type conversion. Never rebuild these containers from their reading Markdown.- Notebook: a top-level container holding documents. Use notebook.list to enumerate; pass notebook ID when creating documents.- hPath (human-readable path): the title-based path shown in the document tree, e.g. "/Diary/2024/June". The "path" parameter in document.create/move/list refers to hPath, not the internal ID-based filesystem path. A rename changes hPath but not the ID.- Document vs block move: document.move relocates an entire document (and children) to a new hPath within a notebook — needs id, notebook (from document.get field "Box"), and path. block.move repositions a single content block under a new parent block.@@ -125,7 +146,7 @@ second paragraph## SiYuan User GuideSiYuan has a built-in user guide notebook documenting all features. IDs by language: 简体中文 "20210808180117-czj9bvb", 繁體中文 "20211226090932-5lcq56f", 日本語 "20240530133126-axarxgx", others "20210808180117-6v0mkxr".-When asked whether/how SiYuan supports a feature: notebook.list to check it's open (notebook.open to open it if not), then search.fulltext the guide for docs, cite if found or honestly say unsupported if not. Do NOT invent features or UI workflows — the guide is authoritative.+When asked whether/how SiYuan supports a feature: notebook.list to check it's open (notebook.open to open it if not), then search.fulltext the guide for docs and cite if found. Missing guide search results alone do not prove a feature is unsupported; also check the native tool descriptions and supported block types above. Do NOT invent features or UI workflows.## Todo TrackingFor multi-step tasks (3+ distinct steps), use todo_write to track progress. Each call replaces the whole list; statuses are pending / in_progress / completed / cancelled. Set in_progress before starting a step, completed when done, and update on every status change. Skip todo_write for single-step requests.diff --git a/kernel/agent/prompt_test.go b/kernel/agent/prompt_test.goindex 3908c3ef81..65acc89aa1 100644--- a/kernel/agent/prompt_test.go+++ b/kernel/agent/prompt_test.go@@ -109,6 +109,25 @@ func TestSystemPromptDocumentsSuperBlockLayout(t *testing.T) {}}+func TestSystemPromptDocumentsNativeContainerEditing(t *testing.T) {+ for _, instruction := range []string{+ "Tabs and Mindmap are native, editable SiYuan blocks",+ "::: tabs\n@tab First",+ "@tab:active Second",+ `data-type="NodeMindmap"`,+ `data-type="NodeMindmapItem"`,+ "block.move/delete on item IDs",+ "call block.dom and preserve all existing data-node-id values and attributes",+ "lockType=true",+ "Never rebuild these containers from their reading Markdown",+ "Missing guide search results alone do not prove a feature is unsupported",+ } {+ if !strings.Contains(systemPrompt, instruction) {+ t.Fatalf("missing native container instruction %q", instruction)+ }+ }+}+func TestSystemPromptOmitsUnavailableSkillInstructions(t *testing.T) {capabilities := &capabilitySet{registrations: map[string]*capabilityRegistration{}}prompt := buildSystemPrompt("English", capabilities)diff --git a/kernel/api/contract_block_transaction_test.go b/kernel/api/contract_block_transaction_test.goindex 305b62f1b5..4608eb032d 100644--- a/kernel/api/contract_block_transaction_test.go+++ b/kernel/api/contract_block_transaction_test.go@@ -107,6 +107,7 @@ func TestAPIContractHeadingTransactions(t *testing.T) {}treenode.UpsertBlockTree(tree)testAPIContractInsertBlockAnchors(t, box.ID, docID, paragraphID)+ testAPIContractNativeContainers(t, box.ID)engine := gin.New()engine.POST("/api/block/getBlockTreeInfos", getBlockTreeInfos)infoRecorder := httptest.NewRecorder()diff --git a/kernel/api/contract_native_container_test.go b/kernel/api/contract_native_container_test.gonew file mode 100644index 0000000000..0e7be319cd--- /dev/null+++ b/kernel/api/contract_native_container_test.go@@ -0,0 +1,250 @@+package api++import (+ "bytes"+ "encoding/json"+ "net/http/httptest"+ "os"+ "path/filepath"+ "slices"+ "strings"+ "testing"++ "github.com/88250/lute/ast"+ "github.com/gin-gonic/gin"+ "github.com/siyuan-note/siyuan/kernel/apicontract"+ "github.com/siyuan-note/siyuan/kernel/filesys"+ "github.com/siyuan-note/siyuan/kernel/mcp/tools"+ "github.com/siyuan-note/siyuan/kernel/model"+ "github.com/siyuan-note/siyuan/kernel/treenode"+ "github.com/siyuan-note/siyuan/kernel/util"+)++// testAPIContractNativeContainers 复用隔离工作区,验证原生工具和 HTTP API 的结构化读写。+func testAPIContractNativeContainers(t *testing.T, boxID string) {+ docID := ast.NewNodeID()+ tree := treenode.NewTree(boxID, "/"+docID+".sy", "/Native containers", "Native containers")+ if _, err := filesys.WriteTree(tree); err != nil {+ t.Fatal(err)+ }+ treenode.UpsertBlockTree(tree)+ call := func(testT *testing.T, args map[string]any) tools.CallToolResult {+ testT.Helper()+ result, err := tools.BlockTool.Handler(args)+ if err != nil || result.IsError {+ testT.Fatalf("block.%s failed: %+v, %v", args["action"], result, err)+ }+ return result+ }+ writeID := func(testT *testing.T, args map[string]any) string {+ testT.Helper()+ result := call(testT, args)+ var output struct{ ID string }+ if err := json.Unmarshal([]byte(result.Content[0].Text), &output); err != nil || !ast.IsNodeIDPattern(output.ID) {+ testT.Fatalf("invalid write result: %+v, %v", result, err)+ }+ return output.ID+ }+ load := func(testT *testing.T, id string) *ast.Node {+ testT.Helper()+ tree, err := model.LoadTreeByBlockID(id)+ if err != nil {+ testT.Fatal(err)+ }+ node := treenode.GetNodeInTree(tree, id)+ if node == nil {+ testT.Fatalf("persisted block %s missing", id)+ }+ if err = treenode.ValidateBlockSubtree(tree.Root); err != nil {+ testT.Fatal(err)+ }+ return node+ }+ readFile := func(testT *testing.T) []byte {+ testT.Helper()+ data, err := os.ReadFile(filepath.Join(util.DataDir, boxID, docID+".sy"))+ if err != nil {+ testT.Fatal(err)+ }+ return data+ }+ engine := gin.New()+ engine.POST("/api/block/insertBlock", insertBlock)+ engine.POST("/api/block/appendBlock", appendBlock)+ engine.POST("/api/block/prependBlock", prependBlock)++ for _, tc := range []struct {+ name, data, dataType string+ groupType, itemType ast.NodeType+ }{+ {"tabs", "::: tabs\n@tab First\n\nOne\n\n@tab:active Second\n\nTwo\n\n:::\n", "markdown", ast.NodeTabs, ast.NodeTabItem},+ {"mindmap", `<div data-type="NodeMindmap" data-subtype="u" class="mindmap"><div data-type="NodeMindmapItem" data-subtype="u" data-marker="-" class="mindmap-item"><div data-type="NodeParagraph" class="p"><div contenteditable="true">One</div></div></div><div data-type="NodeMindmapItem" data-subtype="u" data-marker="-" class="mindmap-item"><div data-type="NodeParagraph" class="p"><div contenteditable="true">Two</div></div></div></div>`, "dom", ast.NodeMindmap, ast.NodeMindmapItem},+ } {+ t.Run("native-containers/"+tc.name, func(t *testing.T) {+ groupID := writeID(t, map[string]any{"action": "append", "parentID": docID, "data": tc.data, "dataType": tc.dataType})+ group := load(t, groupID)+ if group.Type != tc.groupType || len(group.ChildrenByType(tc.itemType)) != 2 {+ t.Fatal("native container creation lost its types or items")+ }+ items := group.ChildrenByType(tc.itemType)+ firstID, secondID := items[0].ID, items[1].ID+ bodyID := items[0].FirstChild.ID+ attrs := map[string]string{"custom-test": "preserved"}+ if tc.groupType == ast.NodeTabs {+ attrs["tabs-position"], attrs["tabs-active-id"] = "left", secondID+ } else {+ attrs["custom-sy-list-mindmap-data"] = `{"version":2,"rootTitle":"Preserved root","nodes":{},"relations":[],"summaries":[]}`+ }+ if err := model.SetBlockAttrs(groupID, attrs); err != nil {+ t.Fatal(err)+ }+ assertAttrs := func() {+ t.Helper()+ current := load(t, groupID)+ for key, value := range attrs {+ if current.IALAttr(key) != value {+ t.Fatalf("container attribute %s changed: %q", key, current.IALAttr(key))+ }+ }+ }+ fragmentDOM := func() string {+ t.Helper()+ var fragment *ast.Node+ if tc.dataType == "dom" {+ fragment = util.NewLute().BlockDOM2Tree(tc.data).Root.FirstChild+ ast.Walk(fragment, func(node *ast.Node, entering bool) ast.WalkStatus {+ if entering && node.IsBlock() && node.Type != ast.NodeKramdownBlockIAL {+ node.ID = ast.NewNodeID()+ node.SetIALAttr("id", node.ID)+ }+ return ast.WalkContinue+ })+ } else {+ fragment = util.NewLute().BlockDOM2Tree(util.NewLute().Md2BlockDOM(tc.data, false)).Root.FirstChild+ }+ return util.NewLute().RenderNodeBlockDOM(fragment)+ }++ for _, action := range []string{"append", "prepend", "insert"} {+ before := load(t, groupID).ChildrenByType(tc.itemType)+ args := map[string]any{"action": action, "parentID": groupID, "data": fragmentDOM(), "dataType": "dom"}+ if action == "insert" {+ args["previousID"] = firstID+ }+ id := writeID(t, args)+ inserted := load(t, id)+ if inserted.Type != tc.itemType || inserted.Parent.ID != groupID || len(load(t, groupID).ChildrenByType(tc.itemType)) != len(before)+2 {+ t.Fatalf("%s did not insert both direct items", action)+ }+ if action == "insert" && inserted.Previous.ID != firstID {+ t.Fatal("previousID insertion lost its position")+ }+ if action == "prepend" && load(t, groupID).FirstChild.ID != id {+ t.Fatal("prepend did not retain input item order")+ }+ if action == "append" && inserted.Previous.ID != before[len(before)-1].ID {+ t.Fatal("append did not retain input item order")+ }+ assertAttrs()+ }+ nestedID := writeID(t, map[string]any{"action": "append", "parentID": firstID, "data": fragmentDOM(), "dataType": "dom"})+ if nested := load(t, nestedID); nested.Type != tc.groupType || nested.Parent.ID != firstID {+ t.Fatal("nested container was flattened into its item parent")+ }+ itemFragment := util.NewLute().BlockDOM2Tree(fragmentDOM()).Root.FirstChild.ChildrenByType(tc.itemType)[0]+ itemDOM := util.NewLute().RenderNodeBlockDOM(itemFragment)+ newItemID := writeID(t, map[string]any{"action": "append", "parentID": groupID, "data": itemDOM, "dataType": "dom"})+ if item := load(t, newItemID); item.Type != tc.itemType || item.Parent.ID != groupID {+ t.Fatal("standalone item fragment was not inserted into its native container")+ }+ call(t, map[string]any{"action": "move", "id": newItemID, "parentID": nestedID})+ if load(t, newItemID).Parent.ID != nestedID {+ t.Fatal("native item could not move between containers")+ }+ itemDOM = call(t, map[string]any{"action": "dom", "id": newItemID}).Content[0].Text+ call(t, map[string]any{"action": "update", "id": newItemID, "data": itemDOM, "dataType": "dom"})+ if load(t, newItemID).Parent.ID != nestedID {+ t.Fatal("item DOM update changed its parent or ID")+ }+ assertAttrs()+ call(t, map[string]any{"action": "move", "id": firstID, "parentID": groupID, "previousID": secondID})+ if load(t, firstID).Previous.ID != secondID {+ t.Fatal("native item move failed")+ }+ call(t, map[string]any{"action": "update", "id": bodyID, "data": "Edited body", "dataType": "markdown"})+ if load(t, bodyID).Parent.ID != firstID {+ t.Fatal("body update changed its parent or ID")+ }+ assertAttrs()+ dom := call(t, map[string]any{"action": "dom", "id": groupID}).Content[0].Text+ beforeIDs := load(t, groupID).BlockIDs()+ call(t, map[string]any{"action": "update", "id": groupID, "data": dom, "dataType": "dom"})+ if !slices.Equal(beforeIDs, load(t, groupID).BlockIDs()) {+ t.Fatal("DOM update changed existing descendant IDs")+ }+ assertAttrs()+ for _, args := range []map[string]any{+ {"action": "append", "parentID": groupID, "data": "Invalid child", "dataType": "markdown"},+ {"action": "update", "id": groupID, "data": call(t, map[string]any{"action": "get_kramdown", "id": groupID}).Content[0].Text, "dataType": "markdown"},+ } {+ before := readFile(t)+ result, err := tools.BlockTool.Handler(args)+ if err != nil || !result.IsError || !bytes.Equal(before, readFile(t)) {+ t.Fatalf("unsafe write was not rejected without persistence: %+v, %v", result, err)+ }+ }++ for _, endpoint := range []string{"appendBlock", "prependBlock", "insertBlock"} {+ for _, invalid := range []bool{false, true} {+ request := map[string]string{"parentID": groupID, "dataType": "dom", "data": fragmentDOM()}+ if endpoint == "insertBlock" {+ request["nextID"] = firstID+ }+ if invalid {+ request["dataType"], request["data"] = "markdown", "Invalid child"+ }+ body, _ := json.Marshal(request)+ path := "/api/block/" + endpoint+ before := readFile(t)+ recorder := httptest.NewRecorder()+ engine.ServeHTTP(recorder, httptest.NewRequest("POST", path, bytes.NewReader(body)))+ requireAPIContract(t, "POST", path, recorder)+ var response struct {+ Code int `json:"code"`+ Data []*apicontract.BlockTransaction `json:"data"`+ }+ if err := json.Unmarshal(recorder.Body.Bytes(), &response); err != nil {+ t.Fatal(err)+ }+ if invalid {+ if !bytes.Equal(before, readFile(t)) ||+ (endpoint != "prependBlock" && (response.Code != -1 || response.Data != nil)) ||+ (endpoint == "prependBlock" && response.Code != 0) {+ t.Fatalf("invalid API insert changed document: %s", recorder.Body.String())+ }+ } else {+ if response.Code != 0 || len(response.Data) != 1 || len(response.Data[0].DoOperations) != 1 {+ t.Fatalf("native API insert failed: %s", recorder.Body.String())+ }+ operation := response.Data[0].DoOperations[0]+ if inserted := load(t, operation.ID); inserted.Type != tc.itemType || inserted.Parent.ID != groupID {+ t.Fatal("API returned a wrapper ID instead of the inserted item")+ }+ }+ assertAttrs()+ }+ }+ deleteID := load(t, groupID).ChildrenByType(tc.itemType)[0].ID+ call(t, map[string]any{"action": "delete", "id": deleteID})+ if strings.Contains(call(t, map[string]any{"action": "dom", "id": groupID}).Content[0].Text, deleteID) {+ t.Fatal("deleted native item remains in DOM")+ }+ assertAttrs()+ convertedID := writeID(t, map[string]any{"action": "append", "parentID": docID, "data": fragmentDOM(), "dataType": "dom"})+ call(t, map[string]any{"action": "update", "id": convertedID, "data": "Intentional conversion", "dataType": "markdown", "lockType": false})+ if load(t, convertedID).Type != ast.NodeParagraph {+ t.Fatal("explicit type conversion was blocked")+ }+ })+ }+}diff --git a/kernel/apicontract/block_inputs.go b/kernel/apicontract/block_inputs.goindex cae85a860e..78ce2a4f02 100644--- a/kernel/apicontract/block_inputs.go+++ b/kernel/apicontract/block_inputs.go@@ -15,12 +15,16 @@ type DailyNoteBlockRequest struct {Notebook string `json:"notebook"`}+// AppendBlockRequest 在父块末尾追加内容,页签和脑图容器只能接收各自的项目块。+// 输入同类型容器片段时插入其直属项目,保留目标容器属性和项目 ID,非法子块由事务校验拒绝。type AppendBlockRequest struct {Data string `json:"data"`DataType string `json:"dataType" api:"trim"`ParentID string `json:"parentID" api:"trim"`}+// PrependBlockRequest 在父块开头插入内容,页签和脑图容器片段按 AppendBlockRequest 的规则展开项目。+// 保留排队执行的响应行为,事务失败不落盘,但成功响应不代表事务已通过校验。type PrependBlockRequest struct {Data string `json:"data"`DataType string `json:"dataType"`@@ -34,6 +38,7 @@ type BatchParentBlockRequest struct {// InsertBlockRequest 按 nextID、previousID、parentID 的顺序选择插入位置。// 生效的 nextID 或 previousID 必须指向非文档块,未使用的定位参数不参与节点类型校验。// parentID 指向文档时插入到文档开头;成功返回已落盘的操作,目标非法时返回 code=-1、data=null。+// 插入位置位于页签或脑图容器内时,同类型容器片段展开为直属项目,保留目标容器属性和项目 ID。type InsertBlockRequest struct {Data string `json:"data"`DataType string `json:"dataType" api:"trim"`diff --git a/kernel/mcp/tools/block.go b/kernel/mcp/tools/block.goindex 13d2b7295c..ac3b7ff0d5 100644--- a/kernel/mcp/tools/block.go+++ b/kernel/mcp/tools/block.go@@ -21,6 +21,7 @@ import ("fmt""strings"+ "github.com/88250/lute/ast""github.com/siyuan-note/siyuan/kernel/filesys""github.com/siyuan-note/siyuan/kernel/model""github.com/siyuan-note/siyuan/kernel/treenode"@@ -29,7 +30,7 @@ import (var BlockTool = &Tool{Name: "block",- Description: "Block operations. Actions: get(id), get_kramdown(id), get_children(id), tree_stat(id, by document), dom(id), insert(data, dataType, parentID?, nextID?, previousID?), append(data, dataType, parentID) / prepend(...) add a NEW child and return its ID — use after block.update when both modifying and adding, update(id, data, dataType, lockType?) replaces ONE block only (no append), delete(id), move(id, parentID, previousID?), breadcrumb(id), batch_get(ids) / batch_kramdown(ids) where ids is comma-separated.",+ Description: "Block operations, including native Tabs (NodeTabs/NodeTabItem) and Mindmap (NodeMindmap/NodeMindmapItem). Actions: get(id), get_kramdown(id), get_children(id), tree_stat(id, by document), dom(id), insert(data, dataType, parentID?, nextID?, previousID?), append(data, dataType, parentID) / prepend(...) add a NEW child and return its ID — use after block.update when both modifying and adding, update(id, data, dataType, lockType?) replaces ONE block only (no append), delete(id), move(id, parentID, previousID?), breadcrumb(id), batch_get(ids) / batch_kramdown(ids) where ids is comma-separated. get/get_kramdown/batch_kramdown return Markdown for reading, which flattens tabs and renders mindmaps as lists; use dom before editing these containers, preserve IDs/attributes, and update with dataType=dom and lockType=true. Prefer editing body blocks individually and move/delete for structural changes.",InputSchema: ToolSchema{Type: "object",Properties: map[string]Property{@@ -37,9 +38,9 @@ var BlockTool = &Tool{"notebook": {Type: "string", Description: "Notebook ID that owns the target blocks; required for encrypted notebooks"},"id": {Type: "string", Description: "Block ID"},"ids": {Type: "string", Description: "Comma-separated block IDs (for batch_get, batch_kramdown)"},- "data": {Type: "string", Description: "Content in markdown or block DOM. Prefer markdown. A horizontal super-block uses {{{col with blank-line-separated child blocks and }}} on its own line; col is horizontal and row is vertical. Raw super-block DOM uses data-type=\"NodeSuperBlock\" and data-sb-layout, never data-layout, and every child needs an explicit data-type. Markdown block references use ((blockID \"anchor text\")); never [[blockID]]"},+ "data": {Type: "string", Description: "Content in markdown or block DOM. Prefer markdown for ordinary blocks. Native Tabs Markdown: ::: tabs\n@tab First\n\nBody\n\n@tab:active Second\n\nOther body\n\n::: (tabs requires a space). For nested tabs use a longer outer colon fence. Native Mindmap requires dataType=dom: <div data-type=\"NodeMindmap\" data-subtype=\"u\" class=\"mindmap\"><div data-type=\"NodeMindmapItem\" data-subtype=\"u\" data-marker=\"-\" class=\"mindmap-item\"><div data-type=\"NodeParagraph\" class=\"p\"><div contenteditable=\"true\">Root</div></div></div></div>. Nest NodeMindmap inside NodeMindmapItem for child branches; every block needs an explicit data-type. New native DOM blocks may omit data-node-id; the tool generates IDs. When inserting a Tabs or Mindmap group into an existing container of the same type, only its direct items are inserted; parent attributes remain unchanged. A horizontal super-block uses {{{col with blank-line-separated child blocks and }}} on its own line; col is horizontal and row is vertical. Raw super-block DOM uses data-type=\"NodeSuperBlock\" and data-sb-layout, never data-layout, and every child needs an explicit data-type. Markdown block references use ((blockID \"anchor text\")); never [[blockID]]"},"dataType": {Type: "string", Description: "Content type: markdown or dom", Enum: []string{"markdown", "dom"}},- "lockType": {Type: "boolean", Description: "Reject update when the parsed block type differs from the existing block type; defaults to false"},+ "lockType": {Type: "boolean", Description: "Reject update when the parsed block type differs from the existing block type; defaults to true for native Tabs/Mindmap containers and items, false otherwise. Set false only for an intentional type conversion"},"parentID": {Type: "string", Description: "Parent block ID"},"nextID": {Type: "string", Description: "Next sibling block ID (for insert)"},"previousID": {Type: "string", Description: "Previous sibling block ID (for insert)"},@@ -204,12 +205,9 @@ func blockInsert(args map[string]any) (CallToolResult, error) {}}- if dataType == "markdown" {- var err error- data, err = markdownToBlockDOM(data)- if err != nil {- return CallToolResult{Content: []ContentItem{{Type: "text", Text: "convert markdown failed: " + err.Error()}}, IsError: true}, nil- }+ data, err := prepareBlockWriteData(data, dataType)+ if err != nil {+ return blockToolError("prepare block data failed: " + err.Error())}operation := &model.Operation{@@ -260,12 +258,9 @@ func blockAppend(args map[string]any) (CallToolResult, error) {return CallToolResult{Content: []ContentItem{{Type: "text", Text: err.Error()}}, IsError: true}, nil}- if dataType == "markdown" {- var err error- data, err = markdownToBlockDOM(data)- if err != nil {- return CallToolResult{Content: []ContentItem{{Type: "text", Text: "convert markdown failed: " + err.Error()}}, IsError: true}, nil- }+ data, err := prepareBlockWriteData(data, dataType)+ if err != nil {+ return blockToolError("prepare block data failed: " + err.Error())}operation := &model.Operation{@@ -304,12 +299,9 @@ func blockPrepend(args map[string]any) (CallToolResult, error) {return CallToolResult{Content: []ContentItem{{Type: "text", Text: err.Error()}}, IsError: true}, nil}- if dataType == "markdown" {- var err error- data, err = markdownToBlockDOM(data)- if err != nil {- return CallToolResult{Content: []ContentItem{{Type: "text", Text: "convert markdown failed: " + err.Error()}}, IsError: true}, nil- }+ data, err := prepareBlockWriteData(data, dataType)+ if err != nil {+ return blockToolError("prepare block data failed: " + err.Error())}operation := &model.Operation{@@ -359,13 +351,30 @@ func blockUpdate(args map[string]any) (CallToolResult, error) {if _, exists := args["data"]; !exists {return CallToolResult{Content: []ContentItem{{Type: "text", Text: "data is required"}}, IsError: true}, nil}- lockType, _ := args["lockType"].(bool)- _, release, scopeErr := beginBlockToolScope(args, true, id)+ boxID, release, scopeErr := beginBlockToolScope(args, true, id)if scopeErr != nil {return blockToolError(scopeErr.Error())}defer release()+ lockType, explicitLockType := args["lockType"].(bool)+ if !explicitLockType {+ if block := treenode.GetBlockTreeInExactBox(id, boxID); block != nil {+ switch block.Type {+ case "tabs", "tab", "mindmap", "mindmap_item":+ lockType = true+ }+ }+ }++ if dataType == "dom" {+ var err error+ data, err = prepareBlockWriteData(data, dataType)+ if err != nil {+ return blockToolError("prepare block data failed: " + err.Error())+ }+ }+_, rootIDs, err := model.PerformBlockUpdates([]model.BlockUpdateInput{{ID: id,Data: data,@@ -432,6 +441,60 @@ func markdownToBlockDOM(md string) (string, error) {return result, nil}+// prepareBlockWriteData 为原生页签和脑图 DOM 中的新块补全 ID,保留已有块的 ID 和属性。+func prepareBlockWriteData(data, dataType string) (string, error) {+ if dataType == "markdown" {+ return markdownToBlockDOM(data)+ }+ if dataType != "dom" {+ return "", fmt.Errorf("unsupported block data type [%s]", dataType)+ }+ engine := util.NewLute()+ tree := engine.BlockDOM2Tree(data)+ if tree == nil || tree.Root == nil {+ return "", fmt.Errorf("parse tree failed")+ }+ hasNativeContainer := false+ ast.Walk(tree.Root, func(node *ast.Node, entering bool) ast.WalkStatus {+ if entering && (node.Type == ast.NodeTabs || node.Type == ast.NodeTabItem ||+ node.Type == ast.NodeMindmap || node.Type == ast.NodeMindmapItem) {+ hasNativeContainer = true+ return ast.WalkStop+ }+ return ast.WalkContinue+ })+ if !hasNativeContainer {+ return data, nil+ }+ var err error+ ids := map[string]struct{}{}+ ast.Walk(tree.Root, func(node *ast.Node, entering bool) ast.WalkStatus {+ if !entering || !node.IsBlock() || node.Type == ast.NodeDocument || node.Type == ast.NodeKramdownBlockIAL {+ return ast.WalkContinue+ }+ if node.ID == "" {+ node.ID = ast.NewNodeID()+ node.SetIALAttr("id", node.ID)+ } else if !ast.IsNodeIDPattern(node.ID) {+ err = fmt.Errorf("found invalid ID [%s]", node.ID)+ return ast.WalkStop+ }+ if _, exists := ids[node.ID]; exists {+ err = fmt.Errorf("found duplicate ID [%s]", node.ID)+ return ast.WalkStop+ }+ ids[node.ID] = struct{}{}+ if node.IALAttr("updated") == "" {+ node.SetIALAttr("updated", node.ID[:14])+ }+ return ast.WalkContinue+ })+ if err != nil {+ return "", err+ }+ return engine.Tree2BlockDOM(tree, engine.RenderOptions, engine.ParseOptions), nil+}+func blockMove(args map[string]any) (CallToolResult, error) {id, _ := args["id"].(string)if id == "" {diff --git a/kernel/mcp/tools/block_test.go b/kernel/mcp/tools/block_test.goindex cb4c5ad904..0dcbc46807 100644--- a/kernel/mcp/tools/block_test.go+++ b/kernel/mcp/tools/block_test.go@@ -12,6 +12,10 @@ import ("encoding/json""strings""testing"++ "github.com/88250/lute/ast"+ "github.com/siyuan-note/siyuan/kernel/treenode"+ "github.com/siyuan-note/siyuan/kernel/util")func TestBlockToolDocumentsSuperBlockSyntax(t *testing.T) {@@ -78,3 +82,74 @@ func TestBlockWriteSuccessRejectsEmptyID(t *testing.T) {t.Fatalf("expected empty block ID to fail: %#v", result)}}++const nativeMindmapTestDOM = `<div data-type="NodeMindmap" data-subtype="u" class="mindmap"><div data-type="NodeMindmapItem" data-subtype="u" data-marker="-" class="mindmap-item"><div data-type="NodeParagraph" class="p"><div contenteditable="true">Root</div></div><div data-type="NodeMindmap" data-subtype="u" class="mindmap"><div data-type="NodeMindmapItem" data-subtype="u" data-marker="-" class="mindmap-item"><div data-type="NodeParagraph" class="p"><div contenteditable="true">Child</div></div></div></div></div></div>`++func TestBlockToolCreatesNativeContainers(t *testing.T) {+ for _, tc := range []struct {+ name, data, dataType string+ want ast.NodeType+ count int+ }{+ {"tabs", "::: tabs\n@tab First\n\nBody\n\n@tab:active Second\n\nOther body\n\n:::\n", "markdown", ast.NodeTabs, 5},+ {"mindmap", nativeMindmapTestDOM, "dom", ast.NodeMindmap, 6},+ } {+ t.Run(tc.name, func(t *testing.T) {+ dom, err := prepareBlockWriteData(tc.data, tc.dataType)+ if err != nil {+ t.Fatal(err)+ }+ tree := util.NewLute().BlockDOM2Tree(dom)+ if tree.Root.FirstChild.Type != tc.want {+ t.Fatalf("expected native %s, got %s", tc.want, tree.Root.FirstChild.Type)+ }+ if err = treenode.ValidateBlockSubtree(tree.Root); err != nil {+ t.Fatal(err)+ }+ ids := map[string]bool{}+ ast.Walk(tree.Root, func(node *ast.Node, entering bool) ast.WalkStatus {+ if entering && node.IsBlock() && node.Type != ast.NodeDocument && node.Type != ast.NodeKramdownBlockIAL {+ if !ast.IsNodeIDPattern(node.ID) || ids[node.ID] || node.IALAttr("updated") == "" {+ t.Fatalf("invalid or duplicate block identity: %+v", node)+ }+ ids[node.ID] = true+ }+ return ast.WalkContinue+ })+ if len(ids) != tc.count {+ t.Fatalf("expected %d independently editable blocks, got %d", tc.count, len(ids))+ }+ if tc.want == ast.NodeTabs && tree.Root.FirstChild.IALAttr("tabs-active-id") != tree.Root.FirstChild.ChildrenByType(ast.NodeTabItem)[1].ID {+ t.Fatal("active tab was not preserved")+ }+ })+ }+}++func TestBlockToolPreservesNativeDOMIdentity(t *testing.T) {+ const id = "20261007000000-para001"+ dom := strings.Replace(nativeMindmapTestDOM, `data-type="NodeParagraph"`, `data-node-id="`+id+`" updated="20261006000000" custom-test="kept" data-type="NodeParagraph"`, 1)+ prepared, err := prepareBlockWriteData(dom, "dom")+ if err != nil {+ t.Fatal(err)+ }+ node := treenode.GetNodeInTree(util.NewLute().BlockDOM2Tree(prepared), id)+ if node == nil || node.IALAttr("updated") != "20261006000000" || node.IALAttr("custom-test") != "kept" {+ t.Fatal("existing identity or attributes were changed")+ }+ if _, err = prepareBlockWriteData(strings.Replace(dom, id, "invalid", 1), "dom"); err == nil {+ t.Fatal("invalid explicit block ID was accepted")+ }+ duplicate := strings.Replace(nativeMindmapTestDOM, `data-type="NodeParagraph"`, `data-node-id="`+id+`" data-type="NodeParagraph"`, -1)+ if _, err = prepareBlockWriteData(duplicate, "dom"); err == nil {+ t.Fatal("duplicate explicit block IDs were accepted")+ }+}++func TestBlockToolDocumentsNativeContainerEditing(t *testing.T) {+ for _, instruction := range []string{"NodeTabs/NodeTabItem", "NodeMindmap/NodeMindmapItem", "use dom before editing", "lockType=true"} {+ if !strings.Contains(BlockTool.Description, instruction) {+ t.Fatalf("missing native container instruction %q", instruction)+ }+ }+}diff --git a/kernel/model/transaction.go b/kernel/model/transaction.goindex 77b1edc8e1..4a1bee4b4b 100644--- a/kernel/model/transaction.go+++ b/kernel/model/transaction.go@@ -1034,6 +1034,11 @@ func (tx *Transaction) doPrependInsert(operation *Operation) (ret *TxErr) {data := strings.ReplaceAll(operation.Data.(string), editor.FrontEndCaret, "")subTree := tx.luteEngine.BlockDOM2Tree(data)+ if changed, insertErr := unwrapNativeContainerInsert(subTree.Root, treenode.GetNodeInTree(tree, operation.ParentID)); insertErr != nil {+ return &TxErr{code: TxErrCodeReloadUI, msg: insertErr.Error(), id: operation.ParentID}+ } else if changed {+ operation.Data = tx.luteEngine.Tree2BlockDOM(subTree, tx.luteEngine.RenderOptions, tx.luteEngine.ParseOptions)+ }// 兜底校验:禁止跨加密边界块引(粘贴/拖拽/API 直调可能携带跨边界引用)// subTree.Box 此时尚未设置,用目标树所在 box 作为 srcBoxtx.degradeCrossBoundaryBlockRefs(subTree.Root, tree.Box)@@ -1137,6 +1142,11 @@ func (tx *Transaction) doAppendInsert(operation *Operation) (ret *TxErr) {data := strings.ReplaceAll(operation.Data.(string), editor.FrontEndCaret, "")subTree := tx.luteEngine.BlockDOM2Tree(data)+ if changed, insertErr := unwrapNativeContainerInsert(subTree.Root, treenode.GetNodeInTree(tree, operation.ParentID)); insertErr != nil {+ return &TxErr{code: TxErrCodeReloadUI, msg: insertErr.Error(), id: operation.ParentID}+ } else if changed {+ operation.Data = tx.luteEngine.Tree2BlockDOM(subTree, tx.luteEngine.RenderOptions, tx.luteEngine.ParseOptions)+ }// 兜底校验:禁止跨加密边界块引(粘贴/拖拽/API 直调可能携带跨边界引用)// subTree.Box 此时尚未设置,用目标树所在 box 作为 srcBoxtx.degradeCrossBoundaryBlockRefs(subTree.Root, tree.Box)@@ -1732,6 +1742,15 @@ func (tx *Transaction) doInsert0(operation *Operation, tree *parse.Tree) (ret *Tdata := strings.ReplaceAll(operation.Data.(string), editor.FrontEndCaret, "")subTree := tx.luteEngine.BlockDOM2Tree(data)+ insertParent := treenode.GetNodeInTree(tree, operation.ParentID)+ if node != nil {+ insertParent = node.Parent+ }+ if changed, insertErr := unwrapNativeContainerInsert(subTree.Root, insertParent); insertErr != nil {+ return &TxErr{code: TxErrCodeReloadUI, msg: insertErr.Error(), id: operation.ParentID}+ } else if changed {+ operation.Data = tx.luteEngine.Tree2BlockDOM(subTree, tx.luteEngine.RenderOptions, tx.luteEngine.ParseOptions)+ }subTree.Box, subTree.Path = tree.Box, tree.Pathtx.processGlobalAssets(subTree)// 兜底校验:禁止跨加密边界块引(粘贴/拖拽/API 直调可能携带跨边界引用)diff --git a/kernel/model/transaction_native_container.go b/kernel/model/transaction_native_container.gonew file mode 100644index 0000000000..fe7ebdc5d5--- /dev/null+++ b/kernel/model/transaction_native_container.go@@ -0,0 +1,40 @@+package model++import (+ "fmt"++ "github.com/88250/lute/ast"+ "github.com/siyuan-note/siyuan/kernel/treenode"+)++// unwrapNativeContainerInsert 将同类型页签或脑图片段的直属项目插入目标容器,保留项目的 ID 和属性。+func unwrapNativeContainerInsert(root, parent *ast.Node) (changed bool, err error) {+ if root == nil || parent == nil || (parent.Type != ast.NodeTabs && parent.Type != ast.NodeMindmap) {+ return false, nil+ }+ for node := root.FirstChild; node != nil; {+ next := node.Next+ if node.Type == parent.Type && node.FirstChild != nil {+ for child := node.FirstChild; child != nil; {+ childNext := child.Next+ child.Unlink()+ node.InsertBefore(child)+ child = childNext+ }+ if next != nil && next.Type == ast.NodeKramdownBlockIAL {+ ial := next+ next = next.Next+ ial.Unlink()+ }+ node.Unlink()+ changed = true+ }+ node = next+ }+ for node := root.FirstChild; node != nil; node = node.Next {+ if node.IsBlock() && node.Type != ast.NodeKramdownBlockIAL && !treenode.CanContainBlock(parent.Type, node.Type) {+ return false, fmt.Errorf("%s cannot directly contain %s", parent.Type, node.Type)+ }+ }+ return+}diff --git a/kernel/treenode/blocktree.go b/kernel/treenode/blocktree.goindex f651ab4b35..b35372f688 100644--- a/kernel/treenode/blocktree.go+++ b/kernel/treenode/blocktree.go@@ -504,7 +504,7 @@ func GetBlockTree(id string) (ret *BlockTree) {// 入参 abbrType 对应 BlockTree.Type(如 "d"/"h"/"p"),由 TypeAbbr 写入。func IsContainerType(abbrType string) bool {switch abbrType {- case "d", "b", "l", "i", "s", "callout", "tab", "mindmap", "mindmap_item":+ case "d", "b", "l", "i", "s", "callout", "tabs", "tab", "mindmap", "mindmap_item":return true}return falsediff --git a/kernel/treenode/container_type_test.go b/kernel/treenode/container_type_test.goindex f287330d12..77c8e16cf3 100644--- a/kernel/treenode/container_type_test.go+++ b/kernel/treenode/container_type_test.go@@ -3,12 +3,12 @@ package treenodeimport "testing"func TestIsContainerType(t *testing.T) {- for _, typ := range []string{"d", "b", "l", "i", "s", "callout", "tab"} {+ for _, typ := range []string{"d", "b", "l", "i", "s", "callout", "tabs", "tab", "mindmap", "mindmap_item"} {if !IsContainerType(typ) {t.Errorf("expected %q to accept child blocks", typ)}}- for _, typ := range []string{"tabs", "h", "p", "c", "", "unknown"} {+ for _, typ := range []string{"h", "p", "c", "", "unknown"} {if IsContainerType(typ) {t.Errorf("expected %q to reject direct child writes", typ)}