@@ -59,6 +59,7 @@ class HtmlParser extends StatelessWidget {
59
59
final NavigationDelegate ? navigationDelegateForIframe;
60
60
final OnTap ? _onAnchorTap;
61
61
final TextSelectionControls ? selectionControls;
62
+ final ScrollPhysics ? scrollPhysics;
62
63
63
64
HtmlParser ({
64
65
required this .key,
@@ -76,7 +77,8 @@ class HtmlParser extends StatelessWidget {
76
77
required this .imageRenders,
77
78
required this .tagsList,
78
79
required this .navigationDelegateForIframe,
79
- this .selectionControls
80
+ this .selectionControls,
81
+ this .scrollPhysics,
80
82
}) : this ._onAnchorTap = onAnchorTap != null
81
83
? onAnchorTap
82
84
: key != null
@@ -128,6 +130,7 @@ class HtmlParser extends StatelessWidget {
128
130
style: cleanedTree.style,
129
131
),
130
132
selectionControls: selectionControls,
133
+ scrollPhysics: scrollPhysics,
131
134
);
132
135
}
133
136
return StyledText (
@@ -420,11 +423,7 @@ class HtmlParser extends StatelessWidget {
420
423
tree.style.listStylePosition == ListStylePosition .OUTSIDE ?
421
424
Padding (
422
425
padding: tree.style.padding ?? EdgeInsets .only (left: tree.style.direction != TextDirection .rtl ? 10.0 : 0.0 , right: tree.style.direction == TextDirection .rtl ? 10.0 : 0.0 ),
423
- child: Text (
424
- "${newContext .style .markerContent }" ,
425
- textAlign: TextAlign .right,
426
- style: newContext.style.generateTextStyle ()
427
- ),
426
+ child: newContext.style.markerContent
428
427
) : Container (height: 0 , width: 0 ),
429
428
Text ("\t " , textAlign: TextAlign .right),
430
429
Expanded (
@@ -433,11 +432,10 @@ class HtmlParser extends StatelessWidget {
433
432
EdgeInsets .only (left: tree.style.direction != TextDirection .rtl ? 10.0 : 0.0 , right: tree.style.direction == TextDirection .rtl ? 10.0 : 0.0 ) : EdgeInsets .zero,
434
433
child: StyledText (
435
434
textSpan: TextSpan (
436
- text: (tree.style.listStylePosition ==
437
- ListStylePosition .INSIDE )
438
- ? '${newContext .style .markerContent }'
439
- : null ,
440
- children: getChildren (tree),
435
+ children: getChildren (tree)..insertAll (0 , tree.style.listStylePosition == ListStylePosition .INSIDE ?
436
+ [
437
+ WidgetSpan (alignment: PlaceholderAlignment .middle, child: newContext.style.markerContent ?? Container (height: 0 , width: 0 ))
438
+ ] : []),
441
439
style: newContext.style.generateTextStyle (),
442
440
),
443
441
style: newContext.style,
@@ -451,12 +449,12 @@ class HtmlParser extends StatelessWidget {
451
449
);
452
450
} else if (tree is ReplacedElement ) {
453
451
if (tree is TextContentElement ) {
454
- return TextSpan (text: tree.text);
452
+ return TextSpan (text: tree.text? . transformed (tree.style.textTransform) );
455
453
} else {
456
454
return WidgetSpan (
457
455
alignment: tree.alignment,
458
456
baseline: TextBaseline .alphabetic,
459
- child: tree.toWidget (context )! ,
457
+ child: tree.toWidget (newContext )! ,
460
458
);
461
459
}
462
460
} else if (tree is InteractableElement ) {
@@ -708,7 +706,10 @@ class HtmlParser extends StatelessWidget {
708
706
/// bullet all list items according to the [ListStyleType] they have been given.
709
707
static StyledElement _processListCharactersRecursive (
710
708
StyledElement tree, ListQueue <Context > olStack) {
711
- if (tree.name == 'ol' && tree.style.listStyleType != null ) {
709
+ if (tree.style.listStylePosition == null ) {
710
+ tree.style.listStylePosition = ListStylePosition .OUTSIDE ;
711
+ }
712
+ if (tree.name == 'ol' && tree.style.listStyleType != null && tree.style.listStyleType! .type == "marker" ) {
712
713
switch (tree.style.listStyleType! ) {
713
714
case ListStyleType .LOWER_LATIN :
714
715
case ListStyleType .LOWER_ALPHA :
@@ -728,26 +729,31 @@ class HtmlParser extends StatelessWidget {
728
729
olStack.add (Context <int >((tree.attributes['start' ] != null ? int .tryParse (tree.attributes['start' ] ?? "" ) ?? 1 : 1 ) - 1 ));
729
730
break ;
730
731
}
732
+ } else if (tree.style.display == Display .LIST_ITEM && tree.style.listStyleType != null && tree.style.listStyleType! .type == "widget" ) {
733
+ tree.style.markerContent = tree.style.listStyleType! .widget! ;
734
+ } else if (tree.style.display == Display .LIST_ITEM && tree.style.listStyleType != null && tree.style.listStyleType! .type == "image" ) {
735
+ tree.style.markerContent = Image .network (tree.style.listStyleType! .text);
731
736
} else if (tree.style.display == Display .LIST_ITEM && tree.style.listStyleType != null ) {
737
+ String marker = "" ;
732
738
switch (tree.style.listStyleType! ) {
733
739
case ListStyleType .NONE :
734
740
tree.style.markerContent = '' ;
735
741
break ;
736
742
case ListStyleType .CIRCLE :
737
- tree.style.markerContent = '○' ;
743
+ marker = '○' ;
738
744
break ;
739
745
case ListStyleType .SQUARE :
740
- tree.style.markerContent = '■' ;
746
+ marker = '■' ;
741
747
break ;
742
748
case ListStyleType .DISC :
743
- tree.style.markerContent = '•' ;
749
+ marker = '•' ;
744
750
break ;
745
751
case ListStyleType .DECIMAL :
746
752
if (olStack.isEmpty) {
747
753
olStack.add (Context <int >((tree.attributes['start' ] != null ? int .tryParse (tree.attributes['start' ] ?? "" ) ?? 1 : 1 ) - 1 ));
748
754
}
749
755
olStack.last.data += 1 ;
750
- tree.style.markerContent = '${olStack .last .data }.' ;
756
+ marker = '${olStack .last .data }.' ;
751
757
break ;
752
758
case ListStyleType .LOWER_LATIN :
753
759
case ListStyleType .LOWER_ALPHA :
@@ -762,7 +768,7 @@ class HtmlParser extends StatelessWidget {
762
768
}
763
769
}
764
770
}
765
- tree.style.markerContent = olStack.last.data.toString () + "." ;
771
+ marker = olStack.last.data.toString () + "." ;
766
772
olStack.last.data = olStack.last.data.toString ().nextLetter ();
767
773
break ;
768
774
case ListStyleType .UPPER_LATIN :
@@ -778,7 +784,7 @@ class HtmlParser extends StatelessWidget {
778
784
}
779
785
}
780
786
}
781
- tree.style.markerContent = olStack.last.data.toString ().toUpperCase () + "." ;
787
+ marker = olStack.last.data.toString ().toUpperCase () + "." ;
782
788
olStack.last.data = olStack.last.data.toString ().nextLetter ();
783
789
break ;
784
790
case ListStyleType .LOWER_ROMAN :
@@ -787,9 +793,9 @@ class HtmlParser extends StatelessWidget {
787
793
}
788
794
olStack.last.data += 1 ;
789
795
if (olStack.last.data <= 0 ) {
790
- tree.style.markerContent = '${olStack .last .data }.' ;
796
+ marker = '${olStack .last .data }.' ;
791
797
} else {
792
- tree.style.markerContent = (olStack.last.data as int ).toRomanNumeralString ()! .toLowerCase () + "." ;
798
+ marker = (olStack.last.data as int ).toRomanNumeralString ()! .toLowerCase () + "." ;
793
799
}
794
800
break ;
795
801
case ListStyleType .UPPER_ROMAN :
@@ -798,12 +804,16 @@ class HtmlParser extends StatelessWidget {
798
804
}
799
805
olStack.last.data += 1 ;
800
806
if (olStack.last.data <= 0 ) {
801
- tree.style.markerContent = '${olStack .last .data }.' ;
807
+ marker = '${olStack .last .data }.' ;
802
808
} else {
803
- tree.style.markerContent = (olStack.last.data as int ).toRomanNumeralString ()! + "." ;
809
+ marker = (olStack.last.data as int ).toRomanNumeralString ()! + "." ;
804
810
}
805
811
break ;
806
812
}
813
+ tree.style.markerContent = Text (
814
+ marker,
815
+ textAlign: TextAlign .right,
816
+ );
807
817
}
808
818
809
819
tree.children.forEach ((e) => _processListCharactersRecursive (e, olStack));
@@ -1067,6 +1077,7 @@ class StyledText extends StatelessWidget {
1067
1077
final AnchorKey ? key;
1068
1078
final bool _selectable;
1069
1079
final TextSelectionControls ? selectionControls;
1080
+ final ScrollPhysics ? scrollPhysics;
1070
1081
1071
1082
const StyledText ({
1072
1083
required this .textSpan,
@@ -1075,6 +1086,7 @@ class StyledText extends StatelessWidget {
1075
1086
required this .renderContext,
1076
1087
this .key,
1077
1088
this .selectionControls,
1089
+ this .scrollPhysics,
1078
1090
}) : _selectable = false ,
1079
1091
super (key: key);
1080
1092
@@ -1084,7 +1096,8 @@ class StyledText extends StatelessWidget {
1084
1096
this .textScaleFactor = 1.0 ,
1085
1097
required this .renderContext,
1086
1098
this .key,
1087
- this .selectionControls
1099
+ this .selectionControls,
1100
+ this .scrollPhysics,
1088
1101
}) : textSpan = textSpan,
1089
1102
_selectable = true ,
1090
1103
super (key: key);
@@ -1100,6 +1113,7 @@ class StyledText extends StatelessWidget {
1100
1113
textScaleFactor: textScaleFactor,
1101
1114
maxLines: style.maxLines,
1102
1115
selectionControls: selectionControls,
1116
+ scrollPhysics: scrollPhysics,
1103
1117
);
1104
1118
}
1105
1119
return SizedBox (
0 commit comments