TF-806 open new tab when click link or tags a

This commit is contained in:
ManhNTX
2022-08-22 08:07:59 +07:00
committed by Dat H. Pham
parent fba2fec23c
commit fe0380b622
@@ -16,6 +16,7 @@ class MessageContentTransformer {
DioClient? dioClient
}
) async {
await _addTargetBlankInTagA(document);
await Future.wait([
if (configuration.domTransformers.isNotEmpty)
...configuration.domTransformers.map((domTransformer) async =>
@@ -26,6 +27,13 @@ class MessageContentTransformer {
]);
}
Future _addTargetBlankInTagA(Document document) async {
final elements = document.querySelectorAll('a');
await Future.wait(elements.map((element) async {
element.attributes['target'] = '_blank';
}));
}
Future<Document> toDocument(
String message,
{