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/10769

Vanessa41b11b44f6d5
diff --git a/app/src/util/highlightById.ts b/app/src/util/highlightById.ts
index c92e573e92..d069606b89 100644
--- a/app/src/util/highlightById.ts
+++ b/app/src/util/highlightById.ts
@@ -40,8 +40,19 @@ export const highlightById = (protyle: IProtyle, id: string, top = false) => {
export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = false, behavior: ScrollBehavior = "auto") => {
if (!protyle.disabled && !top && getSelection().rangeCount > 0) {
- const blockElement = hasClosestBlock(getSelection().getRangeAt(0).startContainer);
+ const range = getSelection().getRangeAt(0)
+ const blockElement = hasClosestBlock(range.startContainer);
if (blockElement) {
+ // https://github.com/siyuan-note/siyuan/issues/10769
+ if (blockElement.classList.contains("code-block")) {
+ const brElement = document.createElement('br');
+ range.insertNode(brElement);
+ brElement.scrollIntoView({
+ block: 'end',
+ });
+ brElement.remove();
+ return;
+ }
// undo 时禁止数据库滚动
if (blockElement.classList.contains("av") && blockElement.dataset.render === "true" &&
(blockElement.querySelector(".av__row--header").getAttribute("style")?.indexOf("transform") > -1 || blockElement.querySelector(".av__row--footer").getAttribute("style")?.indexOf("transform") > -1)) {