diff --git a/app/src/block/util.ts b/app/src/block/util.ts index 47fafe992..24d5532f4 100644 --- a/app/src/block/util.ts +++ b/app/src/block/util.ts @@ -142,6 +142,7 @@ export const insertEmptyBlock = (protyle: IProtyle, position: InsertPosition, id if (!blockElement) { return; } + protyle.observerLoad?.disconnect(); let newElement = genEmptyElement(false, true); let orderIndex = 1; if (blockElement.getAttribute("data-type") === "NodeListItem") { diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts index b73476612..217b63f68 100644 --- a/app/src/editor/util.ts +++ b/app/src/editor/util.ts @@ -347,6 +347,7 @@ const getUnInitTab = (options: IOpenFileOptions) => { }); }; +let resizeObserver:ResizeObserver; const switchEditor = (editor: Editor, options: IOpenFileOptions, allModels: IModels) => { if (options.keepCursor) { editor.parent.headElement.setAttribute("keep-cursor", options.id); @@ -392,7 +393,8 @@ const switchEditor = (editor: Editor, options: IOpenFileOptions, allModels: IMod editor.editor.protyle.toolbar.range = newRange; } scrollCenter(editor.editor.protyle, nodeElement, true); - const resizeObserver = new ResizeObserver(() => { + resizeObserver?.disconnect(); + resizeObserver = new ResizeObserver(() => { if (document.contains(nodeElement)) { scrollCenter(editor.editor.protyle, nodeElement, true); } diff --git a/app/src/protyle/wysiwyg/enter.ts b/app/src/protyle/wysiwyg/enter.ts index 47de6f7cf..f2180ee47 100644 --- a/app/src/protyle/wysiwyg/enter.ts +++ b/app/src/protyle/wysiwyg/enter.ts @@ -31,6 +31,7 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle hideElements(["select"], protyle); return; } + protyle.observerLoad?.disconnect(); // https://github.com/siyuan-note/siyuan/issues/5471 if (disableElement || // https://github.com/siyuan-note/siyuan/issues/10633 diff --git a/app/src/protyle/wysiwyg/remove.ts b/app/src/protyle/wysiwyg/remove.ts index e6d3a52e5..9a35272cc 100644 --- a/app/src/protyle/wysiwyg/remove.ts +++ b/app/src/protyle/wysiwyg/remove.ts @@ -25,6 +25,7 @@ import {Tab} from "../../layout/Tab"; import {Backlink} from "../../layout/dock/Backlink"; export const removeBlock = async (protyle: IProtyle, blockElement: Element, range: Range, type: "Delete" | "Backspace" | "remove") => { + protyle.observerLoad?.disconnect(); // 删除后,防止滚动条滚动后调用 get 请求,因为返回的请求已查找不到内容块了 preventScroll(protyle); const selectElements = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));