From 19c2c7435a416cfde5c4066b652a1d7c6981b06b Mon Sep 17 00:00:00 2001 From: Frederic Cabassut Date: Thu, 5 Mar 2026 21:32:53 +0100 Subject: [PATCH] fix: render checklist items with checkboxes on note cards Checklist-mode notes now display as a visual checklist preview (up to 8 items with overflow indicator) instead of raw markdown checkbox syntax. Regular notes keep the truncated plain-text preview. Co-Authored-By: Claude Opus 4.6 --- src/lib/components/NoteCard.svelte | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) 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} +
    + {#each checklistItems.slice(0, 8) as item} +
  • + + {item.text} +
  • + {/each} + {#if checklistItems.length > 8} +
  • +{checklistItems.length - 8} more
  • + {/if} +
+ {:else if preview}

{preview}

{/if}