From 4213aa108708f05c196b923d26545456c82030f0 Mon Sep 17 00:00:00 2001 From: Xin Yao Date: Sat, 6 Feb 2021 10:29:51 -0800 Subject: [PATCH] Pass styles to TextLine --- lib/widgets/raw_editor.dart | 2 ++ lib/widgets/text_block.dart | 3 +++ lib/widgets/text_line.dart | 7 +++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/widgets/raw_editor.dart b/lib/widgets/raw_editor.dart index 05fe67e8..846bd91d 100644 --- a/lib/widgets/raw_editor.dart +++ b/lib/widgets/raw_editor.dart @@ -571,6 +571,7 @@ class RawEditorState extends EditorState line: node, textDirection: _textDirection, embedBuilder: widget.embedBuilder, + styles: _styles, ); EditableTextLine editableTextLine = EditableTextLine( node, @@ -594,6 +595,7 @@ class RawEditorState extends EditorState _getVerticalSpacingForBlock(node, _styles), widget.controller.selection, widget.selectionColor, + _styles, widget.enableInteractiveSelection, _hasFocus, attrs.containsKey(Attribute.codeBlock.key) diff --git a/lib/widgets/text_block.dart b/lib/widgets/text_block.dart index c17df2bd..f0bc6487 100644 --- a/lib/widgets/text_block.dart +++ b/lib/widgets/text_block.dart @@ -53,6 +53,7 @@ class EditableTextBlock extends StatelessWidget { final Tuple2 verticalSpacing; final TextSelection textSelection; final Color color; + final DefaultStyles styles; final bool enableInteractiveSelection; final bool hasFocus; final EdgeInsets contentPadding; @@ -66,6 +67,7 @@ class EditableTextBlock extends StatelessWidget { this.verticalSpacing, this.textSelection, this.color, + this.styles, this.enableInteractiveSelection, this.hasFocus, this.contentPadding, @@ -117,6 +119,7 @@ class EditableTextBlock extends StatelessWidget { line: line, textDirection: textDirection, embedBuilder: embedBuilder, + styles: styles, ), _getIndentWidth(), _getSpacingForLine(line, index, count, defaultStyles), diff --git a/lib/widgets/text_line.dart b/lib/widgets/text_line.dart index 973c99a9..c3d081c9 100644 --- a/lib/widgets/text_line.dart +++ b/lib/widgets/text_line.dart @@ -24,10 +24,13 @@ class TextLine extends StatelessWidget { final Line line; final TextDirection textDirection; final EmbedBuilder embedBuilder; + final DefaultStyles styles; - const TextLine({Key key, this.line, this.textDirection, this.embedBuilder}) + const TextLine( + {Key key, this.line, this.textDirection, this.embedBuilder, this.styles}) : assert(line != null), assert(embedBuilder != null), + assert(styles != null), super(key: key); @override @@ -77,7 +80,7 @@ class TextLine extends StatelessWidget { } TextSpan _buildTextSpan(BuildContext context) { - DefaultStyles defaultStyles = DefaultStyles.getInstance(context); + DefaultStyles defaultStyles = styles; List children = line.children .map((node) => _getTextSpanFromNode(defaultStyles, node)) .toList(growable: false);