@@ -155,112 +155,49 @@ CustomRender blockElementRender({Style? style, List<InlineSpan>? children}) =>
155
155
});
156
156
157
157
CustomRender listElementRender (
158
- {Style ? style, Widget ? child, List <InlineSpan >? children}) =>
159
- CustomRender .inlineSpan (
160
- inlineSpan: (context, buildChildren) {
161
- final listStyleType = style? .listStyleType ??
162
- context.style. listStyleType ??
163
- ListStyleType .decimal;
164
- final counterStyle =
165
- CounterStyleRegistry . lookup (listStyleType.counterStyle) ;
166
- String counterContent;
167
- if (style ? .marker ? .content.isNormal ??
168
- context.style.marker ? .content.isNormal ??
169
- true ) {
170
- counterContent = counterStyle. generateMarkerContent (
171
- context.tree.counters.lastOrNull ? .value ?? 0 ) ;
172
- } else if ( ! (style ? .marker ? .content.display ??
173
- context.style. marker? .content.display ??
174
- true )) {
175
- counterContent = '' ;
176
- } else {
177
- counterContent = style ? .marker ? .content.replacementContent ??
178
- context.style.marker ? .content.replacementContent ??
179
- counterStyle. generateMarkerContent (
180
- context.tree.counters.lastOrNull ? .value ?? 0 );
181
- }
182
- final markerWidget = counterContent.isNotEmpty
183
- ? Text . rich ( TextSpan (
158
+ {Style ? style, Widget ? child, List <InlineSpan >? children}) {
159
+ return CustomRender .inlineSpan (
160
+ inlineSpan: (context, buildChildren) {
161
+ final usedStyle = style ?? context.style;
162
+ final listStyleType = usedStyle. listStyleType ?? ListStyleType .decimal;
163
+ final counterStyle =
164
+ CounterStyleRegistry . lookup (listStyleType.counterStyle);
165
+ String counterContent ;
166
+ if (usedStyle.marker ? .content.isNormal ?? true ) {
167
+ counterContent = counterStyle. generateMarkerContent (
168
+ context.tree.counters.lastOrNull ? .value ?? 0 ,
169
+ );
170
+ } else if ( ! (usedStyle.marker ? .content.display ?? true )) {
171
+ counterContent = '' ;
172
+ } else {
173
+ counterContent = usedStyle. marker? .content.replacementContent ??
174
+ counterStyle. generateMarkerContent (
175
+ context.tree.counters.lastOrNull ? .value ?? 0 ,
176
+ );
177
+ }
178
+ final listChildren = buildChildren ()
179
+ .. insertAll (
180
+ 0 ,
181
+ [
182
+ if (usedStyle.listStylePosition == ListStylePosition .inside)
183
+ TextSpan (
184
184
text: counterContent,
185
- style: context.tree.style.marker? .style? .generateTextStyle (),
186
- ))
187
- : const SizedBox (width: 0 , height: 0 ); //TODO this is hardcoded
188
-
189
- return WidgetSpan (
190
- child: CssBoxWidget (
191
- key: context.key,
192
- style: style ?? context.tree.style,
193
- shrinkWrap: context.parser.shrinkWrap,
194
- child: Row (
195
- crossAxisAlignment: CrossAxisAlignment .start,
196
- mainAxisSize: MainAxisSize .min,
197
- textDirection: style? .direction ?? context.tree.style.direction,
198
- children: [
199
- (style? .listStylePosition ??
200
- context.tree.style.listStylePosition) ==
201
- ListStylePosition .outside
202
- ? Padding (
203
- padding: style? .padding? .nonNegative ??
204
- context.tree.style.padding? .nonNegative ??
205
- EdgeInsets .only (
206
- left: (style? .direction ??
207
- context.tree.style.direction) !=
208
- TextDirection .rtl
209
- ? 10.0
210
- : 0.0 ,
211
- right: (style? .direction ??
212
- context.tree.style.direction) ==
213
- TextDirection .rtl
214
- ? 10.0
215
- : 0.0 ),
216
- child: markerWidget,
217
- )
218
- : const SizedBox (height: 0 , width: 0 ),
219
- const Text ("\u 0020" ,
220
- textAlign: TextAlign .right,
221
- style: TextStyle (fontWeight: FontWeight .w400)),
222
- Expanded (
223
- child: Padding (
224
- padding: (style? .listStylePosition ??
225
- context.tree.style.listStylePosition) ==
226
- ListStylePosition .inside
227
- ? EdgeInsets .only (
228
- left: (style? .direction ??
229
- context.tree.style.direction) !=
230
- TextDirection .rtl
231
- ? 10.0
232
- : 0.0 ,
233
- right: (style? .direction ??
234
- context.tree.style.direction) ==
235
- TextDirection .rtl
236
- ? 10.0
237
- : 0.0 )
238
- : EdgeInsets .zero,
239
- child: CssBoxWidget .withInlineSpanChildren (
240
- children: _getListElementChildren (
241
- style? .listStylePosition ??
242
- context.tree.style.listStylePosition,
243
- buildChildren)
244
- ..insertAll (
245
- 0 ,
246
- context.tree.style.listStylePosition ==
247
- ListStylePosition .inside
248
- ? [
249
- WidgetSpan (
250
- alignment: PlaceholderAlignment .middle,
251
- child: markerWidget)
252
- ]
253
- : []),
254
- style: style ?? context.style,
255
- ),
256
- ),
257
- ),
258
- ],
259
- ),
260
- ),
185
+ style: usedStyle.marker? .style? .generateTextStyle (),
186
+ ),
187
+ ],
261
188
);
262
- },
263
- );
189
+
190
+ return WidgetSpan (
191
+ child: CssBoxWidget .withInlineSpanChildren (
192
+ key: context.key,
193
+ style: usedStyle,
194
+ shrinkWrap: context.parser.shrinkWrap,
195
+ children: listChildren,
196
+ ),
197
+ );
198
+ },
199
+ );
200
+ }
264
201
265
202
CustomRender replacedElementRender (
266
203
{PlaceholderAlignment ? alignment,
@@ -546,20 +483,6 @@ Map<CustomRenderMatcher, CustomRender> generateDefaultRenders() {
546
483
};
547
484
}
548
485
549
- List <InlineSpan > _getListElementChildren (
550
- ListStylePosition ? position, Function () buildChildren) {
551
- List <InlineSpan > children = buildChildren.call ();
552
- if (position == ListStylePosition .inside) {
553
- const tabSpan = WidgetSpan (
554
- child: Text ("\t " ,
555
- textAlign: TextAlign .right,
556
- style: TextStyle (fontWeight: FontWeight .w400)),
557
- );
558
- children.insert (0 , tabSpan);
559
- }
560
- return children;
561
- }
562
-
563
486
InlineSpan _getInteractableChildren (RenderContext context,
564
487
InteractableElement tree, InlineSpan childSpan, TextStyle childStyle) {
565
488
if (childSpan is TextSpan ) {
0 commit comments