Vanessa 2025-05-22 21:50:42 +08:00
parent ae4adfeba4
commit 71c5c8bec4
4 changed files with 6 additions and 1 deletions

View file

@ -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") {

View file

@ -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);
}

View file

@ -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

View file

@ -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"));