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/5098
Vanessad1a2140cd97d
diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.jsonindex 8d2025efc7..475dc86c67 100644--- a/app/appearance/langs/en_US.json+++ b/app/appearance/langs/en_US.json@@ -1,4 +1,7 @@{+ "newSubFile": "New SubFile",+ "newFileAfter": "New file after",+ "newFileBefore": "New file before","adaptiveWidth": "Adaptive Width","fullWidthTip": "After enabling, the editing area will be displayed as wide as possible","tabLimit": "Tab Limit",diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.jsonindex 125a14cb9d..0c6da71c09 100644--- a/app/appearance/langs/es_ES.json+++ b/app/appearance/langs/es_ES.json@@ -1,4 +1,7 @@{+ "newSubFile": "Nuevo SubArchivo",+ "newFileAfter": "Nuevo archivo en el mismo nivel después",+ "newFileBefore": "Nuevo archivo en el mismo nivel anterior","fullWidth": "Ancho adaptable","fullWidthTip": "Cuando está habilitado, el área de edición se mostrará lo más amplia posible","tabLimit": "Límite de la pestaña",diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.jsonindex 3a7eceb3bb..2165ede418 100644--- a/app/appearance/langs/fr_FR.json+++ b/app/appearance/langs/fr_FR.json@@ -1,4 +1,7 @@{+ "newSubFile": "Nouveau sous-fichier",+ "newFileAfter": "Nouveau fichier au même niveau après",+ "newFileBefore": "Nouveau fichier au même niveau avant","fullWidth": "Largeur adaptative","fullWidthTip": "Lorsqu'il est activé, la zone d'édition sera affichée aussi large que possible","tabLimit": "Nombre maximum d'onglets ouverts",diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.jsonindex 3dc6a87e76..ffff443a0d 100644--- a/app/appearance/langs/zh_CHT.json+++ b/app/appearance/langs/zh_CHT.json@@ -1,4 +1,7 @@{+ "newSubFile": "新建子文檔",+ "newFileAfter": "在後新建同級文檔",+ "newFileBefore": "在前新建同級文檔","fullWidth": "自適應寬度","fullWidthTip": "開啟後將盡可能寬地顯示編輯區","tabLimit": "頁簽打開最大數量",diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.jsonindex e6734ac65a..0771a41033 100644--- a/app/appearance/langs/zh_CN.json+++ b/app/appearance/langs/zh_CN.json@@ -1,4 +1,7 @@{+ "newSubFile": "新建子文档",+ "newFileAfter": "在后新建同级文档",+ "newFileBefore": "在前新建同级文档","fullWidth": "自适应宽度","fullWidthTip": "开启后将尽可能宽地显示编辑区","tabLimit": "页签打开最大数量",diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.tsindex 61cac2e730..7eee401000 100644--- a/app/src/layout/dock/Files.ts+++ b/app/src/layout/dock/Files.ts@@ -217,7 +217,7 @@ export class Files extends Model {}}if (type === "more-file") {- initFileMenu(notebookId, pathString, target.parentElement.getAttribute("data-node-id"), target.parentElement.getAttribute("data-name")).popup({+ initFileMenu(notebookId, pathString, target.parentElement).popup({x: event.clientX,y: event.clientY});diff --git a/app/src/menus/commonMenuItem.ts b/app/src/menus/commonMenuItem.tsindex 6ee978e62c..8573eb9f71 100644--- a/app/src/menus/commonMenuItem.ts+++ b/app/src/menus/commonMenuItem.ts@@ -793,16 +793,6 @@ export const openMenu = (src: string, onlyMenu = false) => {}).element);};-export const newFileMenu = (notebookId?: string, path?: string, open?: boolean) => {- return new MenuItem({- icon: "iconFile",- label: window.siyuan.languages.newFile,- click: () => {- newFile(notebookId, path, open);- }- }).element;-};-export const deleteMenu = (notebookId: string, name: string, pathString: string) => {return new MenuItem({icon: "iconTrashcan",diff --git a/app/src/menus/index.ts b/app/src/menus/index.tsindex 87b0c9f6a1..b190cf4830 100644--- a/app/src/menus/index.ts+++ b/app/src/menus/index.ts@@ -45,7 +45,7 @@ export class Menus {if (dataType === "navigation-file") {this.unselect();// navigation 文件上:删除/重命名/打开文件位置/导出- initFileMenu(this.getDir(target), target.getAttribute("data-path"), target.getAttribute("data-node-id"), target.getAttribute("data-name")).popup({+ initFileMenu(this.getDir(target), target.getAttribute("data-path"), target).popup({x: event.clientX,y: event.clientY});diff --git a/app/src/menus/navigation.ts b/app/src/menus/navigation.tsindex 6381f2732d..15eb4f527d 100644--- a/app/src/menus/navigation.ts+++ b/app/src/menus/navigation.ts@@ -3,7 +3,6 @@ import {deleteMenu,exportMd,movePathToMenu,- newFileMenu,openFileAttr,renameMenu,} from "./commonMenuItem";@@ -23,12 +22,19 @@ import {openFileById} from "../editor/util";/// #endifimport {confirmDialog} from "../dialog/confirmDialog";import {Constants} from "../constants";+import {newFile} from "../util/newFile";export const initNavigationMenu = (liElement: HTMLElement) => {const notebookId = liElement.parentElement.getAttribute("data-url");const name = getNotebookName(notebookId);window.siyuan.menus.menu.remove();- window.siyuan.menus.menu.append(newFileMenu(notebookId, "/", true));+ window.siyuan.menus.menu.append(new MenuItem({+ icon: "iconFile",+ label: window.siyuan.languages.newFile,+ click: () => {+ newFile(notebookId, "/", true);+ }+ }).element);window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);if (!window.siyuan.config.readonly) {window.siyuan.menus.menu.append(renameMenu({@@ -121,11 +127,53 @@ export const initNavigationMenu = (liElement: HTMLElement) => {return window.siyuan.menus.menu;};-export const initFileMenu = (notebookId: string, pathString: string, id: string, name: string) => {+export const initFileMenu = (notebookId: string, pathString: string, liElement: HTMLElement) => {+ const id = liElement.getAttribute("data-node-id")+ let name = liElement.getAttribute("data-name")window.siyuan.menus.menu.remove();name = getDisplayName(name, false, true);if (!window.siyuan.config.readonly) {- window.siyuan.menus.menu.append(newFileMenu(notebookId, pathString, true));+ window.siyuan.menus.menu.append(new MenuItem({+ icon: "iconFile",+ label: window.siyuan.languages.newSubFile,+ click: () => {+ newFile(notebookId, pathString, true);+ }+ }).element);+ if (window.siyuan.config.fileTree.sort === 6) {+ window.siyuan.menus.menu.append(new MenuItem({+ icon: "iconBefore",+ label: window.siyuan.languages.newFileBefore,+ click: () => {+ const paths: string[] = [];+ Array.from(liElement.parentElement.children).forEach((item) => {+ if (item.tagName === "LI") {+ if (item.isSameNode(liElement)) {+ paths.push(undefined)+ }+ paths.push(item.getAttribute("data-path"));+ }+ });+ newFile(notebookId, pathPosix().dirname(pathString), true, paths);+ }+ }).element);+ window.siyuan.menus.menu.append(new MenuItem({+ icon: "iconAfter",+ label: window.siyuan.languages.newFileAfter,+ click: () => {+ const paths: string[] = [];+ Array.from(liElement.parentElement.children).forEach((item) => {+ if (item.tagName === "LI") {+ paths.push(item.getAttribute("data-path"));+ if (item.isSameNode(liElement)) {+ paths.push(undefined);+ }+ }+ });+ newFile(notebookId, pathPosix().dirname(pathString), true, paths);+ }+ }).element);+ }window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);window.siyuan.menus.menu.append(new MenuItem({label: window.siyuan.languages.copy,diff --git a/app/src/mobile/util/MobileFiles.ts b/app/src/mobile/util/MobileFiles.tsindex ed9fa75c78..6616f69166 100644--- a/app/src/mobile/util/MobileFiles.ts+++ b/app/src/mobile/util/MobileFiles.ts@@ -182,7 +182,7 @@ export class MobileFiles extends Model {}}if (type === "more-file") {- initFileMenu(notebookId, pathString, target.parentElement.getAttribute("data-node-id"), target.parentElement.getAttribute("data-name")).popup({+ initFileMenu(notebookId, pathString, target.parentElement).popup({x,y});diff --git a/app/src/util/globalShortcut.ts b/app/src/util/globalShortcut.tsindex e687708117..5cc326200b 100644--- a/app/src/util/globalShortcut.ts+++ b/app/src/util/globalShortcut.ts@@ -812,7 +812,7 @@ const fileTreeKeydown = (event: KeyboardEvent) => {if (matchHotKey("⌘/", event)) {const liRect = liElement.getBoundingClientRect();if (isFile) {- initFileMenu(notebookId, pathString, liElement.getAttribute("data-node-id"), liElement.getAttribute("data-name")).popup({+ initFileMenu(notebookId, pathString, liElement).popup({x: liRect.right - 15,y: liRect.top + 15});diff --git a/app/src/util/newFile.ts b/app/src/util/newFile.tsindex d75f15280d..348f4be147 100644--- a/app/src/util/newFile.ts+++ b/app/src/util/newFile.ts@@ -10,7 +10,7 @@ import {fetchPost} from "./fetch";import {getDisplayName, getOpenNotebookCount, pathPosix} from "./pathName";import {Constants} from "../constants";-export const newFile = (notebookId?: string, currentPath?: string, open?: boolean) => {+export const newFile = (notebookId?: string, currentPath?: string, open?: boolean, paths?: string[]) => {if (getOpenNotebookCount() === 0) {showMessage(window.siyuan.languages.newFileTip);return;@@ -54,11 +54,16 @@ export const newFile = (notebookId?: string, currentPath?: string, open?: boolea}fetchPost("/api/filetree/getDocNameTemplate", {notebook: notebookId}, (data) => {const id = Lute.NewNodeID();+ const newPath = pathPosix().join(getDisplayName(currentPath, false, true), id + ".sy")+ if (paths) {+ paths[paths.indexOf(undefined)] = newPath+ }fetchPost("/api/filetree/createDoc", {notebook: notebookId,- path: pathPosix().join(getDisplayName(currentPath, false, true), id + ".sy"),+ path: newPath,title: data.data.name || "Untitled",md: "",+ sorts: paths}, () => {/// #if !MOBILEif (open) {