From 7e14392cc6ca28344168dab01d0e1304e2c600d2 Mon Sep 17 00:00:00 2001 From: X Code Date: Wed, 11 Jan 2023 12:48:27 -0800 Subject: [PATCH] Revert "aligns numerical and bullet lists along with text content (#1054)" This reverts commit 1c5177953ff8687c1283578c258c75de023c6aff. --- lib/src/widgets/text_block.dart | 23 +++++++++++++++++++++-- lib/src/widgets/text_line.dart | 17 +---------------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/lib/src/widgets/text_block.dart b/lib/src/widgets/text_block.dart index b5790e96..2073ba0d 100644 --- a/lib/src/widgets/text_block.dart +++ b/lib/src/widgets/text_block.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 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; } diff --git a/lib/src/widgets/text_line.dart b/lib/src/widgets/text_line.dart index f3594a91..b20ea22f 100644 --- a/lib/src/widgets/text_line.dart +++ b/lib/src/widgets/text_line.dart @@ -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 { 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,