mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-04 11:50:15 +01:00
This commit is contained in:
parent
cd82976170
commit
a7d951856c
7 changed files with 1564 additions and 61 deletions
|
|
@ -31,6 +31,7 @@ export const openFileById = (options: {
|
|||
action?: string[]
|
||||
keepCursor?: boolean
|
||||
zoomIn?: boolean
|
||||
removeCurrentTab?: boolean
|
||||
}) => {
|
||||
fetchPost("/api/block/getBlockInfo", {id: options.id}, (data) => {
|
||||
if (data.code === 2) {
|
||||
|
|
@ -41,13 +42,14 @@ export const openFileById = (options: {
|
|||
openFile({
|
||||
fileName: data.data.rootTitle,
|
||||
rootIcon: data.data.rootIcon,
|
||||
id: options.id,
|
||||
rootID: data.data.rootID,
|
||||
id: options.id,
|
||||
position: options.position,
|
||||
mode: options.mode,
|
||||
action: options.action,
|
||||
zoomIn: options.zoomIn,
|
||||
keepCursor: options.keepCursor
|
||||
keepCursor: options.keepCursor,
|
||||
removeCurrentTab: options.removeCurrentTab
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
@ -178,8 +180,8 @@ const openFile = (options: IOpenFileOptions) => {
|
|||
}
|
||||
});
|
||||
wnd.addTab(newTab(options));
|
||||
if (unUpdateTab && !window.siyuan.ctrlIsPressed) {
|
||||
wnd.removeTab(unUpdateTab.id);
|
||||
if (unUpdateTab && options.removeCurrentTab) {
|
||||
wnd.removeTab(unUpdateTab.id, false, true, false);
|
||||
}
|
||||
} else {
|
||||
wnd.addTab(newTab(options));
|
||||
|
|
|
|||
|
|
@ -231,17 +231,27 @@ export class Files extends Model {
|
|||
break;
|
||||
} else if (target.tagName === "LI") {
|
||||
needFocus = false;
|
||||
if (!event.metaKey && !event.ctrlKey) {
|
||||
if ((event.metaKey || event.ctrlKey) && !event.altKey && !event.shiftKey) {
|
||||
setPanelFocus(this.element.parentElement);
|
||||
target.classList.toggle("b3-list-item--focus");
|
||||
} else {
|
||||
this.setCurrent(target, false);
|
||||
if (target.getAttribute("data-type") === "navigation-file") {
|
||||
if (window.siyuan.altIsPressed) {
|
||||
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]
|
||||
});
|
||||
} 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]
|
||||
});
|
||||
} else {
|
||||
openFileById({
|
||||
removeCurrentTab: !((event.altKey && (event.metaKey || event.ctrlKey) && !event.shiftKey)),
|
||||
id: target.getAttribute("data-node-id"),
|
||||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
|
||||
});
|
||||
|
|
@ -250,9 +260,6 @@ export class Files extends Model {
|
|||
this.getLeaf(target, notebookId);
|
||||
setPanelFocus(this.element.parentElement);
|
||||
}
|
||||
} else {
|
||||
setPanelFocus(this.element.parentElement);
|
||||
target.classList.toggle("b3-list-item--focus");
|
||||
}
|
||||
this.element.querySelector('[select-end="true"]')?.removeAttribute("select-end");
|
||||
this.element.querySelector('[select-start="true"]')?.removeAttribute("select-start");
|
||||
|
|
|
|||
|
|
@ -266,6 +266,7 @@ export const initFileMenu = (notebookId: string, pathString: string, liElement:
|
|||
}, {
|
||||
icon: "iconLayoutBottom",
|
||||
label: window.siyuan.languages.insertBottom,
|
||||
accelerator: "⇧Click",
|
||||
click: () => {
|
||||
openFileById({id, position: "bottom", action: [Constants.CB_GET_FOCUS]});
|
||||
}
|
||||
|
|
@ -273,14 +274,12 @@ export const initFileMenu = (notebookId: string, pathString: string, liElement:
|
|||
if (window.siyuan.config.fileTree.openFilesUseCurrentTab) {
|
||||
openSubmenus.push({
|
||||
label: window.siyuan.languages.openInNewTab,
|
||||
accelerator: "⌘Click",
|
||||
accelerator: "⌥⌘Click",
|
||||
click: () => {
|
||||
window.siyuan.ctrlIsPressed = true;
|
||||
openFileById({id, action: [Constants.CB_GET_FOCUS]});
|
||||
setTimeout(() => {
|
||||
// 勾选在当前页签中打开后,右键在新页签中打开,不重置的话后续点击都会打开新页签
|
||||
window.siyuan.ctrlIsPressed = false;
|
||||
}, Constants.TIMEOUT_INPUT);
|
||||
openFileById({
|
||||
id, action: [Constants.CB_GET_FOCUS],
|
||||
removeCurrentTab: false
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
|
@ -211,6 +211,7 @@ declare interface IOpenFileOptions {
|
|||
action?: string[]
|
||||
keepCursor?: boolean // file,是否跳转到新 tab 上
|
||||
zoomIn?: boolean // 是否缩放
|
||||
removeCurrentTab?: boolean // 在当前页签打开时需移除原有页签
|
||||
}
|
||||
|
||||
declare interface ILayoutOptions {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue