🎨 Add heading and list subtype filters to search https://github.com/siyuan-note/siyuan/pull/17597

Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel
2026-05-08 11:35:27 +08:00
parent 750f0d9836
commit fecd1bfe17
2 changed files with 11 additions and 3 deletions

View File

@@ -1146,6 +1146,14 @@ func getDoc(c *gin.Context) {
queryTypes[t] = b.(bool)
}
}
var querySubTypes map[string]bool
if querySubTypesArg := arg["querySubTypes"]; nil != querySubTypesArg {
typesArg := querySubTypesArg.(map[string]any)
querySubTypes = map[string]bool{}
for t, b := range typesArg {
querySubTypes[t] = b.(bool)
}
}
m := arg["mode"] // 0: 仅当前 ID1向上 2向下3上下都加载4加载末尾
mode := 0
@@ -1186,7 +1194,7 @@ func getDoc(c *gin.Context) {
}
blockCount, content, parentID, parent2ID, rootID, typ, eof, scroll, boxID, docPath, isBacklinkExpand, keywords, err :=
model.GetDoc(startID, endID, id, index, query, queryTypes, queryMethod, mode, size, isBacklink, originalRefBlockIDs, highlight)
model.GetDoc(startID, endID, id, index, query, queryTypes, querySubTypes, queryMethod, mode, size, isBacklink, originalRefBlockIDs, highlight)
if errors.Is(err, model.ErrBlockNotFound) {
ret.Code = 3
return

View File

@@ -457,7 +457,7 @@ func ListDocTree(boxID, listPath string, sortMode int, flashcard, showHidden boo
return
}
func GetDoc(startID, endID, id string, index int, query string, queryTypes map[string]bool, queryMethod, mode int, size int, isBacklink bool, originalRefBlockIDs map[string]string, highlight bool) (
func GetDoc(startID, endID, id string, index int, query string, queryTypes, querySubTypes map[string]bool, queryMethod, mode int, size int, isBacklink bool, originalRefBlockIDs map[string]string, highlight bool) (
blockCount int, dom, parentID, parent2ID, rootID, typ string, eof, scroll bool, boxID, docPath string, isBacklinkExpand bool, keywords []string, err error) {
//os.MkdirAll("pprof", 0755)
//cpuProfile, _ := os.Create("pprof/GetDoc")
@@ -653,7 +653,7 @@ func GetDoc(startID, endID, id string, index int, query string, queryTypes map[s
query = filterQueryInvisibleChars(query)
if "" != query && (0 == queryMethod || 1 == queryMethod || 3 == queryMethod) { // 只有关键字、查询语法和正则表达式搜索支持高亮
typeFilter := buildTypeFilter(queryTypes, nil)
typeFilter := buildTypeFilter(queryTypes, querySubTypes)
switch queryMethod {
case 0:
query = stringQuery(query)