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

Vanessa714ef0aaab69
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index d151f95aa9..a23599bc4e 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -1786,6 +1786,13 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
});
}
let language = nodeElement.querySelector(".protyle-action__language").textContent;
+ // 语言优先级处理 https://github.com/siyuan-note/siyuan/issues/14767
+ if (range.commonAncestorContainer.nodeType === 1) {
+ const snippetClassName = (range.commonAncestorContainer as HTMLElement).className;
+ if (snippetClassName.startsWith("language-")) {
+ language = snippetClassName.replace("language-", "");
+ }
+ }
if (!window.hljs.getLanguage(language)) {
language = "plaintext";
}