From 714ef0aaab69e33c7f5c3af397f0e23904bc3c1b Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 7 May 2025 17:17:34 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/14767 --- app/src/protyle/wysiwyg/keydown.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index d151f95aa..a23599bc4 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"; }