Revert "aligns numerical and bullet lists along with text content (#1054)"

This reverts commit 1c5177953f.
pull/1061/head
X Code 2 years ago
parent afff4af768
commit 7e14392cc6
  1. 23
      lib/src/widgets/text_block.dart
  2. 17
      lib/src/widgets/text_line.dart

@ -134,7 +134,6 @@ class EditableTextBlock extends StatelessWidget {
_buildLeading(context, line, index, indentLevelCounts, count),
TextLine(
line: line,
index: index,
textDirection: textDirection,
embedBuilder: embedBuilder,
customStyleBuilder: customStyleBuilder,
@ -164,6 +163,25 @@ class EditableTextBlock extends StatelessWidget {
Map<int, int> indentLevelCounts, int count) {
final defaultStyles = QuillStyles.getStyles(context, false);
final attrs = line.style.attributes;
if (attrs[Attribute.list.key] == Attribute.ol) {
return QuillNumberPoint(
index: index,
indentLevelCounts: indentLevelCounts,
count: count,
style: defaultStyles!.leading!.style,
attrs: attrs,
width: 32,
padding: 8,
);
}
if (attrs[Attribute.list.key] == Attribute.ul) {
return QuillBulletPoint(
style:
defaultStyles!.leading!.style.copyWith(fontWeight: FontWeight.bold),
width: 32,
);
}
if (attrs[Attribute.list.key] == Attribute.checked) {
return CheckboxPoint(
@ -216,7 +234,8 @@ class EditableTextBlock extends StatelessWidget {
var baseIndent = 0.0;
if (attrs.containsKey(Attribute.codeBlock.key)) {
if (attrs.containsKey(Attribute.list.key) ||
attrs.containsKey(Attribute.codeBlock.key)) {
baseIndent = 32.0;
}

@ -38,14 +38,12 @@ class TextLine extends StatefulWidget {
required this.controller,
required this.onLaunchUrl,
required this.linkActionPicker,
this.index,
this.textDirection,
this.customStyleBuilder,
Key? key,
}) : super(key: key);
final Line line;
final int? index;
final TextDirection? textDirection;
final EmbedsBuilder embedBuilder;
final DefaultStyles styles;
@ -296,22 +294,9 @@ class _TextLineState extends State<TextLine> {
final nodeStyle = textNode.style;
final isLink = nodeStyle.containsKey(Attribute.link.key) &&
nodeStyle.attributes[Attribute.link.key]!.value != null;
final attrs = widget.line.style.attributes;
const whiteSpace = TextSpan(text: ' ');
var leading = const TextSpan();
if (attrs[Attribute.list.key] == Attribute.ol) {
leading = TextSpan(text: '${widget.index.toString()}.');
} else if (attrs[Attribute.list.key] == Attribute.ul) {
leading = TextSpan(
text: '',
style:
defaultStyles.leading!.style.copyWith(fontWeight: FontWeight.bold),
);
}
return TextSpan(
children: [leading, whiteSpace, TextSpan(text: textNode.value)],
text: textNode.value,
style: _getInlineTextStyle(
textNode, defaultStyles, nodeStyle, lineStyle, isLink),
recognizer: isLink && canLaunchLinks ? _getRecognizer(node) : null,

Loading…
Cancel
Save