client: Improve group for no theme

This commit is contained in:
Elian Doran 2024-10-31 21:17:40 +02:00
parent cc0b3db424
commit a690155d7e
No known key found for this signature in database
4 changed files with 21 additions and 13 deletions

View File

@ -88,11 +88,18 @@ export default class CodeBlockOptions extends OptionsWidget {
this.$themeSelect.empty(); this.$themeSelect.empty();
for (const [ key, themes ] of Object.entries(themeGroups)) { for (const [ key, themes ] of Object.entries(themeGroups)) {
const $group = $("<optgroup>").attr("label", key); const $group = (key ? $("<optgroup>").attr("label", key) : null);
for (const theme of themes) { for (const theme of themes) {
$group.append($("<option>") const option = $("<option>")
.attr("value", theme.val) .attr("value", theme.val)
.text(theme.title)); .text(theme.title);
if ($group) {
$group.append(option);
} else {
this.$themeSelect.append(option);
}
} }
this.$themeSelect.append($group); this.$themeSelect.append($group);
} }

View File

@ -10,15 +10,16 @@ interface ColorTheme {
export function listSyntaxHighlightingThemes() { export function listSyntaxHighlightingThemes() {
const path = "node_modules/@highlightjs/cdn-assets/styles"; const path = "node_modules/@highlightjs/cdn-assets/styles";
const systemThemes = readThemesFromFileSystem(path); const systemThemes = readThemesFromFileSystem(path);
const allThemes = [
return {
"": [
{ {
val: "none", val: "none",
title: t("code_block.theme_none") title: t("code_block.theme_none")
}, }
...systemThemes ],
]; ...groupThemesByLightOrDark(systemThemes)
}
return groupThemesByLightOrDark(allThemes);
} }
function readThemesFromFileSystem(path: string): ColorTheme[] { function readThemesFromFileSystem(path: string): ColorTheme[] {

View File

@ -185,7 +185,7 @@
"search_prefix": "Search:" "search_prefix": "Search:"
}, },
"code_block": { "code_block": {
"theme_none": "None", "theme_none": "No syntax highlighting",
"theme_group_light": "Light themes", "theme_group_light": "Light themes",
"theme_group_dark": "Dark themes" "theme_group_dark": "Dark themes"
} }

View File

@ -185,7 +185,7 @@
"search_prefix": "Căutare:" "search_prefix": "Căutare:"
}, },
"code_block": { "code_block": {
"theme_none": "Niciuna", "theme_none": "Fără evidențiere de sintaxă",
"theme_group_dark": "Teme întunecate", "theme_group_dark": "Teme întunecate",
"theme_group_light": "Teme luminoase" "theme_group_light": "Teme luminoase"
} }