An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/7948
Vanessac3edf5bd9e40
diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.tsindex 734a4a4bfe..911fc102b1 100644--- a/app/src/protyle/util/compatibility.ts+++ b/app/src/protyle/util/compatibility.ts@@ -185,6 +185,7 @@ export const getLocalStorage = (cb: () => void) => {};defaultStorage[Constants.LOCAL_FONTSTYLES] = [];defaultStorage[Constants.LOCAL_SEARCHDATA] = {+ page: 1,sort: 0,group: 0,hasReplace: false,diff --git a/app/src/search/spread.ts b/app/src/search/spread.tsindex bd08dd5c44..699a68066a 100644--- a/app/src/search/spread.ts+++ b/app/src/search/spread.ts@@ -95,7 +95,8 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: striidPath,group: localData.group,sort: localData.sort,- types: localData.types+ types: localData.types,+ page: localData.page}, dialog.element.querySelector(".b3-dialog__container").lastElementChild, () => {dialog.destroy();});diff --git a/app/src/search/util.ts b/app/src/search/util.tsindex 8f5ed85457..3115eabb2a 100644--- a/app/src/search/util.ts+++ b/app/src/search/util.ts@@ -68,7 +68,8 @@ export const openGlobalSearch = (text: string, replace: boolean) => {group: localData.group,sort: localData.sort,types: localData.types,- removed: localData.removed+ removed: localData.removed,+ page: localData.page}});tab.addModel(asset);@@ -148,9 +149,9 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()</div><div id="criteria" class="b3-chips" style="background-color: var(--b3-theme-background)"></div><div class="block__icons">- <span data-type="previous" class="block__icon block__icon--show b3-tooltips b3-tooltips__se" disabled="disabled" aria-label="${window.siyuan.languages.previousLabel}"><svg><use xlink:href='#iconLeft'></use></svg></span>+ <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 class="fn__space"></span>- <span data-type="next" class="block__icon block__icon--show b3-tooltips b3-tooltips__se" disabled="disabled" aria-label="${window.siyuan.languages.nextLabel}"><svg><use xlink:href='#iconRight'></use></svg></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 class="fn__space"></span><span id="searchResult"></span><span class="fn__space"></span>@@ -285,7 +286,24 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()let target = event.target as HTMLElement;const searchPathInputElement = element.querySelector("#searchPathInput");while (target && !target.isSameNode(element)) {- if (target.classList.contains("b3-chip") && target.getAttribute("data-type") === "set-criteria") {+ const type = target.getAttribute("data-type")+ if (type === "next") {+ if (!target.getAttribute("disabled")) {+ config.page++;+ inputTimeout = inputEvent(element, config, inputTimeout, edit);+ }+ event.stopPropagation();+ event.preventDefault();+ break;+ } else if (type === "previous") {+ if (!target.getAttribute("disabled")) {+ config.page--;+ inputTimeout = inputEvent(element, config, inputTimeout, edit);+ }+ event.stopPropagation();+ event.preventDefault();+ break;+ } else if (target.classList.contains("b3-chip") && type === "set-criteria") {config.removed = false;criteriaData.find(item => {if (item.name === target.innerText.trim()) {@@ -296,7 +314,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()event.stopPropagation();event.preventDefault();break;- } else if (target.classList.contains("b3-chip__close") && target.getAttribute("data-type") === "remove-criteria") {+ } else if (target.classList.contains("b3-chip__close") && type === "remove-criteria") {const name = target.parentElement.innerText.trim();fetchPost("/api/storage/removeCriterion", {name});criteriaData.find((item, index) => {@@ -317,6 +335,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()} else if (target.classList.contains("search__rmpath")) {config.idPath = [];config.hPath = "";+ config.page = 1;searchPathInputElement.innerHTML = config.hPath;searchPathInputElement.setAttribute("title", "");inputTimeout = inputEvent(element, config, inputTimeout, edit);@@ -365,6 +384,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()hPathList.push(...response.data);}config.hPath = hPathList.join(" ");+ config.page = 1;searchPathInputElement.innerHTML = `${escapeHtml(config.hPath)}<svg class="search__rmpath"><use xlink:href="#iconCloseRound"></use></svg>`;searchPathInputElement.setAttribute("title", config.hPath);const includeElement = element.querySelector("#searchInclude");@@ -395,6 +415,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()}});}+ config.page = 1;inputTimeout = inputEvent(element, config, inputTimeout, edit);event.stopPropagation();event.preventDefault();@@ -443,8 +464,9 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()break;} else if (target.id === "searchMore") {moreMenu(config, criteriaData, element, () => {+ config.page = 1;inputEvent(element, config, undefined, edit);- }, ()=> {+ }, () => {updateConfig(element, {removed: true,sort: 0,@@ -455,6 +477,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()idPath: [],k: "",r: "",+ page: 1,types: {document: window.siyuan.config.search.document,heading: window.siyuan.config.search.heading,@@ -528,6 +551,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()break;} else if (target.id === "searchFilter") {filterMenu(config, () => {+ config.page = 1;inputEvent(element, config, undefined, edit);});event.stopPropagation();@@ -536,6 +560,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()} else if (target.id === "searchSyntaxCheck") {queryMenu(config, () => {element.querySelector("#searchSyntaxCheck").setAttribute("aria-label", getQueryTip(config.method));+ config.page = 1;inputEvent(element, config, undefined, edit);});window.siyuan.menus.menu.popup({x: event.clientX - 16, y: event.clientY - 16}, true);@@ -601,13 +626,14 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()} else if (target.classList.contains("b3-list-item")) {if (target.parentElement.id === "searchHistoryList") {searchInputElement.value = target.textContent;+ config.page = 1;inputTimeout = inputEvent(element, config, inputTimeout, edit);} else if (target.parentElement.id === "replaceHistoryList") {replaceInputElement.value = target.textContent;replaceHistoryElement.classList.add("fn__none");- } else if (target.getAttribute("data-type") === "search-new") {+ } else if (type === "search-new") {newFileByName(searchInputElement.value);- } else if (target.getAttribute("data-type") === "search-item") {+ } else if (type === "search-item") {if (event.detail === 1) {clickTimeout = window.setTimeout(() => {if (event.altKey) {@@ -671,9 +697,11 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()}, false);searchInputElement.addEventListener("compositionend", (event: InputEvent) => {+ config.page = 1;inputTimeout = inputEvent(element, config, inputTimeout, edit, event);});searchInputElement.addEventListener("input", (event: InputEvent) => {+ config.page = 1;inputTimeout = inputEvent(element, config, inputTimeout, edit, event);});searchInputElement.addEventListener("blur", () => {@@ -1020,13 +1048,22 @@ const inputEvent = (element: Element, config: ISearchOption, inputTimeout: numbeloadingElement.classList.remove("fn__none");const inputValue = searchInputElement.value;element.querySelector("#searchList").scrollTo(0, 0);+ const previousElement = element.querySelector('[data-type="previous"]');+ const nextElement = element.querySelector('[data-type="next"]');if (inputValue === "" && (!config.idPath || config.idPath.length === 0)) {fetchPost("/api/block/getRecentUpdatedBlocks", {}, (response) => {onSearch(response.data, edit, element);loadingElement.classList.add("fn__none");element.querySelector("#searchResult").innerHTML = "";+ previousElement.setAttribute("disabled", "true");+ nextElement.setAttribute("disabled", "true");});} else {+ if (config.page > 1) {+ previousElement.removeAttribute("disabled");+ } else {+ previousElement.setAttribute("disabled", "disabled");+ }fetchPost("/api/search/fullTextSearchBlock", {query: inputValue,method: config.method,@@ -1034,7 +1071,14 @@ const inputEvent = (element: Element, config: ISearchOption, inputTimeout: numbepaths: config.idPath || [],groupBy: config.group,orderBy: config.sort,+ page: config.page || 1,}, (response) => {+ if (config.page < response.data.pageCount) {+ nextElement.removeAttribute("disabled");+ } else {+ nextElement.setAttribute("disabled", "disabled");+ }+ nextElement.setAttribute("disabled", "true");onSearch(response.data.blocks, edit, element);element.querySelector("#searchResult").innerHTML = window.siyuan.languages.findInDoc.replace("${x}", response.data.matchedRootCount).replace("${y}", response.data.matchedBlockCount);loadingElement.classList.add("fn__none");diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex 3c88757557..e9b244efa6 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -87,6 +87,7 @@ interface ICard {}interface ISearchOption {+ page: numberremoved?: boolean // 移除后需记录搜索内容 https://github.com/siyuan-note/siyuan/issues/7745name?: stringsort: number, // 0:按块类型(默认),1:按创建时间升序,2:按创建时间降序,3:按更新时间升序,4:按更新时间降序,5:按内容顺序(仅在按文档分组时),6:按相关度升序,7:按相关度降序