Vanessa 2025-11-09 15:50:22 +08:00
parent 8d6c422af0
commit ef03fd4cb3
11 changed files with 55 additions and 76 deletions

View file

@ -333,7 +333,7 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
blockElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
updateTransaction(protyle, id, blockElement.outerHTML, oldHTML);
setTimeout(() => {
scrollCenter(protyle, blockElement, {behavior: "smooth"});
scrollCenter(protyle, undefined, "nearest", "smooth");
}, Constants.TIMEOUT_LOAD);
return;
}

View file

@ -490,10 +490,8 @@ const focusElementById = (protyle: IProtyle, action: string[], scrollAttr?: IScr
// 下一个请求过来前需断开,否则 observerLoad 重新赋值后无法 disconnect https://ld246.com/article/1704612002446
protyle.observerLoad?.disconnect();
if (action.includes(Constants.CB_GET_FOCUS) || action.includes(Constants.CB_GET_SCROLL) || action.includes(Constants.CB_GET_HL) || action.includes(Constants.CB_GET_FOCUSFIRST)) {
const contentRect = protyle.contentElement.getBoundingClientRect();
const focusRect = focusElement.getBoundingClientRect();
if (!hasScrollTop && (contentRect.top > focusRect.top || contentRect.bottom < focusRect.bottom)) {
scrollCenter(protyle, focusElement, {position: "top"});
if (!hasScrollTop) {
scrollCenter(protyle, focusElement);
}
} else {
return;
@ -504,10 +502,8 @@ const focusElementById = (protyle: IProtyle, action: string[], scrollAttr?: IScr
protyle.contentElement.scrollTop = scrollAttr.scrollTop;
}
if (action.includes(Constants.CB_GET_FOCUS) || action.includes(Constants.CB_GET_HL) || action.includes(Constants.CB_GET_FOCUSFIRST)) {
const contentRect = protyle.contentElement.getBoundingClientRect();
const focusRect = focusElement.getBoundingClientRect();
if (!hasScrollTop && (contentRect.top > focusRect.top || contentRect.bottom < focusRect.bottom)) {
scrollCenter(protyle, focusElement, {position: "top"});
if (!hasScrollTop) {
scrollCenter(protyle, focusElement);
}
}
});

View file

@ -539,7 +539,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
processRender(protyle.wysiwyg.element);
highlightRender(protyle.wysiwyg.element);
avRender(protyle.wysiwyg.element, protyle);
scrollCenter(protyle, undefined, {behavior: "smooth"});
scrollCenter(protyle, undefined, "nearest", "smooth");
});
return;
} else if (files && files.length > 0) {
@ -592,7 +592,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
if (nodeElement.classList.contains("av") && selectCellElement) {
cellScrollIntoView(nodeElement, selectCellElement);
} else {
scrollCenter(protyle, undefined, {behavior: "smooth"});
scrollCenter(protyle, undefined, "nearest", "smooth");
}
};