Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions app/src/main/java/com/astralquarks/notes/ui/components/NoteCard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
Expand Down Expand Up @@ -50,6 +51,7 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.luminance
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextDecoration
Expand All @@ -59,6 +61,7 @@ import androidx.compose.ui.unit.sp
import coil.compose.AsyncImage
import com.astralquarks.notes.model.Note
import com.astralquarks.notes.model.NoteColorPalette
import com.astralquarks.notes.markdown.MarkdownRenderer
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
Expand Down Expand Up @@ -115,13 +118,6 @@ fun NoteCard(
}
}

val plainContentPreview = remember(note.content) {
if (checklistItems.isNotEmpty()) ""
else {
val sample = if (note.content.length > 250) note.content.take(250) else note.content
sample.replace(MD_FORMAT_REGEX, " ").trim()
}
}

Card(
onClick = onClick,
Expand Down Expand Up @@ -225,17 +221,15 @@ fun NoteCard(
}
}
}
} else if (plainContentPreview.isNotBlank()) {
} else if (note.content.isNotBlank()) {
Spacer(modifier = Modifier.height(4.dp))
Text(
text = plainContentPreview,
style = MaterialTheme.typography.bodyMedium.copy(
color = secondaryTextColor,
lineHeight = 20.sp
),
maxLines = 5,
overflow = TextOverflow.Ellipsis
)
Box(modifier = Modifier.heightIn(max = 100.dp).clipToBounds()) {
MarkdownRenderer(
markdown = note.content,
textColor = secondaryTextColor,
modifier = Modifier.fillMaxWidth()
)
}
}

// Tags flow row
Expand Down
7 changes: 1 addition & 6 deletions web/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -656,11 +656,6 @@ class AstralNotesApp {
day: 'numeric'
});

const cleanSnippet = note.content
.replace(/#+\s*/g, '')
.replace(/!\[.*?\]\(.*?\)/g, '[Image]')
.slice(0, 180);

const borderStyle = note.colorHex && note.colorHex !== '#DEFAULT'
? `style="border-left: 4px solid ${note.colorHex};"`
: '';
Expand All @@ -673,7 +668,7 @@ class AstralNotesApp {
${getIconSvg('pin', 16)}
</button>
</div>
<p class="note-card-snippet">${cleanSnippet || 'Empty note...'}</p>
<div class="note-card-snippet markdown-preview">${renderMarkdown(note.content) || 'Empty note...'}</div>
${note.tags.length > 0 ? `
<div class="note-card-tags">
${note.tags.map(t => `<span class="tag-chip">#${t}</span>`).join('')}
Expand Down
17 changes: 17 additions & 0 deletions web/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,23 @@ body {
flex: 1;
}

.note-card-snippet.markdown-preview {
max-height: 150px;
display: block;
}

.note-card-snippet.markdown-preview > * {
margin-bottom: 0.5rem;
}

.note-card-snippet.markdown-preview > *:last-child {
margin-bottom: 0;
}

.note-card-snippet.markdown-preview p {
margin: 0;
}

.note-card-tags {
display: flex;
flex-wrap: wrap;
Expand Down