mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-02 18:01:15 +08:00
This commit is contained in:
parent
1088cf163b
commit
487ded0a06
@ -15,6 +15,8 @@ import {fetchPost} from "../util/fetch";
|
||||
import {showMessage} from "../dialog/message";
|
||||
import {App} from "../index";
|
||||
import {resize} from "../protyle/util/resize";
|
||||
import {checkFold} from "../util/noRelyPCFunction";
|
||||
import {updateHotkeyTip} from "../protyle/util/compatibility";
|
||||
|
||||
export class BlockPanel {
|
||||
public element: HTMLElement;
|
||||
@ -121,11 +123,16 @@ export class BlockPanel {
|
||||
openNewWindowById(this.refDefs[0].refID);
|
||||
/// #endif
|
||||
} else if (type === "stickTab") {
|
||||
openFileById({
|
||||
app: options.app,
|
||||
id: this.refDefs[0].refID,
|
||||
action: this.editors[0].protyle.block.rootID !== this.refDefs[0].refID ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_CONTEXT],
|
||||
checkFold(this.refDefs[0].refID, (zoomIn, action) => {
|
||||
openFileById({
|
||||
app:options.app,
|
||||
id:this.refDefs[0].refID,
|
||||
action,
|
||||
zoomIn,
|
||||
openNewTab: true
|
||||
});
|
||||
});
|
||||
this.destroy();
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
@ -233,7 +240,7 @@ export class BlockPanel {
|
||||
}
|
||||
let openHTML = "";
|
||||
if (this.refDefs.length === 1) {
|
||||
openHTML = `<span data-type="stickTab" class="block__icon block__icon--show b3-tooltips b3-tooltips__sw" aria-label="${window.siyuan.languages.openBy}"><svg><use xlink:href="#iconOpen"></use></svg></span>
|
||||
openHTML = `<span data-type="stickTab" class="block__icon block__icon--show b3-tooltips b3-tooltips__sw" aria-label="${window.siyuan.languages.openInNewTab} ${updateHotkeyTip(window.siyuan.config.keymap.editor.general.openInNewTab.custom)}"><svg><use xlink:href="#iconOpen"></use></svg></span>
|
||||
<span class="fn__space"></span>`;
|
||||
/// #if !BROWSER
|
||||
openHTML += `<span data-type="open" class="block__icon block__icon--show b3-tooltips b3-tooltips__sw" aria-label="${window.siyuan.languages.openByNewWindow}"><svg><use xlink:href="#iconOpenWindow"></use></svg></span>
|
||||
|
@ -465,6 +465,7 @@ export abstract class Constants {
|
||||
rtl: {default: "", custom: ""},
|
||||
ltr: {default: "", custom: ""},
|
||||
aiWriting: {default: "", custom: ""},
|
||||
openInNewTab: {default: "", custom: ""},
|
||||
},
|
||||
insert: {
|
||||
appearance: {default: "⌥⌘X", custom: "⌥⌘X"},
|
||||
|
@ -45,6 +45,7 @@ export const openFileById = async (options: {
|
||||
keepCursor?: boolean
|
||||
zoomIn?: boolean
|
||||
removeCurrentTab?: boolean
|
||||
openNewTab?: boolean
|
||||
afterOpen?: (model: Model) => void
|
||||
}) => {
|
||||
const response = await fetchSyncPost("/api/block/getBlockInfo", {id: options.id});
|
||||
@ -67,7 +68,8 @@ export const openFileById = async (options: {
|
||||
zoomIn: options.zoomIn,
|
||||
keepCursor: options.keepCursor,
|
||||
removeCurrentTab: options.removeCurrentTab,
|
||||
afterOpen: options.afterOpen
|
||||
afterOpen: options.afterOpen,
|
||||
openNewTab: options.openNewTab
|
||||
});
|
||||
};
|
||||
|
||||
@ -155,7 +157,7 @@ export const openFile = async (options: IOpenFileOptions) => {
|
||||
if (search) {
|
||||
return search.parent;
|
||||
}
|
||||
} else if (!options.position) {
|
||||
} else if (!options.position && !options.openNewTab) {
|
||||
let editor: Editor;
|
||||
let activeEditor: Editor;
|
||||
allModels.editor.find((item) => {
|
||||
|
@ -1712,6 +1712,28 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.repeat && matchHotKey(window.siyuan.config.keymap.editor.general.openInNewTab.custom, event)) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
const blockPanel = window.siyuan.blockPanels.find(item => {
|
||||
if (item.element.contains(nodeElement)) {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
const id = nodeElement.getAttribute("data-node-id");
|
||||
checkFold(id, (zoomIn, action) => {
|
||||
openFileById({
|
||||
app: protyle.app,
|
||||
id,
|
||||
action,
|
||||
zoomIn,
|
||||
openNewTab: true
|
||||
});
|
||||
blockPanel.destroy();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// tab 需等待 list 和 table 处理完成
|
||||
if (event.key === "Tab" && isNotCtrl(event) && !event.altKey) {
|
||||
event.preventDefault();
|
||||
|
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
@ -592,6 +592,7 @@ interface IOpenFileOptions {
|
||||
keepCursor?: boolean // file,是否跳转到新 tab 上
|
||||
zoomIn?: boolean // 是否缩放
|
||||
removeCurrentTab?: boolean // 在当前页签打开时需移除原有页签
|
||||
openNewTab?: boolean // 使用新页签打开
|
||||
afterOpen?: (model?: import("../layout/Model").Model) => void // 打开后回调
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user