Skip to content

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

:art: https://ld246.com/article/1724861627569

Vanessa17d131626831
diff --git a/app/src/assets/scss/component/_typography.scss b/app/src/assets/scss/component/_typography.scss
index b6fc061269..4fa83500c4 100644
--- a/app/src/assets/scss/component/_typography.scss
+++ b/app/src/assets/scss/component/_typography.scss
@@ -304,7 +304,6 @@
}
.hljs {
- border-radius: var(--b3-border-radius);
font-size: 85%;
overflow: auto;
font-family: var(--b3-font-family-code);
diff --git a/app/src/protyle/render/highlightRender.ts b/app/src/protyle/render/highlightRender.ts
index f13289815f..bf80cf5376 100644
--- a/app/src/protyle/render/highlightRender.ts
+++ b/app/src/protyle/render/highlightRender.ts
@@ -86,18 +86,17 @@ export const highlightRender = (element: Element, cdn = Constants.PROTYLE_CDN) =
} else {
block.style.fontVariantLigatures = "none";
}
- const codeText = block.textContent;
+ const codeText = block.lastElementChild.textContent;
if (!isPreview && (lineNumber === "true" || (lineNumber !== "false" && window.siyuan.config.editor.codeSyntaxHighlightLineNum))) {
// 需要先添加 class 以防止抖动 https://ld246.com/article/1648116585443
- block.firstElementChild.classList.add("protyle-linenumber__rows");
+ block.firstElementChild.className = "protyle-linenumber__rows";
block.firstElementChild.setAttribute("contenteditable", "false");
lineNumberRender(block);
} else {
- block.firstElementChild.classList.remove("protyle-linenumber__rows");
+ block.firstElementChild.className = "fn__none";
block.firstElementChild.innerHTML = "";
}
-
- (block.childElementCount === 2 ? block.lastElementChild : block).innerHTML = window.hljs.highlight(
+ block.lastElementChild.innerHTML = window.hljs.highlight(
codeText + (codeText.endsWith("\n") ? "" : "\n"), // https://github.com/siyuan-note/siyuan/issues/4609
{
language,