This commit is contained in:
parent
f375a085ce
commit
bd035417ce
3 changed files with 62 additions and 38 deletions
|
@ -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,
|
||||
|
|
|
@ -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]});
|
||||
} else {
|
||||
checkFold(id, (zoomIn, action) => {
|
||||
openFileById({
|
||||
app,
|
||||
id,
|
||||
position: "right",
|
||||
action,
|
||||
zoomIn
|
||||
});
|
||||
openFileById({
|
||||
app,
|
||||
id: ids[0],
|
||||
position: "right",
|
||||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
|
||||
});
|
||||
} else {
|
||||
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]});
|
||||
} else {
|
||||
checkFold(id, (zoomIn, action)=> {
|
||||
openFileById({
|
||||
app,
|
||||
id,
|
||||
position: "bottom",
|
||||
action,
|
||||
zoomIn
|
||||
});
|
||||
openFileById({
|
||||
app,
|
||||
id: ids[0],
|
||||
position: "bottom",
|
||||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
|
||||
});
|
||||
} else {
|
||||
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));
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Add table
Reference in a new issue