mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-02-28 05:32:52 +00:00
🎨 Display reference counts in the backlink panel https://github.com/siyuan-note/siyuan/issues/13618
This commit is contained in:
@@ -20,14 +20,12 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/88250/lute/render"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/88250/lute/ast"
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/88250/lute/render"
|
||||
"github.com/open-spaced-repetition/go-fsrs/v3"
|
||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||
@@ -902,33 +900,7 @@ func getEmbeddedBlock(trees map[string]*parse.Tree, sqlBlock *sql.Block, heading
|
||||
}
|
||||
|
||||
// 嵌入块查询结果中显示块引用计数 https://github.com/siyuan-note/siyuan/issues/7191
|
||||
var defIDs []string
|
||||
for _, n := range nodes {
|
||||
ast.Walk(n, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering {
|
||||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
if n.IsBlock() {
|
||||
defIDs = append(defIDs, n.ID)
|
||||
}
|
||||
return ast.WalkContinue
|
||||
})
|
||||
}
|
||||
defIDs = gulu.Str.RemoveDuplicatedElem(defIDs)
|
||||
refCount := sql.QueryRefCount(defIDs)
|
||||
for _, n := range nodes {
|
||||
ast.Walk(n, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering || !n.IsBlock() {
|
||||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
if cnt := refCount[n.ID]; 0 < cnt {
|
||||
n.SetIALAttr("refcount", strconv.Itoa(cnt))
|
||||
}
|
||||
return ast.WalkContinue
|
||||
})
|
||||
}
|
||||
fillBlockRefCount(nodes)
|
||||
|
||||
luteEngine := NewLute()
|
||||
luteEngine.RenderOptions.ProtyleContenteditable = false // 不可编辑
|
||||
|
||||
Reference in New Issue
Block a user