diff --git a/src/lib/components/NoteCard.svelte b/src/lib/components/NoteCard.svelte index 05ff018..49398d8 100644 --- a/src/lib/components/NoteCard.svelte +++ b/src/lib/components/NoteCard.svelte @@ -5,6 +5,11 @@ import { togglePin, trashNote, archiveNote, unarchiveNote, restoreNote, deleteNote, currentFilter } from '$lib/stores/notes.js'; import type { Note } from '$lib/types/index.js'; + interface ChecklistItem { + text: string; + checked: boolean; + } + interface Props { note: Note; onEdit: (note: Note) => void; @@ -22,6 +27,15 @@ const preview = $derived(stripMarkdown(note.content).slice(0, 200)); + const checklistItems = $derived( + note.checklistMode + ? note.content.split('\n').filter(l => l.trim()).map(line => ({ + text: line.replace(/^- \[[ x]\] /, ''), + checked: line.startsWith('- [x] ') + })) + : [] + ); + function stop(fn: () => void) { return (e: Event) => { e.stopPropagation(); @@ -44,7 +58,19 @@

{note.title}

{/if} - {#if preview} + {#if note.checklistMode && checklistItems.length > 0} + + {:else if preview}

{preview}

{/if}