mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-12 23:21:23 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
cca0ef4e37
@ -51,7 +51,7 @@ func getBackmentionDoc(c *gin.Context) {
|
|||||||
defID := arg["defID"].(string)
|
defID := arg["defID"].(string)
|
||||||
refTreeID := arg["refTreeID"].(string)
|
refTreeID := arg["refTreeID"].(string)
|
||||||
keyword := arg["keyword"].(string)
|
keyword := arg["keyword"].(string)
|
||||||
containChildren := true
|
containChildren := false
|
||||||
if val, ok := arg["containChildren"]; ok {
|
if val, ok := arg["containChildren"]; ok {
|
||||||
containChildren = val.(bool)
|
containChildren = val.(bool)
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ func getBacklinkDoc(c *gin.Context) {
|
|||||||
defID := arg["defID"].(string)
|
defID := arg["defID"].(string)
|
||||||
refTreeID := arg["refTreeID"].(string)
|
refTreeID := arg["refTreeID"].(string)
|
||||||
keyword := arg["keyword"].(string)
|
keyword := arg["keyword"].(string)
|
||||||
containChildren := true
|
containChildren := false
|
||||||
if val, ok := arg["containChildren"]; ok {
|
if val, ok := arg["containChildren"]; ok {
|
||||||
containChildren = val.(bool)
|
containChildren = val.(bool)
|
||||||
}
|
}
|
||||||
@ -109,7 +109,11 @@ func getBacklink2(c *gin.Context) {
|
|||||||
if nil != mentionSortArg {
|
if nil != mentionSortArg {
|
||||||
mentionSort, _ = strconv.Atoi(mentionSortArg.(string))
|
mentionSort, _ = strconv.Atoi(mentionSortArg.(string))
|
||||||
}
|
}
|
||||||
boxID, backlinks, backmentions, linkRefsCount, mentionsCount := model.GetBacklink2(id, keyword, mentionKeyword, sort, mentionSort)
|
containChildren := false
|
||||||
|
if val, ok := arg["containChildren"]; ok {
|
||||||
|
containChildren = val.(bool)
|
||||||
|
}
|
||||||
|
boxID, backlinks, backmentions, linkRefsCount, mentionsCount := model.GetBacklink2(id, keyword, mentionKeyword, sort, mentionSort, containChildren)
|
||||||
ret.Data = map[string]interface{}{
|
ret.Data = map[string]interface{}{
|
||||||
"backlinks": backlinks,
|
"backlinks": backlinks,
|
||||||
"linkRefsCount": linkRefsCount,
|
"linkRefsCount": linkRefsCount,
|
||||||
@ -141,7 +145,11 @@ func getBacklink(c *gin.Context) {
|
|||||||
if nil != arg["beforeLen"] {
|
if nil != arg["beforeLen"] {
|
||||||
beforeLen = int(arg["beforeLen"].(float64))
|
beforeLen = int(arg["beforeLen"].(float64))
|
||||||
}
|
}
|
||||||
boxID, backlinks, backmentions, linkRefsCount, mentionsCount := model.GetBacklink(id, keyword, mentionKeyword, beforeLen)
|
containChildren := false
|
||||||
|
if val, ok := arg["containChildren"]; ok {
|
||||||
|
containChildren = val.(bool)
|
||||||
|
}
|
||||||
|
boxID, backlinks, backmentions, linkRefsCount, mentionsCount := model.GetBacklink(id, keyword, mentionKeyword, beforeLen, containChildren)
|
||||||
ret.Data = map[string]interface{}{
|
ret.Data = map[string]interface{}{
|
||||||
"backlinks": backlinks,
|
"backlinks": backlinks,
|
||||||
"linkRefsCount": linkRefsCount,
|
"linkRefsCount": linkRefsCount,
|
||||||
|
@ -171,10 +171,10 @@ func buildBacklink(refID string, refTree *parse.Tree, keywords []string, luteEng
|
|||||||
|
|
||||||
dom := renderBlockDOMByNodes(renderNodes, luteEngine)
|
dom := renderBlockDOMByNodes(renderNodes, luteEngine)
|
||||||
blockPaths := []*BlockPath{}
|
blockPaths := []*BlockPath{}
|
||||||
if nil != n.Parent && nil != n.Parent.Parent {
|
if nil != n.Parent && ast.NodeDocument != n.Parent.Type && nil != n.Parent.Parent && ast.NodeDocument != n.Parent.Parent.Type {
|
||||||
// 仅在多余一层时才显示面包屑,这样界面展示更加简洁
|
// 仅在多余一层时才显示面包屑,这样界面展示更加简洁
|
||||||
// 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
|
||||||
blockPaths = buildBlockBreadcrumb(n, nil)
|
blockPaths = buildBlockBreadcrumb(n, nil, false)
|
||||||
}
|
}
|
||||||
ret = &Backlink{DOM: dom, BlockPaths: blockPaths, Expand: expand}
|
ret = &Backlink{DOM: dom, BlockPaths: blockPaths, Expand: expand}
|
||||||
return
|
return
|
||||||
@ -230,7 +230,7 @@ func getBacklinkRenderNodes(n *ast.Node) (ret []*ast.Node, expand bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetBacklink2(id, keyword, mentionKeyword string, sortMode, mentionSortMode int) (boxID string, backlinks, backmentions []*Path, linkRefsCount, mentionsCount int) {
|
func GetBacklink2(id, keyword, mentionKeyword string, sortMode, mentionSortMode int, containChildren bool) (boxID string, backlinks, backmentions []*Path, linkRefsCount, mentionsCount int) {
|
||||||
keyword = strings.TrimSpace(keyword)
|
keyword = strings.TrimSpace(keyword)
|
||||||
mentionKeyword = strings.TrimSpace(mentionKeyword)
|
mentionKeyword = strings.TrimSpace(mentionKeyword)
|
||||||
backlinks, backmentions = []*Path{}, []*Path{}
|
backlinks, backmentions = []*Path{}, []*Path{}
|
||||||
@ -242,7 +242,7 @@ func GetBacklink2(id, keyword, mentionKeyword string, sortMode, mentionSortMode
|
|||||||
rootID := sqlBlock.RootID
|
rootID := sqlBlock.RootID
|
||||||
boxID = sqlBlock.Box
|
boxID = sqlBlock.Box
|
||||||
|
|
||||||
refs := sql.QueryRefsByDefID(id, false)
|
refs := sql.QueryRefsByDefID(id, containChildren)
|
||||||
refs = removeDuplicatedRefs(refs)
|
refs = removeDuplicatedRefs(refs)
|
||||||
|
|
||||||
linkRefs, linkRefsCount, excludeBacklinkIDs := buildLinkRefs(rootID, refs, keyword)
|
linkRefs, linkRefsCount, excludeBacklinkIDs := buildLinkRefs(rootID, refs, keyword)
|
||||||
@ -328,7 +328,7 @@ func GetBacklink2(id, keyword, mentionKeyword string, sortMode, mentionSortMode
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetBacklink(id, keyword, mentionKeyword string, beforeLen int) (boxID string, linkPaths, mentionPaths []*Path, linkRefsCount, mentionsCount int) {
|
func GetBacklink(id, keyword, mentionKeyword string, beforeLen int, containChildren bool) (boxID string, linkPaths, mentionPaths []*Path, linkRefsCount, mentionsCount int) {
|
||||||
linkPaths = []*Path{}
|
linkPaths = []*Path{}
|
||||||
mentionPaths = []*Path{}
|
mentionPaths = []*Path{}
|
||||||
|
|
||||||
@ -340,7 +340,7 @@ func GetBacklink(id, keyword, mentionKeyword string, beforeLen int) (boxID strin
|
|||||||
boxID = sqlBlock.Box
|
boxID = sqlBlock.Box
|
||||||
|
|
||||||
var links []*Block
|
var links []*Block
|
||||||
refs := sql.QueryRefsByDefID(id, false)
|
refs := sql.QueryRefsByDefID(id, containChildren)
|
||||||
refs = removeDuplicatedRefs(refs)
|
refs = removeDuplicatedRefs(refs)
|
||||||
|
|
||||||
// 为了减少查询,组装好 IDs 后一次查出
|
// 为了减少查询,组装好 IDs 后一次查出
|
||||||
|
@ -887,7 +887,7 @@ func getEmbeddedBlock(trees map[string]*parse.Tree, sqlBlock *sql.Block, heading
|
|||||||
}
|
}
|
||||||
|
|
||||||
if breadcrumb {
|
if breadcrumb {
|
||||||
blockPaths = buildBlockBreadcrumb(def, nil)
|
blockPaths = buildBlockBreadcrumb(def, nil, true)
|
||||||
}
|
}
|
||||||
if 1 > len(blockPaths) {
|
if 1 > len(blockPaths) {
|
||||||
blockPaths = []*BlockPath{}
|
blockPaths = []*BlockPath{}
|
||||||
|
@ -416,11 +416,11 @@ func BuildBlockBreadcrumb(id string, excludeTypes []string) (ret []*BlockPath, e
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = buildBlockBreadcrumb(node, excludeTypes)
|
ret = buildBlockBreadcrumb(node, excludeTypes, true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildBlockBreadcrumb(node *ast.Node, excludeTypes []string) (ret []*BlockPath) {
|
func buildBlockBreadcrumb(node *ast.Node, excludeTypes []string, displayCurrentNodeContent bool) (ret []*BlockPath) {
|
||||||
ret = []*BlockPath{}
|
ret = []*BlockPath{}
|
||||||
if nil == node {
|
if nil == node {
|
||||||
return
|
return
|
||||||
@ -480,6 +480,12 @@ func buildBlockBreadcrumb(node *ast.Node, excludeTypes []string) (ret []*BlockPa
|
|||||||
|
|
||||||
name = strings.ReplaceAll(name, editor.Caret, "")
|
name = strings.ReplaceAll(name, editor.Caret, "")
|
||||||
name = util.EscapeHTML(name)
|
name = util.EscapeHTML(name)
|
||||||
|
|
||||||
|
if parent == node && !displayCurrentNodeContent {
|
||||||
|
// 反链中不显示当前块内容 https://github.com/siyuan-note/siyuan/issues/12862#issuecomment-2426406327
|
||||||
|
name = ""
|
||||||
|
}
|
||||||
|
|
||||||
if add {
|
if add {
|
||||||
ret = append([]*BlockPath{{
|
ret = append([]*BlockPath{{
|
||||||
ID: id,
|
ID: id,
|
||||||
|
Loading…
Reference in New Issue
Block a user