Merge pull request #3038 from pangeachat/2975-bullet-text-size-inconsistency-in-reading-assistance

chore: fix text sizing in non-token elements of HTML messages
pull/2245/head
ggurdin 5 months ago committed by GitHub
commit 280087cfe6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -277,19 +277,7 @@ class HtmlMessage extends StatelessWidget {
// We must not render tags which are not in the allow list:
if (!allowedHtmlTags.contains(node.localName)) return const TextSpan();
switch (node.localName) {
// #Pangea
case 'token':
final token = getToken(
node.attributes['offset'] ?? '',
int.tryParse(node.attributes['offset'] ?? '') ?? 0,
int.tryParse(node.attributes['length'] ?? '') ?? 0,
);
final selected = token != null && isSelected != null
? isSelected!.call(token)
: false;
final renderer = TokenRenderingUtil(
pangeaMessageEvent: pangeaMessageEvent,
readingAssistanceMode: readingAssistanceMode,
@ -302,6 +290,20 @@ class HtmlMessage extends StatelessWidget {
overlayController: overlayController,
isTransitionAnimation: isTransitionAnimation,
);
// Pangea#
switch (node.localName) {
// #Pangea
case 'token':
final token = getToken(
node.attributes['offset'] ?? '',
int.tryParse(node.attributes['offset'] ?? '') ?? 0,
int.tryParse(node.attributes['length'] ?? '') ?? 0,
);
final selected = token != null && isSelected != null
? isSelected!.call(token)
: false;
final tokenWidth = renderer.tokenTextWidthForContainer(
context,
@ -493,11 +495,33 @@ class HtmlMessage extends StatelessWidget {
TextSpan(
children: [
if (node.parent?.localName == 'ul')
const TextSpan(text: ''),
// #Pangea
// const TextSpan(text: ''),
TextSpan(
text: '',
style: renderer.style(
context,
color: renderer.backgroundColor(
context,
false,
),
),
),
// Pangea#
if (node.parent?.localName == 'ol')
TextSpan(
text:
'${(node.parent?.nodes.whereType<dom.Element>().toList().indexOf(node) ?? 0) + (int.tryParse(node.parent?.attributes['start'] ?? '1') ?? 1)}. ',
// #Pangea
// style: textStyle,
style: renderer.style(
context,
color: renderer.backgroundColor(
context,
false,
),
),
// Pangea#
),
if (node.className == 'task-list-item')
WidgetSpan(

Loading…
Cancel
Save