mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-27 17:34:06 +01:00
❤️ 完整开源界面和内核 https://github.com/siyuan-note/siyuan/issues/5013
This commit is contained in:
parent
e650b8100c
commit
f40ed985e1
1214 changed files with 345766 additions and 9 deletions
25
app/src/protyle/ui/setCodeTheme.ts
Normal file
25
app/src/protyle/ui/setCodeTheme.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import {Constants} from "../../constants";
|
||||
import {addStyle} from "../util/addStyle";
|
||||
|
||||
export const setCodeTheme = (cdn = Constants.PROTYLE_CDN) => {
|
||||
const protyleHljsStyle = document.getElementById("protyleHljsStyle") as HTMLLinkElement;
|
||||
let css;
|
||||
if (window.siyuan.config.appearance.mode === 0) {
|
||||
css = window.siyuan.config.appearance.codeBlockThemeLight;
|
||||
if (!Constants.SIYUAN_CONFIG_APPEARANCE_LIGHT_CODE.includes(css)) {
|
||||
css = "default";
|
||||
}
|
||||
} else {
|
||||
css = window.siyuan.config.appearance.codeBlockThemeDark;
|
||||
if (!Constants.SIYUAN_CONFIG_APPEARANCE_DARK_CODE.includes(css)) {
|
||||
css = "github-dark";
|
||||
}
|
||||
}
|
||||
const href = `${cdn}/js/highlight.js/styles/${css}.min.css?v=11.5.0`;
|
||||
if (!protyleHljsStyle) {
|
||||
addStyle(href, "protyleHljsStyle");
|
||||
} else if (!protyleHljsStyle.href.includes(href)) {
|
||||
protyleHljsStyle.remove();
|
||||
addStyle(href, "protyleHljsStyle");
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue