mirror of
https://github.com/zadam/trilium.git
synced 2026-01-18 12:34:24 +01:00
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
/**
|
|
* @module notes Common logic for notes (across front-end and back-end)
|
|
*/
|
|
|
|
import { MIME_TYPES_DICT } from "./mime_type.js";
|
|
import { NoteType } from "./rows.js";
|
|
|
|
export const NOTE_TYPE_ICONS = {
|
|
file: "bx bx-file",
|
|
image: "bx bx-image",
|
|
code: "bx bx-code",
|
|
render: "bx bx-extension",
|
|
search: "bx bx-file-find",
|
|
relationMap: "bx bxs-network-chart",
|
|
book: "bx bx-book",
|
|
noteMap: "bx bxs-network-chart",
|
|
mermaid: "bx bx-selection",
|
|
canvas: "bx bx-pen",
|
|
webView: "bx bx-globe-alt",
|
|
launcher: "bx bx-link",
|
|
doc: "bx bxs-file-doc",
|
|
contentWidget: "bx bxs-widget",
|
|
mindMap: "bx bx-sitemap",
|
|
aiChat: "bx bx-bot"
|
|
};
|
|
|
|
export function getNoteIcon({ noteId, type, mime, iconClass, workspaceIconClass, isFolder }: {
|
|
noteId: string;
|
|
type: NoteType;
|
|
mime: string;
|
|
iconClass: string | undefined;
|
|
workspaceIconClass: string | undefined;
|
|
isFolder: () => boolean;
|
|
}) {
|
|
if (iconClass) {
|
|
return iconClass;
|
|
} else if (workspaceIconClass) {
|
|
return workspaceIconClass;
|
|
} else if (noteId === "root") {
|
|
return "bx bx-home-alt-2";
|
|
}
|
|
if (noteId === "_share") {
|
|
return "bx bx-share-alt";
|
|
} else if (type === "text") {
|
|
if (isFolder()) {
|
|
return "bx bx-folder";
|
|
}
|
|
return "bx bx-note";
|
|
} else if (type === "code") {
|
|
const correspondingMimeType = MIME_TYPES_DICT.find(m => m.mime === mime);
|
|
return correspondingMimeType?.icon ?? NOTE_TYPE_ICONS.code;
|
|
}
|
|
return NOTE_TYPE_ICONS[type];
|
|
}
|