Skip to content

Build your personal knowledge base with Trilium Notes

feat(fonts): head the font picker with the user's own fonts

Elian Doran807b9cfe7b64
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index cc39bbc13a..13c5f95d0c 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -1824,7 +1824,7 @@
"not_all_fonts_available": "Not all listed fonts may be available on your system",
"apply_changes": "Reload to apply changes",
"generic-fonts": "Generic fonts",
- "user-fonts": "Your fonts",
+ "user-fonts": "Custom fonts",
"sans-serif-system-fonts": "Sans-serif system fonts",
"serif-system-fonts": "Serif system fonts",
"monospace-system-fonts": "Monospace system fonts",
diff --git a/apps/client/src/widgets/type_widgets/options/appearance.spec.tsx b/apps/client/src/widgets/type_widgets/options/appearance.spec.tsx
index adc877f35d..bc5a81a35f 100644
--- a/apps/client/src/widgets/type_widgets/options/appearance.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/options/appearance.spec.tsx
@@ -119,7 +119,8 @@ describe("the font settings", () => {
const picker = document.querySelector(".font-picker-list");
const headers = [ ...(picker?.querySelectorAll(".dropdown-header") ?? []) ].map((header) => header.textContent);
- expect(headers).toContain("fonts.user-fonts");
+ // Ahead of the stock families, which the user has to scroll past otherwise.
+ expect(headers[0]).toBe("fonts.user-fonts");
// Each is named by its note's own title, and stands for the note rather than for a family.
const listed = [ ...(picker?.querySelectorAll(".dropdown-item") ?? []) ].map((item) => item.textContent?.trim());
diff --git a/apps/client/src/widgets/type_widgets/options/appearance.tsx b/apps/client/src/widgets/type_widgets/options/appearance.tsx
index 86c6a8e0a7..2a843c8464 100644
--- a/apps/client/src/widgets/type_widgets/options/appearance.tsx
+++ b/apps/client/src/widgets/type_widgets/options/appearance.tsx
@@ -530,11 +530,12 @@ function useFontGroups(): FontGroup[] {
};
}, []);
+ // Ahead of the stock families: a font the user went and added is the one they are looking for.
return useMemo(() => (customFonts.length
- ? [ ...FONT_FAMILIES, {
+ ? [ {
title: t("fonts.user-fonts"),
items: customFonts.map(({ noteId, title }) => ({ value: customFontOption(noteId), label: title }))
- } ]
+ }, ...FONT_FAMILIES ]
: FONT_FAMILIES), [ customFonts ]);
}