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/6589
Vanessa0dedf8c55f66
diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.jsonindex 180bfa518c..9d8782b299 100644--- a/app/appearance/langs/zh_CN.json+++ b/app/appearance/langs/zh_CN.json@@ -1,4 +1,6 @@{+ "saveSearch": "保存查询条件",+ "useSearch": "使用查询条件","group": "分组","noGroupBy": "不分组","groupByDoc": "按文档分组",diff --git a/app/src/search/util.ts b/app/src/search/util.tsindex 13e80ea761..aaf7f63db5 100644--- a/app/src/search/util.ts+++ b/app/src/search/util.ts@@ -350,6 +350,9 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()html += `<div class="b3-list-item">${escapeHtml(s)}</div>`;}});+ if (html === "") {+ return;+ }historyElement.classList.remove("fn__none");historyElement.innerHTML = html;replaceHistoryElement.classList.add("fn__none");@@ -366,6 +369,9 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()html += `<div class="b3-list-item">${escapeHtml(s)}</div>`;}});+ if (html === "") {+ return;+ }replaceHistoryElement.classList.remove("fn__none");replaceHistoryElement.innerHTML = html;historyElement.classList.add("fn__none");@@ -466,7 +472,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()}config.list = searches;config.k = searchInputElement.value;- if (!element.parentElement.getAttribute("data-id")) {+ if (!element.getAttribute("data-id")) {localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(config));}});@@ -640,7 +646,7 @@ const addConfigMoreMenu = (config: ISearchOption, edit: Protyle, element: Elemenelement.querySelector(".search__layout").classList.remove("search__layout--row");setPadding(edit.protyle);config.layout = 0;- if (!element.parentElement.getAttribute("data-id")) {+ if (!element.getAttribute("data-id")) {localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(config));}}@@ -651,12 +657,104 @@ const addConfigMoreMenu = (config: ISearchOption, edit: Protyle, element: Elemenelement.querySelector(".search__layout").classList.add("search__layout--row");setPadding(edit.protyle);config.layout = 1;- if (!element.parentElement.getAttribute("data-id")) {+ if (!element.getAttribute("data-id")) {localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(config));}}}]}).element);+ window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);+ window.siyuan.menus.menu.append(new MenuItem({+ label: window.siyuan.languages.saveSearch,+ click() {+ const saveDialog = new Dialog({+ title: window.siyuan.languages.saveSearch,+ content: `<div class="b3-dialog__content">+ <input class="fn__flex-center" placeholder="${window.siyuan.languages.memo}">+</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",+ });+ const btnsElement = saveDialog.element.querySelectorAll(".b3-button");+ btnsElement[0].addEventListener("click", () => {+ saveDialog.destroy();+ });+ btnsElement[1].addEventListener("click", () => {+ fetchPost("/api/setting/setCriterion", {criterion: Object.assign({name: saveDialog.element.querySelector("input").value}, config)}, () => {+ saveDialog.destroy();+ })+ });+ }+ }).element)+ const searchSubMenu: IMenu[] = []+ window.siyuan.config.criteria.forEach(item => {+ searchSubMenu.push({+ label: item.name,+ click() {+ if (config.layout !== item.layout) {+ if (item.layout === 0) {+ element.querySelector(".search__layout").classList.remove("search__layout--row");+ } else {+ element.querySelector(".search__layout").classList.add("search__layout--row");+ }+ setPadding(edit.protyle);+ }+ if (config.hasReplace !== item.hasReplace) {+ if (item.hasReplace) {+ element.querySelector("#replaceHistoryBtn").parentElement.classList.remove("fn__none");+ } else {+ element.querySelector("#replaceHistoryBtn").parentElement.classList.add("fn__none");+ }+ }+ if (item.hPath) {+ element.querySelector("#searchPathInput").innerHTML = `${item.hPath}<svg class="search__rmpath"><use xlink:href="#iconClose"></use></svg>`;+ } else {+ element.querySelector("#searchPathInput").innerHTML = "";+ }+ if (config.group !== item.group) {+ if (item.group === 0) {+ element.querySelector("#searchExpand").parentElement.classList.add("fn__none");+ } else {+ element.querySelector("#searchExpand").parentElement.classList.remove("fn__none");+ }+ }+ let includeChild = true;+ let enableIncludeChild = false;+ item.idPath.forEach(item => {+ if (item.endsWith(".sy")) {+ includeChild = false;+ }+ if (item.split("/").length > 1) {+ enableIncludeChild = true;+ }+ });+ const searchIncludeElement = element.querySelector("#searchInclude");+ if (includeChild) {+ searchIncludeElement.classList.remove("b3-button--cancel");+ } else {+ searchIncludeElement.classList.add("b3-button--cancel");+ }+ if (enableIncludeChild) {+ searchIncludeElement.removeAttribute("disabled")+ } else {+ searchIncludeElement.setAttribute("disabled", "disabled")+ }+ (element.querySelector("#searchInput") as HTMLInputElement).value = item.k;+ (element.querySelector("#replaceInput") as HTMLInputElement).value = item.r;+ inputEvent(element, Object.assign({}, item), undefined, edit);+ }+ })+ })+ if (searchSubMenu.length > 0) {+ window.siyuan.menus.menu.append(new MenuItem({+ label: window.siyuan.languages.useSearch,+ type: "submenu",+ submenu: searchSubMenu+ }).element)+ }};const addConfigFilterMenu = (config: ISearchOption, edit: Protyle, element: Element) => {@@ -851,7 +949,7 @@ const replace = (element: Element, config: ISearchOption, edit: Protyle, isAll:}config.replaceList = searches;config.r = replaceInputElement.value;- if (!element.parentElement.getAttribute("data-id")) {+ if (!element.getAttribute("data-id")) {localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(config));}let currentList: HTMLElement = searchPanelElement.querySelector(".b3-list-item--focus");@@ -947,7 +1045,7 @@ const inputEvent = (element: Element, config: ISearchOption, inputTimeout: numbe}if (saveConfig) {config.k = inputValue;- if (!element.parentElement.getAttribute("data-id")) {+ if (!element.getAttribute("data-id")) {localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(config));}}diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex fbe8ac034d..a5e490c1eb 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -1,12 +1,30 @@type TLayout = "normal" | "top" | "bottom" | "left" | "right" | "center"-type TSearchFilter = "mathBlock" | "table" | "blockquote" | "superBlock" | "paragraph" | "document" | "heading"+type TSearchFilter = "mathBlock" | "table" | "blockquote" | "superBlock" | "paragraph" | "document" | "heading"| "list" | "listItem" | "codeBlock" | "htmlBlock"type TDirection = "lr" | "tb"-type TDockType = "file" | "outline" | "bookmark" | "tag" | "graph" | "globalGraph" | "backlink" | "backlinkOld" | "inbox"+type TDockType =+ "file"+ | "outline"+ | "bookmark"+ | "tag"+ | "graph"+ | "globalGraph"+ | "backlink"+ | "backlinkOld"+ | "inbox"type TDockPosition = "Left" | "Right" | "Top" | "Bottom"type TWS = "main" | "filetree" | "protyle"type TEditorMode = "preview" | "wysiwyg"-type TOperation = "insert" | "update" | "delete" | "move" | "foldHeading" | "unfoldHeading" | "setAttrs" | "updateAttrs" | "append"+type TOperation =+ "insert"+ | "update"+ | "delete"+ | "move"+ | "foldHeading"+ | "unfoldHeading"+ | "setAttrs"+ | "updateAttrs"+ | "append"type TBazaarType = "templates" | "icons" | "widgets" | "themes"declare module "blueimp-md5"@@ -34,6 +52,7 @@ interface Window {}interface ISearchOption {+ name?: stringsort: number, // 0:按块类型(默认),1:按创建时间升序,2:按创建时间降序,3:按更新时间升序,4:按更新时间降序,5:按内容顺序(仅在按文档分组时)group: number, // 0:不分组,1:按文档分组layout: number // 0:上下,1:左右