Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/11542

Danield9a19bb3dc19
diff --git a/kernel/api/block.go b/kernel/api/block.go
index addafe6cd3..e6e2a62a4d 100644
--- a/kernel/api/block.go
+++ b/kernel/api/block.go
@@ -233,7 +233,11 @@ func checkBlockFold(c *gin.Context) {
}
id := arg["id"].(string)
- ret.Data = model.IsBlockFolded(id)
+ isFolded, isRoot := model.IsBlockFolded(id)
+ ret.Data = map[string]interface{}{
+ "isFolded": isFolded,
+ "isRoot": isRoot,
+ }
}
func checkBlockExist(c *gin.Context) {
diff --git a/kernel/model/block.go b/kernel/model/block.go
index 4f551bda4d..defd002ad9 100644
--- a/kernel/model/block.go
+++ b/kernel/model/block.go
@@ -268,20 +268,31 @@ func GetBlockSiblingID(id string) (parent, previous, next string) {
return
}
-func IsBlockFolded(id string) bool {
+func IsBlockFolded(id string) (isFolded, isRoot bool) {
+ tree, _ := LoadTreeByBlockID(id)
+ if nil == tree {
+ return
+ }
+
+ if tree.Root.ID == id {
+ isRoot = true
+ }
+
for i := 0; i < 32; i++ {
b, _ := getBlock(id, nil)
if nil == b {
- return false
+ return
}
if "1" == b.IAL["fold"] {
- return true
+ isFolded = true
+ return
}
id = b.ParentID
+
}
- return false
+ return
}
func RecentUpdatedBlocks() (ret []*Block) {