mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 08:30:12 +01:00
🎨 Improve doc dynamic loading https://github.com/siyuan-note/siyuan/issues/10851
This commit is contained in:
parent
435a53cb49
commit
9c61d2a36f
4 changed files with 12 additions and 6 deletions
|
|
@ -50,6 +50,11 @@ type Editor struct {
|
||||||
BackmentionExpandCount int `json:"backmentionExpandCount"` // 反链提及默认展开数量
|
BackmentionExpandCount int `json:"backmentionExpandCount"` // 反链提及默认展开数量
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
MinDynamicLoadBlocks = 48
|
||||||
|
MaxDynamicLoadBlocks = 1024
|
||||||
|
)
|
||||||
|
|
||||||
func NewEditor() *Editor {
|
func NewEditor() *Editor {
|
||||||
return &Editor{
|
return &Editor{
|
||||||
FontSize: 16,
|
FontSize: 16,
|
||||||
|
|
|
||||||
|
|
@ -242,11 +242,11 @@ func InitConf() {
|
||||||
if 1 > Conf.Editor.HistoryRetentionDays {
|
if 1 > Conf.Editor.HistoryRetentionDays {
|
||||||
Conf.Editor.HistoryRetentionDays = 30
|
Conf.Editor.HistoryRetentionDays = 30
|
||||||
}
|
}
|
||||||
if 48 > Conf.Editor.DynamicLoadBlocks {
|
if conf.MinDynamicLoadBlocks > Conf.Editor.DynamicLoadBlocks {
|
||||||
Conf.Editor.DynamicLoadBlocks = 48
|
Conf.Editor.DynamicLoadBlocks = conf.MinDynamicLoadBlocks
|
||||||
}
|
}
|
||||||
if 1024 < Conf.Editor.DynamicLoadBlocks {
|
if conf.MaxDynamicLoadBlocks < Conf.Editor.DynamicLoadBlocks {
|
||||||
Conf.Editor.DynamicLoadBlocks = 1024
|
Conf.Editor.DynamicLoadBlocks = conf.MaxDynamicLoadBlocks
|
||||||
}
|
}
|
||||||
if 0 > Conf.Editor.BacklinkExpandCount {
|
if 0 > Conf.Editor.BacklinkExpandCount {
|
||||||
Conf.Editor.BacklinkExpandCount = 0
|
Conf.Editor.BacklinkExpandCount = 0
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ import (
|
||||||
"github.com/siyuan-note/riff"
|
"github.com/siyuan-note/riff"
|
||||||
"github.com/siyuan-note/siyuan/kernel/av"
|
"github.com/siyuan-note/siyuan/kernel/av"
|
||||||
"github.com/siyuan-note/siyuan/kernel/cache"
|
"github.com/siyuan-note/siyuan/kernel/cache"
|
||||||
|
"github.com/siyuan-note/siyuan/kernel/conf"
|
||||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
"github.com/siyuan-note/siyuan/kernel/filesys"
|
||||||
"github.com/siyuan-note/siyuan/kernel/search"
|
"github.com/siyuan-note/siyuan/kernel/search"
|
||||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||||
|
|
@ -665,7 +666,7 @@ func GetDoc(startID, endID, id string, index int, query string, queryTypes map[s
|
||||||
childCount += treenode.CountBlockNodes(n)
|
childCount += treenode.CountBlockNodes(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
if childCount > Conf.Editor.DynamicLoadBlocks {
|
if childCount > Conf.Editor.DynamicLoadBlocks && blockCount > conf.MinDynamicLoadBlocks {
|
||||||
scroll = true
|
scroll = true
|
||||||
return ast.WalkStop
|
return ast.WalkStop
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -342,7 +342,7 @@ func FirstLeafBlock(node *ast.Node) (ret *ast.Node) {
|
||||||
|
|
||||||
func CountBlockNodes(node *ast.Node) (ret int) {
|
func CountBlockNodes(node *ast.Node) (ret int) {
|
||||||
ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus {
|
ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||||
if !entering || !n.IsBlock() || ast.NodeList == n.Type || ast.NodeBlockquote == n.Type || ast.NodeSuperBlock == n.Type {
|
if !entering || !n.IsBlock() || ast.NodeList == n.Type || ast.NodeListItem == n.Type || ast.NodeBlockquote == n.Type || ast.NodeSuperBlock == n.Type {
|
||||||
return ast.WalkContinue
|
return ast.WalkContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue