🎨 反链面板中文档标题在鼠标悬浮时显示文档完整路径 https://github.com/siyuan-note/insider/issues/1088

This commit is contained in:
Liang Ding 2022-10-05 21:36:40 +08:00
parent d5931778cf
commit 1b0426b987
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 29 additions and 0 deletions

View file

@ -317,6 +317,7 @@ func GetBacklink2(id, keyword, mentionKeyword string, sortMode, mentionSortMode
linkRefs, linkRefsCount, excludeBacklinkIDs := buildLinkRefs(rootID, refs)
tmpBacklinks := toFlatTree(linkRefs, 0, "backlink")
var boxIDs []string
for _, l := range tmpBacklinks {
l.Blocks = nil
if "" != keyword {
@ -325,6 +326,14 @@ func GetBacklink2(id, keyword, mentionKeyword string, sortMode, mentionSortMode
}
}
backlinks = append(backlinks, l)
boxIDs = append(boxIDs, l.Box)
}
boxIDs = gulu.Str.RemoveDuplicatedElem(boxIDs)
boxNames := Conf.BoxNames(boxIDs)
for _, l := range backlinks {
name := boxNames[l.Box]
l.HPath = name + "/" + l.HPath
}
sort.Slice(backlinks, func(i, j int) bool {
@ -361,6 +370,11 @@ func GetBacklink2(id, keyword, mentionKeyword string, sortMode, mentionSortMode
backmentions = append(backmentions, l)
}
for _, l := range backmentions {
name := boxNames[l.Box]
l.HPath = name + "/" + l.HPath
}
sort.Slice(backmentions, func(i, j int) bool {
switch mentionSortMode {
case util.SortModeUpdatedDESC:

View file

@ -467,6 +467,21 @@ func (conf *AppConf) Box(boxID string) *Box {
return nil
}
func (conf *AppConf) BoxNames(boxIDs []string) (ret map[string]string) {
ret = map[string]string{}
boxes := conf.GetOpenedBoxes()
for _, boxID := range boxIDs {
for _, box := range boxes {
if box.ID == boxID {
ret[boxID] = box.Name
break
}
}
}
return
}
func (conf *AppConf) GetBoxes() (ret []*Box) {
ret = []*Box{}
notebooks, err := ListNotebooks()