Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
electron: Fix code block theme loading in dev mode
Elian Doranf5205fdd3068
diff --git a/src/services/code_block_theme.ts b/src/services/code_block_theme.tsindex 037df7be59..e92199e74e 100644--- a/src/services/code_block_theme.ts+++ b/src/services/code_block_theme.ts@@ -9,6 +9,7 @@ import themeNames from "./code_block_theme_names.json" with { type: "json" }import { t } from "i18next";import { join } from "path";import utils from "./utils.js";+import env from "./env.js";/*** Represents a color scheme for the code block syntax highlight.@@ -30,8 +31,7 @@ interface ColorTheme {* @returns the supported themes, grouped.*/export function listSyntaxHighlightingThemes() {- const stylesDir = (!utils.isElectron() ? "node_modules/@highlightjs/cdn-assets/styles" : "styles");- const path = join(utils.getResourceDir(), stylesDir);+ const path = join(utils.getResourceDir(), getStylesDirectory());const systemThemes = readThemesFromFileSystem(path);return {@@ -45,6 +45,14 @@ export function listSyntaxHighlightingThemes() {}}+function getStylesDirectory() {+ if (utils.isElectron() && !env.isDev()) {+ return "styles";+ }++ return "node_modules/@highlightjs/cdn-assets/styles";+}+/*** Reads all the predefined themes by listing all minified CSSes from a given directory.*