From 96b9042559659d87307adac08f85bb68d19f2a6c Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 27 Oct 2024 21:39:50 +0200 Subject: [PATCH] client: Rename option to codeBlockTheme --- src/public/app/services/library_loader.js | 6 +++++- .../widgets/type_widgets/options/appearance/highlighting.js | 4 ++-- src/routes/api/options.ts | 2 +- src/services/options_init.ts | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/public/app/services/library_loader.js b/src/public/app/services/library_loader.js index 88ad4ec7d..a6b770038 100644 --- a/src/public/app/services/library_loader.js +++ b/src/public/app/services/library_loader.js @@ -98,7 +98,7 @@ const HIGHLIGHT_JS = { } } - const currentTheme = optionsService.get("highlightingTheme"); + const currentTheme = optionsService.get("codeBlockTheme"); loadHighlightingTheme(currentTheme); return Array.from(scriptsToLoad); @@ -158,6 +158,10 @@ async function requireCss(url, prependAssetPath = true) { let highlightingThemeEl = null; function loadHighlightingTheme(theme) { + if (!theme) { + return; + } + if (!highlightingThemeEl) { highlightingThemeEl = $(``); $("head").append(highlightingThemeEl); diff --git a/src/public/app/widgets/type_widgets/options/appearance/highlighting.js b/src/public/app/widgets/type_widgets/options/appearance/highlighting.js index 07cd1412e..9b6c5aa24 100644 --- a/src/public/app/widgets/type_widgets/options/appearance/highlighting.js +++ b/src/public/app/widgets/type_widgets/options/appearance/highlighting.js @@ -46,7 +46,7 @@ export default class HighlightingOptions extends OptionsWidget { this.$themeSelect.on("change", async () => { const newTheme = this.$themeSelect.val(); library_loader.loadHighlightingTheme(newTheme); - await server.put(`options/highlightingTheme/${newTheme}`); + await server.put(`options/codeBlockTheme/${newTheme}`); }); // Set up preview @@ -70,6 +70,6 @@ export default class HighlightingOptions extends OptionsWidget { .attr("value", theme.val) .text(theme.title)); } - this.$themeSelect.val(options.highlightingTheme); + this.$themeSelect.val(options.codeBlockTheme); } } \ No newline at end of file diff --git a/src/routes/api/options.ts b/src/routes/api/options.ts index 459654a29..d028e7c0e 100644 --- a/src/routes/api/options.ts +++ b/src/routes/api/options.ts @@ -16,7 +16,7 @@ const ALLOWED_OPTIONS = new Set([ 'revisionSnapshotNumberLimit', 'zoomFactor', 'theme', - 'highlightingTheme', + 'codeBlockTheme', 'syncServerHost', 'syncServerTimeout', 'syncProxy', diff --git a/src/services/options_init.ts b/src/services/options_init.ts index 1d456ee3f..f649b4e05 100644 --- a/src/services/options_init.ts +++ b/src/services/options_init.ts @@ -41,7 +41,7 @@ async function initNotSyncedOptions(initialized: boolean, theme: string, opts: N optionService.createOption('lastSyncedPush', '0', false); optionService.createOption('theme', theme, false); - optionService.createOption('highlightingTheme', "default:atom-one-dark", false); + optionService.createOption('codeBlockTheme', "default:atom-one-dark", false); optionService.createOption('syncServerHost', opts.syncServerHost || '', false); optionService.createOption('syncServerTimeout', '120000', false);