An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: fix https://github.com/siyuan-note/siyuan/issues/7979
Vanessa2ee6b54bc7db
diff --git a/app/src/editor/util.ts b/app/src/editor/util.tsindex 4822869188..58bf8e7eda 100644--- a/app/src/editor/util.ts+++ b/app/src/editor/util.ts@@ -34,6 +34,7 @@ export const openFileById = async (options: {keepCursor?: booleanzoomIn?: booleanremoveCurrentTab?: boolean+ afterOpen?: () => void}) => {fetchPost("/api/block/getBlockInfo", {id: options.id}, (data) => {if (data.code === 3) {@@ -53,7 +54,8 @@ export const openFileById = async (options: {action: options.action,zoomIn: options.zoomIn,keepCursor: options.keepCursor,- removeCurrentTab: options.removeCurrentTab+ removeCurrentTab: options.removeCurrentTab,+ afterOpen: options.afterOpen});});};@@ -82,6 +84,9 @@ const openFile = (options: IOpenFileOptions) => {}});if (asset) {+ if (options.afterOpen) {+ options.afterOpen();+ }return;}} else if (!options.position) {@@ -105,11 +110,17 @@ const openFile = (options: IOpenFileOptions) => {if (!pdfIsLoading(editor.parent.parent.element)) {switchEditor(editor, options, allModels);}+ if (options.afterOpen) {+ options.afterOpen();+ }return true;}// 没有初始化的页签无法检测到const hasEditor = getUnInitTab(options);if (hasEditor) {+ if (options.afterOpen) {+ options.afterOpen();+ }return;}}@@ -134,6 +145,9 @@ const openFile = (options: IOpenFileOptions) => {});/// #endifif (hasOpen) {+ if (options.afterOpen) {+ options.afterOpen();+ }return;}@@ -165,6 +179,9 @@ const openFile = (options: IOpenFileOptions) => {}if (targetWnd) {if (pdfIsLoading(targetWnd.element)) {+ if (options.afterOpen) {+ options.afterOpen();+ }return;}// 在右侧/下侧打开已有页签将进行页签切换 https://github.com/siyuan-note/siyuan/issues/5366@@ -184,9 +201,15 @@ const openFile = (options: IOpenFileOptions) => {wnd.split(direction).addTab(newTab(options));}wnd.showHeading();+ if (options.afterOpen) {+ options.afterOpen();+ }return;}if (pdfIsLoading(wnd.element)) {+ if (options.afterOpen) {+ options.afterOpen();+ }return;}if (options.keepCursor && wnd.children[0].headElement) {@@ -213,6 +236,9 @@ const openFile = (options: IOpenFileOptions) => {wnd.addTab(newTab(options));}wnd.showHeading();+ if (options.afterOpen) {+ options.afterOpen();+ }}};diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.tsindex 2b6dce1338..c728b97300 100644--- a/app/src/layout/dock/Files.ts+++ b/app/src/layout/dock/Files.ts@@ -190,11 +190,15 @@ export class Files extends Model {}let target = event.target as HTMLElement;while (target && !target.isEqualNode(this.element)) {- if (target.tagName === "LI") {+ if (target.tagName === "LI" && !target.getAttribute("data-opening")) {+ target.setAttribute("data-opening", "true")openFileById({removeCurrentTab: false,id: target.getAttribute("data-node-id"),- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]+ action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],+ afterOpen() {+ target.removeAttribute("data-opening")+ }});event.stopPropagation();event.preventDefault();@@ -252,29 +256,45 @@ export class Files extends Model {this.setCurrent(target, false);if (target.getAttribute("data-type") === "navigation-file") {needFocus = false;+ if (target.getAttribute("data-opening")) {+ return+ }+ target.setAttribute("data-opening", "true");if (event.altKey && !event.metaKey && !event.ctrlKey && !event.shiftKey) {openFileById({id: target.getAttribute("data-node-id"),position: "right",- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]+ action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],+ afterOpen() {+ target.removeAttribute("data-opening")+ }});} else if (!event.altKey && !event.metaKey && !event.ctrlKey && event.shiftKey) {openFileById({id: target.getAttribute("data-node-id"),position: "bottom",- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]+ action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],+ afterOpen() {+ target.removeAttribute("data-opening")+ }});} else if (window.siyuan.config.fileTree.openFilesUseCurrentTab &&event.altKey && (event.metaKey || event.ctrlKey) && !event.shiftKey) {openFileById({removeCurrentTab: false,id: target.getAttribute("data-node-id"),- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]+ action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],+ afterOpen() {+ target.removeAttribute("data-opening")+ }});} else {openFileById({id: target.getAttribute("data-node-id"),- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]+ action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],+ afterOpen() {+ target.removeAttribute("data-opening")+ }});}} else if (target.getAttribute("data-type") === "navigation-root") {@@ -562,7 +582,7 @@ export class Files extends Model {if (hasMove) {fetchPost("/api/filetree/listDocsByPath", {notebook: toURL,- path: toDir === "/" ? "/" : toDir + ".sy",+ path: toDir === "/" ? "/" : toDir + ".sy",sort: window.siyuan.config.fileTree.sort,}, response => {if (response.data.path === "/" && response.data.files.length === 0) {@@ -998,7 +1018,7 @@ class="b3-list-item b3-list-item--hide-action" data-path="${item.path}">}}).element);if (!window.siyuan.config.readonly) {- const subMenu = sortMenu("notebooks", window.siyuan.config.fileTree.sort, (sort: number) => {+ const subMenu = sortMenu("notebooks", window.siyuan.config.fileTree.sort, (sort: number) => {window.siyuan.config.fileTree.sort = sort;fetchPost("/api/setting/setFiletree", {sort: window.siyuan.config.fileTree.sort,@@ -1017,7 +1037,7 @@ class="b3-list-item b3-list-item--hide-action" data-path="${item.path}">icon: "iconSort",label: window.siyuan.languages.sort,type: "submenu",- submenu:subMenu,+ submenu: subMenu,}).element);}return window.siyuan.menus.menu;diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex 7aa425a921..9e64d9802a 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -291,6 +291,7 @@ declare interface IOpenFileOptions {keepCursor?: boolean // file,是否跳转到新 tab 上zoomIn?: boolean // 是否缩放removeCurrentTab?: boolean // 在当前页签打开时需移除原有页签+ afterOpen?: () => void // 打开后回调}declare interface ILayoutOptions {