This commit is contained in:
Vanessa 2023-05-10 15:26:03 +08:00
parent a4b13e4894
commit cfdea78c1e

View file

@ -527,41 +527,49 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
event.preventDefault(); event.preventDefault();
break; break;
} else if (target.id === "searchHistoryBtn") { } else if (target.id === "searchHistoryBtn") {
const list = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS]; if (historyElement.classList.contains("fn__none")) {
if (!list.keys || list.keys.length === 0) { const list = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS];
return; if (!list.keys || list.keys.length === 0) {
} return;
let html = "";
list.keys.forEach((s: string) => {
if (s !== searchInputElement.value) {
html += `<div class="b3-list-item">${escapeHtml(s)}</div>`;
} }
}); let html = "";
if (html === "") { list.keys.forEach((s: string) => {
return; if (s !== searchInputElement.value) {
html += `<div class="b3-list-item">${escapeHtml(s)}</div>`;
}
});
if (html === "") {
return;
}
historyElement.classList.remove("fn__none");
historyElement.innerHTML = html;
} else {
historyElement.classList.add("fn__none");
} }
historyElement.classList.remove("fn__none");
historyElement.innerHTML = html;
replaceHistoryElement.classList.add("fn__none"); replaceHistoryElement.classList.add("fn__none");
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
return; return;
} else if (target.id === "replaceHistoryBtn") { } else if (target.id === "replaceHistoryBtn") {
const list = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS]; if (replaceHistoryElement.classList.contains("fn__none")) {
if (!list.replaceKeys || list.replaceKeys.length === 0) { const list = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS];
return; if (!list.replaceKeys || list.replaceKeys.length === 0) {
} return;
let html = "";
list.replaceKeys.forEach((s: string) => {
if (s !== replaceInputElement.value) {
html += `<div class="b3-list-item">${escapeHtml(s)}</div>`;
} }
}); let html = "";
if (html === "") { list.replaceKeys.forEach((s: string) => {
return; if (s !== replaceInputElement.value) {
html += `<div class="b3-list-item">${escapeHtml(s)}</div>`;
}
});
if (html === "") {
return;
}
replaceHistoryElement.classList.remove("fn__none");
replaceHistoryElement.innerHTML = html;
} else {
replaceHistoryElement.classList.add("fn__none");
} }
replaceHistoryElement.classList.remove("fn__none");
replaceHistoryElement.innerHTML = html;
historyElement.classList.add("fn__none"); historyElement.classList.add("fn__none");
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();