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,
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)

@ -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),

@ -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<TextSpan> children = line.children
.map((node) => _getTextSpanFromNode(defaultStyles, node))
.toList(growable: false);

Loading…
Cancel
Save