MCPcopy
hub / github.com/callumalpass/tasknotes / createNoteCard

Function createNoteCard

src/ui/NoteCard.ts:26–163  ·  view source on GitHub ↗
(
	note: NoteInfo,
	plugin: TaskNotesPlugin,
	options: Partial<NoteCardOptions> = {}
)

Source from the content-addressed store, hash-verified

24 * Create a reusable note card element
25 */
26export function createNoteCard(
27 note: NoteInfo,
28 plugin: TaskNotesPlugin,
29 options: Partial<NoteCardOptions> = {}
30): HTMLElement {
31 const opts = { ...DEFAULT_NOTE_CARD_OPTIONS, ...options };
32
33 const item = activeDocument.createElement("div");
34 // Check if this is a daily note using the core plugin
35 let isDailyNote = false;
36 try {
37 const allDailyNotes = getAllDailyNotes();
38 isDailyNote = Object.values(allDailyNotes).some((file) => file.path === note.path);
39 } catch {
40 // Daily Notes interface not available, fallback to false
41 isDailyNote = false;
42 }
43
44 // Build BEM class names
45 const cardClasses = ["note-card"];
46
47 // Add modifiers
48 if (isDailyNote) cardClasses.push("note-card--daily-note");
49 cardClasses.push("note-card--compact", "note-card--shadow-light");
50
51 item.className = cardClasses.join(" ");
52 item.dataset.notePath = note.path;
53
54 // Daily note badge (if enabled and applicable)
55 if (opts.showDailyNoteBadge && isDailyNote) {
56 item.createSpan({
57 cls: "note-card__badge",
58 text: plugin.i18n.translate("ui.noteCard.dailyBadge"),
59 attr: { title: plugin.i18n.translate("ui.noteCard.dailyTooltip") },
60 });
61 }
62
63 // Main content container with icon
64 const mainRow = item.createDiv({ cls: "note-card__main-row" });
65
66 // Left indicator area: note icon
67 const leftIconWrap = mainRow.createEl("span", { cls: "note-card__icon" });
68 const leftIcon = leftIconWrap.createEl("span");
69 setIcon(leftIcon, "file-text");
70
71 // Content container
72 const contentContainer = mainRow.createDiv({ cls: "note-card__content" });
73
74 // Title
75 contentContainer.createDiv({
76 cls: "note-card__title",
77 text: note.title,
78 });
79
80 // Tags section (separate from other metadata)
81 if (opts.showTags && note.tags && note.tags.length > 0) {
82 // Divider line
83 contentContainer.createEl("div", { cls: "note-card__divider" });

Callers

nothing calls this directly

Calls 7

setIconFunction · 0.90
formatDateForDisplayFunction · 0.90
getAllDailyNotesFunction · 0.85
getAbstractFileByPathMethod · 0.80
getLeafMethod · 0.80
translateMethod · 0.65
triggerMethod · 0.65

Tested by

no test coverage detected