From 5c56c1c542b88ce5db6049c0532a06e5e1721f87 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 4 Jan 2024 17:05:24 +0800 Subject: [PATCH] :bug: https://github.com/siyuan-note/siyuan/issues/10073 --- app/src/protyle/render/av/cell.ts | 17 ++++++++++++++--- app/src/protyle/util/paste.ts | 8 +++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts index e4feda8d1..e898d992d 100644 --- a/app/src/protyle/render/av/cell.ts +++ b/app/src/protyle/render/av/cell.ts @@ -214,11 +214,22 @@ export const cellScrollIntoView = (blockElement: HTMLElement, cellElement: Eleme contentElement.scrollTop = contentElement.scrollTop + cellRect.top - avHeaderRect.bottom; } } else { - const avFooterRect = blockElement.querySelector(".av__row--footer").getBoundingClientRect(); - if (avFooterRect.top < cellRect.bottom) { + const footerElement = blockElement.querySelector(".av__row--footer") + if (footerElement.querySelector(".av__calc--ashow")) { + const avFooterRect = footerElement.getBoundingClientRect(); + if (avFooterRect.top < cellRect.bottom) { + const contentElement = hasClosestByClassName(blockElement, "protyle-content", true); + if (contentElement) { + contentElement.scrollTop = contentElement.scrollTop + cellRect.bottom - avFooterRect.top; + } + } + } else { const contentElement = hasClosestByClassName(blockElement, "protyle-content", true); if (contentElement) { - contentElement.scrollTop = contentElement.scrollTop + cellRect.bottom - avFooterRect.top; + const contentBottom = contentElement.getBoundingClientRect().bottom; + if (cellRect.bottom > contentBottom) { + contentElement.scrollTop = contentElement.scrollTop + (cellRect.bottom - contentBottom); + } } } } diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.ts index 6edce2611..0e56fc04c 100644 --- a/app/src/protyle/util/paste.ts +++ b/app/src/protyle/util/paste.ts @@ -15,6 +15,7 @@ import {insertHTML} from "./insertHTML"; import {scrollCenter} from "../../util/highlightById"; import {hideElements} from "../ui/hideElements"; import {avRender} from "../render/av/render"; +import {cellScrollIntoView} from "../render/av/cell"; export const pasteEscaped = async (protyle: IProtyle, nodeElement: Element) => { try { @@ -366,5 +367,10 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven highlightRender(protyle.wysiwyg.element); avRender(protyle.wysiwyg.element, protyle); } - scrollCenter(protyle, undefined, false, "smooth"); + const selectCellElement = nodeElement.querySelector(".av__cell--select"); + if (nodeElement.classList.contains("av") && selectCellElement) { + cellScrollIntoView(nodeElement, selectCellElement); + } else { + scrollCenter(protyle, undefined, false, "smooth"); + } };