From a5eab977289faf990cbf9ed44056d542e24f5683 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sat, 19 Apr 2025 17:01:34 +0800 Subject: [PATCH 1/2] :art: Improve the SQL method in the global search https://github.com/siyuan-note/siyuan/issues/14641 --- kernel/model/search.go | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/kernel/model/search.go b/kernel/model/search.go index 33b97e5ce..686c85300 100644 --- a/kernel/model/search.go +++ b/kernel/model/search.go @@ -1406,19 +1406,34 @@ func searchBySQL(stmt string, beforeLen, page, pageSize int) (ret []*Block, matc } stmt = strings.ToLower(stmt) - if strings.HasPrefix(stmt, "select a.* ") { // 多个搜索关键字匹配文档 https://github.com/siyuan-note/siyuan/issues/7350 - stmt = strings.ReplaceAll(stmt, "select a.* ", "select COUNT(a.id) AS `matches`, COUNT(DISTINCT(a.root_id)) AS `docs` ") - } else { - stmt = strings.ReplaceAll(stmt, "select * ", "select COUNT(id) AS `matches`, COUNT(DISTINCT(root_id)) AS `docs` ") + stdQuery := !strings.Contains(stmt, "with recursive") && !strings.Contains(stmt, "union") + if stdQuery { + if strings.HasPrefix(stmt, "select a.* ") { // 多个搜索关键字匹配文档 https://github.com/siyuan-note/siyuan/issues/7350 + stmt = strings.ReplaceAll(stmt, "select a.* ", "select COUNT(a.id) AS `matches`, COUNT(DISTINCT(a.root_id)) AS `docs` ") + } else { + stmt = strings.ReplaceAll(stmt, "select * ", "select COUNT(id) AS `matches`, COUNT(DISTINCT(root_id)) AS `docs` ") + } } stmt = removeLimitClause(stmt) result, _ := sql.QueryNoLimit(stmt) - if 1 > len(ret) { + if 1 > len(result) { return } - matchedBlockCount = int(result[0]["matches"].(int64)) - matchedRootCount = int(result[0]["docs"].(int64)) + if !stdQuery { + var rootIDs, blockIDs []string + for _, queryResult := range result { + rootIDs = append(rootIDs, queryResult["root_id"].(string)) + blockIDs = append(blockIDs, queryResult["id"].(string)) + } + rootIDs = gulu.Str.RemoveDuplicatedElem(rootIDs) + blockIDs = gulu.Str.RemoveDuplicatedElem(blockIDs) + matchedRootCount = len(rootIDs) + matchedBlockCount = len(blockIDs) + } else { + matchedBlockCount = int(result[0]["matches"].(int64)) + matchedRootCount = int(result[0]["docs"].(int64)) + } return } From 31e1248020c8547c44a5e2910b54c1c552d25463 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sat, 19 Apr 2025 20:23:31 +0800 Subject: [PATCH 2/2] :bug: Clicking on the video will jump to the block where the cursor is on mobile https://github.com/siyuan-note/siyuan/issues/14569 --- app/src/mobile/util/touch.ts | 6 ++++++ app/src/protyle/wysiwyg/index.ts | 17 ++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/src/mobile/util/touch.ts b/app/src/mobile/util/touch.ts index cd387714b..bf227e175 100644 --- a/app/src/mobile/util/touch.ts +++ b/app/src/mobile/util/touch.ts @@ -135,6 +135,12 @@ export const handleTouchEnd = (event: TouchEvent, app: App) => { }; export const handleTouchStart = (event: TouchEvent) => { + if (0 < event.touches.length && ((event.touches[0].target as HTMLElement).tagName === "VIDEO" || (event.touches[0].target as HTMLElement).tagName === "AUDIO")) { + // https://github.com/siyuan-note/siyuan/issues/14569 + activeBlur(); + return; + } + if (globalTouchStart(event)) { return; } diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index b11c1c056..ba5ff183a 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -2,7 +2,8 @@ import {getTextStar, paste} from "../util/paste"; import { hasClosestBlock, hasClosestByAttribute, - hasClosestByClassName, hasClosestByTag, + hasClosestByClassName, + hasClosestByTag, hasTopClosestByClassName, isInEmbedBlock, } from "../util/hasClosest"; @@ -13,7 +14,8 @@ import { focusSideBlock, getEditorRange, getSelectionOffset, - setFirstNodeRange, setInsertWbrHTML, + setFirstNodeRange, + setInsertWbrHTML, setLastNodeRange, } from "../util/selection"; import {Constants} from "../../constants"; @@ -39,7 +41,8 @@ import { getNextBlock, getTopAloneElement, hasNextSibling, - hasPreviousSibling, isEndOfBlock, + hasPreviousSibling, + isEndOfBlock, isNotEditBlock } from "./getBlock"; import {transaction, updateTransaction} from "./transaction"; @@ -2175,14 +2178,6 @@ export class WYSIWYG { }); }); hideElements(["hint", "util"], protyle); - /// #if MOBILE - // https://github.com/siyuan-note/siyuan/issues/14569 - if (event.target.tagName === "VIDEO") { - mobileBlur = true; - activeBlur(); - return; - } - /// #endif const ctrlIsPressed = isOnlyMeta(event); const backlinkBreadcrumbItemElement = hasClosestByClassName(event.target, "protyle-breadcrumb__item"); if (backlinkBreadcrumbItemElement) {