mirror of
https://github.com/zadam/trilium.git
synced 2026-01-06 22:54:23 +01:00
feat(icon_packs): use note title isntead of manifest
This commit is contained in:
parent
8053221b12
commit
13fff33aa4
@ -2,7 +2,6 @@ import { buildNote } from "../test/becca_easy_mocking";
|
|||||||
import { determineBestFontAttachment, generateCss, generateIconRegistry, IconPackManifest, processIconPack } from "./icon_packs";
|
import { determineBestFontAttachment, generateCss, generateIconRegistry, IconPackManifest, processIconPack } from "./icon_packs";
|
||||||
|
|
||||||
const manifest: IconPackManifest = {
|
const manifest: IconPackManifest = {
|
||||||
name: "Boxicons v2",
|
|
||||||
prefix: "bx",
|
prefix: "bx",
|
||||||
icons: {
|
icons: {
|
||||||
"bx-ball": {
|
"bx-ball": {
|
||||||
@ -33,6 +32,7 @@ describe("Processing icon packs", () => {
|
|||||||
|
|
||||||
it("processes manifest", () => {
|
it("processes manifest", () => {
|
||||||
const iconPack = processIconPack(buildNote({
|
const iconPack = processIconPack(buildNote({
|
||||||
|
title: "Boxicons v2",
|
||||||
type: "text",
|
type: "text",
|
||||||
content: JSON.stringify(manifest),
|
content: JSON.stringify(manifest),
|
||||||
attachments: [ defaultAttachment ]
|
attachments: [ defaultAttachment ]
|
||||||
@ -111,7 +111,6 @@ describe("Mapping attachments", () => {
|
|||||||
describe("CSS generation", () => {
|
describe("CSS generation", () => {
|
||||||
it("generates the CSS", () => {
|
it("generates the CSS", () => {
|
||||||
const manifest: IconPackManifest = {
|
const manifest: IconPackManifest = {
|
||||||
name: "Boxicons v2",
|
|
||||||
prefix: "bx",
|
prefix: "bx",
|
||||||
icons: {
|
icons: {
|
||||||
"bx-ball": {
|
"bx-ball": {
|
||||||
@ -126,6 +125,7 @@ describe("CSS generation", () => {
|
|||||||
};
|
};
|
||||||
const processedResult = processIconPack(buildNote({
|
const processedResult = processIconPack(buildNote({
|
||||||
type: "text",
|
type: "text",
|
||||||
|
title: "Boxicons v2",
|
||||||
content: JSON.stringify(manifest),
|
content: JSON.stringify(manifest),
|
||||||
attachments: [
|
attachments: [
|
||||||
{
|
{
|
||||||
@ -153,6 +153,7 @@ describe("CSS generation", () => {
|
|||||||
describe("Icon registery", () => {
|
describe("Icon registery", () => {
|
||||||
it("generates the registry", () => {
|
it("generates the registry", () => {
|
||||||
const iconPack = processIconPack(buildNote({
|
const iconPack = processIconPack(buildNote({
|
||||||
|
title: "Boxicons v2",
|
||||||
type: "text",
|
type: "text",
|
||||||
content: JSON.stringify(manifest),
|
content: JSON.stringify(manifest),
|
||||||
attachments: [ defaultAttachment ]
|
attachments: [ defaultAttachment ]
|
||||||
|
|||||||
@ -19,7 +19,6 @@ const MIME_TO_CSS_FORMAT_MAPPINGS: Record<typeof PREFERRED_MIME_TYPE[number], st
|
|||||||
};
|
};
|
||||||
|
|
||||||
export interface IconPackManifest {
|
export interface IconPackManifest {
|
||||||
name: string;
|
|
||||||
prefix: string;
|
prefix: string;
|
||||||
icons: Record<string, {
|
icons: Record<string, {
|
||||||
glyph: string,
|
glyph: string,
|
||||||
@ -31,6 +30,7 @@ interface ProcessResult {
|
|||||||
manifest: IconPackManifest;
|
manifest: IconPackManifest;
|
||||||
fontMime: string;
|
fontMime: string;
|
||||||
fontAttachmentId: string;
|
fontAttachmentId: string;
|
||||||
|
manifestNote: BNote;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getIconPacks() {
|
export function getIconPacks() {
|
||||||
@ -42,7 +42,7 @@ export function getIconPacks() {
|
|||||||
export function generateIconRegistry(iconPacks: ProcessResult[]): IconRegistry {
|
export function generateIconRegistry(iconPacks: ProcessResult[]): IconRegistry {
|
||||||
const sources: IconRegistry["sources"] = [];
|
const sources: IconRegistry["sources"] = [];
|
||||||
|
|
||||||
for (const { manifest } of iconPacks) {
|
for (const { manifest, manifestNote } of iconPacks) {
|
||||||
const icons: IconRegistry["sources"][number]["icons"] = Object.entries(manifest.icons)
|
const icons: IconRegistry["sources"][number]["icons"] = Object.entries(manifest.icons)
|
||||||
.map(( [id, { terms }] ) => {
|
.map(( [id, { terms }] ) => {
|
||||||
if (!id || !terms) return null;
|
if (!id || !terms) return null;
|
||||||
@ -53,7 +53,7 @@ export function generateIconRegistry(iconPacks: ProcessResult[]): IconRegistry {
|
|||||||
|
|
||||||
sources.push({
|
sources.push({
|
||||||
prefix: manifest.prefix,
|
prefix: manifest.prefix,
|
||||||
name: manifest.name,
|
name: manifestNote.title,
|
||||||
icons
|
icons
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -77,7 +77,8 @@ export function processIconPack(iconPackNote: BNote): ProcessResult | undefined
|
|||||||
return {
|
return {
|
||||||
manifest,
|
manifest,
|
||||||
fontMime: attachment.mime,
|
fontMime: attachment.mime,
|
||||||
fontAttachmentId: attachment.attachmentId
|
fontAttachmentId: attachment.attachmentId,
|
||||||
|
manifestNote: iconPackNote
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user