MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / applyCustomExportTheme

Function applyCustomExportTheme

apps/desktop/src/renderer/export-window.tsx:150–170  ·  view source on GitHub ↗

Inject a custom theme's CSS and finalize its mode. Falls back to the clean * light export if the theme can't be loaded, so a broken or missing custom * theme never yields an unreadable PDF.

(prefs: ExportPrefs)

Source from the content-addressed store, hash-verified

148 * light export if the theme can't be loaded, so a broken or missing custom
149 * theme never yields an unreadable PDF. */
150async function applyCustomExportTheme(prefs: ExportPrefs): Promise<void> {
151 const html = document.documentElement
152 try {
153 const themes = await window.zen.listCustomThemes()
154 const slug = customThemeSlugFromId(prefs.themeId)
155 const theme = themes.find((t) => t.slug === slug)
156 if (!theme) {
157 applyLightExportTheme()
158 return
159 }
160 const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches
161 const wantDark = prefs.themeMode === 'auto' ? prefersDark : prefs.themeMode === 'dark'
162 const mode = resolveCustomThemeMode(theme, wantDark)
163 html.dataset.theme = prefs.themeId
164 html.dataset.themeMode = mode
165 html.style.colorScheme = mode
166 injectActiveTheme(prefs.themeId, themes)
167 } catch {
168 applyLightExportTheme()
169 }
170}
171
172function applyExportPrefs(prefs: ExportPrefs): void {
173 const html = document.documentElement

Callers 1

loadFunction · 0.85

Calls 5

customThemeSlugFromIdFunction · 0.90
resolveCustomThemeModeFunction · 0.90
injectActiveThemeFunction · 0.90
applyLightExportThemeFunction · 0.85
listCustomThemesMethod · 0.80

Tested by

no test coverage detected