mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 10:22:29 +08:00
feat(client/fonts): add groups for fonts
This commit is contained in:
parent
639d118f41
commit
710a80aa26
@ -3,11 +3,14 @@ import utils from "../../../../services/utils.js";
|
||||
import { t } from "../../../../services/i18n.js";
|
||||
import { OptionMap, OptionNames } from "../../../../../../services/options_interface.js";
|
||||
|
||||
const FONT_FAMILIES = [
|
||||
const FONT_FAMILIES = {
|
||||
"Generic fonts": [
|
||||
{ value: "theme", label: t("fonts.theme_defined") },
|
||||
{ value: "serif", label: "Serif" },
|
||||
{ value: "sans-serif", label: "Sans Serif" },
|
||||
{ value: "monospace", label: "Monospace" },
|
||||
],
|
||||
"System fonts": [
|
||||
{ value: "Arial", label: "Arial" },
|
||||
{ value: "Verdana", label: "Verdana" },
|
||||
{ value: "Helvetica", label: "Helvetica" },
|
||||
@ -27,7 +30,8 @@ const FONT_FAMILIES = [
|
||||
{ value: "Luminari", label: "Luminari" },
|
||||
{ value: "Comic Sans MS", label: "Comic Sans MS" },
|
||||
{ value: "Microsoft YaHei", label: "Microsoft YaHei" },
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
const TPL = `
|
||||
<div class="options-section">
|
||||
@ -186,11 +190,17 @@ export default class FontsOptions extends OptionsWidget {
|
||||
fillFontFamilyOptions($select: JQuery<HTMLElement>, currentValue: string) {
|
||||
$select.empty();
|
||||
|
||||
for (const {value, label} of FONT_FAMILIES) {
|
||||
for (const [group, fonts] of Object.entries(FONT_FAMILIES)) {
|
||||
$select.append($("<optgroup>")
|
||||
.attr("label", group));
|
||||
|
||||
for (const {value, label} of fonts) {
|
||||
$select.append($("<option>")
|
||||
.attr("value", value)
|
||||
.prop("selected", value === currentValue)
|
||||
.text(label));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user