diff --git a/app/src/layout/tabUtil.ts b/app/src/layout/tabUtil.ts index 677725f90..0c520ddda 100644 --- a/app/src/layout/tabUtil.ts +++ b/app/src/layout/tabUtil.ts @@ -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")); } } } diff --git a/app/src/protyle/util/resize.ts b/app/src/protyle/util/resize.ts index c2c1c8875..3ef367ba1 100644 --- a/app/src/protyle/util/resize.ts +++ b/app/src/protyle/util/resize.ts @@ -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 动画结束