Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/14878

Vanessa71c5c8bec437
diff --git a/app/src/block/util.ts b/app/src/block/util.ts
index 47fafe9929..24d5532f40 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 b73476612c..217b63f68e 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 47de6f7cf8..f2180ee474 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 e6d3a52e59..9a35272cc1 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"));