mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-24 02:20:13 +01:00
🎨 Export related flashcard data when exporting .sy.zip https://github.com/siyuan-note/siyuan/issues/9372
This commit is contained in:
parent
2ca7253d1f
commit
a8806968d0
3 changed files with 72 additions and 2 deletions
|
|
@ -148,6 +148,12 @@ func GetNotebookFlashcards(boxID string, page int) (blocks []*Block, total, page
|
|||
|
||||
func GetTreeFlashcards(rootID string, page int) (blocks []*Block, total, pageCount int) {
|
||||
blocks = []*Block{}
|
||||
cards := getTreeSubTreeFlashcards(rootID)
|
||||
blocks, total, pageCount = getCardsBlocks(cards, page)
|
||||
return
|
||||
}
|
||||
|
||||
func getTreeSubTreeFlashcards(rootID string) (ret []riff.Card) {
|
||||
deck := Decks[builtinDeckID]
|
||||
if nil == deck {
|
||||
return
|
||||
|
|
@ -162,9 +168,26 @@ func GetTreeFlashcards(rootID string, page int) (blocks []*Block, total, pageCou
|
|||
}
|
||||
}
|
||||
allBlockIDs = gulu.Str.RemoveDuplicatedElem(allBlockIDs)
|
||||
cards := deck.GetCardsByBlockIDs(allBlockIDs)
|
||||
ret = deck.GetCardsByBlockIDs(allBlockIDs)
|
||||
return
|
||||
}
|
||||
|
||||
blocks, total, pageCount = getCardsBlocks(cards, page)
|
||||
func getTreeFlashcards(rootID string) (ret []riff.Card) {
|
||||
deck := Decks[builtinDeckID]
|
||||
if nil == deck {
|
||||
return
|
||||
}
|
||||
|
||||
var allBlockIDs []string
|
||||
deckBlockIDs := deck.GetBlockIDs()
|
||||
treeBlockIDsMap, _ := getTreeBlocks(rootID)
|
||||
for _, blockID := range deckBlockIDs {
|
||||
if treeBlockIDsMap[blockID] {
|
||||
allBlockIDs = append(allBlockIDs, blockID)
|
||||
}
|
||||
}
|
||||
allBlockIDs = gulu.Str.RemoveDuplicatedElem(allBlockIDs)
|
||||
ret = deck.GetCardsByBlockIDs(allBlockIDs)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -420,6 +443,16 @@ func getTreeSubTreeChildBlocks(rootID string) (treeBlockIDsMap map[string]bool,
|
|||
return
|
||||
}
|
||||
|
||||
func getTreeBlocks(rootID string) (treeBlockIDsMap map[string]bool, treeBlockIDs []string) {
|
||||
treeBlockIDsMap = map[string]bool{}
|
||||
bts := treenode.GetBlockTreesByRootID(rootID)
|
||||
for _, bt := range bts {
|
||||
treeBlockIDsMap[bt.ID] = true
|
||||
treeBlockIDs = append(treeBlockIDs, bt.ID)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func getBoxBlocks(boxID string) (blockIDsMap map[string]bool, blockIDs []string) {
|
||||
blockIDsMap = map[string]bool{}
|
||||
bts := treenode.GetBlockTreesByBoxID(boxID)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue