Vanessa 2025-10-24 12:51:21 +08:00
parent a1781ae34d
commit fdef7398ed
7 changed files with 96 additions and 26 deletions

View file

@ -8,7 +8,7 @@ import {popSearch} from "../../../mobile/menu/search";
import {getRecentDocs} from "../../../mobile/menu/getRecentDocs";
/// #else
import {openNewWindow} from "../../../window/openNewWindow";
import {selectOpenTab, toggleDockBar} from "../../../layout/dock/util";
import {openBacklink, openGraph, openOutline, selectOpenTab, toggleDockBar} from "../../../layout/dock/util";
import {openGlobalSearch} from "../../../search/util";
import {workspaceMenu} from "../../../menus/workspace";
import {isWindow} from "../../../util/functions";
@ -40,7 +40,7 @@ import {openCard} from "../../../card/openCard";
import {syncGuide} from "../../../sync/syncGuide";
import {Wnd} from "../../../layout/Wnd";
import {unsplitWnd} from "../../../menus/tab";
import {openFileById} from "../../../editor/util";
import {openFile} from "../../../editor/util";
export const globalCommand = (command: string, app: App) => {
/// #if MOBILE
@ -151,11 +151,60 @@ export const globalCommand = (command: string, app: App) => {
return true;
case "recentClosed":
if (window.siyuan.closedTabs.length > 0) {
openFileById({
app,
id: window.siyuan.closedTabs.pop(),
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
});
const closeData = window.siyuan.closedTabs.pop();
const childData = closeData.children as ILayoutJSON;
if (childData.instance === "Editor") {
openFile({
app,
fileName: closeData.title,
id: childData.blockId,
rootID: childData.rootId,
mode: childData.mode,
action: [childData.action]
});
} else if (childData.instance === "Asset") {
openFile({
app,
assetPath: childData.path,
page: childData.page,
});
} else if (childData.instance === "Backlink") {
openBacklink({
app,
blockId: childData.blockId,
rootId: childData.rootId,
title: closeData.title,
});
} else if (childData.instance === "Graph") {
openGraph({
app,
blockId: childData.blockId,
rootId: childData.rootId,
title: closeData.title
});
} else if (childData.instance === "Outline") {
openOutline({
app,
rootId: childData.blockId,
title: closeData.title,
isPreview: childData.isPreview
});
} else if (childData.instance === "Search") {
openFile({
app,
searchData: childData.config,
});
} else if (childData.instance === "Custom") {
openFile({
app,
custom: {
icon: closeData.icon,
title: closeData.title,
data: childData.customModelData,
id: childData.customModelType
},
});
}
}
return true;
case "toggleDock":

View file

@ -442,7 +442,12 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
if (matchHotKey(window.siyuan.config.keymap.editor.general.outline.custom, event)) {
event.preventDefault();
const offset = getSelectionOffset(target);
openOutline(protyle);
openOutline({
app,
rootId: protyle.block.rootID,
title: protyle.options.render.title ? (protyle.title.editElement.textContent || window.siyuan.languages.untitled) : "",
isPreview: !protyle.preview.element.classList.contains("fn__none")
});
// switchWnd 后range会被清空需要重新设置
focusByOffset(target, offset.start, offset.end);
return true;
@ -1534,7 +1539,8 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
if (matchHotKey(window.siyuan.config.keymap.general.recentClosed.custom, event)) {
execByCommand({
command: "closeTab"
command: "recentClosed",
app
});
event.preventDefault();
return;