chore(icon_packs): address requested changes

This commit is contained in:
Elian Doran 2025-12-28 15:50:01 +02:00
parent e730378b27
commit 02d42dc5ff
No known key found for this signature in database
2 changed files with 9 additions and 4 deletions

View File

@ -2,6 +2,7 @@ import "./note_icon.css";
import { IconRegistry } from "@triliumnext/commons";
import { Dropdown as BootstrapDropdown } from "bootstrap";
import clsx from "clsx";
import { t } from "i18next";
import { RefObject } from "preact";
import { useEffect, useRef, useState } from "preact/hooks";
@ -164,9 +165,9 @@ function NoteIconList({ note, dropdownRef }: {
onClick={(e) => {
// Make sure we are not clicking on something else than a button.
const clickedTarget = e.target as HTMLElement;
if (clickedTarget.tagName !== "SPAN" || clickedTarget.classList.length !== 2) return;
if (!clickedTarget.classList.contains("tn-icon")) return;
const iconClass = Array.from(clickedTarget.classList.values()).join(" ");
const iconClass = Array.from(clickedTarget.classList.values()).filter(c => c !== "tn-icon").join(" ");
if (note) {
const attributeToSet = note.hasOwnedLabel("workspace") ? "workspaceIconClass" : "iconClass";
attributes.setLabel(note.noteId, attributeToSet, iconClass);
@ -178,7 +179,7 @@ function NoteIconList({ note, dropdownRef }: {
(iconData?.icons ?? []).map(({ id, terms, iconPack }) => (
<span
key={id}
class={id}
class={clsx(id, "tn-icon")}
title={t("note_icon.icon_tooltip", { name: terms?.[0] ?? id, iconPack })}
/>
))

View File

@ -10,6 +10,7 @@ import type BNote from "../../../becca/entities/bnote.js";
import { getClientDir, getShareThemeAssetDir } from "../../../routes/assets";
import { getDefaultTemplatePath, readTemplate, renderNoteForExport } from "../../../share/content_renderer";
import { getIconPacks, MIME_TO_EXTENSION_MAPPINGS, ProcessedIconPack } from "../../icon_packs";
import log from "../../log";
import NoteMeta, { NoteMetaFile } from "../../meta/note_meta";
import { RESOURCE_DIR } from "../../resource_dir";
import { getResourceDir, isDev } from "../../utils";
@ -152,7 +153,10 @@ export default class ShareThemeExportProvider extends ZipExportProvider {
fontData = becca.getAttachment(iconPack.fontAttachmentId)?.getContent();
}
if (!fontData) continue;
if (!fontData) {
log.error(`Failed to find font data for icon pack ${iconPack.prefix} with attachment ID ${iconPack.fontAttachmentId}`);
continue;
};
const fontFileName = `assets/icon-pack-${iconPack.prefix.toLowerCase()}.${extension}`;
this.archive.append(fontData, { name: fontFileName });
}