mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-10 22:23:28 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
12873e8f15
@ -151,9 +151,35 @@ func GetBacklinkDoc(defID, refTreeID, keyword string, containChildren bool) (ret
|
|||||||
}
|
}
|
||||||
|
|
||||||
sortBacklinks(ret, refTree)
|
sortBacklinks(ret, refTree)
|
||||||
|
|
||||||
|
for i := len(ret) - 1; 0 < i; i-- {
|
||||||
|
curPaths := ret[i].BlockPaths
|
||||||
|
prevPaths := ret[i-1].BlockPaths
|
||||||
|
// 如果当前反链的面包屑和前一个反链的面包屑一致,则清空当前反链的面包屑以简化显示
|
||||||
|
if blockPathsEqual(curPaths, prevPaths) {
|
||||||
|
ret[i].BlockPaths = []*BlockPath{}
|
||||||
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func blockPathsEqual(paths1, paths2 []*BlockPath) bool {
|
||||||
|
if len(paths1) != len(paths2) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if 2 < len(paths1) {
|
||||||
|
paths1 = paths1[:len(paths1)-1]
|
||||||
|
paths2 = paths2[:len(paths2)-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := range paths1 {
|
||||||
|
if paths1[i].ID != paths2[i].ID {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func sortBacklinks(backlinks []*Backlink, tree *parse.Tree) {
|
func sortBacklinks(backlinks []*Backlink, tree *parse.Tree) {
|
||||||
contentSorts := map[string]int{}
|
contentSorts := map[string]int{}
|
||||||
sortVal := 0
|
sortVal := 0
|
||||||
@ -206,13 +232,16 @@ func buildBacklink(refID string, refTree *parse.Tree, keywords []string, luteEng
|
|||||||
}
|
}
|
||||||
|
|
||||||
dom := renderBlockDOMByNodes(renderNodes, luteEngine)
|
dom := renderBlockDOMByNodes(renderNodes, luteEngine)
|
||||||
blockPaths := []*BlockPath{}
|
var blockPaths []*BlockPath
|
||||||
if (nil != n.Parent && ast.NodeDocument != n.Parent.Type && nil != n.Parent.Parent && ast.NodeDocument != n.Parent.Parent.Type) || nil != treenode.HeadingParent(n) {
|
if (nil != n.Parent && ast.NodeDocument != n.Parent.Type) || 0 != treenode.HeadingLevel(n) {
|
||||||
// 仅在多于一层时才显示面包屑,这样界面展示更加简洁
|
// 仅在多于一层时才显示面包屑,这样界面展示更加简洁
|
||||||
// The backlink panel no longer displays breadcrumbs of the first-level blocks https://github.com/siyuan-note/siyuan/issues/12862
|
// The backlink panel no longer displays breadcrumbs of the first-level blocks https://github.com/siyuan-note/siyuan/issues/12862
|
||||||
// Improve the backlink panel breadcrumb and block sorting https://github.com/siyuan-note/siyuan/issues/13008
|
// Improve the backlink panel breadcrumb and block sorting https://github.com/siyuan-note/siyuan/issues/13008
|
||||||
blockPaths = buildBlockBreadcrumb(n, nil, false)
|
blockPaths = buildBlockBreadcrumb(n, nil, false)
|
||||||
}
|
}
|
||||||
|
if 1 > len(blockPaths) {
|
||||||
|
blockPaths = []*BlockPath{}
|
||||||
|
}
|
||||||
ret = &Backlink{DOM: dom, BlockPaths: blockPaths, Expand: expand, node: n}
|
ret = &Backlink{DOM: dom, BlockPaths: blockPaths, Expand: expand, node: n}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -420,7 +420,7 @@ func BuildBlockBreadcrumb(id string, excludeTypes []string) (ret []*BlockPath, e
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildBlockBreadcrumb(node *ast.Node, excludeTypes []string, displayCurrentNodeContent bool) (ret []*BlockPath) {
|
func buildBlockBreadcrumb(node *ast.Node, excludeTypes []string, displayCurrentNode bool) (ret []*BlockPath) {
|
||||||
ret = []*BlockPath{}
|
ret = []*BlockPath{}
|
||||||
if nil == node {
|
if nil == node {
|
||||||
return
|
return
|
||||||
@ -481,9 +481,8 @@ func buildBlockBreadcrumb(node *ast.Node, excludeTypes []string, displayCurrentN
|
|||||||
name = strings.ReplaceAll(name, editor.Caret, "")
|
name = strings.ReplaceAll(name, editor.Caret, "")
|
||||||
name = util.EscapeHTML(name)
|
name = util.EscapeHTML(name)
|
||||||
|
|
||||||
if parent == node && !displayCurrentNodeContent {
|
if parent == node && !displayCurrentNode {
|
||||||
// 反链中不显示当前块内容 https://github.com/siyuan-note/siyuan/issues/12862#issuecomment-2426406327
|
add = false
|
||||||
name = ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if add {
|
if add {
|
||||||
|
Loading…
Reference in New Issue
Block a user