Pass styles to TextLine

pull/13/head
Xin Yao 4 years ago
parent b04f31e118
commit 4213aa1087
  1. 2
      lib/widgets/raw_editor.dart
  2. 3
      lib/widgets/text_block.dart
  3. 7
      lib/widgets/text_line.dart

@ -571,6 +571,7 @@ class RawEditorState extends EditorState
line: node, line: node,
textDirection: _textDirection, textDirection: _textDirection,
embedBuilder: widget.embedBuilder, embedBuilder: widget.embedBuilder,
styles: _styles,
); );
EditableTextLine editableTextLine = EditableTextLine( EditableTextLine editableTextLine = EditableTextLine(
node, node,
@ -594,6 +595,7 @@ class RawEditorState extends EditorState
_getVerticalSpacingForBlock(node, _styles), _getVerticalSpacingForBlock(node, _styles),
widget.controller.selection, widget.controller.selection,
widget.selectionColor, widget.selectionColor,
_styles,
widget.enableInteractiveSelection, widget.enableInteractiveSelection,
_hasFocus, _hasFocus,
attrs.containsKey(Attribute.codeBlock.key) attrs.containsKey(Attribute.codeBlock.key)

@ -53,6 +53,7 @@ class EditableTextBlock extends StatelessWidget {
final Tuple2 verticalSpacing; final Tuple2 verticalSpacing;
final TextSelection textSelection; final TextSelection textSelection;
final Color color; final Color color;
final DefaultStyles styles;
final bool enableInteractiveSelection; final bool enableInteractiveSelection;
final bool hasFocus; final bool hasFocus;
final EdgeInsets contentPadding; final EdgeInsets contentPadding;
@ -66,6 +67,7 @@ class EditableTextBlock extends StatelessWidget {
this.verticalSpacing, this.verticalSpacing,
this.textSelection, this.textSelection,
this.color, this.color,
this.styles,
this.enableInteractiveSelection, this.enableInteractiveSelection,
this.hasFocus, this.hasFocus,
this.contentPadding, this.contentPadding,
@ -117,6 +119,7 @@ class EditableTextBlock extends StatelessWidget {
line: line, line: line,
textDirection: textDirection, textDirection: textDirection,
embedBuilder: embedBuilder, embedBuilder: embedBuilder,
styles: styles,
), ),
_getIndentWidth(), _getIndentWidth(),
_getSpacingForLine(line, index, count, defaultStyles), _getSpacingForLine(line, index, count, defaultStyles),

@ -24,10 +24,13 @@ class TextLine extends StatelessWidget {
final Line line; final Line line;
final TextDirection textDirection; final TextDirection textDirection;
final EmbedBuilder embedBuilder; 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(line != null),
assert(embedBuilder != null), assert(embedBuilder != null),
assert(styles != null),
super(key: key); super(key: key);
@override @override
@ -77,7 +80,7 @@ class TextLine extends StatelessWidget {
} }
TextSpan _buildTextSpan(BuildContext context) { TextSpan _buildTextSpan(BuildContext context) {
DefaultStyles defaultStyles = DefaultStyles.getInstance(context); DefaultStyles defaultStyles = styles;
List<TextSpan> children = line.children List<TextSpan> children = line.children
.map((node) => _getTextSpanFromNode(defaultStyles, node)) .map((node) => _getTextSpanFromNode(defaultStyles, node))
.toList(growable: false); .toList(growable: false);

Loading…
Cancel
Save