This commit is contained in:
Liang Ding 2022-11-17 22:39:22 +08:00
parent 454353d06f
commit bec79ce100
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
8 changed files with 26 additions and 20 deletions

View file

@ -38,7 +38,7 @@
"generateConflictDoc": "Generate conflict documentation when syncing conflicts",
"generateConflictDocTip": "After enabling, a conflict document will be generated when a synchronization conflict occurs, so that it can be opened and viewed directly. Whether enabled or not, the data history will record the conflict document",
"deleteOpConfirm": "⚠️ Delete operation confirmation",
"filterDocNameEnter": "Filter doc name Enter",
"filterKeywordEnter": "Keyword filtering Enter",
"defBlock": "Def block",
"defBlockChildren": "Define block and its children",
"filter": "Filter",

View file

@ -38,7 +38,7 @@
"generateConflictDoc": "Generar documentación de conflicto al sincronizar conflictos",
"generateConflictDocTip": "Cuando está habilitado, se generará un documento de conflicto cuando ocurra un conflicto de sincronización, para que pueda abrirse y verse directamente. Ya sea que esté habilitado o no, el historial de datos registrará el documento de conflicto",
"deleteOpConfirm": "⚠️ Confirmación de operación de eliminación",
"filterDocNameEnter": "Filtrar doc name Enter",
"filterKeywordEnter": "Filtrado de palabras clave Entrar",
"defBlock": "Definir bloque",
"defBlockChildren": "Definir bloque y sus hijos",
"filter": "Filtro",

View file

@ -38,7 +38,7 @@
"generateConflictDoc": "Générer une documentation sur les conflits lors de la synchronisation des conflits",
"generateConflictDocTip": "Lorsqu'il est activé, un document de conflit sera généré lorsqu'un conflit de synchronisation se produit, afin qu'il puisse être ouvert et visualisé directement. Qu'il soit activé ou non, l'historique des données enregistrera le document de conflit",
"deleteOpConfirm": "⚠️ Supprimer la confirmation de l'opération",
"filterDocNameEnter": "Filtre doc name Enter",
"filterKeywordEnter": "Filtrage des mots-clés Entrée",
"defBlock": "Définir le bloc",
"defBlockChildren": "Définir le bloc et ses enfants",
"filter": "Filtre",

View file

@ -38,7 +38,7 @@
"generateConflictDoc": "同步衝突時生成衝突文檔",
"generateConflictDocTip": "啟用後當同步發生衝突時會生成衝突文檔,以便直接打開查看。無論是否啟用,數據歷史都會記錄衝突文檔",
"deleteOpConfirm": "⚠️ Delete operation confirmation",
"filterDocNameEnter": "過濾文檔名 Enter",
"filterKeywordEnter": "關鍵字過濾 Enter",
"defBlock": "定義塊",
"defBlockChildren": "定義塊及其子塊",
"filter": "過濾",

View file

@ -38,7 +38,7 @@
"generateConflictDoc": "同步冲突时生成冲突文档",
"generateConflictDocTip": "启用后当同步发生冲突时会生成冲突文档,以便直接打开查看。无论是否启用,数据历史都会记录冲突文档",
"deleteOpConfirm": "⚠️ 删除操作确认",
"filterDocNameEnter": "过滤文档名 Enter",
"filterKeywordEnter": "关键字过滤 Enter",
"defBlock": "定义块",
"defBlockChildren": "定义块及其子块",
"filter": "过滤",

View file

@ -84,7 +84,7 @@ export class Backlink extends Model {
<span class="fn__space"></span>
<label class="b3-form__icon b3-form__icon--small search__label">
<svg class="b3-form__icon-icon"><use xlink:href="#iconFilter"></use></svg>
<input class="b3-text-field b3-text-field--small b3-form__icon-input" placeholder="${window.siyuan.languages.filterDocNameEnter}" />
<input class="b3-text-field b3-text-field--small b3-form__icon-input" placeholder="${window.siyuan.languages.filterKeywordEnter}" />
</label>
<span class="fn__space"></span>
<span data-type="refresh" class="block__icon b3-tooltips b3-tooltips__sw" aria-label="${window.siyuan.languages.refresh}"><svg><use xlink:href='#iconRefresh'></use></svg></span>
@ -107,7 +107,7 @@ export class Backlink extends Model {
<span class="fn__space"></span>
<label class="b3-form__icon b3-form__icon--small search__label">
<svg class="b3-form__icon-icon"><use xlink:href="#iconFilter"></use></svg>
<input class="b3-text-field b3-text-field--small b3-form__icon-input" placeholder="${window.siyuan.languages.filterDocNameEnter}" />
<input class="b3-text-field b3-text-field--small b3-form__icon-input" placeholder="${window.siyuan.languages.filterKeywordEnter}" />
</label>
<span class="fn__space"></span>
<span data-type="mSort" data-sort="3" class="block__icon b3-tooltips b3-tooltips__nw" aria-label="${window.siyuan.languages.sort}"><svg><use xlink:href='#iconSort'></use></svg></span>

View file

@ -50,7 +50,7 @@ func getBackmentionDoc(c *gin.Context) {
defID := arg["defID"].(string)
refTreeID := arg["refTreeID"].(string)
keyword := ""
keyword := arg["keyword"].(string)
backlinks := model.GetBackmentionDoc(defID, refTreeID, keyword)
ret.Data = map[string]interface{}{
"backmentions": backlinks,
@ -68,7 +68,8 @@ func getBacklinkDoc(c *gin.Context) {
defID := arg["defID"].(string)
refTreeID := arg["refTreeID"].(string)
backlinks := model.GetBacklinkDoc(defID, refTreeID)
keyword := arg["keyword"].(string)
backlinks := model.GetBacklinkDoc(defID, refTreeID, keyword)
ret.Data = map[string]interface{}{
"backlinks": backlinks,
}

View file

@ -178,7 +178,7 @@ func GetBackmentionDoc(defID, refTreeID, keyword string) (ret []*Backlink) {
refs := sql.QueryRefsByDefID(defID, true)
refs = removeDuplicatedRefs(refs) // 同一个块中引用多个相同块时反链去重 https://github.com/siyuan-note/siyuan/issues/3317
linkRefs, _, excludeBacklinkIDs := buildLinkRefs(rootID, refs)
linkRefs, _, excludeBacklinkIDs := buildLinkRefs(rootID, refs, keyword)
tmpMentions, mentionKeywords := buildTreeBackmention(sqlBlock, linkRefs, keyword, excludeBacklinkIDs, beforeLen)
luteEngine := NewLute()
treeCache := map[string]*parse.Tree{}
@ -206,7 +206,7 @@ func GetBackmentionDoc(defID, refTreeID, keyword string) (ret []*Backlink) {
return
}
func GetBacklinkDoc(defID, refTreeID string) (ret []*Backlink) {
func GetBacklinkDoc(defID, refTreeID, keyword string) (ret []*Backlink) {
ret = []*Backlink{}
sqlBlock := sql.GetBlock(defID)
if nil == sqlBlock {
@ -223,7 +223,7 @@ func GetBacklinkDoc(defID, refTreeID string) (ret []*Backlink) {
}
refs = removeDuplicatedRefs(refs) // 同一个块中引用多个相同块时反链去重 https://github.com/siyuan-note/siyuan/issues/3317
linkRefs, _, _ := buildLinkRefs(rootID, refs)
linkRefs, _, _ := buildLinkRefs(rootID, refs, keyword)
refTree, err := loadTreeByBlockID(refTreeID)
if nil != err {
logging.LogWarnf("load ref tree [%s] failed: %s", refTreeID, err)
@ -353,16 +353,11 @@ func GetBacklink2(id, keyword, mentionKeyword string, sortMode, mentionSortMode
refs := sql.QueryRefsByDefID(id, true)
refs = removeDuplicatedRefs(refs) // 同一个块中引用多个相同块时反链去重 https://github.com/siyuan-note/siyuan/issues/3317
linkRefs, linkRefsCount, excludeBacklinkIDs := buildLinkRefs(rootID, refs)
linkRefs, linkRefsCount, excludeBacklinkIDs := buildLinkRefs(rootID, refs, keyword)
tmpBacklinks := toFlatTree(linkRefs, 0, "backlink")
for _, l := range tmpBacklinks {
l.Blocks = nil
if "" != keyword {
if !strings.Contains(l.Name, keyword) {
continue
}
}
backlinks = append(backlinks, l)
}
@ -558,7 +553,7 @@ func GetBacklink(id, keyword, mentionKeyword string, beforeLen int) (boxID strin
return
}
func buildLinkRefs(defRootID string, refs []*sql.Ref) (ret []*Block, refsCount int, excludeBacklinkIDs *hashset.Set) {
func buildLinkRefs(defRootID string, refs []*sql.Ref, keyword string) (ret []*Block, refsCount int, excludeBacklinkIDs *hashset.Set) {
// 为了减少查询,组装好 IDs 后一次查出
defSQLBlockIDs, refSQLBlockIDs := map[string]bool{}, map[string]bool{}
var queryBlockIDs []string
@ -627,8 +622,13 @@ func buildLinkRefs(defRootID string, refs []*sql.Ref) (ret []*Block, refsCount i
paragraphParents := sql.GetBlocks(paragraphParentIDs)
for _, p := range paragraphParents {
if "i" == p.Type || "h" == p.Type {
ret = append(ret, fromSQLBlock(p, "", 12))
processedParagraphs.Add(p.ID)
if !strings.Contains(p.Content, keyword) {
refsCount--
continue
}
ret = append(ret, fromSQLBlock(p, "", 12))
}
}
for _, link := range links {
@ -639,6 +639,11 @@ func buildLinkRefs(defRootID string, refs []*sql.Ref) (ret []*Block, refsCount i
}
}
if !strings.Contains(ref.Content, keyword) {
refsCount--
continue
}
ref.DefID = link.ID
ref.DefPath = link.Path
ret = append(ret, ref)