From 340dec725cc8fce77831862b834ad72900c55c42 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 11 May 2025 21:40:13 +0300 Subject: [PATCH] fix(code): align syntax highlight settings --- .../widgets/type_widgets/abstract_code_type_widget.ts | 11 ++++++++--- apps/server/src/routes/api/options.ts | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) 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 85d749653..2ea5fcd71 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 256b7d125..66c2e4b91 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 })); }