An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Improve backmention highlighting https://github.com/siyuan-note/siyuan/issues/13328
Daniel8f89caf22e91
diff --git a/kernel/api/ref.go b/kernel/api/ref.goindex 4de046c81c..73715dae3a 100644--- a/kernel/api/ref.go+++ b/kernel/api/ref.go@@ -60,9 +60,10 @@ func getBackmentionDoc(c *gin.Context) {if val, ok := arg["highlight"]; ok {highlight = val.(bool)}- backlinks := model.GetBackmentionDoc(defID, refTreeID, keyword, containChildren, highlight)+ backlinks, keywords := model.GetBackmentionDoc(defID, refTreeID, keyword, containChildren, highlight)ret.Data = map[string]interface{}{"backmentions": backlinks,+ "keywords": keywords,}}@@ -86,9 +87,10 @@ func getBacklinkDoc(c *gin.Context) {if val, ok := arg["highlight"]; ok {highlight = val.(bool)}- backlinks := model.GetBacklinkDoc(defID, refTreeID, keyword, containChildren, highlight)+ backlinks, keywords := model.GetBacklinkDoc(defID, refTreeID, keyword, containChildren, highlight)ret.Data = map[string]interface{}{"backlinks": backlinks,+ "keywords": keywords,}}diff --git a/kernel/model/backlink.go b/kernel/model/backlink.goindex 9bf0b9d50a..334196ae90 100644--- a/kernel/model/backlink.go+++ b/kernel/model/backlink.go@@ -62,8 +62,7 @@ type Backlink struct {node *ast.Node // 仅用于按文档内容顺序排序}-func GetBackmentionDoc(defID, refTreeID, keyword string, containChildren, highlight bool) (ret []*Backlink) {- var keywords []string+func GetBackmentionDoc(defID, refTreeID, keyword string, containChildren, highlight bool) (ret []*Backlink, keywords []string) {keyword = strings.TrimSpace(keyword)if "" != keyword {keywords = strings.Split(keyword, " ")@@ -98,6 +97,11 @@ func GetBackmentionDoc(defID, refTreeID, keyword string, containChildren, highlimentionKeywords = append(mentionKeywords, strings.Split(keyword, " ")...)}mentionKeywords = gulu.Str.RemoveDuplicatedElem(mentionKeywords)+ keywords = append(keywords, mentionKeywords...)+ keywords = gulu.Str.RemoveDuplicatedElem(keywords)+ if 1 > len(keywords) {+ keywords = []string{}+ }var refTree *parse.Treetrees := filesys.LoadTrees(mentionBlockIDs)@@ -118,12 +122,15 @@ func GetBackmentionDoc(defID, refTreeID, keyword string, containChildren, highlireturn}-func GetBacklinkDoc(defID, refTreeID, keyword string, containChildren, highlight bool) (ret []*Backlink) {- var keywords []string+func GetBacklinkDoc(defID, refTreeID, keyword string, containChildren, highlight bool) (ret []*Backlink, keywords []string) {keyword = strings.TrimSpace(keyword)if "" != keyword {keywords = strings.Split(keyword, " ")}+ keywords = gulu.Str.RemoveDuplicatedElem(keywords)+ if 1 > len(keywords) {+ keywords = []string{}+ }ret = []*Backlink{}sqlBlock := sql.GetBlock(defID)