Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(icons): draw spreadsheet files with a spreadsheet icon
Elian Doranc2714e6036d0
diff --git a/packages/commons/src/lib/notes.spec.ts b/packages/commons/src/lib/notes.spec.tsindex f2a8307a4a..e9c7d17179 100644--- a/packages/commons/src/lib/notes.spec.ts+++ b/packages/commons/src/lib/notes.spec.ts@@ -146,6 +146,17 @@ describe("getNoteIcon", () => {expect(icon).toBe("bx bx-trip");});+ it("marks every spreadsheet format as a spreadsheet", () => {+ for (const mime of [+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",+ "application/vnd.oasis.opendocument.spreadsheet",+ "application/vnd.ms-excel",+ "text/csv"+ ]) {+ expect(getNoteIcon(buildArgs({ type: "file", mime }))).toBe("bx bx-spreadsheet");+ }+ });+it("falls back to the file icon for a file note with an unmapped mime", () => {const icon = getNoteIcon(buildArgs({ type: "file", mime: "text/plain" }));expect(icon).toBe("bx bx-file");@@ -199,6 +210,8 @@ describe("getMimeIcon", () => {expect(getMimeIcon("image/gif")).toBe("bx bxs-file-gif");expect(getMimeIcon("image/png")).toBe("bx bx-image");expect(getMimeIcon("application/gpx+xml")).toBe("bx bx-trip");+ expect(getMimeIcon("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")).toBe("bx bx-spreadsheet");+ expect(getMimeIcon("text/csv")).toBe("bx bx-spreadsheet");expect(getMimeIcon("text/plain")).toBe("bx bx-file");});diff --git a/packages/commons/src/lib/notes.ts b/packages/commons/src/lib/notes.tsindex c9dfbb8a16..16442f732a 100644--- a/packages/commons/src/lib/notes.ts+++ b/packages/commons/src/lib/notes.ts@@ -83,6 +83,11 @@ const FILE_MIME_MAPPINGS: Record<string, string> = {"application/vnd.oasis.opendocument.text": "bx bxs-file-doc","application/vnd.openxmlformats-officedocument.wordprocessingml.document": "bx bxs-file-doc","application/gpx+xml": "bx bx-trip",+ // Workbooks kept as file notes or attachments, which `convertOfficeToHtml` previews as a grid.+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "bx bx-spreadsheet",+ "application/vnd.oasis.opendocument.spreadsheet": "bx bx-spreadsheet",+ "application/vnd.ms-excel": "bx bx-spreadsheet",+ "text/csv": "bx bx-spreadsheet",};const IMAGE_MIME_MAPPINGS: Record<string, string> = {