Refactor code

pull/13/head
singerdmx 4 years ago
parent 96438514ba
commit e808d07ecc
  1. 14
      lib/widgets/raw_editor.dart
  2. 7
      lib/widgets/text_line.dart

@ -564,14 +564,15 @@ class RawEditorState extends EditorState
final result = <Widget>[]; final result = <Widget>[];
for (Node node in widget.controller.document.root.children) { for (Node node in widget.controller.document.root.children) {
if (node is Line) { if (node is Line) {
result.add(EditableTextLine( TextLine textLine = TextLine(
node,
null,
TextLine(
line: node, line: node,
textDirection: _textDirection, textDirection: _textDirection,
embedBuilder: widget.embedBuilder, embedBuilder: widget.embedBuilder,
), );
EditableTextLine editableTextLine = EditableTextLine(
node,
null,
textLine,
0, 0,
_getVerticalSpacingForLine(node, _styles), _getVerticalSpacingForLine(node, _styles),
_textDirection, _textDirection,
@ -580,7 +581,8 @@ class RawEditorState extends EditorState
widget.enableInteractiveSelection, widget.enableInteractiveSelection,
_hasFocus, _hasFocus,
MediaQuery.of(context).devicePixelRatio, MediaQuery.of(context).devicePixelRatio,
_cursorCont)); _cursorCont);
result.add(editableTextLine);
} else if (node is Block) { } else if (node is Block) {
Map<String, Attribute> attrs = node.style.attributes; Map<String, Attribute> attrs = node.style.attributes;
result.add(EditableTextBlock( result.add(EditableTextBlock(

@ -42,13 +42,14 @@ class TextLine extends StatelessWidget {
TextSpan textSpan = _buildTextSpan(context); TextSpan textSpan = _buildTextSpan(context);
StrutStyle strutStyle = StrutStyle strutStyle =
StrutStyle.fromTextStyle(textSpan.style, forceStrutHeight: true); StrutStyle.fromTextStyle(textSpan.style, forceStrutHeight: true);
return RichTextProxy( RichText child = RichText(
RichText(
text: _buildTextSpan(context), text: _buildTextSpan(context),
textDirection: textDirection, textDirection: textDirection,
strutStyle: strutStyle, strutStyle: strutStyle,
textScaleFactor: MediaQuery.textScaleFactorOf(context), textScaleFactor: MediaQuery.textScaleFactorOf(context),
), );
return RichTextProxy(
child,
textSpan.style, textSpan.style,
textDirection, textDirection,
1.0, 1.0,

Loading…
Cancel
Save