An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:recycle: :art: fix https://github.com/siyuan-note/siyuan/issues/3171
Vanessadba6ed203ddc
diff --git a/app/src/search/index.ts b/app/src/search/index.tsindex c6c2e2f6a1..7912fd2375 100644--- a/app/src/search/index.ts+++ b/app/src/search/index.ts@@ -77,18 +77,7 @@ export class Search extends Model {searchPanelElement.scrollTop > currentList.offsetTop) {searchPanelElement.scrollTop = currentList.offsetTop - searchPanelElement.clientHeight + lineHeight;}- const id = currentList.getAttribute("data-node-id");- addLoading(this.protyle.protyle);- fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {- fetchPost("/api/filetree/getDoc", {- id,- k: inputElement.value,- mode: foldResponse.data ? 0 : 3,- size: foldResponse.data ? Constants.SIZE_GET_MAX : Constants.SIZE_GET,- }, getResponse => {- onGet(getResponse, this.protyle.protyle, foldResponse.data ? [Constants.CB_GET_ALL] : [Constants.CB_GET_HL]);- });- });+ this.getArticle(currentList.getAttribute("data-node-id"), inputElement.value)event.preventDefault();} else if (event.key === "ArrowUp") {currentList.classList.remove("b3-list-item--focus");@@ -103,18 +92,7 @@ export class Search extends Model {searchPanelElement.scrollTop > currentList.offsetTop - lineHeight * 2) {searchPanelElement.scrollTop = currentList.offsetTop - lineHeight * 2;}- addLoading(this.protyle.protyle);- const id = currentList.getAttribute("data-node-id");- fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {- fetchPost("/api/filetree/getDoc", {- id,- k: inputElement.value,- mode: foldResponse.data ? 0 : 3,- size: foldResponse.data ? Constants.SIZE_GET_MAX : Constants.SIZE_GET,- }, getResponse => {- onGet(getResponse, this.protyle.protyle, foldResponse.data ? [Constants.CB_GET_ALL] : [Constants.CB_GET_HL]);- });- });+ this.getArticle(currentList.getAttribute("data-node-id"), inputElement.value);event.preventDefault();}});@@ -148,19 +126,7 @@ export class Search extends Model {item.classList.remove("b3-list-item--focus");});target.classList.add("b3-list-item--focus");- this.protyle.protyle.scroll.lastScrollTop = 0;- const id = target.getAttribute("data-node-id");- addLoading(this.protyle.protyle);- fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {- fetchPost("/api/filetree/getDoc", {- id,- k: inputElement.value,- mode: foldResponse.data ? 0 : 3,- size: foldResponse.data ? Constants.SIZE_GET_MAX : Constants.SIZE_GET,- }, getResponse => {- onGet(getResponse, this.protyle.protyle, foldResponse.data ? [Constants.CB_GET_ALL] : [Constants.CB_GET_HL]);- });- });+ this.getArticle(target.getAttribute("data-node-id"), inputElement.value);}}, Constants.TIMEOUT_DBLCLICK);} else if (event.detail === 2) {@@ -209,6 +175,39 @@ export class Search extends Model {}, false);}+ private getArticle(id: string, value: string) {+ fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {+ if (this.protyle) {+ this.protyle.protyle.element.classList.remove("fn__none");+ this.protyle.protyle.scroll.lastScrollTop = 0;+ addLoading(this.protyle.protyle);++ fetchPost("/api/filetree/getDoc", {+ id,+ k: value,+ mode: foldResponse.data ? 0 : 3,+ size: foldResponse.data ? Constants.SIZE_GET_MAX : Constants.SIZE_GET,+ }, getResponse => {+ onGet(getResponse, this.protyle.protyle, foldResponse.data ? [Constants.CB_GET_ALL] : [Constants.CB_GET_HL]);+ this.protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${id}"] span[data-type="search-mark"]`).scrollIntoView();+ });+ } else {+ this.protyle = new Protyle(this.element.querySelector("#searchPreview") as HTMLElement, {+ blockId: id,+ hasContext: !foldResponse.data,+ key: value,+ render: {+ gutter: true,+ breadcrumbDocName: true,+ },+ after: () => {+ this.protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${id}"] span[data-type="search-mark"]`).scrollIntoView();+ }+ });+ }+ });+ }+private setLocalStorage(value: string) {if (!value) {return;@@ -281,30 +280,6 @@ export class Search extends Model {}return;}- fetchPost("/api/block/checkBlockFold", {id: data[0].id}, (foldResponse) => {- if (this.protyle) {- this.protyle.protyle.element.classList.remove("fn__none");- this.protyle.protyle.scroll.lastScrollTop = 0;- addLoading(this.protyle.protyle);- fetchPost("/api/filetree/getDoc", {- id: data[0].id,- k: (this.element.querySelector(".b3-text-field") as HTMLInputElement).value,- mode: foldResponse.data ? 0 : 3,- size: foldResponse.data ? Constants.SIZE_GET_MAX : Constants.SIZE_GET,- }, getResponse => {- onGet(getResponse, this.protyle.protyle, foldResponse.data ? [Constants.CB_GET_ALL] : [Constants.CB_GET_HL]);- });- } else {- this.protyle = new Protyle(this.element.querySelector("#searchPreview") as HTMLElement, {- blockId: data[0].id,- hasContext: !foldResponse.data,- key: (this.element.querySelector(".b3-text-field") as HTMLInputElement).value,- render: {- gutter: true,- breadcrumbDocName: true,- },- });- }- });+ this.getArticle(data[0].id, (this.element.querySelector(".b3-text-field") as HTMLInputElement).value);}}diff --git a/app/src/search/spread.ts b/app/src/search/spread.tsindex fe6d7c4d8c..b4d10a03a1 100644--- a/app/src/search/spread.ts+++ b/app/src/search/spread.ts@@ -433,14 +433,10 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: strisearchPanelElement.scrollTop > currentList.offsetTop) {searchPanelElement.scrollTop = currentList.offsetTop - searchPanelElement.clientHeight + lineHeight;}- const id = currentList.getAttribute("data-node-id");- fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {- getArticle({- dialog,- folded: foldResponse.data,- id,- k: searchInputElement.value,- });+ getArticle({+ dialog,+ id: currentList.getAttribute("data-node-id"),+ k: searchInputElement.value,});event.preventDefault();} else if (event.key === "ArrowUp") {@@ -456,14 +452,10 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: strisearchPanelElement.scrollTop > currentList.offsetTop - lineHeight * 2) {searchPanelElement.scrollTop = currentList.offsetTop - lineHeight * 2;}- const id = currentList.getAttribute("data-node-id");- fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {- getArticle({- dialog,- folded: foldResponse.data,- id,- k: searchInputElement.value,- });+ getArticle({+ dialog,+ id: currentList.getAttribute("data-node-id"),+ k: searchInputElement.value,});event.preventDefault();} else if (event.key === "Enter") {@@ -559,14 +551,10 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: strisearchPanelElement.scrollTop > currentList.offsetTop) {searchPanelElement.scrollTop = currentList.offsetTop - searchPanelElement.clientHeight + lineHeight;}- const id = currentList.getAttribute("data-node-id");- fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {- getArticle({- dialog,- folded: foldResponse.data,- id,- k: searchInputElement.value,- });+ getArticle({+ dialog,+ id: currentList.getAttribute("data-node-id"),+ k: searchInputElement.value,});});};@@ -609,14 +597,10 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri} else {searchPanelElement.querySelector(".b3-list-item--focus").classList.remove("b3-list-item--focus");target.classList.add("b3-list-item--focus");- const id = target.getAttribute("data-node-id");- fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {- getArticle({- dialog,- folded: foldResponse.data,- id,- k: searchInputElement.value,- });+ getArticle({+ dialog,+ id: target.getAttribute("data-node-id"),+ k: searchInputElement.value,});searchInputElement.focus();}@@ -650,36 +634,37 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: striconst getArticle = (options: {id: string,- folded: boolean,k: string,dialog: Dialog}) => {- if (!protyle) {- protyle = new Protyle(options.dialog.element.querySelector("#searchPreview") as HTMLElement, {- blockId: options.id,- hasContext: !options.folded,- key: options.k,- render: {- gutter: true,- breadcrumbDocName: true- },- after: (protyle) => {+ fetchPost("/api/block/checkBlockFold", {id:options.id}, (foldResponse) => {+ if (!protyle) {+ protyle = new Protyle(options.dialog.element.querySelector("#searchPreview") as HTMLElement, {+ blockId: options.id,+ hasContext: !foldResponse.data,+ key: options.k,+ render: {+ gutter: true,+ breadcrumbDocName: true+ },+ after: () => {+ protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type="search-mark"]`).scrollIntoView();+ }+ });+ } else {+ protyle.protyle.scroll.lastScrollTop = 0;+ addLoading(protyle.protyle);+ fetchPost("/api/filetree/getDoc", {+ id: options.id,+ k: options.k,+ mode: foldResponse.data ? 0 : 3,+ size: foldResponse.data ? Constants.SIZE_GET_MAX : Constants.SIZE_GET,+ }, getResponse => {+ onGet(getResponse, protyle.protyle, foldResponse.data ? [Constants.CB_GET_ALL] : [Constants.CB_GET_HL]);protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type="search-mark"]`).scrollIntoView();- }- });- } else {- protyle.protyle.scroll.lastScrollTop = 0;- addLoading(protyle.protyle);- fetchPost("/api/filetree/getDoc", {- id: options.id,- k: options.k,- mode: options.folded ? 0 : 3,- size: options.folded ? Constants.SIZE_GET_MAX : Constants.SIZE_GET,- }, getResponse => {- onGet(getResponse, protyle.protyle, options.folded ? [Constants.CB_GET_ALL] : [Constants.CB_GET_HL]);- protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type="search-mark"]`).scrollIntoView();- });- }+ });+ }+ });};const onSearch = (data: IBlock[], dialog: Dialog) => {@@ -699,13 +684,10 @@ const onSearch = (data: IBlock[], dialog: Dialog) => {} else {dialog.element.querySelector("#searchPreview").classList.remove("fn__none");}- fetchPost("/api/block/checkBlockFold", {id: data[0].id}, (foldResponse) => {- getArticle({- dialog,- folded: foldResponse.data,- id: data[0].id,- k: (dialog.element.querySelector("input") as HTMLInputElement).value,- });+ getArticle({+ dialog,+ id: data[0].id,+ k: (dialog.element.querySelector("input") as HTMLInputElement).value,});} else {if (protyle) {