-
-
Notifications
You must be signed in to change notification settings - Fork 901
[FEATURE] align support #1071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This property is deprecated and not (officially) supported in html5. I am not sure if we should therefor support it in our package. On the other hand, we did decide to add support for the similarly deprecated font tag (see #277) so I guess we could? |
Well, there's probably an immense amount of HTML out there that still uses it, so I'd say it makes sense. |
Wouldn't hurt for backwards compatibility. Obviously we must draw the line somewhere when it comes to deprecated items. I'll look into this. |
@Sub6Resources I think it should have to do with usefulness and willingness. |
I agree. Shouldn't be too hard using those parameters. Thanks @TheCarpetMerchant |
Following up on this ; At first glance I'm seeing that |
Yes, there are a couple other elements that use the inline attributes for styling purposes. I'm pretty busy and can't promise a quick implementation, but you are more than welcome to submit a pull request! |
Used such workaround, seems to be working class AppHtmlView extends StatelessWidget {
final String html;
final EdgeInsets? margin;
final TextAlign? textAlign;
const AppHtmlView({
super.key,
required this.html,
this.margin,
this.textAlign,
});
@override
Widget build(BuildContext context) {
TextAlign? textAlign;
return Html(
data: html,
customRenders: {
(RenderContext c) {
final el = c.tree.element;
final isCenterElement = el?.localName == 'center';
if (isCenterElement) {
textAlign = TextAlign.center;
return isCenterElement;
}
final style = el?.attributes['style'];
if (style == null) return false;
textAlign = null;
for (final s in style.split(';')) {
if (!s.startsWith('text-align')) continue;
textAlign = TextAlign.values
.firstWhereOrNull((e) => e.name == s.split(':').last.trim());
break;
}
return textAlign != null;
}: CustomRender.widget(
widget: (c, _) => SizedBox(
width: MediaQuery.of(context).size.width,
child: AppHtmlView(
html: c.tree.element!.innerHtml,
textAlign: textAlign,
margin: EdgeInsets.zero,
),
),
),
},
shrinkWrap: true,
style: {
'*': Style(
textAlign: this.textAlign,
margin: margin,
),
},
);
}
} |
I'm not seeing the
align
tag in the Supported list, buttext-align
is, for example.Could it be possible to provide support for
align
, ie this being centered :The text was updated successfully, but these errors were encountered: