Vanessa 2023-08-15 15:26:52 +08:00
parent ae259933ca
commit 0a32050f60
2 changed files with 336 additions and 98 deletions

View file

@ -1,47 +1,54 @@
/// #if !BROWSER
import {shell} from "electron";
import * as path from "path";
/// #endif
import {Constants} from "../constants";
import {fetchPost} from "../util/fetch";
import {upDownHint} from "../util/upDownHint";
import {escapeHtml} from "../util/escape";
import {setStorageVal} from "../protyle/util/compatibility";
import {getQueryTip} from "./util";
import {MenuItem} from "../menus/Menu";
import {Dialog} from "../dialog";
export const openSearchAsset = (element: Element, isStick: boolean) => {
const localSearch = window.siyuan.storage[Constants.LOCAL_SEARCHASSET] as ISearchAssetOption
let methodText = window.siyuan.languages.keyword;
if (localSearch.method === 1) {
methodText = window.siyuan.languages.querySyntax;
} else if (localSearch.method === 2) {
methodText = "SQL";
} else if (localSearch.method === 3) {
methodText = window.siyuan.languages.regex;
window.siyuan.menus.menu.remove();
element.previousElementSibling.classList.add("fn__none");
element.classList.remove("fn__none");
if (element.innerHTML) {
(element.querySelector("#searchAssetInput") as HTMLInputElement).select();
return;
}
const localSearch = window.siyuan.storage[Constants.LOCAL_SEARCHASSET] as ISearchAssetOption
const loadingElement = element.nextElementSibling;
loadingElement.classList.remove("fn__none");
let enterTip = ""
/// #if !BROWSER
enterTip = `<kbd>Enter/Double Click</kbd> ${window.siyuan.languages.showInFolder}`
/// #endif
element.innerHTML = `<div class="b3-form__icon search__header">
<span class="fn__a" id="searchHistoryBtn">
<span class="fn__a" id="assetHistoryBtn">
<svg data-menu="true" class="b3-form__icon-icon"><use xlink:href="#iconSearch"></use></svg>
<svg class="search__arrowdown"><use xlink:href="#iconDown"></use></svg>
</span>
<input id="searchAssetInput" value="${localSearch.k}" style="padding-right: 60px" class="b3-text-field b3-text-field--text" placeholder="${window.siyuan.languages.keyword}">
<div id="searchAssetHistoryList" data-close="false" class="fn__none b3-menu b3-list b3-list--background"></div>
<div class="block__icons">
<span data-type="reindexAssets" aria-label="${window.siyuan.languages.refresh}" class="block__icon b3-tooltips b3-tooltips__w">
<span data-type="assetRefresh" aria-label="${window.siyuan.languages.refresh}" class="block__icon b3-tooltips b3-tooltips__w">
<svg><use xlink:href="#iconRefresh"></use></svg>
</span>
<span class="fn__space"></span>
<span id="searchSyntaxCheck" aria-label="${window.siyuan.languages.searchMethod} ${methodText}" class="block__icon b3-tooltips b3-tooltips__w">
<span id="assetSyntaxCheck" aria-label="${getQueryTip(localSearch.method)}" class="block__icon b3-tooltips b3-tooltips__w">
<svg><use xlink:href="#iconRegex"></use></svg>
</span>
<span class="fn__space"></span>
<span id="searchFilter" aria-label="${window.siyuan.languages.type}" class="block__icon b3-tooltips b3-tooltips__w">
<span id="assetFilter" aria-label="${window.siyuan.languages.type}" class="block__icon b3-tooltips b3-tooltips__w">
<svg><use xlink:href="#iconFilter"></use></svg>
</span>
<span class="fn__space"></span>
<span id="searchMore" aria-label="${window.siyuan.languages.more}" class="block__icon b3-tooltips b3-tooltips__w">
<svg><use xlink:href="#iconMore"></use></svg>
</span>
<span class="${isStick ? "" : "fn__none "}fn__space"></span>
<span id="searchOpen" aria-label="${window.siyuan.languages.openInNewTab}" class="${isStick ? "" : "fn__none "}block__icon b3-tooltips b3-tooltips__w">
<svg><use xlink:href="#iconLayoutRight"></use></svg>
</span>
<span class="fn__space"></span>
<span id="searchAssetClose" aria-label="${isStick ? window.siyuan.languages.stickSearch : window.siyuan.languages.globalSearch}" class="block__icon b3-tooltips b3-tooltips__w">
<svg><use xlink:href="#iconBack"></use></svg>
@ -49,26 +56,24 @@ export const openSearchAsset = (element: Element, isStick: boolean) => {
</div>
</div>
<div class="block__icons">
<span data-type="previous" class="block__icon block__icon--show b3-tooltips b3-tooltips__ne" disabled="disabled" aria-label="${window.siyuan.languages.previousLabel}"><svg><use xlink:href='#iconLeft'></use></svg></span>
<span data-type="assetPrevious" class="block__icon block__icon--show b3-tooltips b3-tooltips__ne" disabled="disabled" aria-label="${window.siyuan.languages.previousLabel}"><svg><use xlink:href='#iconLeft'></use></svg></span>
<span class="fn__space"></span>
<span data-type="next" class="block__icon block__icon--show b3-tooltips b3-tooltips__ne" disabled="disabled" aria-label="${window.siyuan.languages.nextLabel}"><svg><use xlink:href='#iconRight'></use></svg></span>
<span data-type="assetNext" class="block__icon block__icon--show b3-tooltips b3-tooltips__ne" disabled="disabled" aria-label="${window.siyuan.languages.nextLabel}"><svg><use xlink:href='#iconRight'></use></svg></span>
<span class="fn__space"></span>
<span id="searchResult"></span>
<span id="searchAssetResult"></span>
<span class="fn__space"></span>
<span class="fn__flex-1"></span>
</div>
<div class="search__layout${localSearch.layout === 1 ? " search__layout--row" : ""}">
<div id="searchAssetList" class="fn__flex-1 search__list b3-list b3-list--background"></div>
<div class="search__drag"></div>
<div id="searchPreview" class="fn__flex-1 search__preview"></div>
<div id="searchAssetPreview" class="fn__flex-1 search__preview" style="padding: 8px"></div>
</div>
<div class="search__tip${isStick ? "" : " fn__none"}">
<kbd>/</kbd> ${window.siyuan.languages.searchTip1}
<kbd>Enter/Double Click</kbd> ${window.siyuan.languages.searchTip2}
${enterTip}
<kbd>Esc</kbd> ${window.siyuan.languages.searchTip5}
</div>`
element.previousElementSibling.classList.add("fn__none");
element.classList.remove("fn__none")
const searchPanelElement = element.querySelector("#searchAssetList");
if (element.querySelector("#searchAssetList").innerHTML !== "") {
return
@ -79,42 +84,57 @@ export const openSearchAsset = (element: Element, isStick: boolean) => {
if (event.isComposing) {
return;
}
inputEvent(localSearch, element, 1);
assetInputEvent(element, localSearch);
});
searchInputElement.addEventListener("input", (event: InputEvent) => {
if (event.isComposing) {
return;
}
inputEvent(localSearch, element, 1);
assetInputEvent(element, localSearch);
});
searchInputElement.addEventListener("blur", () => {
// saveKeyList("keys", searchInputElement.value);
if (!searchInputElement.value) {
return
}
let list: string[] = window.siyuan.storage[Constants.LOCAL_SEARCHASSET].keys;
list.splice(0, 0, searchInputElement.value);
list = Array.from(new Set(list));
if (list.length > window.siyuan.config.search.limit) {
list.splice(window.siyuan.config.search.limit, list.length - window.siyuan.config.search.limit);
}
window.siyuan.storage[Constants.LOCAL_SEARCHASSET].k = searchInputElement.value;
window.siyuan.storage[Constants.LOCAL_SEARCHASSET].keys = list;
setStorageVal(Constants.LOCAL_SEARCHASSET, window.siyuan.storage[Constants.LOCAL_SEARCHASSET]);
});
const historyElement = element.querySelector("#searchAssetHistoryList")
const lineHeight = 30;
const lineHeight = 28;
searchInputElement.addEventListener("keydown", (event: KeyboardEvent) => {
let currentList: HTMLElement = searchPanelElement.querySelector(".b3-list-item--focus");
if (!currentList || event.isComposing) {
if (event.isComposing) {
return;
}
let currentList: HTMLElement = searchPanelElement.querySelector(".b3-list-item--focus");
const isHistory = !historyElement.classList.contains("fn__none");
if (event.key === "Enter") {
if (!isHistory) {
// TODO open folder
if (currentList) {
/// #if !BROWSER
shell.showItemInFolder(path.join(window.siyuan.config.system.dataDir, currentList.lastElementChild.getAttribute("aria-label")));
/// #endif
}
} else {
searchInputElement.value = historyElement.querySelector(".b3-list-item--focus").textContent.trim();
inputEvent(localSearch, element, 1);
toggleSearchHistory(historyElement, searchInputElement);
assetInputEvent(element, localSearch);
toggleAssetHistory(historyElement, searchInputElement);
}
event.preventDefault();
}
if (event.key === "ArrowDown" && event.altKey) {
toggleSearchHistory(historyElement, searchInputElement);
toggleAssetHistory(historyElement, searchInputElement);
return;
}
if (isHistory) {
if (event.key === "Escape") {
toggleSearchHistory(historyElement, searchInputElement);
toggleAssetHistory(historyElement, searchInputElement);
} else {
upDownHint(historyElement, event);
}
@ -122,7 +142,7 @@ export const openSearchAsset = (element: Element, isStick: boolean) => {
event.preventDefault();
return;
}
if (!isHistory) {
if (!currentList) {
return;
}
if (event.key === "ArrowDown") {
@ -152,34 +172,83 @@ export const openSearchAsset = (element: Element, isStick: boolean) => {
}
event.preventDefault();
}
renderPreview(element.querySelector('#searchAssetPreview'), currentList.dataset.id, searchInputElement.value, localSearch.method);
});
inputEvent(localSearch, element);
assetInputEvent(element, localSearch);
}
const inputEvent = (localSearch: ISearchAssetOption, element: Element, page = 1) => {
const searchInputElement = element.querySelector("#searchAssetInput") as HTMLInputElement
fetchPost("/api/search/fullTextSearchAssetContent", {
page,
query: searchInputElement.value,
types: localSearch.types,
method: localSearch.method,
orderBy: localSearch.sort
}, (response) => {
element.nextElementSibling.classList.add("fn__none")
console.log(response)
})
let inputTimeout: number
export const assetInputEvent = (element: Element, localSearch?: ISearchAssetOption, page = 1,) => {
element.nextElementSibling.classList.remove("fn__none")
clearTimeout(inputTimeout);
inputTimeout = window.setTimeout(() => {
if (!localSearch) {
localSearch = window.siyuan.storage[Constants.LOCAL_SEARCHASSET] as ISearchAssetOption
}
const previousElement = element.querySelector('[data-type="assetPrevious"]')
if (page > 1) {
previousElement.removeAttribute("disabled");
} else {
previousElement.setAttribute("disabled", "disabled");
}
const searchInputElement = element.querySelector("#searchAssetInput") as HTMLInputElement
fetchPost("/api/search/fullTextSearchAssetContent", {
page,
query: searchInputElement.value,
types: localSearch.types,
method: localSearch.method,
orderBy: localSearch.sort
}, (response) => {
element.nextElementSibling.classList.add("fn__none")
const nextElement = element.querySelector('[data-type="assetNext"]')
const previewElement = element.querySelector('#searchAssetPreview')
if (page < response.data.pageCount) {
nextElement.removeAttribute("disabled");
} else {
nextElement.setAttribute("disabled", "disabled");
}
let resultHTML = "";
response.data.assetContents.forEach((item: {
content: string
ext: string
id: string
path: string
name: string
hSize: string
}, index: number) => {
resultHTML += `<div data-type="search-item" class="b3-list-item${index === 0 ? " b3-list-item--focus" : ""}" data-id="${item.id}">
<span class="ft__on-surface">${item.ext}</span>
<span class="fn__space"></span>
<span class="b3-list-item__text">${item.content}</span>
<span class="b3-list-item__meta">${item.hSize}</span>
<span class="b3-list-item__meta b3-list-item__meta--ellipsis b3-tooltips__w b3-tooltips" aria-label="${item.path}">${item.name}</span>
</div>`;
});
if (response.data.assetContents.length > 0) {
previewElement.classList.remove("fn__none");
element.querySelector(".search__drag").classList.remove("fn__none");
renderPreview(previewElement, response.data.assetContents[0].id, searchInputElement.value, localSearch.method);
} else {
previewElement.classList.add("fn__none");
element.querySelector(".search__drag").classList.add("fn__none");
}
element.querySelector("#searchAssetResult").innerHTML = `${page}/${response.data.pageCount || 1}<span class="fn__space"></span>
<span class="ft__on-surface">${window.siyuan.languages.total} ${response.data.matchedAssetCount}</span>`;
element.querySelector("#searchAssetList").innerHTML = resultHTML || `<div class="search__empty">
${window.siyuan.languages.emptyContent}
</div>`
})
}, Constants.TIMEOUT_INPUT);
}
export const reIndexAssets = (loadingElement: HTMLElement) => {
loadingElement.classList.remove("fn__none")
fetchPost("/api/asset/fullReindexAssetContent", {}, (response) => {
loadingElement.classList.add("fn__none")
// assetInputEvent()
})
}
const toggleSearchHistory = (historyElement: Element, searchInputElement: HTMLInputElement) => {
export const toggleAssetHistory = (historyElement: Element, searchInputElement: HTMLInputElement) => {
if (historyElement.classList.contains("fn__none")) {
const keys = window.siyuan.storage[Constants.LOCAL_SEARCHASSET].keys;
if (!keys || keys.length === 0) {
@ -200,3 +269,120 @@ const toggleSearchHistory = (historyElement: Element, searchInputElement: HTMLIn
historyElement.classList.add("fn__none");
}
};
export const renderPreview = (element: Element, id: string, query: string, queryMethod: number) => {
fetchPost('/api/search/getAssetContent', {id, query, queryMethod}, (response) => {
element.innerHTML = response.data.assetContent.content;
})
}
export const assetMethodMenu = (target: HTMLElement, cb:() => void) => {
const method = window.siyuan.storage[Constants.LOCAL_SEARCHASSET].method
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === "searchMethod") {
window.siyuan.menus.menu.remove();
return;
}
window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", "searchMethod");
window.siyuan.menus.menu.append(new MenuItem({
iconHTML: Constants.ZWSP,
label: window.siyuan.languages.keyword,
current: method === 0,
click() {
window.siyuan.storage[Constants.LOCAL_SEARCHASSET].method = 0
cb();
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({
iconHTML: Constants.ZWSP,
label: window.siyuan.languages.querySyntax,
current: method === 1,
click() {
window.siyuan.storage[Constants.LOCAL_SEARCHASSET].method = 1
cb();
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({
iconHTML: Constants.ZWSP,
label: "SQL",
current: method === 2,
click() {
window.siyuan.storage[Constants.LOCAL_SEARCHASSET].method = 2
cb();
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({
iconHTML: Constants.ZWSP,
label: window.siyuan.languages.regex,
current: method === 3,
click() {
window.siyuan.storage[Constants.LOCAL_SEARCHASSET].method = 3
cb();
}
}).element);
const rect = target.getBoundingClientRect();
window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom}, true);
}
export const assetFilterMenu = (assetsElement:Element) => {
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHASSET].types
const filterDialog = new Dialog({
title: window.siyuan.languages.type,
content: `<div class="b3-dialog__content">
<label class="fn__flex b3-label">
<div class="fn__flex-1 fn__flex-center">
.txt
</div>
<span class="fn__space"></span>
<input class="b3-switch fn__flex-center" data-type=".txt" type="checkbox"${localData[".txt"] ? " checked" : ""}>
</label>
<label class="fn__flex b3-label">
<div class="fn__flex-1 fn__flex-center">
.md
</div>
<span class="fn__space"></span>
<input class="b3-switch fn__flex-center" data-type=".md" type="checkbox"${localData[".md"] ? " checked" : ""}>
</label>
<label class="fn__flex b3-label">
<div class="fn__flex-1 fn__flex-center">
.docx
</div>
<span class="fn__space"></span>
<input class="b3-switch fn__flex-center" data-type=".docx" type="checkbox"${localData[".docx"] ? " checked" : ""}>
</label>
<label class="fn__flex b3-label">
<div class="fn__flex-1 fn__flex-center">
.xlsx
</div>
<span class="fn__space"></span>
<input class="b3-switch fn__flex-center" data-type=".xlsx" type="checkbox"${localData[".xlsx"] ? " checked" : ""}>
</label>
<label class="fn__flex b3-label">
<div class="fn__flex-1 fn__flex-center">
.pptx
</div>
<span class="fn__space"></span>
<input class="b3-switch fn__flex-center" data-type=".pptx" type="checkbox"${localData[".pptx"] ? " checked" : ""}>
</label>
</div>
<div class="b3-dialog__action">
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
<button class="b3-button b3-button--text">${window.siyuan.languages.confirm}</button>
</div>`,
width: "520px",
height: "70vh",
});
const btnsElement = filterDialog.element.querySelectorAll(".b3-button");
btnsElement[0].addEventListener("click", () => {
filterDialog.destroy();
});
btnsElement[1].addEventListener("click", () => {
filterDialog.element.querySelectorAll(".b3-switch").forEach((item: HTMLInputElement) => {
localData[item.getAttribute("data-type")] = item.checked;
});
assetInputEvent(assetsElement);
setStorageVal(Constants.LOCAL_SEARCHASSET, window.siyuan.storage[Constants.LOCAL_SEARCHASSET]);
filterDialog.destroy();
});
};

View file

@ -1,4 +1,8 @@
import {getAllModels} from "../layout/getAll";
/// #if !BROWSER
import {shell} from "electron";
import * as path from "path";
/// #endif
import {Constants} from "../constants";
import {escapeAttr, escapeGreat, escapeHtml} from "../util/escape";
import {fetchPost} from "../util/fetch";
@ -19,7 +23,14 @@ import {matchHotKey} from "../protyle/util/hotKey";
import {filterMenu, getKeyByLiElement, initCriteriaMenu, moreMenu, queryMenu, saveCriterion} from "./menu";
import {App} from "../index";
import {upDownHint} from "../util/upDownHint";
import {openSearchAsset, reIndexAssets} from "./assets";
import {
assetFilterMenu,
assetInputEvent,
assetMethodMenu,
openSearchAsset,
renderPreview,
toggleAssetHistory
} from "./assets";
const toggleReplaceHistory = (replaceHistoryElement: Element, historyElement: Element, replaceInputElement: HTMLInputElement) => {
if (replaceHistoryElement.classList.contains("fn__none")) {
@ -236,7 +247,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
const replaceHistoryElement = element.querySelector("#replaceHistoryList");
const historyElement = element.querySelector("#searchHistoryList");
const lineHeight = 30;
const lineHeight = 28;
const edit = new Protyle(app, element.querySelector("#searchPreview") as HTMLElement, {
blockId: "",
render: {
@ -502,6 +513,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
event.preventDefault();
break;
} else if (target.id === "searchAssetClose") {
window.siyuan.menus.menu.remove();
assetsElement.classList.add("fn__none")
assetsElement.previousElementSibling.classList.remove("fn__none")
searchInputElement.select();
@ -624,6 +636,20 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
event.stopPropagation();
event.preventDefault();
break;
} else if (target.id === "assetFilter") {
assetFilterMenu(assetsElement);
event.stopPropagation();
event.preventDefault();
break;
} else if (target.id === "assetSyntaxCheck") {
assetMethodMenu(target, () => {
element.querySelector("#assetSyntaxCheck").setAttribute("aria-label", getQueryTip(window.siyuan.storage[Constants.LOCAL_SEARCHASSET].method));
assetInputEvent(assetsElement);
setStorageVal(Constants.LOCAL_SEARCHASSET, window.siyuan.storage[Constants.LOCAL_SEARCHASSET]);
})
event.stopPropagation();
event.preventDefault();
break;
} else if (target.id === "searchSyntaxCheck") {
queryMenu(config, () => {
element.querySelector("#searchSyntaxCheck").setAttribute("aria-label", getQueryTip(config.method));
@ -640,6 +666,11 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
event.stopPropagation();
event.preventDefault();
return;
} else if (target.id === "assetHistoryBtn") {
toggleAssetHistory(target.nextElementSibling.nextElementSibling, target.nextElementSibling as HTMLInputElement);
event.stopPropagation();
event.preventDefault();
return;
} else if (target.id === "replaceHistoryBtn") {
toggleReplaceHistory(replaceHistoryElement, historyElement, replaceInputElement);
event.stopPropagation();
@ -650,8 +681,8 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
event.stopPropagation();
event.preventDefault();
break;
} else if (type === "reindexAssets") {
reIndexAssets(element.querySelector(".fn__loading--top"));
} else if (type === "assetRefresh") {
assetInputEvent(assetsElement);
event.stopPropagation();
event.preventDefault();
break;
@ -667,65 +698,85 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
event.preventDefault();
break;
} else if (target.classList.contains("b3-list-item")) {
const searchAssetInputElement = element.querySelector("#searchAssetInput") as HTMLInputElement
if (target.parentElement.id === "searchHistoryList") {
searchInputElement.value = target.textContent;
config.page = 1;
inputTimeout = inputEvent(element, config, inputTimeout, edit, true);
} else if (target.parentElement.id === "searchAssetHistoryList") {
searchAssetInputElement.value = target.textContent;
assetInputEvent(assetsElement);
} else if (target.parentElement.id === "replaceHistoryList") {
replaceInputElement.value = target.textContent;
replaceHistoryElement.classList.add("fn__none");
} else if (type === "search-new") {
newFileByName(app, searchInputElement.value);
} else if (type === "search-item") {
const isAsset = target.dataset.id;
if (event.detail === 1) {
clickTimeout = window.setTimeout(() => {
if (event.altKey) {
const id = target.getAttribute("data-node-id");
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
openFileById({
app,
id,
action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],
zoomIn: foldResponse.data,
position: "right"
if (isAsset) {
if (!target.classList.contains("b3-list-item--focus")) {
assetsElement.querySelector(".b3-list-item--focus").classList.remove("b3-list-item--focus");
target.classList.add("b3-list-item--focus");
renderPreview(element.querySelector('#searchAssetPreview'), target.dataset.id, searchAssetInputElement.value, window.siyuan.storage[Constants.LOCAL_SEARCHASSET].method);
searchAssetInputElement.focus();
}
} else {
if (event.altKey) {
const id = target.getAttribute("data-node-id");
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
openFileById({
app,
id,
action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],
zoomIn: foldResponse.data,
position: "right"
});
if (closeCB) {
closeCB();
}
});
if (closeCB) {
closeCB();
}
});
} else if (!target.classList.contains("b3-list-item--focus")) {
searchPanelElement.querySelector(".b3-list-item--focus").classList.remove("b3-list-item--focus");
target.classList.add("b3-list-item--focus");
getArticle({
edit,
id: target.getAttribute("data-node-id"),
config,
value: searchInputElement.value,
});
searchInputElement.focus();
} else if (target.classList.contains("b3-list-item--focus")) {
renderNextSearchMark({
edit,
id: target.getAttribute("data-node-id"),
target,
});
searchInputElement.focus();
} else if (!target.classList.contains("b3-list-item--focus")) {
searchPanelElement.querySelector(".b3-list-item--focus").classList.remove("b3-list-item--focus");
target.classList.add("b3-list-item--focus");
getArticle({
edit,
id: target.getAttribute("data-node-id"),
config,
value: searchInputElement.value,
});
searchInputElement.focus();
} else if (target.classList.contains("b3-list-item--focus")) {
renderNextSearchMark({
edit,
id: target.getAttribute("data-node-id"),
target,
});
searchInputElement.focus();
}
}
}, Constants.TIMEOUT_DBLCLICK);
} else if (event.detail === 2 && !event.ctrlKey) {
clearTimeout(clickTimeout);
const id = target.getAttribute("data-node-id");
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
openFileById({
app,
id,
action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],
zoomIn: foldResponse.data
if (isAsset) {
/// #if !BROWSER
shell.showItemInFolder(path.join(window.siyuan.config.system.dataDir, target.lastElementChild.getAttribute("aria-label")));
/// #endif
} else {
const id = target.getAttribute("data-node-id");
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
openFileById({
app,
id,
action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],
zoomIn: foldResponse.data
});
if (closeCB) {
closeCB();
}
});
if (closeCB) {
closeCB();
}
});
}
}
window.siyuan.menus.menu.remove();
} else if (target.querySelector(".b3-list-item__toggle")) {
@ -740,6 +791,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
}
historyElement.classList.add("fn__none");
replaceHistoryElement.classList.add("fn__none");
element.querySelector("#searchAssetHistoryList")?.classList.add("fn__none");
}, false);
searchInputElement.addEventListener("compositionend", (event: InputEvent) => {
@ -927,7 +979,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
return edit;
};
const getQueryTip = (method: number) => {
export const getQueryTip = (method: number) => {
let methodTip = window.siyuan.languages.searchMethod + " ";
switch (method) {
case 0: