mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-04 15:58:49 +01:00
🎨 Content type filtering when inserting reference links via ((, [[ https://github.com/siyuan-note/siyuan/issues/8009
This commit is contained in:
parent
b13398cbdd
commit
c316951592
3 changed files with 23 additions and 8 deletions
|
|
@ -120,12 +120,12 @@ func searchEmbedBlock(embedBlockID, stmt string, excludeIDs []string, headingMod
|
|||
return
|
||||
}
|
||||
|
||||
func SearchRefBlock(id, rootID, keyword string, beforeLen int) (ret []*Block, newDoc bool) {
|
||||
func SearchRefBlock(id, rootID, keyword string, beforeLen int, onlyDoc bool) (ret []*Block, newDoc bool) {
|
||||
cachedTrees := map[string]*parse.Tree{}
|
||||
|
||||
if "" == keyword {
|
||||
// 查询为空时默认的块引排序规则按最近使用优先 https://github.com/siyuan-note/siyuan/issues/3218
|
||||
refs := sql.QueryRefsRecent()
|
||||
refs := sql.QueryRefsRecent(onlyDoc)
|
||||
for _, ref := range refs {
|
||||
tree := cachedTrees[ref.DefBlockRootID]
|
||||
if nil == tree {
|
||||
|
|
@ -157,7 +157,7 @@ func SearchRefBlock(id, rootID, keyword string, beforeLen int) (ret []*Block, ne
|
|||
return
|
||||
}
|
||||
|
||||
ret = fullTextSearchRefBlock(keyword, beforeLen)
|
||||
ret = fullTextSearchRefBlock(keyword, beforeLen, onlyDoc)
|
||||
tmp := ret[:0]
|
||||
for _, b := range ret {
|
||||
tree := cachedTrees[b.RootID]
|
||||
|
|
@ -624,7 +624,7 @@ func searchBySQL(stmt string, beforeLen int) (ret []*Block, matchedBlockCount, m
|
|||
return
|
||||
}
|
||||
|
||||
func fullTextSearchRefBlock(keyword string, beforeLen int) (ret []*Block) {
|
||||
func fullTextSearchRefBlock(keyword string, beforeLen int, onlyDoc bool) (ret []*Block) {
|
||||
keyword = gulu.Str.RemoveInvisible(keyword)
|
||||
|
||||
if ast.IsNodeIDPattern(keyword) {
|
||||
|
|
@ -646,7 +646,12 @@ func fullTextSearchRefBlock(keyword string, beforeLen int) (ret []*Block) {
|
|||
"tag, " +
|
||||
"snippet(" + table + ", 11, '" + search.SearchMarkLeft + "', '" + search.SearchMarkRight + "', '...', 64) AS content, " +
|
||||
"fcontent, markdown, length, type, subtype, ial, sort, created, updated"
|
||||
stmt := "SELECT " + projections + " FROM " + table + " WHERE " + table + " MATCH '" + columnFilter() + ":(" + quotedKeyword + ")' AND type IN " + Conf.Search.TypeFilter()
|
||||
stmt := "SELECT " + projections + " FROM " + table + " WHERE " + table + " MATCH '" + columnFilter() + ":(" + quotedKeyword + ")' AND type"
|
||||
if onlyDoc {
|
||||
stmt += " = 'd'"
|
||||
} else {
|
||||
stmt += " IN " + Conf.Search.TypeFilter()
|
||||
}
|
||||
orderBy := ` order by case
|
||||
when name = '${keyword}' then 10
|
||||
when alias = '${keyword}' then 20
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue