better link support
This commit is contained in:
parent
0c58ae562d
commit
7890add93c
1 changed files with 20 additions and 2 deletions
|
|
@ -112,7 +112,8 @@ class RoomChat extends HookConsumerWidget {
|
|||
builders: Builders(
|
||||
chatAnimatedListBuilder: (_, itemBuilder) =>
|
||||
ChatAnimatedList(
|
||||
itemBuilder: itemBuilder,
|
||||
itemBuilder:
|
||||
itemBuilder, // TODO: Load earlier
|
||||
onEndReached: notifier.loadOlder,
|
||||
onStartReached: () => notifier.markRead(),
|
||||
),
|
||||
|
|
@ -130,7 +131,24 @@ class RoomChat extends HookConsumerWidget {
|
|||
MessageGroupStatus? groupStatus,
|
||||
}) => FlyerChatTextMessage(
|
||||
customWidget: HtmlWidget(
|
||||
message.metadata?["formatted"],
|
||||
message.metadata?["formatted"].replaceAllMapped(
|
||||
RegExp(regexLink, unicode: true),
|
||||
(match) {
|
||||
final full = match.group(0)!;
|
||||
|
||||
// If no protocol is present, add https://
|
||||
final hasProtocol =
|
||||
full.startsWith("http://") ||
|
||||
full.startsWith("https://") ||
|
||||
full.startsWith("ftp://");
|
||||
|
||||
final url = hasProtocol
|
||||
? full
|
||||
: "https://$full";
|
||||
|
||||
return "<a href=\"$url\">$full</a>";
|
||||
},
|
||||
),
|
||||
customWidgetBuilder: (element) {
|
||||
if (element.localName == "mx-reply") {
|
||||
return SizedBox.shrink();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue