diff --git a/app/src/constants.ts b/app/src/constants.ts index 274153702..e7d3a39ab 100644 --- a/app/src/constants.ts +++ b/app/src/constants.ts @@ -657,17 +657,17 @@ export abstract class Constants { "text": true, "imgText": true, "imgTitle": true, - "imgSrc": false, + "imgSrc": true, "aText": true, "aTitle": true, - "aHref": false, - "code": false, + "aHref": true, + "code": true, "em": true, "strong": true, - "inlineMath": false, + "inlineMath": true, "inlineMemo": true, - "blockRef": false, - "fileAnnotationRef": false, + "blockRef": true, + "fileAnnotationRef": true, "kbd": true, "mark": true, "s": true, @@ -676,9 +676,9 @@ export abstract class Constants { "tag": true, "u": true, "docTitle": true, - "codeBlock": false, - "mathBlock": false, - "htmlBlock": false + "codeBlock": true, + "mathBlock": true, + "htmlBlock": true }; // image diff --git a/kernel/model/search.go b/kernel/model/search.go index 8d8160b5e..8fdd9296f 100644 --- a/kernel/model/search.go +++ b/kernel/model/search.go @@ -790,12 +790,18 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids if 0 == method { if strings.Contains(n.TextMarkInlineMemoContent, keyword) { n.TextMarkInlineMemoContent = strings.ReplaceAll(n.TextMarkInlineMemoContent, keyword, replacement) + n.TextMarkTextContent = strings.ReplaceAll(n.TextMarkTextContent, keyword, replacement) } } else if 3 == method { if nil != r && r.MatchString(n.TextMarkInlineMemoContent) { n.TextMarkInlineMemoContent = r.ReplaceAllString(n.TextMarkInlineMemoContent, replacement) + n.TextMarkTextContent = r.ReplaceAllString(n.TextMarkTextContent, replacement) } } + + if "" == n.TextMarkTextContent { + unlinks = append(unlinks, n) + } } else if n.IsTextMarkType("text") { // Search and replace fails in some cases https://github.com/siyuan-note/siyuan/issues/10016 if !replaceTypes["text"] { @@ -988,11 +994,6 @@ func FullTextSearchBlock(query string, boxes, paths []string, types map[string]b } query = filterQueryInvisibleChars(query) - trimQuery := strings.TrimSpace(query) - if "" != trimQuery { - query = trimQuery - } - var ignoreFilter string if ignoreLines := getSearchIgnoreLines(); 0 < len(ignoreLines) { // Support ignore search results https://github.com/siyuan-note/siyuan/issues/10089 @@ -1755,22 +1756,26 @@ func columnConcat() string { } func stringQuery(query string) string { - if "" == strings.TrimSpace(query) { + trimmedQuery := strings.TrimSpace(query) + if "" == trimmedQuery { return "\"" + query + "\"" } query = strings.ReplaceAll(query, "\"", "\"\"") query = strings.ReplaceAll(query, "'", "''") - buf := bytes.Buffer{} - parts := strings.Split(query, " ") - for _, part := range parts { - part = strings.TrimSpace(part) - part = "\"" + part + "\"" - buf.WriteString(part) - buf.WriteString(" ") + if strings.Contains(trimmedQuery, " ") { + buf := bytes.Buffer{} + parts := strings.Split(query, " ") + for _, part := range parts { + part = strings.TrimSpace(part) + part = "\"" + part + "\"" + buf.WriteString(part) + buf.WriteString(" ") + } + return strings.TrimSpace(buf.String()) } - return strings.TrimSpace(buf.String()) + return "\"" + query + "\"" } // markReplaceSpan 用于处理搜索高亮。