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: fix https://github.com/siyuan-note/siyuan/issues/5225
Vanessa24709d29ad25
diff --git a/app/src/config/fileTree.ts b/app/src/config/fileTree.tsindex 45e3a49c95..728e17512a 100644--- a/app/src/config/fileTree.ts+++ b/app/src/config/fileTree.ts@@ -27,6 +27,14 @@ export const fileTree = {<span class="fn__space"></span><input class="b3-switch fn__flex-center" id="allowCreateDeeper" type="checkbox"${window.siyuan.config.fileTree.allowCreateDeeper ? " checked" : ""}/></label>+<label class="fn__flex b3-label">+ <div class="fn__flex-1">+ ${window.siyuan.languages.fileTree3}+ <div class="b3-label__text">${window.siyuan.languages.fileTree4}</div>+ </div>+ <span class="fn__space"></span>+ <input class="b3-switch fn__flex-center" id="removeDocWithoutConfirm" type="checkbox"${window.siyuan.config.fileTree.removeDocWithoutConfirm ? " checked" : ""}/>+</label><label class="fn__flex b3-label"><div class="fn__flex-1">${window.siyuan.languages.fileTree12}@@ -60,6 +68,7 @@ export const fileTree = {createDocNameTemplate: (fileTree.element.querySelector("#createDocNameTemplate") as HTMLInputElement).value,openFilesUseCurrentTab: (fileTree.element.querySelector("#openFilesUseCurrentTab") as HTMLInputElement).checked,allowCreateDeeper: (fileTree.element.querySelector("#allowCreateDeeper") as HTMLInputElement).checked,+ removeDocWithoutConfirm: (fileTree.element.querySelector("#removeDocWithoutConfirm") as HTMLInputElement).checked,maxListCount: parseInt((fileTree.element.querySelector("#maxListCount") as HTMLInputElement).value),}, response => {fileTree.onSetfiletree(response.data);diff --git a/app/src/config/search.ts b/app/src/config/search.tsindex 4a2fd8775c..95099c9932 100644--- a/app/src/config/search.ts+++ b/app/src/config/search.ts@@ -18,7 +18,7 @@ export const initConfigSearch = (element: HTMLElement) => {]),// 文档树- getLang(["selectOpen", "fileTree", "fileTree2",+ getLang(["selectOpen", "fileTree", "fileTree2", "fileTree3", "fileTree4","fileTree5", "fileTree6", "fileTree7", "fileTree8", "fileTree12", "fileTree13", "fileTree15", "fileTree16", "fileTree17"]),// 图片diff --git a/app/src/editor/util.ts b/app/src/editor/util.tsindex 326edb87c0..b04f5ab997 100644--- a/app/src/editor/util.ts+++ b/app/src/editor/util.ts@@ -30,6 +30,7 @@ import {import {getPreviousHeading} from "../protyle/wysiwyg/getBlock";import {lockFile, setTitle} from "../dialog/processSystem";import {zoomOut} from "../menus/protyle";+import {confirmDialog} from "../dialog/confirmDialog";export const openOutline = (protyle: IProtyle) => {const outlinePanel = getAllModels().outline.find(item => {@@ -539,3 +540,27 @@ export const openBy = (url: string, type: "folder" | "app") => {}/// #endif};++export const deleteFile = (notebookId: string, pathString: string, name: string) => {+ if (window.siyuan.config.fileTree.removeDocWithoutConfirm) {+ fetchPost("/api/filetree/removeDoc", {+ notebook: notebookId,+ path: pathString+ });+ return;+ }+ fetchPost("/api/block/getDocInfo", {+ id: getDisplayName(pathString, true, true)+ }, (response) => {+ let tip = `${window.siyuan.languages.confirmDelete} <b>${name}</b>?`;+ if (response.data.subFileCount > 0) {+ tip = `${window.siyuan.languages.confirmDelete} <b>${name}</b> ${window.siyuan.languages.andSubFile.replace("x", response.data.subFileCount)}?`;+ }+ confirmDialog(window.siyuan.languages.delete, tip, () => {+ fetchPost("/api/filetree/removeDoc", {+ notebook: notebookId,+ path: pathString+ });+ });+ });+}diff --git a/app/src/menus/commonMenuItem.ts b/app/src/menus/commonMenuItem.tsindex 775f7e020b..9ec6395b70 100644--- a/app/src/menus/commonMenuItem.ts+++ b/app/src/menus/commonMenuItem.ts@@ -19,7 +19,7 @@ import {setPosition} from "../util/setPosition";import {updateTransaction} from "../protyle/wysiwyg/transaction";import {Bookmark} from "../layout/dock/Bookmark";import {rename} from "../editor/rename";-import {openAsset, openBy} from "../editor/util";+import {deleteFile, openAsset, openBy} from "../editor/util";import {matchHotKey} from "../protyle/util/hotKey";import * as dayjs from "dayjs";import {Constants} from "../constants";@@ -774,20 +774,7 @@ export const deleteMenu = (notebookId: string, name: string, pathString: string)label: window.siyuan.languages.delete,accelerator: "⌦",click: () => {- fetchPost("/api/block/getDocInfo", {- id: getDisplayName(pathString, true, true)- }, (response) => {- let tip = `${window.siyuan.languages.confirmDelete} <b>${name}</b>?`;- if (response.data.subFileCount > 0) {- tip = `${window.siyuan.languages.confirmDelete} <b>${name}</b> ${window.siyuan.languages.andSubFile.replace("x", response.data.subFileCount)}?`;- }- confirmDialog(window.siyuan.languages.delete, tip, () => {- fetchPost("/api/filetree/removeDoc", {- notebook: notebookId,- path: pathString- });- });- });+ deleteFile(notebookId, pathString, name);}}).element;};diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.tsindex 09337837ac..d49a85b7c2 100644--- a/app/src/protyle/header/Title.ts+++ b/app/src/protyle/header/Title.ts@@ -17,9 +17,8 @@ import {hasClosestByClassName} from "../util/hasClosest";import {matchHotKey} from "../util/hotKey";import {updateHotkeyTip, writeText} from "../util/compatibility";import {setPanelFocus} from "../../layout/util";-import {confirmDialog} from "../../dialog/confirmDialog";import {escapeHtml} from "../../util/escape";-import {openBacklink, openGraph, openOutline, updatePanelByEditor} from "../../editor/util";+import {deleteFile, openBacklink, openGraph, openOutline, updatePanelByEditor} from "../../editor/util";import * as dayjs from "dayjs";import {setTitle} from "../../dialog/processSystem";import {getNoContainerElement} from "../wysiwyg/getBlock";@@ -262,20 +261,7 @@ export class Title {icon: "iconTrashcan",label: window.siyuan.languages.delete,click: () => {- fetchPost("/api/block/getDocInfo", {- id: protyle.block.rootID- }, (response) => {- let tip = `${window.siyuan.languages.confirmDelete} <b>${escapeHtml(this.editElement.textContent)}</b>?`;- if (response.data.subFileCount > 0) {- tip = `${window.siyuan.languages.confirmDelete} <b>${escapeHtml(this.editElement.textContent)}</b> ${window.siyuan.languages.andSubFile.replace("x", response.data.subFileCount)}?`;- }- confirmDialog(window.siyuan.languages.delete, tip, () => {- fetchPost("/api/filetree/removeDoc", {- notebook: protyle.notebookId,- path: protyle.path- });- });- });+ deleteFile(protyle.notebookId, protyle.path, escapeHtml(this.editElement.textContent))}}).element);}diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex c16ccf49fa..d974df1c04 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -226,6 +226,7 @@ declare interface IAppearance {declare interface IFileTree {alwaysSelectOpenedFile: booleanopenFilesUseCurrentTab: boolean+ removeDocWithoutConfirm: booleanallowCreateDeeper: booleanrefCreateSavePath: stringcreateDocNameTemplate: stringdiff --git a/app/src/util/globalShortcut.ts b/app/src/util/globalShortcut.tsindex 239cc291e7..22cabe93f8 100644--- a/app/src/util/globalShortcut.ts+++ b/app/src/util/globalShortcut.ts@@ -24,7 +24,7 @@ import {goBack, goForward} from "./backForward";import {onGet} from "../protyle/util/onGet";import {getDisplayName, getNotebookName, movePathTo} from "./pathName";import {confirmDialog} from "../dialog/confirmDialog";-import {openFileById} from "../editor/util";+import {deleteFile, openFileById} from "../editor/util";import {getAllDocks, getAllModels, getAllTabs} from "../layout/getAll";import {openGlobalSearch} from "../search/util";import {getColIndex} from "../protyle/util/table";@@ -815,21 +815,7 @@ const fileTreeKeydown = (event: KeyboardEvent) => {}if (event.key === "Delete" || (event.key === "Backspace" && isMac())) {if (isFile) {- fetchPost("/api/block/getDocInfo", {- id: getDisplayName(pathString, true, true)- }, (response) => {- const name = getDisplayName(liElement.getAttribute("data-name"), false, true);- let tip = `${window.siyuan.languages.confirmDelete} <b>${name}</b>?`;- if (response.data.subFileCount > 0) {- tip = `${window.siyuan.languages.confirmDelete} <b>${name}</b> ${window.siyuan.languages.andSubFile.replace("x", response.data.subFileCount)}?`;- }- confirmDialog(window.siyuan.languages.delete, tip, () => {- fetchPost("/api/filetree/removeDoc", {- notebook: notebookId,- path: pathString- });- });- });+ deleteFile(notebookId, pathString, getDisplayName(liElement.getAttribute("data-name"), false, true));} else {confirmDialog(window.siyuan.languages.delete,`${window.siyuan.languages.confirmDelete} <b>${Lute.EscapeHTMLStr(getNotebookName(notebookId))}</b>?`, () => {