Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Load super block DOM without block tree entries https://github.com/siyuan-note/siyuan/issues/18804

Danield65371b70d88
diff --git a/kernel/model/block.go b/kernel/model/block.go
index 3f1e2e5c5f..4e60eee46d 100644
--- a/kernel/model/block.go
+++ b/kernel/model/block.go
@@ -1282,6 +1282,13 @@ func resolveEmbedContent(n *ast.Node, luteEngine *lute.Lute) {
// loadTreeForBlockDOM 按指定 box 加载树,空 box 不回退搜索已打开的加密笔记本。
func loadTreeForBlockDOM(id, boxID string) *parse.Tree {
bt := treenode.GetBlockTreeInBox(id, boxID)
+ if nil == bt {
+ block := sql.GetBlockInBox(id, boxID)
+ if nil == block {
+ return nil
+ }
+ bt = treenode.GetBlockTreeInBox(block.RootID, boxID)
+ }
if nil == bt {
return nil
}
diff --git a/kernel/model/transaction_fold_fts5_test.go b/kernel/model/transaction_fold_fts5_test.go
index a7623a67a2..5a4003d563 100644
--- a/kernel/model/transaction_fold_fts5_test.go
+++ b/kernel/model/transaction_fold_fts5_test.go
@@ -22,6 +22,7 @@ import (
"os"
"path/filepath"
"slices"
+ "strings"
"testing"
"github.com/88250/lute/ast"
@@ -72,6 +73,15 @@ func TestCancelFoldedHeadingSuperBlockKeepsUndoBoundary(t *testing.T) {
t.Fatalf("write test tree failed: %s", err)
}
treenode.UpsertBlockTree(tree)
+ sql.IndexTreeQueue(tree)
+ sql.FlushQueue()
+ treenode.RemoveBlockTree(tree.Box, superBlockID)
+ superBlockDOM := GetBlockDOM(superBlockID)
+ for _, id := range []string{superBlockID, headingID, paragraphID} {
+ if !strings.Contains(superBlockDOM, `data-node-id="`+id+`"`) {
+ t.Fatalf("rendered super block DOM should contain block [%s]", id)
+ }
+ }
doOperations := []*Operation{
{Action: "unfoldHeading", ID: headingID},