mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
This commit is contained in:
parent
6afa1fc1ec
commit
aac6ddc1f9
8 changed files with 1 additions and 47 deletions
|
|
@ -181,16 +181,12 @@ const focusStack = async (stack: IBackStack) => {
|
|||
};
|
||||
|
||||
export const goBack = async () => {
|
||||
if (document.querySelector("#barBack").classList.contains("toolbar__item--disabled")) {
|
||||
return;
|
||||
}
|
||||
if (window.siyuan.backStack.length === 0) {
|
||||
if (forwardStack.length > 0) {
|
||||
await focusStack(forwardStack[forwardStack.length - 1]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
document.querySelector("#barForward").classList.remove("toolbar__item--disabled");
|
||||
|
||||
if (!previousIsBack) {
|
||||
forwardStack.push(window.siyuan.backStack.pop());
|
||||
|
|
@ -205,24 +201,16 @@ export const goBack = async () => {
|
|||
stack = window.siyuan.backStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
if (window.siyuan.backStack.length === 0) {
|
||||
document.querySelector("#barBack").classList.add("toolbar__item--disabled");
|
||||
}
|
||||
previousIsBack = true;
|
||||
};
|
||||
|
||||
export const goForward = async () => {
|
||||
if (document.querySelector("#barForward").classList.contains("toolbar__item--disabled")) {
|
||||
return;
|
||||
}
|
||||
if (forwardStack.length === 0) {
|
||||
if (window.siyuan.backStack.length > 0) {
|
||||
await focusStack(window.siyuan.backStack[window.siyuan.backStack.length - 1]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
document.querySelector("#barBack").classList.remove("toolbar__item--disabled");
|
||||
if (previousIsBack) {
|
||||
window.siyuan.backStack.push(forwardStack.pop());
|
||||
}
|
||||
|
|
@ -237,10 +225,6 @@ export const goForward = async () => {
|
|||
stack = forwardStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
if (forwardStack.length === 0) {
|
||||
document.querySelector("#barForward").classList.add("toolbar__item--disabled");
|
||||
}
|
||||
previousIsBack = false;
|
||||
};
|
||||
|
||||
|
|
@ -273,7 +257,6 @@ export const pushBack = (protyle: IProtyle, range?: Range, blockElement?: Elemen
|
|||
window.siyuan.backStack.push(forwardStack.pop());
|
||||
}
|
||||
forwardStack = [];
|
||||
document.querySelector("#barForward").classList.add("toolbar__item--disabled");
|
||||
}
|
||||
window.siyuan.backStack.push({
|
||||
position,
|
||||
|
|
@ -286,9 +269,5 @@ export const pushBack = (protyle: IProtyle, range?: Range, blockElement?: Elemen
|
|||
}
|
||||
previousIsBack = false;
|
||||
}
|
||||
|
||||
if (window.siyuan.backStack.length > 1) {
|
||||
document.querySelector("#barBack").classList.remove("toolbar__item--disabled");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue