Skip to content

Build your personal knowledge base with Trilium Notes

feat(note_icon): display icon pack in note title

Elian Doran761a67f2388e
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 6af1053068..c160298963 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -769,7 +769,8 @@
"reset-default": "Reset to default icon",
"filter": "Filter",
"filter-none": "All icons",
- "filter-default": "Default icons"
+ "filter-default": "Default icons",
+ "icon_tooltip": "{{name}}\nIcon pack: {{iconPack}}"
},
"basic_properties": {
"note_type": "Note type",
diff --git a/apps/client/src/widgets/note_icon.tsx b/apps/client/src/widgets/note_icon.tsx
index e70f2ae20b..7ce5e020f7 100644
--- a/apps/client/src/widgets/note_icon.tsx
+++ b/apps/client/src/widgets/note_icon.tsx
@@ -21,7 +21,7 @@ interface IconToCountCache {
interface IconData {
iconToCount: Record<string, number>;
- icons: IconRegistry["sources"][number]["icons"];
+ icons: (IconRegistry["sources"][number]["icons"][number] & { iconPack: string })[];
}
let iconToCountCache!: Promise<IconToCountCache> | null;
@@ -65,8 +65,11 @@ function NoteIconList({ note, dropdownRef }: {
useEffect(() => {
async function loadIcons() {
// Filter by text and/or category.
- let icons: IconRegistry["sources"][number]["icons"] = [
- ...glob.iconRegistry.sources.map(s => s.icons).flat()
+ let icons: IconData["icons"] = [
+ ...glob.iconRegistry.sources.map(s => s.icons.map((i) => ({
+ ...i,
+ iconPack: s.name,
+ }))).flat()
];
const processedSearch = search?.trim()?.toLowerCase();
if (processedSearch || filterByPrefix !== null) {
@@ -162,8 +165,12 @@ function NoteIconList({ note, dropdownRef }: {
dropdownRef?.current?.hide();
}}
>
- {(iconData?.icons ?? []).map(({ id, terms }) => (
- <span key={id} class={id} title={terms[0]} />
+ {(iconData?.icons ?? []).map(({ id, terms, iconPack }) => (
+ <span
+ key={id}
+ class={id}
+ title={t("note_icon.icon_tooltip", { name: terms?.[0] ?? id, iconPack })}
+ />
))}
</div>
</>