markdown support for talk messages

This commit is contained in:
2026-08-16 21:35:41 +02:00
parent bd83a88e70
commit 02a7b87b5b
14 changed files with 379 additions and 19 deletions
+21 -7
View File
@@ -8,6 +8,7 @@ import '../../../../model/endpoint_data.dart';
import '../../../../utils/emoji_detection.dart';
import '../../../../utils/url_opener.dart';
import '../widgets/highlighted_linkify.dart';
import '../widgets/message_markdown.dart';
class ChatMessage {
String originalMessage;
@@ -26,7 +27,11 @@ class ChatMessage {
);
}
Widget getWidget({String? highlightQuery, TextStyle? style}) {
Widget getWidget({
String? highlightQuery,
TextStyle? style,
bool renderMarkdown = false,
}) {
final emojiFontSize = standaloneEmojiFontSize(content);
final effectiveStyle = emojiFontSize == null
? style
@@ -35,12 +40,21 @@ class ChatMessage {
height: 1.15,
);
Widget contentWidget = HighlightedLinkify(
text: content,
onOpen: UrlOpener.onOpen,
highlight: highlightQuery,
style: effectiveStyle,
);
// Markdown replaces the plain linkified text only for regular messages.
// Emoji-only bodies keep their enlarged rendering, and while searching we
// fall back to the linkify path so matches can still be highlighted (the
// search highlight can't be threaded through Markdown formatting).
final hasQuery = highlightQuery?.trim().isNotEmpty ?? false;
final useMarkdown = renderMarkdown && emojiFontSize == null && !hasQuery;
var contentWidget = useMarkdown
? MessageMarkdown(data: content, style: effectiveStyle)
: HighlightedLinkify(
text: content,
onOpen: UrlOpener.onOpen,
highlight: highlightQuery,
style: effectiveStyle,
);
// Enlarged emoji glyphs otherwise sit flush against the bubble edges.
if (emojiFontSize != null) {