UNPKG

vditor

Version:

♏ 易于使用的 Markdown 编辑器,为适配不同的应用场景而生

17 lines (15 loc) 635 B
import {Constants} from "../constants"; import {addStyle} from "../util/addStyle"; export const setCodeTheme = (codeTheme: string, cdn = Constants.CDN) => { if (!Constants.CODE_THEME.includes(codeTheme)) { codeTheme = "github"; } const vditorHljsStyle = document.getElementById("vditorHljsStyle") as HTMLLinkElement; const href = `${cdn}/dist/js/highlight.js/styles/${codeTheme}.min.css`; if (!vditorHljsStyle) { addStyle(href, "vditorHljsStyle"); } else if (vditorHljsStyle.getAttribute('href') !== href) { vditorHljsStyle.remove(); addStyle(href, "vditorHljsStyle"); } };