Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2023-10-06 22:33:16 +08:00
commit 872a409ec4

View file

@ -23,6 +23,7 @@ import (
"strings"
"github.com/88250/lute/parse"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/cache"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/treenode"
@ -162,16 +163,26 @@ func BuildBookmark() (ret *Bookmarks) {
ret = &Bookmarks{}
sqlBlocks := sql.QueryBookmarkBlocks()
labelBlocks := map[BookmarkLabel]BookmarkBlocks{}
blocks := fromSQLBlocks(&sqlBlocks, "", 0)
luteEngine := NewLute()
for _, block := range blocks {
label := BookmarkLabel(block.IAL["bookmark"])
if "" != block.Name {
// Blocks in the bookmark panel display their name instead of content https://github.com/siyuan-note/siyuan/issues/8514
block.Content = block.Name
} else {
// Improve bookmark panel rendering https://github.com/siyuan-note/siyuan/issues/9361
tree, err := loadTreeByBlockID(block.ID)
if nil != err {
logging.LogErrorf("parse block [%s] failed: %s", block.ID, err)
} else {
n := treenode.GetNodeInTree(tree, block.ID)
block.Content = renderOutline(n, luteEngine)
}
}
label := BookmarkLabel(block.IAL["bookmark"])
if bs, ok := labelBlocks[label]; ok {
bs = append(bs, block)
labelBlocks[label] = bs