Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/11150

Vanessabd035417ce99
diff --git a/app/src/menus/navigation.ts b/app/src/menus/navigation.ts
index 9571c8ebae..c1b7ddcb74 100644
--- a/app/src/menus/navigation.ts
+++ b/app/src/menus/navigation.ts
@@ -117,6 +117,8 @@ const initMultiMenu = (selectItemElements: NodeListOf<Element>, app: App) => {
icon: "iconRiffCard",
submenu: riffCardMenu,
}).element);
+ window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
+ openEditorTab(app, blockIDs);
if (app.plugins) {
emitOpenMenu({
plugins: app.plugins,
@@ -630,7 +632,7 @@ export const initFileMenu = (app: App, notebookId: string, pathString: string, l
}).element);
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
}
- openEditorTab(app, id, notebookId, pathString);
+ openEditorTab(app, [id], notebookId, pathString);
if (!window.siyuan.config.readonly) {
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.fileHistory,
diff --git a/app/src/menus/util.ts b/app/src/menus/util.ts
index ba2bf0d625..d50bc79285 100644
--- a/app/src/menus/util.ts
+++ b/app/src/menus/util.ts
@@ -32,67 +32,83 @@ export const exportAsset = (src: string) => {
};
-export const openEditorTab = (app: App, id: string, notebookId?: string, pathString?: string) => {
+export const openEditorTab = (app: App, ids: string[], notebookId?: string, pathString?: string) => {
/// #if !MOBILE
const openSubmenus: IMenu[] = [{
icon: "iconLayoutRight",
label: window.siyuan.languages.insertRight,
- accelerator: `${updateHotkeyTip(window.siyuan.config.keymap.editor.general.insertRight.custom)}/${updateHotkeyTip("⌥Click")}`,
+ accelerator: ids.length === 1 ? `${updateHotkeyTip(window.siyuan.config.keymap.editor.general.insertRight.custom)}/${updateHotkeyTip("⌥Click")}` : undefined,
click: () => {
if (notebookId) {
- openFileById({app, id, position: "right", action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]});
+ openFileById({
+ app,
+ id: ids[0],
+ position: "right",
+ action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
+ });
} else {
- checkFold(id, (zoomIn, action) => {
- openFileById({
- app,
- id,
- position: "right",
- action,
- zoomIn
+ ids.forEach((id) => {
+ checkFold(id, (zoomIn, action) => {
+ openFileById({
+ app,
+ id,
+ position: "right",
+ action,
+ zoomIn
+ });
});
- });
+ })
}
}
}, {
icon: "iconLayoutBottom",
label: window.siyuan.languages.insertBottom,
- accelerator: "⇧Click",
+ accelerator: ids.length === 1 ? "⇧Click" : "",
click: () => {
if (notebookId) {
- openFileById({app, id, position: "bottom", action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]});
+ openFileById({
+ app,
+ id: ids[0],
+ position: "bottom",
+ action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
+ });
} else {
- checkFold(id, (zoomIn, action)=> {
- openFileById({
- app,
- id,
- position: "bottom",
- action,
- zoomIn
+ ids.forEach((id) => {
+ checkFold(id, (zoomIn, action) => {
+ openFileById({
+ app,
+ id,
+ position: "bottom",
+ action,
+ zoomIn
+ });
});
- });
+ })
}
}
}];
if (window.siyuan.config.fileTree.openFilesUseCurrentTab) {
openSubmenus.push({
label: window.siyuan.languages.openInNewTab,
- accelerator: "⌥⌘Click",
+ accelerator: ids.length === 1 ? "⌥⌘Click" : undefined,
click: () => {
if (notebookId) {
openFileById({
app,
- id,
+ id: ids[0],
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],
removeCurrentTab: false
});
} else {
- checkFold(id, (zoomIn, action)=> {
- openFileById({
- app,
- id,
- action,
- zoomIn,
- removeCurrentTab: false
+ ids.forEach((id) => {
+ checkFold(id, (zoomIn, action) => {
+ openFileById({
+ app,
+ id,
+ action,
+ zoomIn,
+ removeCurrentTab: false
+ });
});
});
}
@@ -104,7 +120,9 @@ export const openEditorTab = (app: App, id: string, notebookId?: string, pathStr
label: window.siyuan.languages.openByNewWindow,
icon: "iconOpenWindow",
click() {
- openNewWindowById(id);
+ ids.forEach((id) => {
+ openNewWindowById(id);
+ });
}
});
/// #endif
@@ -113,7 +131,9 @@ export const openEditorTab = (app: App, id: string, notebookId?: string, pathStr
icon: "iconPreview",
label: window.siyuan.languages.preview,
click: () => {
- openFileById({app, id, mode: "preview"});
+ ids.forEach((id) => {
+ openFileById({app, id, mode: "preview"});
+ });
}
});
/// #if !BROWSER
@@ -125,8 +145,10 @@ export const openEditorTab = (app: App, id: string, notebookId?: string, pathStr
if (notebookId) {
showFileInFolder(path.join(window.siyuan.config.system.dataDir, notebookId, pathString));
} else {
- fetchPost("/api/block/getBlockInfo", {id}, (response) => {
- showFileInFolder(path.join(window.siyuan.config.system.dataDir, response.data.box, response.data.path));
+ ids.forEach((id) => {
+ fetchPost("/api/block/getBlockInfo", {id}, (response) => {
+ showFileInFolder(path.join(window.siyuan.config.system.dataDir, response.data.box, response.data.path));
+ });
});
}
}
diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts
index f13f62d95d..61f3e3f435 100644
--- a/app/src/protyle/render/av/action.ts
+++ b/app/src/protyle/render/av/action.ts
@@ -260,7 +260,7 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
const keyCellElement = rowElements[0].querySelector(".av__cell[data-block-id]") as HTMLElement;
if (rowElements.length === 1 && keyCellElement.getAttribute("data-detached") !== "true") {
const blockId = rowElements[0].getAttribute("data-id");
- openEditorTab(protyle.app, blockId);
+ openEditorTab(protyle.app, [blockId]);
menu.addItem({
label: window.siyuan.languages.copy,
icon: "iconCopy",