mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-29 03:36:10 +01:00
🎨 Add configuration item Editor - [[ Only search doc block Fix https://github.com/siyuan-note/siyuan/issues/8077
This commit is contained in:
parent
4393d844ad
commit
4ec4e1d882
12 changed files with 38 additions and 13 deletions
|
|
@ -191,16 +191,11 @@ func searchRefBlock(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
onlyDoc := false
|
||||
if nil != arg["onlyDoc"] {
|
||||
onlyDoc = arg["onlyDoc"].(bool)
|
||||
}
|
||||
|
||||
rootID := arg["rootID"].(string)
|
||||
id := arg["id"].(string)
|
||||
keyword := arg["k"].(string)
|
||||
beforeLen := int(arg["beforeLen"].(float64))
|
||||
blocks, newDoc := model.SearchRefBlock(id, rootID, keyword, beforeLen, onlyDoc)
|
||||
blocks, newDoc := model.SearchRefBlock(id, rootID, keyword, beforeLen)
|
||||
ret.Data = map[string]interface{}{
|
||||
"blocks": blocks,
|
||||
"newDoc": newDoc,
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ type Editor struct {
|
|||
Justify bool `json:"justify"` // 是否两端对齐
|
||||
RTL bool `json:"rtl"` // 是否从右到左显示
|
||||
Spellcheck bool `json:"spellcheck"` // 是否启用拼写检查
|
||||
OnlySearchForDoc bool `json:"onlySearchForDoc"` // 是否启用 [[ 仅搜索文档块
|
||||
BacklinkExpandCount int `json:"backlinkExpandCount"` // 反向链接默认展开数量
|
||||
BackmentionExpandCount int `json:"backmentionExpandCount"` // 反链提及默认展开数量
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,12 +121,12 @@ func searchEmbedBlock(embedBlockID, stmt string, excludeIDs []string, headingMod
|
|||
return
|
||||
}
|
||||
|
||||
func SearchRefBlock(id, rootID, keyword string, beforeLen int, onlyDoc bool) (ret []*Block, newDoc bool) {
|
||||
func SearchRefBlock(id, rootID, keyword string, beforeLen int) (ret []*Block, newDoc bool) {
|
||||
cachedTrees := map[string]*parse.Tree{}
|
||||
|
||||
if "" == keyword {
|
||||
// 查询为空时默认的块引排序规则按最近使用优先 https://github.com/siyuan-note/siyuan/issues/3218
|
||||
refs := sql.QueryRefsRecent(onlyDoc)
|
||||
refs := sql.QueryRefsRecent(Conf.Editor.OnlySearchForDoc)
|
||||
for _, ref := range refs {
|
||||
tree := cachedTrees[ref.DefBlockRootID]
|
||||
if nil == tree {
|
||||
|
|
@ -158,7 +158,7 @@ func SearchRefBlock(id, rootID, keyword string, beforeLen int, onlyDoc bool) (re
|
|||
return
|
||||
}
|
||||
|
||||
ret = fullTextSearchRefBlock(keyword, beforeLen, onlyDoc)
|
||||
ret = fullTextSearchRefBlock(keyword, beforeLen)
|
||||
tmp := ret[:0]
|
||||
for _, b := range ret {
|
||||
tree := cachedTrees[b.RootID]
|
||||
|
|
@ -646,7 +646,7 @@ func removeLimitClause(stmt string) string {
|
|||
return stmt
|
||||
}
|
||||
|
||||
func fullTextSearchRefBlock(keyword string, beforeLen int, onlyDoc bool) (ret []*Block) {
|
||||
func fullTextSearchRefBlock(keyword string, beforeLen int) (ret []*Block) {
|
||||
keyword = gulu.Str.RemoveInvisible(keyword)
|
||||
|
||||
if ast.IsNodeIDPattern(keyword) {
|
||||
|
|
@ -669,7 +669,7 @@ func fullTextSearchRefBlock(keyword string, beforeLen int, onlyDoc bool) (ret []
|
|||
"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"
|
||||
if onlyDoc {
|
||||
if Conf.Editor.OnlySearchForDoc {
|
||||
stmt += " = 'd'"
|
||||
} else {
|
||||
stmt += " IN " + Conf.Search.TypeFilter()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue