This commit is contained in:
Vanessa 2023-12-12 20:53:42 +08:00
parent f40ad7a8f1
commit 63eab3c5c1
3 changed files with 6 additions and 6 deletions

View file

@ -359,7 +359,7 @@ export const enableProtyle = (protyle: IProtyle) => {
const focusElementById = (protyle: IProtyle, action: string[], scrollAttr?: IScrollAttr) => {
let focusElement: Element;
if (scrollAttr && scrollAttr.focusId) {
focusElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${scrollAttr.focusId}"]`)
focusElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${scrollAttr.focusId}"]`);
} else {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${protyle.block.id}"]`)).find((item: HTMLElement) => {
if (!hasClosestByAttribute(item, "data-type", "block-render", true)) {
@ -372,7 +372,7 @@ const focusElementById = (protyle: IProtyle, action: string[], scrollAttr?: IScr
preventScroll(protyle);
focusElement = protyle.wysiwyg.element.lastElementChild;
} else if (!focusElement || action.includes(Constants.CB_GET_FOCUSFIRST)) {
focusElement = protyle.wysiwyg.element.firstElementChild
focusElement = protyle.wysiwyg.element.firstElementChild;
}
if (action.includes(Constants.CB_GET_HL)) {
preventScroll(protyle); // 搜索页签滚动会导致再次请求
@ -397,7 +397,7 @@ const focusElementById = (protyle: IProtyle, action: string[], scrollAttr?: IScr
protyle.contentElement.scrollTop = scrollAttr.scrollTop;
}
// 加强定位
protyle.observerLoad = new ResizeObserver((entries) => {
protyle.observerLoad = new ResizeObserver(() => {
if (action.includes(Constants.CB_GET_FOCUS) || action.includes(Constants.CB_GET_HL) || action.includes(Constants.CB_GET_FOCUSFIRST)) {
focusElement.scrollIntoView();
} else if (scrollAttr && scrollAttr.scrollTop) {