This commit is contained in:
Daniel 2023-10-06 22:26:00 +08:00
parent 0f64f95733
commit 3b9d4b3a73
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

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