Address KeyboardListener class name conflict

pull/410/head
Xin Yao 4 years ago
parent feec35386e
commit 52f5193819
  1. 4
      lib/src/models/rules/delete.dart
  2. 8
      lib/src/models/rules/format.dart
  3. 4
      lib/src/models/rules/insert.dart
  4. 4
      lib/src/widgets/keyboard_listener.dart
  5. 4
      lib/src/widgets/raw_editor.dart

@ -66,7 +66,9 @@ class PreserveLineStyleOnMergeRule extends DeleteRule {
attributes ??= <String, dynamic>{}; attributes ??= <String, dynamic>{};
attributes.addAll(attrs!); attributes.addAll(attrs!);
} }
delta..retain(lineBreak)..retain(1, attributes); delta
..retain(lineBreak)
..retain(1, attributes);
break; break;
} }
return delta; return delta;

@ -114,7 +114,9 @@ class FormatLinkAtCaretPositionRule extends FormatRule {
return null; return null;
} }
delta..retain(beg)..retain(retain!, attribute.toJson()); delta
..retain(beg)
..retain(retain!, attribute.toJson());
return delta; return delta;
} }
} }
@ -143,7 +145,9 @@ class ResolveInlineFormatRule extends FormatRule {
} }
var pos = 0; var pos = 0;
while (lineBreak >= 0) { while (lineBreak >= 0) {
delta..retain(lineBreak - pos, attribute.toJson())..retain(1); delta
..retain(lineBreak - pos, attribute.toJson())
..retain(1);
pos = lineBreak + 1; pos = lineBreak + 1;
lineBreak = text.indexOf('\n', pos); lineBreak = text.indexOf('\n', pos);
} }

@ -192,7 +192,9 @@ class AutoExitBlockRule extends InsertRule {
attributes.keys.firstWhere(Attribute.blockKeysExceptHeader.contains); attributes.keys.firstWhere(Attribute.blockKeysExceptHeader.contains);
attributes[k] = null; attributes[k] = null;
// retain(1) should be '\n', set it with no attribute // retain(1) should be '\n', set it with no attribute
return Delta()..retain(index + (len ?? 0))..retain(1, attributes); return Delta()
..retain(index + (len ?? 0))
..retain(1, attributes);
} }
} }

@ -9,8 +9,8 @@ typedef CursorMoveCallback = void Function(
typedef InputShortcutCallback = void Function(InputShortcut? shortcut); typedef InputShortcutCallback = void Function(InputShortcut? shortcut);
typedef OnDeleteCallback = void Function(bool forward); typedef OnDeleteCallback = void Function(bool forward);
class KeyboardListener { class CustomKeyboardListener {
KeyboardListener(this.onCursorMove, this.onShortcut, this.onDelete); CustomKeyboardListener(this.onCursorMove, this.onShortcut, this.onDelete);
final CursorMoveCallback onCursorMove; final CursorMoveCallback onCursorMove;
final InputShortcutCallback onShortcut; final InputShortcutCallback onShortcut;

@ -106,7 +106,7 @@ class RawEditorState extends EditorState
final GlobalKey _editorKey = GlobalKey(); final GlobalKey _editorKey = GlobalKey();
// Keyboard // Keyboard
late KeyboardListener _keyboardListener; late CustomKeyboardListener _keyboardListener;
KeyboardVisibilityController? _keyboardVisibilityController; KeyboardVisibilityController? _keyboardVisibilityController;
StreamSubscription<bool>? _keyboardVisibilitySubscription; StreamSubscription<bool>? _keyboardVisibilitySubscription;
bool _keyboardVisible = false; bool _keyboardVisible = false;
@ -340,7 +340,7 @@ class RawEditorState extends EditorState
tickerProvider: this, tickerProvider: this,
); );
_keyboardListener = KeyboardListener( _keyboardListener = CustomKeyboardListener(
handleCursorMovement, handleCursorMovement,
handleShortcut, handleShortcut,
handleDelete, handleDelete,

Loading…
Cancel
Save