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/16233 https://github.com/siyuan-note/siyuan/issues/16121

Daniel15fc11e60003
diff --git a/kernel/model/outline.go b/kernel/model/outline.go
index 766fbf9a1c..d63d1cf91f 100644
--- a/kernel/model/outline.go
+++ b/kernel/model/outline.go
@@ -239,10 +239,15 @@ func Outline(rootID string, preview bool) (ret []*Path, err error) {
ret = outline(tree)
storage, _ := GetOutlineStorage(rootID)
- if nil == storage {
- // 默认展开顶层
+ if nil == storage || 0 == len(storage) {
+ // 默认全部展开
for _, p := range ret {
- p.Folded = false
+ for _, b := range p.Blocks {
+ b.Folded = false
+ for _, c := range b.Children {
+ walkChildren(c, []string{"expandAll"})
+ }
+ }
}
}
@@ -254,8 +259,6 @@ func Outline(rootID string, preview bool) (ret []*Path, err error) {
}
for _, p := range ret {
- p.Folded = false // 顶层默认展开
-
for _, b := range p.Blocks {
b.Folded = !gulu.Str.Contains(b.ID, expandIDs)
for _, c := range b.Children {
@@ -268,7 +271,12 @@ func Outline(rootID string, preview bool) (ret []*Path, err error) {
}
func walkChildren(b *Block, expandIDs []string) {
- b.Folded = !gulu.Str.Contains(b.ID, expandIDs)
+ if 1 == len(expandIDs) && "expandAll" == expandIDs[0] {
+ b.Folded = false
+ } else {
+ b.Folded = !gulu.Str.Contains(b.ID, expandIDs)
+ }
+
for _, c := range b.Children {
walkChildren(c, expandIDs)
}