An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: fix https://github.com/siyuan-note/siyuan/issues/6640
Vanessa95e233da95e4
diff --git a/app/src/search/util.ts b/app/src/search/util.tsindex ce8a4adfb4..fae3513641 100644--- a/app/src/search/util.ts+++ b/app/src/search/util.ts@@ -10,9 +10,9 @@ import {openFileById} from "../editor/util";import {showMessage} from "../dialog/message";import {reloadProtyle} from "../protyle/util/reload";import {MenuItem} from "../menus/Menu";-import {getDisplayName, getNotebookName, movePathTo} from "../util/pathName";+import {getDisplayName, getNotebookName, movePathTo, pathPosix} from "../util/pathName";import {Protyle} from "../protyle";-import {disabledProtyle, onGet} from "../protyle/util/onGet";+import {onGet} from "../protyle/util/onGet";import {addLoading} from "../protyle/ui/initUI";import {getIconByType} from "../editor/getIcon";import {unicode2Emoji} from "../emoji";@@ -38,6 +38,7 @@ export const openGlobalSearch = (text: string, replace: boolean) => {icon: "iconSearch",title: text,callback(tab) {+ // ctrl+p 仅保存 types, querySyntax, 搜索/替换历史和文本const localData = JSON.parse(localStorage.getItem(Constants.LOCAL_SEARCHEDATA) || "{}");if (!localData.types) {localData.types = {@@ -62,7 +63,6 @@ export const openGlobalSearch = (text: string, replace: boolean) => {hasReplace: false,querySyntax: localData.querySyntax || false,hPath: "",- notebookId: "",idPath: "",types: localData.types}@@ -120,7 +120,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()<span class="fn__flex-1"></span><span id="searchPathInput" class="ft__on-surface fn__flex-center ft__smaller fn__ellipsis" style="white-space: nowrap;" title="${config.hPath}">${config.hPath}</span><span class="fn__space"></span>- <button id="includeChildCheck" class="b3-button b3-button--small${(config.notebookId && config.idPath && !config.idPath.endsWith(".sy")) ? "" : " b3-button--cancel"}">${window.siyuan.languages.includeChildDoc}</button>+ <button id="includeChildCheck" class="b3-button b3-button--small${(config.idPath && config.idPath.endsWith(".sy")) ? " b3-button--cancel" : ""}">${window.siyuan.languages.includeChildDoc}</button><span class="fn__space"></span><button id="searchSyntaxCheck" class="b3-button b3-button--small${config.querySyntax ? "" : " b3-button--cancel"}">${window.siyuan.languages.querySyntax}</button></div>@@ -153,18 +153,26 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()let target = event.target as HTMLElementwhile (target && !target.isSameNode(element)) {if (target.id === "searchPath") {- movePathTo([], undefined, (toPath) => {- config.idPath = toPath;- fetchPost("/api/filetree/getHPathsByPaths", {paths: [toPath]}, (response) => {- config.hPath = escapeHtml(response.data.join(", "));- element.querySelector("#searchPathInput").innerHTML = escapeHtml(response.data.join(", "));- });- inputTimeout = inputEvent(element, config, inputTimeout, edit);- });+ movePathTo([], undefined, (toPath, toNotebook) => {+ if (toPath === "/") {+ config.idPath = toNotebook;+ config.hPath = escapeHtml(getNotebookName(toNotebook));+ element.querySelector("#searchPathInput").innerHTML = config.hPath;+ inputTimeout = inputEvent(element, config, inputTimeout, edit);+ } else {+ config.idPath = pathPosix().join(toNotebook, toPath);+ fetchPost("/api/filetree/getHPathsByPaths", {paths: [toPath]}, (response) => {+ config.hPath = escapeHtml(response.data ? response.data[0] : "");+ element.querySelector("#searchPathInput").innerHTML = config.hPath;+ inputTimeout = inputEvent(element, config, inputTimeout, edit);+ });+ }+ }, window.siyuan.languages.specifyPath);event.stopPropagation();event.preventDefault();break;} else if (target.id === "searchReplace") {+ config.hasReplace = !config.hasReplace;element.querySelector("#replaceHistoryBtn").parentElement.classList.toggle("fn__none");event.stopPropagation();event.preventDefault();@@ -195,23 +203,17 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()target.classList.toggle("b3-button--cancel");let reload = false;if (target.classList.contains("b3-button--cancel")) {- if (!config.idPath.endsWith(".sy")) {+ if (!config.idPath.endsWith(".sy") && config.idPath.split("/").length > 1) {config.idPath = config.idPath + ".sy";reload = true;}} else {- if (config.hPath) {- reload = true;- }if (config.idPath.endsWith(".sy")) {config.idPath = config.idPath.replace(".sy", "");reload = true;}}if (reload) {- if (closeCB) {- localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(config));- }inputTimeout = inputEvent(element, config, inputTimeout, edit);}event.stopPropagation();@@ -474,7 +476,6 @@ const getArticle = (options: {k: string,edit: Protyle}) => {- console.log(options.edit);fetchPost("/api/block/checkBlockFold", {id: options.id}, (foldResponse) => {options.edit.protyle.scroll.lastScrollTop = 0;addLoading(options.edit.protyle);@@ -590,7 +591,7 @@ const inputEvent = (element: Element, config: ISearchOption, inputTimeout: numbequery: inputValue,querySyntax: config.querySyntax,types: config.types,- path: config.hPath ? config.idPath : ""+ path: config.idPath || ""}, (response) => {onSearch(response.data.blocks, edit, element);element.querySelector("#searchResult").innerHTML = window.siyuan.languages.findInDoc.replace("${x}", response.data.matchedRootCount).replace("${y}", response.data.matchedBlockCount);diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex 044bd72457..a92e69a92f 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -52,7 +52,6 @@ interface ISearchOption {hasReplace: boolean,querySyntax: boolean,hPath: string- notebookId: stringidPath: stringk: stringr: stringdiff --git a/app/src/util/pathName.ts b/app/src/util/pathName.tsindex b041284225..e26c99c960 100644--- a/app/src/util/pathName.ts+++ b/app/src/util/pathName.ts@@ -85,7 +85,7 @@ const moveToPath = (fromPaths: string[], toNotebook: string, toPath: string) =>});};-export const movePathTo = (paths?: string[], range?: Range, cb?: (toPath:string) => void) => {+export const movePathTo = (paths?: string[], range?: Range, cb?: (toPath: string, toNotebook:string) => void, title?: string) => {const exitDialog = window.siyuan.dialogs.find((item) => {if (item.element.querySelector("#foldList")) {item.destroy();@@ -96,7 +96,7 @@ export const movePathTo = (paths?: string[], range?: Range, cb?: (toPath:string)return;}const dialog = new Dialog({- title: `${window.siyuan.languages.move} <span class="ft__smaller ft__on-surface"></span>`,+ title: `${title || window.siyuan.languages.move} <span class="ft__smaller ft__on-surface"></span>`,content: `<div><div class="b3-form__icon" style="margin: 8px"><svg class="b3-form__icon-icon"><use xlink:href="#iconSearch"></use></svg>@@ -309,7 +309,7 @@ export const movePathTo = (paths?: string[], range?: Range, cb?: (toPath:string)}if (event.key === "Enter") {if (cb) {- cb(currentItemElement.getAttribute("data-path"));+ cb(currentItemElement.getAttribute("data-path"), currentItemElement.getAttribute("data-box"));} else {moveToPath(paths, currentItemElement.getAttribute("data-box"), currentItemElement.getAttribute("data-path"));}@@ -332,7 +332,7 @@ export const movePathTo = (paths?: string[], range?: Range, cb?: (toPath:string)return;}if (cb) {- cb(currentItemElement.getAttribute("data-path"));+ cb(currentItemElement.getAttribute("data-path"), currentItemElement.getAttribute("data-box"));} else {moveToPath(paths, currentItemElement.getAttribute("data-box"), currentItemElement.getAttribute("data-path"));}