feat(note_icon): display icon pack in note title

This commit is contained in:
Elian Doran 2025-12-27 20:37:59 +02:00
parent 736c69816d
commit 761a67f238
No known key found for this signature in database
2 changed files with 14 additions and 6 deletions

View File

@ -769,7 +769,8 @@
"reset-default": "Reset to default icon", "reset-default": "Reset to default icon",
"filter": "Filter", "filter": "Filter",
"filter-none": "All icons", "filter-none": "All icons",
"filter-default": "Default icons" "filter-default": "Default icons",
"icon_tooltip": "{{name}}\nIcon pack: {{iconPack}}"
}, },
"basic_properties": { "basic_properties": {
"note_type": "Note type", "note_type": "Note type",

View File

@ -21,7 +21,7 @@ interface IconToCountCache {
interface IconData { interface IconData {
iconToCount: Record<string, number>; iconToCount: Record<string, number>;
icons: IconRegistry["sources"][number]["icons"]; icons: (IconRegistry["sources"][number]["icons"][number] & { iconPack: string })[];
} }
let iconToCountCache!: Promise<IconToCountCache> | null; let iconToCountCache!: Promise<IconToCountCache> | null;
@ -65,8 +65,11 @@ function NoteIconList({ note, dropdownRef }: {
useEffect(() => { useEffect(() => {
async function loadIcons() { async function loadIcons() {
// Filter by text and/or category. // Filter by text and/or category.
let icons: IconRegistry["sources"][number]["icons"] = [ let icons: IconData["icons"] = [
...glob.iconRegistry.sources.map(s => s.icons).flat() ...glob.iconRegistry.sources.map(s => s.icons.map((i) => ({
...i,
iconPack: s.name,
}))).flat()
]; ];
const processedSearch = search?.trim()?.toLowerCase(); const processedSearch = search?.trim()?.toLowerCase();
if (processedSearch || filterByPrefix !== null) { if (processedSearch || filterByPrefix !== null) {
@ -162,8 +165,12 @@ function NoteIconList({ note, dropdownRef }: {
dropdownRef?.current?.hide(); dropdownRef?.current?.hide();
}} }}
> >
{(iconData?.icons ?? []).map(({ id, terms }) => ( {(iconData?.icons ?? []).map(({ id, terms, iconPack }) => (
<span key={id} class={id} title={terms[0]} /> <span
key={id}
class={id}
title={t("note_icon.icon_tooltip", { name: terms?.[0] ?? id, iconPack })}
/>
))} ))}
</div> </div>
</> </>