Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/5632

Vanessa1faeb1358c3a
diff --git a/app/src/search/spread.ts b/app/src/search/spread.ts
index c0556ffbd6..f7c5315014 100644
--- a/app/src/search/spread.ts
+++ b/app/src/search/spread.ts
@@ -441,7 +441,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
getArticle({
dialog,
id: currentList.getAttribute("data-node-id"),
- k: searchInputElement.value,
+ k: getKey(currentList),
});
event.preventDefault();
} else if (event.key === "ArrowUp") {
@@ -460,7 +460,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
getArticle({
dialog,
id: currentList.getAttribute("data-node-id"),
- k: searchInputElement.value,
+ k: getKey(currentList)
});
event.preventDefault();
} else if (event.key === "Enter") {
@@ -509,7 +509,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
rootIds = [currentList.getAttribute("data-root-id")];
}
fetchPost("/api/search/findReplace", {
- k: searchInputElement.value,
+ k: getKey(currentList),
r: replaceInputElement.value,
ids,
types: {
@@ -558,7 +558,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
getArticle({
dialog,
id: currentList.getAttribute("data-node-id"),
- k: searchInputElement.value,
+ k: getKey(currentList)
});
});
};
@@ -603,7 +603,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
getArticle({
dialog,
id: target.getAttribute("data-node-id"),
- k: searchInputElement.value,
+ k: getKey(target)
});
searchInputElement.focus();
}
@@ -634,6 +634,14 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
inputEvent();
};
+const getKey = (element: HTMLElement) => {
+ const keys: string[] = []
+ element.querySelectorAll("mark").forEach(item => {
+ keys.push(item.textContent);
+ })
+ return [...new Set(keys)].join(" ");
+}
+
const getArticle = (options: {
id: string,
k: string,
@@ -694,10 +702,12 @@ const onSearch = (data: IBlock[], dialog: Dialog) => {
} else {
dialog.element.querySelector("#searchPreview").classList.remove("fn__none");
}
+ const contentElement = document.createElement("div");
+ contentElement.innerHTML = data[0].content;
getArticle({
dialog,
id: data[0].id,
- k: (dialog.element.querySelector("input") as HTMLInputElement).value,
+ k: getKey(contentElement),
});
} else {
if (protyle) {