diff --git a/app/src/block/Panel.ts b/app/src/block/Panel.ts index 222bca3c7..6cb40fd1f 100644 --- a/app/src/block/Panel.ts +++ b/app/src/block/Panel.ts @@ -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 = ` + openHTML = ` `; /// #if !BROWSER openHTML += ` diff --git a/app/src/constants.ts b/app/src/constants.ts index e595f9d0e..8e9670491 100644 --- a/app/src/constants.ts +++ b/app/src/constants.ts @@ -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"}, diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts index c68cef1d5..7c358aa8b 100644 --- a/app/src/editor/util.ts +++ b/app/src/editor/util.ts @@ -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) => { diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index a28eabb08..df741e816 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -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(); diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index 6970314ef..6491c39f1 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -592,6 +592,7 @@ interface IOpenFileOptions { keepCursor?: boolean // file,是否跳转到新 tab 上 zoomIn?: boolean // 是否缩放 removeCurrentTab?: boolean // 在当前页签打开时需移除原有页签 + openNewTab?: boolean // 使用新页签打开 afterOpen?: (model?: import("../layout/Model").Model) => void // 打开后回调 }