mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 09:05:10 +00:00
fix: Render tg-forward html tags
This commit is contained in:
parent
21af30e4c5
commit
172cd651fc
1 changed files with 20 additions and 1 deletions
|
@ -156,6 +156,7 @@ class HtmlMessage extends StatelessWidget {
|
|||
SpoilerExtension(textColor: textColor),
|
||||
const ImageExtension(),
|
||||
FontColorExtension(),
|
||||
FallbackTextExtension(fontSize: fontSize),
|
||||
],
|
||||
onLinkTap: (url, _, element) => UrlLauncher(
|
||||
context,
|
||||
|
@ -172,6 +173,8 @@ class HtmlMessage extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
static const Set<String> fallbackTextTags = {'tg-forward'};
|
||||
|
||||
/// Keep in sync with: https://spec.matrix.org/v1.6/client-server-api/#mroommessage-msgtypes
|
||||
static const Set<String> allowedHtmlTags = {
|
||||
'font',
|
||||
|
@ -217,7 +220,7 @@ class HtmlMessage extends StatelessWidget {
|
|||
'rp',
|
||||
'rt',
|
||||
// Workaround for https://github.com/krille-chan/fluffychat/issues/507
|
||||
'tg-forward',
|
||||
...fallbackTextTags,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -410,6 +413,22 @@ class CodeExtension extends HtmlExtension {
|
|||
);
|
||||
}
|
||||
|
||||
class FallbackTextExtension extends HtmlExtension {
|
||||
final double fontSize;
|
||||
|
||||
FallbackTextExtension({required this.fontSize});
|
||||
@override
|
||||
Set<String> get supportedTags => HtmlMessage.fallbackTextTags;
|
||||
|
||||
@override
|
||||
InlineSpan build(ExtensionContext context) => TextSpan(
|
||||
text: context.element?.text ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: fontSize,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class RoomPillExtension extends HtmlExtension {
|
||||
final Room room;
|
||||
final BuildContext context;
|
||||
|
|
Loading…
Reference in a new issue