Skip to content

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

:art: Inputting data in a table with a fixed header no longer resets the scroll position https://github.com/siyuan-note/siyuan/issues/18035

Daniel77d73ca519fc
diff --git a/app/src/protyle/wysiwyg/input.ts b/app/src/protyle/wysiwyg/input.ts
index 9d05beb140..62fee824a8 100644
--- a/app/src/protyle/wysiwyg/input.ts
+++ b/app/src/protyle/wysiwyg/input.ts
@@ -218,8 +218,11 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range:
protyle.wysiwyg.lastHTMLs[id] = blockElement.outerHTML;
}
let scrollLeft: number;
+ let scrollTop: number;
if (blockElement.classList.contains("table")) {
scrollLeft = blockElement.firstElementChild.scrollLeft;
+ // 固定表头后表格出现纵向滚动条,输入会重置滚动位置 https://github.com/siyuan-note/siyuan/issues/18035
+ scrollTop = blockElement.querySelector("table").scrollTop;
}
if (!/<span data-type="backslash">.{1,8}<\/span><wbr>/.test(html)) {
// 使用 md 闭合后继续输入应为普通文本, 转义不需要添加 zwsp
@@ -299,6 +302,9 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range:
if (scrollLeft > 0) {
blockElement.firstElementChild.scrollLeft = scrollLeft;
}
+ if (scrollTop > 0) {
+ blockElement.querySelector("table").scrollTop = scrollTop;
+ }
}
}
// https://github.com/siyuan-note/siyuan/issues/14766