Skip to content

Build your personal knowledge base with Trilium Notes

fix(code): align syntax highlight settings

Elian Doran340dec725cc8
diff --git a/apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts b/apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts
index 85d7496536..2ea5fcd71b 100644
--- a/apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts
+++ b/apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts
@@ -4,6 +4,8 @@ import options from "../../services/options.js";
import TypeWidget from "./type_widget.js";
import CodeMirror, { type EditorConfig } from "@triliumnext/codemirror";
+export const DEFAULT_PREFIX = "default:";
+
/**
* An abstract {@link TypeWidget} which implements the CodeMirror editor, meant to be used as a parent for
* widgets requiring the editor.
@@ -34,9 +36,12 @@ export default class AbstractCodeTypeWidget extends TypeWidget {
});
// Load the theme.
- const theme = getThemeById(options.get("codeNoteTheme"));
- if (theme) {
- await this.codeEditor.setTheme(theme);
+ const themeId = options.get("codeNoteTheme");
+ if (themeId?.startsWith(DEFAULT_PREFIX)) {
+ const theme = getThemeById(themeId.substring(DEFAULT_PREFIX.length));
+ if (theme) {
+ await this.codeEditor.setTheme(theme);
+ }
}
}
diff --git a/apps/server/src/routes/api/options.ts b/apps/server/src/routes/api/options.ts
index 256b7d1259..66c2e4b91d 100644
--- a/apps/server/src/routes/api/options.ts
+++ b/apps/server/src/routes/api/options.ts
@@ -197,7 +197,7 @@ function getSyntaxHighlightingThemes() {
function getCodeNoteThemes() {
return ColorThemes.map((theme) => ({
- val: theme.id,
+ val: `default:${theme.id}`,
title: theme.id
}));
}