mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 01:20:12 +01:00
This commit is contained in:
parent
e772e97b72
commit
d44a928463
1 changed files with 28 additions and 27 deletions
|
|
@ -20,7 +20,7 @@ let previousIsBack = false;
|
||||||
const focusStack = async (stack: IBackStack) => {
|
const focusStack = async (stack: IBackStack) => {
|
||||||
hideElements(["gutter", "toolbar", "hint", "util", "dialog"], stack.protyle);
|
hideElements(["gutter", "toolbar", "hint", "util", "dialog"], stack.protyle);
|
||||||
let blockElement: Element;
|
let blockElement: Element;
|
||||||
if (!stack.protyle.element.parentElement) {
|
if (!document.contains(stack.protyle.element)) {
|
||||||
const response = await fetchSyncPost("/api/block/checkBlockExist", {id: stack.protyle.block.rootID});
|
const response = await fetchSyncPost("/api/block/checkBlockExist", {id: stack.protyle.block.rootID});
|
||||||
if (!response.data) {
|
if (!response.data) {
|
||||||
// 页签删除
|
// 页签删除
|
||||||
|
|
@ -74,20 +74,20 @@ const focusStack = async (stack: IBackStack) => {
|
||||||
wnd.addTab(tab);
|
wnd.addTab(tab);
|
||||||
}
|
}
|
||||||
wnd.showHeading();
|
wnd.showHeading();
|
||||||
// 页签关闭
|
// 替换被关闭的 protyle
|
||||||
setTimeout(() => {
|
|
||||||
const protyle = (tab.model as Editor).editor.protyle;
|
const protyle = (tab.model as Editor).editor.protyle;
|
||||||
forwardStack.find(item => {
|
stack.protyle = protyle;
|
||||||
if (!item.protyle.element.parentElement && item.protyle.block.rootID === protyle.block.rootID) {
|
forwardStack.forEach(item => {
|
||||||
|
if (!document.contains(item.protyle.element) && item.protyle.block.rootID === info.data.rootID) {
|
||||||
item.protyle = protyle;
|
item.protyle = protyle;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
window.siyuan.backStack.find(item => {
|
window.siyuan.backStack.forEach(item => {
|
||||||
if (!item.protyle.element.parentElement && item.protyle.block.rootID === protyle.block.rootID) {
|
if (!document.contains(item.protyle.element) && item.protyle.block.rootID === info.data.rootID) {
|
||||||
item.protyle = protyle;
|
item.protyle = protyle;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (protyle.block.rootID === stack.id) {
|
if (info.data.rootID === stack.id) {
|
||||||
focusByOffset(protyle.title.editElement, stack.position.start, stack.position.end);
|
focusByOffset(protyle.title.editElement, stack.position.start, stack.position.end);
|
||||||
} else {
|
} else {
|
||||||
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${stack.id}"]`)).find(item => {
|
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${stack.id}"]`)).find(item => {
|
||||||
|
|
@ -99,7 +99,6 @@ const focusStack = async (stack: IBackStack) => {
|
||||||
focusByOffset(getContenteditableElement(blockElement), stack.position.start, stack.position.end);
|
focusByOffset(getContenteditableElement(blockElement), stack.position.start, stack.position.end);
|
||||||
scrollCenter(protyle, blockElement);
|
scrollCenter(protyle, blockElement);
|
||||||
}
|
}
|
||||||
}, 500);
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -193,7 +192,9 @@ export const goBack = async () => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
document.querySelector("#barForward")?.classList.remove("toolbar__item--disabled");
|
document.querySelector("#barForward")?.classList.remove("toolbar__item--disabled");
|
||||||
if (!previousIsBack) {
|
if (!previousIsBack &&
|
||||||
|
// 页签被关闭时应优先打开该页签,页签存在时即可返回上一步,不用再重置光标到该页签上
|
||||||
|
document.contains(window.siyuan.backStack[window.siyuan.backStack.length - 1].protyle.element)) {
|
||||||
forwardStack.push(window.siyuan.backStack.pop());
|
forwardStack.push(window.siyuan.backStack.pop());
|
||||||
}
|
}
|
||||||
let stack = window.siyuan.backStack.pop();
|
let stack = window.siyuan.backStack.pop();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue