From 56cfc90c8cfa6f8f12fe1330251543f6505965ba Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 21 Apr 2023 14:54:21 +0800 Subject: [PATCH] :iphone: https://github.com/siyuan-note/siyuan/issues/7948 --- app/src/mobile/menu/search.ts | 22 ++++++++++++---------- app/src/protyle/header/Background.ts | 18 ++++++++++++++++++ app/src/protyle/wysiwyg/index.ts | 23 ++++++++++++++++++++--- 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/app/src/mobile/menu/search.ts b/app/src/mobile/menu/search.ts index 29bda5117..1ef6a8674 100644 --- a/app/src/mobile/menu/search.ts +++ b/app/src/mobile/menu/search.ts @@ -149,7 +149,7 @@ const updateConfig = (element: Element, newConfig: ISearchOption, config: ISearc window.siyuan.menus.menu.remove(); }; -const onRecentBlocks = (data: IBlock[], config: ISearchOption, response?:IWebSocketData) => { +const onRecentBlocks = (data: IBlock[], config: ISearchOption, response?: IWebSocketData) => { const listElement = document.querySelector("#searchList"); let resultHTML = ""; data.forEach((item: IBlock, index: number) => { @@ -191,13 +191,11 @@ ${unicode2Emoji(childItem.ial.icon, false, "b3-list-item__graphic", true)} listElement.scrollTop = 0; let countHTML = ""; if (response) { - countHTML = `
- ${config.page}/${response.data.pageCount || 1} - - ${window.siyuan.languages.findInDoc.replace("${x}", response.data.matchedRootCount).replace("${y}", response.data.matchedBlockCount)} -
`; + countHTML = `${window.siyuan.languages.findInDoc.replace("${x}", response.data.matchedRootCount).replace("${y}", response.data.matchedBlockCount)} + +${config.page}/${response.data.pageCount || 1}`; } - listElement.previousElementSibling.innerHTML = countHTML; + listElement.previousElementSibling.querySelector('[data-type="result"]').innerHTML = countHTML; }; let toolbarSearchTimeout = 0; @@ -542,7 +540,13 @@ export const popSearch = (config = window.siyuan.storage[Constants.LOCAL_SEARCHD
-
+
+ + + + + +
@@ -552,8 +556,6 @@ export const popSearch = (config = window.siyuan.storage[Constants.LOCAL_SEARCHD
- - diff --git a/app/src/protyle/header/Background.ts b/app/src/protyle/header/Background.ts index 698bb0bb2..4ed8e26e8 100644 --- a/app/src/protyle/header/Background.ts +++ b/app/src/protyle/header/Background.ts @@ -13,9 +13,12 @@ import { import {upDownHint} from "../../util/upDownHint"; /// #if !MOBILE import {openGlobalSearch} from "../../search/util"; +/// #else +import {popSearch} from "../../mobile/menu/search"; /// #endif import {getEventName} from "../util/compatibility"; import {Dialog} from "../../dialog"; +import {Constants} from "../../constants"; export class Background { public element: HTMLElement; @@ -335,6 +338,21 @@ export class Background { } else if (type === "open-search") { /// #if !MOBILE openGlobalSearch(`#${target.textContent}#`, !window.siyuan.ctrlIsPressed); + /// #else + const searchOption = window.siyuan.storage[Constants.LOCAL_SEARCHDATA]; + popSearch({ + removed: searchOption.removed, + sort: searchOption.sort, + group: searchOption.group, + hasReplace: false, + method: 0, + hPath: "", + idPath: [], + k: `#${target.textContent}#`, + r: "", + page: 1, + types: Object.assign({}, searchOption.types) + }); /// #endif event.preventDefault(); event.stopPropagation(); diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index 6b2ab3886..5bdd1e896 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -51,6 +51,8 @@ import {getAllModels} from "../../layout/getAll"; import {pushBack} from "../../util/backForward"; import {openAsset, openBy, openFileById} from "../../editor/util"; import {openGlobalSearch} from "../../search/util"; +/// #else +import {popSearch} from "../../mobile/menu/search"; /// #endif import {BlockPanel} from "../../block/Panel"; import {isCtrl, openByMobile} from "../util/compatibility"; @@ -1684,14 +1686,29 @@ export class WYSIWYG { return; } - /// #if !MOBILE const tagElement = hasClosestByAttribute(event.target, "data-type", "tag"); - if (tagElement && !event.altKey && protyle.model) { + if (tagElement && !event.altKey) { + /// #if !MOBILE openGlobalSearch(`#${tagElement.textContent}#`, !ctrlIsPressed); hideElements(["dialog"]); + /// #else + const searchOption = window.siyuan.storage[Constants.LOCAL_SEARCHDATA]; + popSearch({ + removed: searchOption.removed, + sort: searchOption.sort, + group: searchOption.group, + hasReplace: false, + method: 0, + hPath: "", + idPath: [], + k: `#${tagElement.textContent}#`, + r: "", + page: 1, + types: Object.assign({}, searchOption.types) + }); + /// #endif return; } - /// #endif const embedItemElement = hasClosestByClassName(event.target, "protyle-wysiwyg__embed"); if (embedItemElement) {