fix(code): align syntax highlight settings

This commit is contained in:
Elian Doran 2025-05-11 21:40:13 +03:00
parent b2aec4dfdb
commit 340dec725c
No known key found for this signature in database
2 changed files with 9 additions and 4 deletions

View File

@ -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);
}
}
}

View File

@ -197,7 +197,7 @@ function getSyntaxHighlightingThemes() {
function getCodeNoteThemes() {
return ColorThemes.map((theme) => ({
val: theme.id,
val: `default:${theme.id}`,
title: theme.id
}));
}