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
client: Allow switching theme
Elian Doran60b6f7df89c7
diff --git a/src/public/app/widgets/type_widgets/options/appearance/highlighting.js b/src/public/app/widgets/type_widgets/options/appearance/highlighting.jsindex 1b99430c1e..9e63960043 100644--- a/src/public/app/widgets/type_widgets/options/appearance/highlighting.js+++ b/src/public/app/widgets/type_widgets/options/appearance/highlighting.js@@ -18,6 +18,10 @@ export default class HighlightingOptions extends OptionsWidget {doRender() {this.$widget = $(TPL);this.$themeSelect = this.$widget.find(".theme-select");+ this.$themeSelect.on("change", async () => {+ const newTheme = this.$themeSelect.val();+ await server.put(`options/highlightingTheme/${newTheme}`);+ });}async optionsLoaded(options) {@@ -27,8 +31,8 @@ export default class HighlightingOptions extends OptionsWidget {for (const theme of themes) {this.$themeSelect.append($("<option>").attr("value", theme.val)- .text(theme.title)- );+ .text(theme.title));}+ this.$themeSelect.val(options.highlightingTheme);}}\ No newline at end of filediff --git a/src/routes/api/options.ts b/src/routes/api/options.tsindex 7bf21890d8..5b8f4aea48 100644--- a/src/routes/api/options.ts+++ b/src/routes/api/options.ts@@ -16,6 +16,7 @@ const ALLOWED_OPTIONS = new Set(['revisionSnapshotNumberLimit','zoomFactor','theme',+ 'highlightingTheme','syncServerHost','syncServerTimeout','syncProxy',diff --git a/src/services/options_init.ts b/src/services/options_init.tsindex 6ed4d52a8f..1d456ee3fd 100644--- a/src/services/options_init.ts+++ b/src/services/options_init.ts@@ -41,6 +41,7 @@ async function initNotSyncedOptions(initialized: boolean, theme: string, opts: NoptionService.createOption('lastSyncedPush', '0', false);optionService.createOption('theme', theme, false);+ optionService.createOption('highlightingTheme', "default:atom-one-dark", false);optionService.createOption('syncServerHost', opts.syncServerHost || '', false);optionService.createOption('syncServerTimeout', '120000', false);@@ -99,7 +100,7 @@ const defaultOptions: DefaultOption[] = [// Internationalization{ name: 'locale', value: 'en', isSynced: true },- { name: 'firstDayOfWeek', value: '1', isSynced: true }+ { name: 'firstDayOfWeek', value: '1', isSynced: true }];function initStartupOptions() {