From 3dc2d80821b7aa1f581ea12dda149d42e24451b8 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sun, 19 Feb 2023 09:38:09 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=94=AF=E6=8C=81=E5=9F=BA=E4=BA=8E?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E5=A4=8D=E4=B9=A0=E9=97=AA=E5=8D=A1=20https:?= =?UTF-8?q?//github.com/siyuan-note/siyuan/issues/7057?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/flashcard.go | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index 1dd810409..2cea61fa7 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -18,7 +18,6 @@ package model import ( "errors" - "github.com/siyuan-note/siyuan/kernel/sql" "math" "os" "path/filepath" @@ -34,6 +33,8 @@ import ( "github.com/siyuan-note/logging" "github.com/siyuan-note/riff" "github.com/siyuan-note/siyuan/kernel/cache" + "github.com/siyuan-note/siyuan/kernel/filesys" + "github.com/siyuan-note/siyuan/kernel/sql" "github.com/siyuan-note/siyuan/kernel/treenode" "github.com/siyuan-note/siyuan/kernel/util" ) @@ -49,15 +50,34 @@ func GetTreeFlashcards(rootID string, page int) (blocks []*Block, total, pageCou return } - treeBlockIDs := map[string]bool{} - ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus { - if !entering || !n.IsBlock() { - return ast.WalkContinue + trees := []*parse.Tree{tree} + box := Conf.Box(tree.Box) + luteEngine := util.NewLute() + files := box.ListFiles(tree.Path) + for _, subFile := range files { + if !strings.HasSuffix(subFile.path, ".sy") { + continue } - treeBlockIDs[n.ID] = true - return ast.WalkContinue - }) + subTree, loadErr := filesys.LoadTree(box.ID, subFile.path, luteEngine) + if nil != loadErr { + continue + } + + trees = append(trees, subTree) + } + + treeBlockIDs := map[string]bool{} + for _, t := range trees { + ast.Walk(t.Root, func(n *ast.Node, entering bool) ast.WalkStatus { + if !entering || !n.IsBlock() { + return ast.WalkContinue + } + + treeBlockIDs[n.ID] = true + return ast.WalkContinue + }) + } var allBlockIDs []string const pageSize = 20