MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / injectStyles

Function injectStyles

src/utils/codeHighlight.js:111–128  ·  view source on GitHub ↗

* Injects dynamic CSS for syntax highlighting based on current editor theme

()

Source from the content-addressed store, hash-verified

109 * Injects dynamic CSS for syntax highlighting based on current editor theme
110 */
111function injectStyles() {
112 const themeId = settings?.value?.editorTheme || "one_dark";
113 const config = getThemeConfig(themeId);
114
115 // Code blocks need background, references panel uses parent's background
116 const codeBlockStyles = generateStyles(config, ".cm-highlighted", true);
117 const refPreviewStyles = generateStyles(config, ".ref-preview", false);
118 const allStyles = `${codeBlockStyles}\n${refPreviewStyles}`;
119
120 if (!styleElement) {
121 styleElement = document.createElement("style");
122 styleElement.id = "cm-static-highlight-styles";
123 document.head.appendChild(styleElement);
124 }
125
126 styleElement.textContent = allStyles;
127 currentThemeId = themeId;
128}
129
130/**
131 * Gets the language parser for a given URI using the modelist

Callers 1

initHighlightingFunction · 0.85

Calls 2

getThemeConfigFunction · 0.90
generateStylesFunction · 0.85

Tested by

no test coverage detected