mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 23:50:13 +01:00
🎨 https://github.com/siyuan-note/siyuan/issues/11205 & https://github.com/siyuan-note/siyuan/pull/15824
This commit is contained in:
parent
d9e0c56a47
commit
ec6e7a019e
9 changed files with 63 additions and 58 deletions
|
|
@ -40,6 +40,7 @@ import {openCard} from "../../../card/openCard";
|
||||||
import {syncGuide} from "../../../sync/syncGuide";
|
import {syncGuide} from "../../../sync/syncGuide";
|
||||||
import {Wnd} from "../../../layout/Wnd";
|
import {Wnd} from "../../../layout/Wnd";
|
||||||
import {unsplitWnd} from "../../../menus/tab";
|
import {unsplitWnd} from "../../../menus/tab";
|
||||||
|
import {openFileById} from "../../../editor/util";
|
||||||
|
|
||||||
export const globalCommand = (command: string, app: App) => {
|
export const globalCommand = (command: string, app: App) => {
|
||||||
/// #if MOBILE
|
/// #if MOBILE
|
||||||
|
|
@ -148,6 +149,15 @@ export const globalCommand = (command: string, app: App) => {
|
||||||
case "recentDocs":
|
case "recentDocs":
|
||||||
openRecentDocs();
|
openRecentDocs();
|
||||||
return true;
|
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]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return true;
|
||||||
case "toggleDock":
|
case "toggleDock":
|
||||||
toggleDockBar(document.querySelector("#barDock use"));
|
toggleDockBar(document.querySelector("#barDock use"));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ export const commandPanel = (app: App) => {
|
||||||
"goToTab5", "goToTab6", "goToTab7", "goToTab8", "goToTab9", "goToTabNext", "goToTabPrev", "lockScreen",
|
"goToTab5", "goToTab6", "goToTab7", "goToTab8", "goToTab9", "goToTabNext", "goToTabPrev", "lockScreen",
|
||||||
"mainMenu", "move", "newFile", "recentDocs", "replace", "riffCard", "search", "selectOpen1", "syncNow",
|
"mainMenu", "move", "newFile", "recentDocs", "replace", "riffCard", "search", "selectOpen1", "syncNow",
|
||||||
"splitLR", "splitMoveB", "splitMoveR", "splitTB", "tabToWindow", "stickSearch", "toggleDock", "unsplitAll",
|
"splitLR", "splitMoveB", "splitMoveR", "splitTB", "tabToWindow", "stickSearch", "toggleDock", "unsplitAll",
|
||||||
"unsplit"];
|
"unsplit", "recentClosed"];
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
keys.push("toggleWin");
|
keys.push("toggleWin");
|
||||||
/// #endif
|
/// #endif
|
||||||
|
|
|
||||||
|
|
@ -1532,15 +1532,10 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchHotKey("⇧⌘T", event)) {
|
if (matchHotKey(window.siyuan.config.keymap.general.recentClosed.custom, event)) {
|
||||||
if ((window as any).siyuan.closedTabs && (window as any).siyuan.closedTabs.length > 0) {
|
execByCommand({
|
||||||
const closedTab = (window as any).siyuan.closedTabs.pop();
|
command: "closeTab"
|
||||||
openFileById({
|
|
||||||
app,
|
|
||||||
id: closedTab.id,
|
|
||||||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -453,6 +453,7 @@ export abstract class Constants {
|
||||||
goToTabPrev: {default: "⇧⌘[", custom: "⇧⌘["},
|
goToTabPrev: {default: "⇧⌘[", custom: "⇧⌘["},
|
||||||
goToEditTabNext: {default: "⌃⇥", custom: "⌃⇥"},
|
goToEditTabNext: {default: "⌃⇥", custom: "⌃⇥"},
|
||||||
goToEditTabPrev: {default: "⌃⇧⇥", custom: "⌃⇧⇥"},
|
goToEditTabPrev: {default: "⌃⇧⇥", custom: "⌃⇧⇥"},
|
||||||
|
recentClosed: {default: "⇧⌘T", custom: "⇧⌘T"},
|
||||||
move: {default: "", custom: ""},
|
move: {default: "", custom: ""},
|
||||||
selectOpen1: {default: "", custom: ""},
|
selectOpen1: {default: "", custom: ""},
|
||||||
toggleDock: {default: "", custom: ""},
|
toggleDock: {default: "", custom: ""},
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ export class App {
|
||||||
layout: {},
|
layout: {},
|
||||||
dialogs: [],
|
dialogs: [],
|
||||||
blockPanels: [],
|
blockPanels: [],
|
||||||
|
closedTabs: [],
|
||||||
ctrlIsPressed: false,
|
ctrlIsPressed: false,
|
||||||
altIsPressed: false,
|
altIsPressed: false,
|
||||||
ws: new Model({
|
ws: new Model({
|
||||||
|
|
|
||||||
|
|
@ -793,12 +793,7 @@ export class Wnd {
|
||||||
saveScroll(item.model.editor.protyle);
|
saveScroll(item.model.editor.protyle);
|
||||||
// 更新文档关闭时间
|
// 更新文档关闭时间
|
||||||
fetchPost("/api/storage/updateRecentDocCloseTime", {rootID: item.model.editor.protyle.block.rootID});
|
fetchPost("/api/storage/updateRecentDocCloseTime", {rootID: item.model.editor.protyle.block.rootID});
|
||||||
if (!(window as any).siyuan.closedTabs) {
|
window.siyuan.closedTabs.push(item.model.editor.protyle.block.rootID);
|
||||||
(window as any).siyuan.closedTabs = [];
|
|
||||||
}
|
|
||||||
(window as any).siyuan.closedTabs.push({
|
|
||||||
id: item.model.editor.protyle.block.rootID
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (this.children.length === 1) {
|
if (this.children.length === 1) {
|
||||||
this.destroyModel(this.children[0].model);
|
this.destroyModel(this.children[0].model);
|
||||||
|
|
|
||||||
73
app/src/types/config.d.ts
vendored
73
app/src/types/config.d.ts
vendored
|
|
@ -1000,29 +1000,35 @@ declare namespace Config {
|
||||||
* SiYuan general shortcut keys
|
* SiYuan general shortcut keys
|
||||||
*/
|
*/
|
||||||
export interface IKeymapGeneral extends IKeys {
|
export interface IKeymapGeneral extends IKeys {
|
||||||
addToDatabase: IKey;
|
mainMenu: IKey;
|
||||||
backlinks: IKey;
|
|
||||||
bookmark: IKey;
|
|
||||||
closeAll: IKey;
|
|
||||||
closeLeft: IKey;
|
|
||||||
closeOthers: IKey;
|
|
||||||
closeRight: IKey;
|
|
||||||
closeTab: IKey;
|
|
||||||
closeUnmodified: IKey;
|
|
||||||
commandPanel: IKey;
|
commandPanel: IKey;
|
||||||
config: IKey;
|
|
||||||
dailyNote: IKey;
|
|
||||||
dataHistory: IKey;
|
|
||||||
editReadonly: IKey;
|
editReadonly: IKey;
|
||||||
enter: IKey;
|
syncNow: IKey;
|
||||||
enterBack: IKey;
|
enterBack: IKey;
|
||||||
fileTree: IKey;
|
enter: IKey;
|
||||||
globalGraph: IKey;
|
|
||||||
globalSearch: IKey;
|
|
||||||
goBack: IKey;
|
|
||||||
goForward: IKey;
|
goForward: IKey;
|
||||||
goToEditTabNext: IKey;
|
goBack: IKey;
|
||||||
goToEditTabPrev: IKey;
|
newFile: IKey;
|
||||||
|
search: IKey;
|
||||||
|
globalSearch: IKey;
|
||||||
|
stickSearch: IKey;
|
||||||
|
replace: IKey;
|
||||||
|
closeTab: IKey;
|
||||||
|
fileTree: IKey;
|
||||||
|
outline: IKey;
|
||||||
|
bookmark: IKey;
|
||||||
|
tag: IKey;
|
||||||
|
dailyNote: IKey;
|
||||||
|
inbox: IKey;
|
||||||
|
backlinks: IKey;
|
||||||
|
graphView: IKey;
|
||||||
|
globalGraph: IKey;
|
||||||
|
riffCard: IKey;
|
||||||
|
config: IKey;
|
||||||
|
dataHistory: IKey;
|
||||||
|
toggleWin: IKey;
|
||||||
|
lockScreen: IKey;
|
||||||
|
recentDocs: IKey;
|
||||||
goToTab1: IKey;
|
goToTab1: IKey;
|
||||||
goToTab2: IKey;
|
goToTab2: IKey;
|
||||||
goToTab3: IKey;
|
goToTab3: IKey;
|
||||||
|
|
@ -1034,28 +1040,25 @@ declare namespace Config {
|
||||||
goToTab9: IKey;
|
goToTab9: IKey;
|
||||||
goToTabNext: IKey;
|
goToTabNext: IKey;
|
||||||
goToTabPrev: IKey;
|
goToTabPrev: IKey;
|
||||||
graphView: IKey;
|
goToEditTabNext: IKey;
|
||||||
inbox: IKey;
|
goToEditTabPrev: IKey;
|
||||||
lockScreen: IKey;
|
recentClosed: IKey;
|
||||||
mainMenu: IKey;
|
|
||||||
move: IKey;
|
move: IKey;
|
||||||
newFile: IKey;
|
|
||||||
outline: IKey;
|
|
||||||
recentDocs: IKey;
|
|
||||||
replace: IKey;
|
|
||||||
riffCard: IKey;
|
|
||||||
search: IKey;
|
|
||||||
selectOpen1: IKey;
|
selectOpen1: IKey;
|
||||||
|
toggleDock: IKey;
|
||||||
splitLR: IKey;
|
splitLR: IKey;
|
||||||
splitMoveB: IKey;
|
|
||||||
splitMoveR: IKey;
|
splitMoveR: IKey;
|
||||||
splitTB: IKey;
|
splitTB: IKey;
|
||||||
stickSearch: IKey;
|
splitMoveB: IKey;
|
||||||
syncNow: IKey;
|
closeOthers: IKey;
|
||||||
|
closeAll: IKey;
|
||||||
|
closeUnmodified: IKey;
|
||||||
|
closeLeft: IKey;
|
||||||
|
closeRight: IKey;
|
||||||
tabToWindow: IKey;
|
tabToWindow: IKey;
|
||||||
tag: IKey;
|
addToDatabase: IKey;
|
||||||
toggleDock: IKey;
|
unsplit: IKey;
|
||||||
toggleWin: IKey;
|
unsplitAll: IKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
7
app/src/types/index.d.ts
vendored
7
app/src/types/index.d.ts
vendored
|
|
@ -216,10 +216,6 @@ interface Window {
|
||||||
encode(options: string): string,
|
encode(options: string): string,
|
||||||
};
|
};
|
||||||
pdfjsLib: any;
|
pdfjsLib: any;
|
||||||
|
|
||||||
dataLayer: any[];
|
|
||||||
|
|
||||||
siyuan: ISiyuan;
|
|
||||||
webkit: {
|
webkit: {
|
||||||
messageHandlers: {
|
messageHandlers: {
|
||||||
openLink: { postMessage: (url: string) => void }
|
openLink: { postMessage: (url: string) => void }
|
||||||
|
|
@ -233,6 +229,8 @@ interface Window {
|
||||||
toCanvas: (element: Element) => Promise<HTMLCanvasElement>
|
toCanvas: (element: Element) => Promise<HTMLCanvasElement>
|
||||||
toBlob: (element: Element) => Promise<Blob>
|
toBlob: (element: Element) => Promise<Blob>
|
||||||
};
|
};
|
||||||
|
|
||||||
|
siyuan: ISiyuan;
|
||||||
JSAndroid: {
|
JSAndroid: {
|
||||||
returnDesktop(): void
|
returnDesktop(): void
|
||||||
openExternal(url: string): void
|
openExternal(url: string): void
|
||||||
|
|
@ -462,6 +460,7 @@ interface ISiyuan {
|
||||||
storage?: {
|
storage?: {
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
},
|
},
|
||||||
|
closedTabs: string[]
|
||||||
transactions?: {
|
transactions?: {
|
||||||
protyle: IProtyle,
|
protyle: IProtyle,
|
||||||
doOperations: IOperation[],
|
doOperations: IOperation[],
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ class App {
|
||||||
layout: {},
|
layout: {},
|
||||||
dialogs: [],
|
dialogs: [],
|
||||||
blockPanels: [],
|
blockPanels: [],
|
||||||
|
closedTabs: [],
|
||||||
ctrlIsPressed: false,
|
ctrlIsPressed: false,
|
||||||
altIsPressed: false,
|
altIsPressed: false,
|
||||||
ws: new Model({
|
ws: new Model({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue