Vanessa 2025-04-07 23:50:44 +08:00
parent ee36abed5c
commit b86d583d1a
2 changed files with 8 additions and 4 deletions

View file

@ -276,7 +276,7 @@ export const copyTab = (app: App, tab: Tab) => {
if (newElement) {
editor.protyle.observerLoad?.disconnect();
newElement.scrollIntoView();
editor.protyle.contentElement.scrollTop += newElement.getBoundingClientRect().top - parseInt(copyResizeTopElement.getAttribute("data-resize-top"));
editor.protyle.contentElement.scrollTop += parseInt(copyResizeTopElement.getAttribute("data-resize-top"));
}
}
}

View file

@ -1,6 +1,6 @@
import {hideElements} from "../ui/hideElements";
import {setPadding} from "../ui/initUI";
import {hasClosestBlock} from "./hasClosest";
import {hasClosestBlock, hasClosestByClassName} from "./hasClosest";
import {Constants} from "../../constants";
import {lineNumberRender} from "../render/highlightRender";
/// #if !MOBILE
@ -16,6 +16,10 @@ export const recordBeforeResizeTop = () => {
item.editor.protyle.wysiwyg.element.querySelector("[data-resize-top]")?.removeAttribute("data-resize-top");
const contentRect = item.editor.protyle.contentElement.getBoundingClientRect();
let topElement = document.elementFromPoint(contentRect.left + (contentRect.width / 2), contentRect.top);
if (hasClosestByClassName(topElement, "b3-menu")) {
window.siyuan.menus.menu.remove();
topElement = document.elementFromPoint(contentRect.left + (contentRect.width / 2), contentRect.top);
}
if (!topElement) {
topElement = document.elementFromPoint(contentRect.left + (contentRect.width / 2), contentRect.top + 17);
}
@ -26,7 +30,7 @@ export const recordBeforeResizeTop = () => {
if (!topElement) {
return;
}
topElement.setAttribute("data-resize-top", topElement.getBoundingClientRect().top.toString());
topElement.setAttribute("data-resize-top", (contentRect.top - topElement.getBoundingClientRect().top).toString());
}
});
/// #endif
@ -68,7 +72,7 @@ export const resize = (protyle: IProtyle) => {
const topElement = protyle.wysiwyg.element.querySelector("[data-resize-top]");
if (topElement) {
topElement.scrollIntoView();
protyle.contentElement.scrollTop += topElement.getBoundingClientRect().top - parseInt(topElement.getAttribute("data-resize-top"));
protyle.contentElement.scrollTop += parseInt(topElement.getAttribute("data-resize-top"));
topElement.removeAttribute("data-resize-top");
}
}, Constants.TIMEOUT_TRANSITION + 100); // 等待 setPadding 动画结束