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 2ea5fcd71..8f081a7d7 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 @@ -3,6 +3,7 @@ import type FNote from "../../entities/fnote.js"; import options from "../../services/options.js"; import TypeWidget from "./type_widget.js"; import CodeMirror, { type EditorConfig } from "@triliumnext/codemirror"; +import type { EventData } from "../../components/app_context.js"; export const DEFAULT_PREFIX = "default:"; @@ -103,4 +104,17 @@ export default class AbstractCodeTypeWidget extends TypeWidget { // }); } } + + async entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) { + if (loadResults.isOptionReloaded("codeNoteTheme")) { + 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); + } + } + } + } + }