mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
7b9a74ea52
5 changed files with 20 additions and 16 deletions
|
@ -221,6 +221,10 @@ func (value *Value) IsEdited() bool {
|
|||
}
|
||||
|
||||
func (value *Value) IsEmpty() bool {
|
||||
if nil == value {
|
||||
return true
|
||||
}
|
||||
|
||||
switch value.Type {
|
||||
case KeyTypeBlock:
|
||||
if nil == value.Block {
|
||||
|
|
|
@ -72,18 +72,6 @@ func LoadTrees(ids []string) (ret map[string]*parse.Tree) {
|
|||
return
|
||||
}
|
||||
|
||||
func LoadTree(boxID, p string, luteEngine *lute.Lute) (ret *parse.Tree, err error) {
|
||||
filePath := filepath.Join(util.DataDir, boxID, p)
|
||||
data, err := filelock.ReadFile(filePath)
|
||||
if err != nil {
|
||||
logging.LogErrorf("load tree [%s] failed: %s", p, err)
|
||||
return
|
||||
}
|
||||
|
||||
ret, err = LoadTreeByData(data, boxID, p, luteEngine)
|
||||
return
|
||||
}
|
||||
|
||||
func batchLoadTrees(boxIDs, paths []string, luteEngine *lute.Lute) (ret []*parse.Tree, errs []error) {
|
||||
waitGroup := sync.WaitGroup{}
|
||||
lock := sync.Mutex{}
|
||||
|
@ -119,6 +107,18 @@ func batchLoadTrees(boxIDs, paths []string, luteEngine *lute.Lute) (ret []*parse
|
|||
return
|
||||
}
|
||||
|
||||
func LoadTree(boxID, p string, luteEngine *lute.Lute) (ret *parse.Tree, err error) {
|
||||
filePath := filepath.Join(util.DataDir, boxID, p)
|
||||
data, err := filelock.ReadFile(filePath)
|
||||
if err != nil {
|
||||
logging.LogErrorf("load tree [%s] failed: %s", p, err)
|
||||
return
|
||||
}
|
||||
|
||||
ret, err = LoadTreeByData(data, boxID, p, luteEngine)
|
||||
return
|
||||
}
|
||||
|
||||
func LoadTreeByData(data []byte, boxID, p string, luteEngine *lute.Lute) (ret *parse.Tree, err error) {
|
||||
ret = parseJSON2Tree(boxID, p, data, luteEngine)
|
||||
if nil == ret {
|
||||
|
|
|
@ -230,7 +230,7 @@ func buildBacklink(refID string, refTree *parse.Tree, keywords []string, highlig
|
|||
}
|
||||
|
||||
// 反链面板中显示块引用计数 Display reference counts in the backlink panel https://github.com/siyuan-note/siyuan/issues/13618
|
||||
fillBlockRefCount(renderNodes, 1)
|
||||
fillBlockRefCount(renderNodes)
|
||||
|
||||
dom := renderBlockDOMByNodes(renderNodes, luteEngine)
|
||||
var blockPaths []*BlockPath
|
||||
|
|
|
@ -900,7 +900,7 @@ func getEmbeddedBlock(trees map[string]*parse.Tree, sqlBlock *sql.Block, heading
|
|||
}
|
||||
|
||||
// 嵌入块查询结果中显示块引用计数 https://github.com/siyuan-note/siyuan/issues/7191
|
||||
fillBlockRefCount(nodes, 0)
|
||||
fillBlockRefCount(nodes)
|
||||
|
||||
luteEngine := NewLute()
|
||||
luteEngine.RenderOptions.ProtyleContenteditable = false // 不可编辑
|
||||
|
|
|
@ -144,7 +144,7 @@ func renderBlockText(node *ast.Node, excludeTypes []string, removeLineBreak bool
|
|||
return
|
||||
}
|
||||
|
||||
func fillBlockRefCount(nodes []*ast.Node, minRefCount int) {
|
||||
func fillBlockRefCount(nodes []*ast.Node) {
|
||||
var defIDs []string
|
||||
for _, n := range nodes {
|
||||
ast.Walk(n, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
|
@ -166,7 +166,7 @@ func fillBlockRefCount(nodes []*ast.Node, minRefCount int) {
|
|||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
if cnt := refCount[n.ID]; minRefCount < cnt {
|
||||
if cnt := refCount[n.ID]; 0 < cnt {
|
||||
n.SetIALAttr("refcount", strconv.Itoa(cnt))
|
||||
}
|
||||
return ast.WalkContinue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue