diff --git a/lib/main.dart b/lib/main.dart index e878060..caa48cb 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -644,8 +644,8 @@ class MainPageState extends State with WindowListener { // Build rich text with highlights for search results List _buildHighlightedText(String highlightedText) { List spans = []; - // The text comes with highlighted parts - RegExp exp = RegExp(r'(.*?)'); + // The text comes with highlighted parts + RegExp exp = RegExp(r'(.*?)'); int lastIndex = 0; for (final match in exp.allMatches(highlightedText)) { @@ -656,7 +656,7 @@ class MainPageState extends State with WindowListener { text: highlightedText.substring(lastIndex, match.start), style: const TextStyle( fontSize: 13, - ), // Smaller font for regular text + ), ), ); } @@ -669,7 +669,7 @@ class MainPageState extends State with WindowListener { fontWeight: FontWeight.bold, backgroundColor: Colors.yellow, color: Colors.black, - fontSize: 13, // Smaller font for highlighted text + fontSize: 13, ), ), ); @@ -682,7 +682,7 @@ class MainPageState extends State with WindowListener { spans.add( TextSpan( text: highlightedText.substring(lastIndex), - style: const TextStyle(fontSize: 13), // Smaller font for regular text + style: const TextStyle(fontSize: 13), ), ); } @@ -805,24 +805,13 @@ class MainPageState extends State with WindowListener { 12, // Smaller font for date ), ), - subtitle: - note.snippet != null - ? Text.rich( - TextSpan( - children: - _buildHighlightedText( - note.snippet!, - ), - ), - ) - : Text( - note.content.length > 200 - ? '${note.content.substring(0, 200)}...' - : note.content, - style: const TextStyle( - fontSize: 13, - ), // Smaller font for content - ), + subtitle: Text.rich( + TextSpan( + children: _buildHighlightedText( + note.snippet ?? note.content, + ), + ), + ), isThreeLine: true, onTap: () async { // Save current note if needed diff --git a/lib/meilisearch.dart b/lib/meilisearch.dart index 6c82eb3..8ba8485 100644 --- a/lib/meilisearch.dart +++ b/lib/meilisearch.dart @@ -184,8 +184,8 @@ Future> searchNotes(String query) async { limit: 10, attributesToHighlight: ['content'], showRankingScore: true, - highlightPreTag: '', - highlightPostTag: '', + highlightPreTag: '', + highlightPostTag: '', ); final response = await http.post( Uri.parse('$endpoint/indexes/$noteIndex/search'), @@ -201,7 +201,8 @@ Future> searchNotes(String query) async { (hit) => Note( id: hit['id'] as String, epochTime: hit['date'] as int, - content: hit['_formatted']['content'] as String, + content: hit['content'] as String, + snippet: hit['_formatted']['content'] as String, ), ) .toList();