An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: fix https://github.com/siyuan-note/siyuan/issues/7723
Vanessa9cae6356470a
diff --git a/app/src/protyle/util/insertHTML.ts b/app/src/protyle/util/insertHTML.tsindex 755066a63d..69b703226c 100644--- a/app/src/protyle/util/insertHTML.ts+++ b/app/src/protyle/util/insertHTML.ts@@ -44,7 +44,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);+ scrollCenter(protyle, blockElement, false, "smooth");}, Constants.TIMEOUT_BLOCKLOAD);return;}diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.tsindex 83cbdc9055..958ba9d21f 100644--- a/app/src/protyle/util/paste.ts+++ b/app/src/protyle/util/paste.ts@@ -78,7 +78,7 @@ export const pasteText = (protyle: IProtyle, textPlain: string, nodeElement: EleprocessRender(protyle.wysiwyg.element);highlightRender(protyle.wysiwyg.element);filterClipboardHint(protyle, textPlain);- scrollCenter(protyle);+ scrollCenter(protyle, undefined, false, "smooth");};export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEvent) & { target: HTMLElement }) => {@@ -262,7 +262,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEvenprocessRender(protyle.wysiwyg.element);highlightRender(protyle.wysiwyg.element);filterClipboardHint(protyle, response.data);- scrollCenter(protyle);+ scrollCenter(protyle, undefined, false, "smooth");});return;} else if (files && files.length > 0) {@@ -285,5 +285,5 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEvenprocessRender(protyle.wysiwyg.element);highlightRender(protyle.wysiwyg.element);}- scrollCenter(protyle);+ scrollCenter(protyle, undefined, false, "smooth");};diff --git a/app/src/util/highlightById.ts b/app/src/util/highlightById.tsindex 736287883e..44c34811f7 100644--- a/app/src/util/highlightById.ts+++ b/app/src/util/highlightById.ts@@ -38,14 +38,18 @@ export const highlightById = (protyle: IProtyle, id: string, top = false) => {}};-export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = false) => {+export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = false, behavior: ScrollBehavior = "auto") => {if (!top && getSelection().rangeCount > 0 && hasClosestBlock(getSelection().getRangeAt(0).startContainer)) {const editorElement = protyle.contentElement;const cursorTop = getSelectionPosition(editorElement).top - editorElement.getBoundingClientRect().top;+ let top = 0if (cursorTop < 0) {- editorElement.scrollTop = editorElement.scrollTop + cursorTop;+ top = editorElement.scrollTop + cursorTop;} else if (cursorTop > editorElement.clientHeight - 74) { // 74 = 移动端底部 + 段落块高度- editorElement.scrollTop = editorElement.scrollTop + (cursorTop + 74 - editorElement.clientHeight);+ top = editorElement.scrollTop + (cursorTop + 74 - editorElement.clientHeight);+ }+ if (top !== 0) {+ editorElement.scroll({top, behavior});}return;}@@ -64,12 +68,15 @@ export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = falparentNodeElement = parentNodeElement.parentElement;}if (top) {- protyle.contentElement.scrollTop = offsetTop - 32;+ protyle.contentElement.scroll({top: offsetTop - 32, behavior});return;}if (protyle.contentElement.scrollTop > offsetTop - 32) {- protyle.contentElement.scrollTop = offsetTop - 32;+ protyle.contentElement.scroll({top: offsetTop - 32, behavior});} else if (protyle.contentElement.scrollTop + protyle.contentElement.clientHeight < offsetTop + nodeElement.clientHeight - 32) {- protyle.contentElement.scrollTop = offsetTop + nodeElement.clientHeight - 32 - protyle.contentElement.clientHeight;+ protyle.contentElement.scroll({+ top: offsetTop + nodeElement.clientHeight - 32 - protyle.contentElement.clientHeight,+ behavior+ });}};