Reformat code

pull/1134/head
X Code 2 years ago
parent 3e9452e675
commit 3c64a08c6a
  1. 10
      lib/src/models/rules/insert.dart
  2. 21
      lib/src/widgets/default_styles.dart
  3. 3
      lib/src/widgets/raw_editor.dart
  4. 10
      lib/src/widgets/toolbar/link_style_button.dart

@ -83,9 +83,8 @@ class PreserveBlockStyleOnInsertRule extends InsertRule {
// Look for the next newline. // Look for the next newline.
final nextNewLine = _getNextNewLine(itr); final nextNewLine = _getNextNewLine(itr);
final lineStyle = final lineStyle = Style.fromJson(
Style.fromJson( nextNewLine.operation?.attributes ?? <String, dynamic>{});
nextNewLine.operation?.attributes ?? <String, dynamic>{});
final blockStyle = lineStyle.getBlocksExceptHeader(); final blockStyle = lineStyle.getBlocksExceptHeader();
// Are we currently in a block? If not then ignore. // Are we currently in a block? If not then ignore.
@ -189,8 +188,9 @@ class AutoExitBlockRule extends InsertRule {
final nextNewLine = _getNextNewLine(itr); final nextNewLine = _getNextNewLine(itr);
if (nextNewLine.operation != null && if (nextNewLine.operation != null &&
nextNewLine.operation!.attributes != null && nextNewLine.operation!.attributes != null &&
Style.fromJson(nextNewLine.operation!.attributes).getBlockExceptHeader() Style.fromJson(nextNewLine.operation!.attributes)
== blockStyle) { .getBlockExceptHeader() ==
blockStyle) {
// We are not at the end of this block, ignore. // We are not at the end of this block, ignore.
return null; return null;
} }

@ -241,11 +241,8 @@ class DefaultStyles {
const VerticalSpacing(8, 0), const VerticalSpacing(8, 0),
const VerticalSpacing(0, 0), const VerticalSpacing(0, 0),
null), null),
paragraph: DefaultTextBlockStyle( paragraph: DefaultTextBlockStyle(baseStyle, const VerticalSpacing(0, 0),
baseStyle, const VerticalSpacing(0, 0), null),
const VerticalSpacing(0, 0),
const VerticalSpacing(0, 0),
null),
bold: const TextStyle(fontWeight: FontWeight.bold), bold: const TextStyle(fontWeight: FontWeight.bold),
italic: const TextStyle(fontStyle: FontStyle.italic), italic: const TextStyle(fontStyle: FontStyle.italic),
small: const TextStyle(fontSize: 12), small: const TextStyle(fontSize: 12),
@ -304,16 +301,10 @@ class DefaultStyles {
)), )),
indent: DefaultTextBlockStyle( indent: DefaultTextBlockStyle(
baseStyle, baseSpacing, const VerticalSpacing(0, 6), null), baseStyle, baseSpacing, const VerticalSpacing(0, 6), null),
align: DefaultTextBlockStyle( align: DefaultTextBlockStyle(baseStyle, const VerticalSpacing(0, 0),
baseStyle, const VerticalSpacing(0, 0), null),
const VerticalSpacing(0, 0), leading: DefaultTextBlockStyle(baseStyle, const VerticalSpacing(0, 0),
const VerticalSpacing(0, 0), const VerticalSpacing(0, 0), null),
null),
leading: DefaultTextBlockStyle(
baseStyle,
const VerticalSpacing(0, 0),
const VerticalSpacing(0, 0),
null),
sizeSmall: const TextStyle(fontSize: 10), sizeSmall: const TextStyle(fontSize: 10),
sizeLarge: const TextStyle(fontSize: 18), sizeLarge: const TextStyle(fontSize: 18),
sizeHuge: const TextStyle(fontSize: 22)); sizeHuge: const TextStyle(fontSize: 22));

@ -1281,8 +1281,7 @@ class RawEditorState extends EditorState
final index = textEditingValue.selection.baseOffset; final index = textEditingValue.selection.baseOffset;
final length = textEditingValue.selection.extentOffset - index; final length = textEditingValue.selection.extentOffset - index;
final copied = controller.copiedImageUrl!; final copied = controller.copiedImageUrl!;
controller.replaceText( controller.replaceText(index, length, BlockEmbed.image(copied.url), null);
index, length, BlockEmbed.image(copied.url), null);
if (copied.styleString.isNotEmpty) { if (copied.styleString.isNotEmpty) {
controller.formatText(getEmbedNode(controller, index + 1).offset, 1, controller.formatText(getEmbedNode(controller, index + 1).offset, 1,
StyleAttribute(copied.styleString)); StyleAttribute(copied.styleString));

@ -134,8 +134,8 @@ class _LinkStyleButtonState extends State<LinkStyleButton> {
} }
} }
widget.controller.replaceText(index, length, value.text, null); widget.controller.replaceText(index, length, value.text, null);
widget.controller.formatText( widget.controller
index, value.text.length, LinkAttribute(value.link)); .formatText(index, value.text.length, LinkAttribute(value.link));
} }
} }
@ -242,9 +242,9 @@ class _LinkDialogState extends State<_LinkDialog> {
class _TextLink { class _TextLink {
_TextLink( _TextLink(
this.text, this.text,
this.link, this.link,
); );
final String text; final String text;
final String link; final String link;

Loading…
Cancel
Save