Vanessa 2023-04-21 14:54:21 +08:00
parent 74bb7bdd4f
commit 56cfc90c8c
3 changed files with 50 additions and 13 deletions

View File

@ -149,7 +149,7 @@ const updateConfig = (element: Element, newConfig: ISearchOption, config: ISearc
window.siyuan.menus.menu.remove(); 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"); const listElement = document.querySelector("#searchList");
let resultHTML = ""; let resultHTML = "";
data.forEach((item: IBlock, index: number) => { data.forEach((item: IBlock, index: number) => {
@ -191,13 +191,11 @@ ${unicode2Emoji(childItem.ial.icon, false, "b3-list-item__graphic", true)}
listElement.scrollTop = 0; listElement.scrollTop = 0;
let countHTML = ""; let countHTML = "";
if (response) { if (response) {
countHTML = `<div class="b3-list--empty"> countHTML = `${window.siyuan.languages.findInDoc.replace("${x}", response.data.matchedRootCount).replace("${y}", response.data.matchedBlockCount)}
${config.page}/${response.data.pageCount || 1} <span class="fn__flex-1"></span>
<span class="fn__space"></span> ${config.page}/${response.data.pageCount || 1}`;
${window.siyuan.languages.findInDoc.replace("${x}", response.data.matchedRootCount).replace("${y}", response.data.matchedBlockCount)}
</div>`;
} }
listElement.previousElementSibling.innerHTML = countHTML; listElement.previousElementSibling.querySelector('[data-type="result"]').innerHTML = countHTML;
}; };
let toolbarSearchTimeout = 0; let toolbarSearchTimeout = 0;
@ -542,7 +540,13 @@ export const popSearch = (config = window.siyuan.storage[Constants.LOCAL_SEARCHD
<div class="fn__space"></div> <div class="fn__space"></div>
</div> </div>
<div id="criteria" style="background-color: var(--b3-theme-background);" class="b3-chips"></div> <div id="criteria" style="background-color: var(--b3-theme-background);" class="b3-chips"></div>
<div></div> <div class="toolbar">
<span class="fn__space"></span>
<span data-type="result" class="fn__flex-1 fn__flex"></span>
<span class="fn__space"></span>
<svg data-type="previous" disabled="disabled" class="toolbar__icon"><use xlink:href="#iconLeft"></use></svg>
<svg data-type="next" disabled="disabled" class="toolbar__icon"><use xlink:href="#iconRight"></use></svg>
</div>
<div id="searchList" style="overflow:auto;" class="fn__flex-1 b3-list b3-list--background"></div> <div id="searchList" style="overflow:auto;" class="fn__flex-1 b3-list b3-list--background"></div>
<div id="searchPath" class="b3-chips${config.hPath ? "" : " fn__none"}" style="background-color: var(--b3-theme-background);"> <div id="searchPath" class="b3-chips${config.hPath ? "" : " fn__none"}" style="background-color: var(--b3-theme-background);">
<div class="b3-chip b3-chip--middle"> <div class="b3-chip b3-chip--middle">
@ -552,8 +556,6 @@ export const popSearch = (config = window.siyuan.storage[Constants.LOCAL_SEARCHD
</div> </div>
<div class="toolbar"> <div class="toolbar">
<span class="fn__flex-1"></span> <span class="fn__flex-1"></span>
<svg data-type="previous" disabled="disabled" class="toolbar__icon"><use xlink:href="#iconLeft"></use></svg>
<svg data-type="next" disabled="disabled" class="toolbar__icon"><use xlink:href="#iconRight"></use></svg>
<svg data-type="toggle-replace" class="toolbar__icon${config.hasReplace ? " toolbar__icon--active" : ""}"><use xlink:href="#iconReplace"></use></svg> <svg data-type="toggle-replace" class="toolbar__icon${config.hasReplace ? " toolbar__icon--active" : ""}"><use xlink:href="#iconReplace"></use></svg>
<svg data-type="query" class="toolbar__icon"><use xlink:href="#iconRegex"></use></svg> <svg data-type="query" class="toolbar__icon"><use xlink:href="#iconRegex"></use></svg>
<svg data-type="filter" class="toolbar__icon"><use xlink:href="#iconFilter"></use></svg> <svg data-type="filter" class="toolbar__icon"><use xlink:href="#iconFilter"></use></svg>

View File

@ -13,9 +13,12 @@ import {
import {upDownHint} from "../../util/upDownHint"; import {upDownHint} from "../../util/upDownHint";
/// #if !MOBILE /// #if !MOBILE
import {openGlobalSearch} from "../../search/util"; import {openGlobalSearch} from "../../search/util";
/// #else
import {popSearch} from "../../mobile/menu/search";
/// #endif /// #endif
import {getEventName} from "../util/compatibility"; import {getEventName} from "../util/compatibility";
import {Dialog} from "../../dialog"; import {Dialog} from "../../dialog";
import {Constants} from "../../constants";
export class Background { export class Background {
public element: HTMLElement; public element: HTMLElement;
@ -335,6 +338,21 @@ export class Background {
} else if (type === "open-search") { } else if (type === "open-search") {
/// #if !MOBILE /// #if !MOBILE
openGlobalSearch(`#${target.textContent}#`, !window.siyuan.ctrlIsPressed); 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 /// #endif
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();

View File

@ -51,6 +51,8 @@ import {getAllModels} from "../../layout/getAll";
import {pushBack} from "../../util/backForward"; import {pushBack} from "../../util/backForward";
import {openAsset, openBy, openFileById} from "../../editor/util"; import {openAsset, openBy, openFileById} from "../../editor/util";
import {openGlobalSearch} from "../../search/util"; import {openGlobalSearch} from "../../search/util";
/// #else
import {popSearch} from "../../mobile/menu/search";
/// #endif /// #endif
import {BlockPanel} from "../../block/Panel"; import {BlockPanel} from "../../block/Panel";
import {isCtrl, openByMobile} from "../util/compatibility"; import {isCtrl, openByMobile} from "../util/compatibility";
@ -1684,14 +1686,29 @@ export class WYSIWYG {
return; return;
} }
/// #if !MOBILE
const tagElement = hasClosestByAttribute(event.target, "data-type", "tag"); const tagElement = hasClosestByAttribute(event.target, "data-type", "tag");
if (tagElement && !event.altKey && protyle.model) { if (tagElement && !event.altKey) {
/// #if !MOBILE
openGlobalSearch(`#${tagElement.textContent}#`, !ctrlIsPressed); openGlobalSearch(`#${tagElement.textContent}#`, !ctrlIsPressed);
hideElements(["dialog"]); 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; return;
} }
/// #endif
const embedItemElement = hasClosestByClassName(event.target, "protyle-wysiwyg__embed"); const embedItemElement = hasClosestByClassName(event.target, "protyle-wysiwyg__embed");
if (embedItemElement) { if (embedItemElement) {