mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: bold tests failed (#2122)
This commit is contained in:
parent
6ee54d6194
commit
7b61ed228f
@ -77,10 +77,10 @@ Next we will simulate the input of a shortcut key being pressed that will select
|
||||
|
||||
```dart
|
||||
// Meta + A.
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.keyA, isMetaPressed: true);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.keyA, isMetaPressed: true);
|
||||
// Meta + shift + S.
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.keyS,
|
||||
await editor.pressLogicKey
|
||||
key: LogicalKeyboardKey.keyS,
|
||||
isMetaPressed: true,
|
||||
isShiftPressed: true,
|
||||
);
|
||||
@ -130,7 +130,7 @@ void main() async {
|
||||
editor.insertTextNode(text);
|
||||
}
|
||||
await editor.startTesting();
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.keyA, isMetaPressed: true);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.keyA, isMetaPressed: true);
|
||||
|
||||
expect(
|
||||
editor.documentSelection,
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
import 'package:appflowy_editor/src/render/selection_menu/selection_menu_item_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
|
@ -121,8 +121,6 @@ class _AppFlowyKeyboardState extends State<AppFlowyKeyboard>
|
||||
return KeyEventResult.ignored;
|
||||
}
|
||||
|
||||
Log.keyboard.debug('on keyboard event $event');
|
||||
|
||||
if (event is! RawKeyDownEvent) {
|
||||
return KeyEventResult.ignored;
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ List<ShortcutEvent> builtInShortcutEvents = [
|
||||
),
|
||||
ShortcutEvent(
|
||||
key: 'Double tilde to strikethrough',
|
||||
command: 'tilde,shift+tilde',
|
||||
character: '~',
|
||||
handler: doubleTildeToStrikethrough,
|
||||
),
|
||||
ShortcutEvent(
|
||||
@ -314,7 +314,7 @@ List<ShortcutEvent> builtInShortcutEvents = [
|
||||
),
|
||||
ShortcutEvent(
|
||||
key: 'Double underscore to bold',
|
||||
command: 'shift+underscore',
|
||||
character: '_',
|
||||
handler: doubleUnderscoreToBoldHandler,
|
||||
),
|
||||
// https://github.com/flutter/flutter/issues/104944
|
||||
|
@ -120,8 +120,9 @@ class EditorWidgetTester {
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Future<void> pressLogicKey(
|
||||
LogicalKeyboardKey key, {
|
||||
Future<void> pressLogicKey({
|
||||
String? character,
|
||||
LogicalKeyboardKey? key,
|
||||
bool isControlPressed = false,
|
||||
bool isShiftPressed = false,
|
||||
bool isAltPressed = false,
|
||||
@ -130,11 +131,13 @@ class EditorWidgetTester {
|
||||
if (!isControlPressed &&
|
||||
!isShiftPressed &&
|
||||
!isAltPressed &&
|
||||
!isMetaPressed) {
|
||||
!isMetaPressed &&
|
||||
key != null) {
|
||||
await tester.sendKeyDownEvent(key);
|
||||
} else {
|
||||
final testRawKeyEventData = TestRawKeyEventData(
|
||||
logicalKey: key,
|
||||
logicalKey: key ?? LogicalKeyboardKey.nonConvert,
|
||||
character: character,
|
||||
isControlPressed: isControlPressed,
|
||||
isShiftPressed: isShiftPressed,
|
||||
isAltPressed: isAltPressed,
|
||||
|
@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
|
||||
class TestRawKeyEvent extends RawKeyDownEvent {
|
||||
const TestRawKeyEvent({
|
||||
required super.data,
|
||||
required super.character,
|
||||
this.isControlPressed = false,
|
||||
this.isShiftPressed = false,
|
||||
this.isAltPressed = false,
|
||||
@ -24,7 +25,9 @@ class TestRawKeyEvent extends RawKeyDownEvent {
|
||||
|
||||
class TestRawKeyEventData extends RawKeyEventData {
|
||||
const TestRawKeyEventData({
|
||||
required this.logicalKey,
|
||||
this.logicalKey =
|
||||
LogicalKeyboardKey.nonConvert, // use nonConvert as placeholder.
|
||||
this.character,
|
||||
this.isControlPressed = false,
|
||||
this.isShiftPressed = false,
|
||||
this.isAltPressed = false,
|
||||
@ -46,6 +49,8 @@ class TestRawKeyEventData extends RawKeyEventData {
|
||||
@override
|
||||
final LogicalKeyboardKey logicalKey;
|
||||
|
||||
final String? character;
|
||||
|
||||
@override
|
||||
PhysicalKeyboardKey get physicalKey => logicalKey.toPhysicalKey;
|
||||
|
||||
@ -55,8 +60,10 @@ class TestRawKeyEventData extends RawKeyEventData {
|
||||
}
|
||||
|
||||
@override
|
||||
bool isModifierPressed(ModifierKey key,
|
||||
{KeyboardSide side = KeyboardSide.any}) {
|
||||
bool isModifierPressed(
|
||||
ModifierKey key, {
|
||||
KeyboardSide side = KeyboardSide.any,
|
||||
}) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@ -66,6 +73,7 @@ class TestRawKeyEventData extends RawKeyEventData {
|
||||
RawKeyEvent get toKeyEvent {
|
||||
return TestRawKeyEvent(
|
||||
data: this,
|
||||
character: character,
|
||||
isAltPressed: isAltPressed,
|
||||
isControlPressed: isControlPressed,
|
||||
isMetaPressed: isMetaPressed,
|
||||
|
@ -100,16 +100,16 @@ void main() async {
|
||||
Selection.single(path: [0], startOffset: text.length),
|
||||
);
|
||||
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.enter);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.enter);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.enter);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.enter);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.enter);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.enter);
|
||||
|
||||
expect(
|
||||
editor.documentSelection,
|
||||
Selection.single(path: [2], startOffset: 0),
|
||||
);
|
||||
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.slash);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.slash);
|
||||
await tester.pumpAndSettle(const Duration(milliseconds: 1000));
|
||||
|
||||
expect(
|
||||
|
@ -1,5 +1,4 @@
|
||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
import 'package:appflowy_editor/src/render/selection_menu/selection_menu_item_widget.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import '../../infra/test_editor.dart';
|
||||
@ -22,10 +21,10 @@ void main() async {
|
||||
(tester) async {
|
||||
final editor = await _prepare(tester);
|
||||
for (var j = 0; j < i; j++) {
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.arrowDown);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.arrowDown);
|
||||
}
|
||||
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.enter);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.enter);
|
||||
expect(
|
||||
find.byType(SelectionMenuWidget, skipOffstage: false),
|
||||
findsNothing,
|
||||
@ -52,33 +51,33 @@ void main() async {
|
||||
testWidgets('Search item in selection menu util no results',
|
||||
(tester) async {
|
||||
final editor = await _prepare(tester);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.keyT);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.keyE);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.keyT);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.keyE);
|
||||
expect(
|
||||
find.byType(SelectionMenuItemWidget, skipOffstage: false),
|
||||
findsNWidgets(3),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.backspace);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.backspace);
|
||||
expect(
|
||||
find.byType(SelectionMenuItemWidget, skipOffstage: false),
|
||||
findsNWidgets(5),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.keyE);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.keyE);
|
||||
expect(
|
||||
find.byType(SelectionMenuItemWidget, skipOffstage: false),
|
||||
findsNWidgets(3),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.keyX);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.keyX);
|
||||
expect(
|
||||
find.byType(SelectionMenuItemWidget, skipOffstage: false),
|
||||
findsNWidgets(1),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.keyT);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.keyT);
|
||||
expect(
|
||||
find.byType(SelectionMenuItemWidget, skipOffstage: false),
|
||||
findsNWidgets(1),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.keyT);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.keyT);
|
||||
expect(
|
||||
find.byType(SelectionMenuItemWidget, skipOffstage: false),
|
||||
findsNothing,
|
||||
@ -88,13 +87,13 @@ void main() async {
|
||||
testWidgets('Search item in selection menu and presses esc',
|
||||
(tester) async {
|
||||
final editor = await _prepare(tester);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.keyT);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.keyE);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.keyT);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.keyE);
|
||||
expect(
|
||||
find.byType(SelectionMenuItemWidget, skipOffstage: false),
|
||||
findsNWidgets(3),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.escape);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.escape);
|
||||
expect(
|
||||
find.byType(SelectionMenuItemWidget, skipOffstage: false),
|
||||
findsNothing,
|
||||
@ -104,15 +103,15 @@ void main() async {
|
||||
testWidgets('Search item in selection menu and presses backspace',
|
||||
(tester) async {
|
||||
final editor = await _prepare(tester);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.keyT);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.keyE);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.keyT);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.keyE);
|
||||
expect(
|
||||
find.byType(SelectionMenuItemWidget, skipOffstage: false),
|
||||
findsNWidgets(3),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.backspace);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.backspace);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.backspace);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.backspace);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.backspace);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.backspace);
|
||||
expect(
|
||||
find.byType(SelectionMenuItemWidget, skipOffstage: false),
|
||||
findsNothing,
|
||||
@ -120,71 +119,70 @@ void main() async {
|
||||
});
|
||||
|
||||
group('tab and arrow keys move selection in desired direction', () {
|
||||
|
||||
testWidgets('left and right keys move selection in desired direction',
|
||||
(tester) async {
|
||||
(tester) async {
|
||||
final editor = await _prepare(tester);
|
||||
|
||||
var initialSelection = getSelectedMenuItem(tester);
|
||||
expect(defaultSelectionMenuItems.indexOf(initialSelection.item), 0);
|
||||
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.arrowRight);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.arrowRight);
|
||||
|
||||
var newSelection = getSelectedMenuItem(tester);
|
||||
expect(defaultSelectionMenuItems.indexOf(newSelection.item), 5);
|
||||
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.arrowLeft);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.arrowLeft);
|
||||
|
||||
var finalSelection = getSelectedMenuItem(tester);
|
||||
expect(defaultSelectionMenuItems.indexOf(initialSelection.item), 0);
|
||||
});
|
||||
|
||||
testWidgets('up and down keys move selection in desired direction',
|
||||
(tester) async {
|
||||
(tester) async {
|
||||
final editor = await _prepare(tester);
|
||||
|
||||
var initialSelection = getSelectedMenuItem(tester);
|
||||
expect(defaultSelectionMenuItems.indexOf(initialSelection.item), 0);
|
||||
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.arrowDown);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.arrowDown);
|
||||
|
||||
var newSelection = getSelectedMenuItem(tester);
|
||||
expect(defaultSelectionMenuItems.indexOf(newSelection.item), 1);
|
||||
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.arrowUp);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.arrowUp);
|
||||
|
||||
var finalSelection = getSelectedMenuItem(tester);
|
||||
expect(defaultSelectionMenuItems.indexOf(finalSelection.item), 0);
|
||||
});
|
||||
|
||||
testWidgets('arrow keys and tab move same selection',
|
||||
(tester) async {
|
||||
testWidgets('arrow keys and tab move same selection', (tester) async {
|
||||
final editor = await _prepare(tester);
|
||||
|
||||
var initialSelection = getSelectedMenuItem(tester);
|
||||
expect(defaultSelectionMenuItems.indexOf(initialSelection.item), 0);
|
||||
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.arrowDown);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.arrowDown);
|
||||
|
||||
var newSelection = getSelectedMenuItem(tester);
|
||||
expect(defaultSelectionMenuItems.indexOf(newSelection.item), 1);
|
||||
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.tab);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.tab);
|
||||
|
||||
var finalSelection = getSelectedMenuItem(tester);
|
||||
expect(defaultSelectionMenuItems.indexOf(finalSelection.item), 6);
|
||||
});
|
||||
|
||||
testWidgets('tab moves selection to next row Item on reaching end of current row',
|
||||
(tester) async {
|
||||
testWidgets(
|
||||
'tab moves selection to next row Item on reaching end of current row',
|
||||
(tester) async {
|
||||
final editor = await _prepare(tester);
|
||||
|
||||
final initialSelection = getSelectedMenuItem(tester);
|
||||
|
||||
expect(defaultSelectionMenuItems.indexOf(initialSelection.item), 0);
|
||||
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.tab);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.tab);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.tab);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.tab);
|
||||
|
||||
final finalSelection = getSelectedMenuItem(tester);
|
||||
|
||||
@ -203,7 +201,7 @@ Future<EditorWidgetTester> _prepare(WidgetTester tester) async {
|
||||
}
|
||||
await editor.startTesting();
|
||||
await editor.updateSelection(Selection.single(path: [1], startOffset: 0));
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.slash);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.slash);
|
||||
|
||||
await tester.pumpAndSettle(const Duration(milliseconds: 1000));
|
||||
|
||||
@ -256,6 +254,6 @@ SelectionMenuItemWidget getSelectedMenuItem(WidgetTester tester) {
|
||||
return tester
|
||||
.state(find.byWidgetPredicate(
|
||||
(widget) => widget is SelectionMenuItemWidget && widget.isSelected,
|
||||
))
|
||||
))
|
||||
.widget as SelectionMenuItemWidget;
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ void main() async {
|
||||
|
||||
final textNode = editor.nodeAtPath([0]) as TextNode;
|
||||
for (var i = 0; i < text.length; i++) {
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.arrowRight);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.arrowRight);
|
||||
|
||||
if (i == text.length - 1) {
|
||||
// Wrap to next node if the cursor is at the end of the current node.
|
||||
@ -73,7 +73,7 @@ void main() async {
|
||||
await editor.updateSelection(selection);
|
||||
for (var i = offset - 1; i >= 0; i--) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowLeft,
|
||||
key: LogicalKeyboardKey.arrowLeft,
|
||||
isShiftPressed: true,
|
||||
);
|
||||
expect(
|
||||
@ -85,7 +85,7 @@ void main() async {
|
||||
}
|
||||
for (var i = text.length; i >= 0; i--) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowLeft,
|
||||
key: LogicalKeyboardKey.arrowLeft,
|
||||
isShiftPressed: true,
|
||||
);
|
||||
expect(
|
||||
@ -97,7 +97,7 @@ void main() async {
|
||||
}
|
||||
for (var i = 1; i <= text.length; i++) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowRight,
|
||||
key: LogicalKeyboardKey.arrowRight,
|
||||
isShiftPressed: true,
|
||||
);
|
||||
expect(
|
||||
@ -109,7 +109,7 @@ void main() async {
|
||||
}
|
||||
for (var i = 0; i < text.length; i++) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowRight,
|
||||
key: LogicalKeyboardKey.arrowRight,
|
||||
isShiftPressed: true,
|
||||
);
|
||||
expect(
|
||||
@ -139,7 +139,7 @@ void main() async {
|
||||
await editor.updateSelection(selection);
|
||||
for (var i = end + 1; i <= text.length; i++) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowRight,
|
||||
key: LogicalKeyboardKey.arrowRight,
|
||||
isShiftPressed: true,
|
||||
);
|
||||
expect(
|
||||
@ -151,7 +151,7 @@ void main() async {
|
||||
}
|
||||
for (var i = text.length - 1; i >= 0; i--) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowLeft,
|
||||
key: LogicalKeyboardKey.arrowLeft,
|
||||
isShiftPressed: true,
|
||||
);
|
||||
expect(
|
||||
@ -181,7 +181,7 @@ void main() async {
|
||||
await editor.updateSelection(selection);
|
||||
for (var i = end - 1; i >= 0; i--) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowLeft,
|
||||
key: LogicalKeyboardKey.arrowLeft,
|
||||
isShiftPressed: true,
|
||||
);
|
||||
expect(
|
||||
@ -193,7 +193,7 @@ void main() async {
|
||||
}
|
||||
for (var i = 1; i <= text.length; i++) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowRight,
|
||||
key: LogicalKeyboardKey.arrowRight,
|
||||
isShiftPressed: true,
|
||||
);
|
||||
expect(
|
||||
@ -238,7 +238,7 @@ void main() async {
|
||||
await editor.updateSelection(selection);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowUp,
|
||||
key: LogicalKeyboardKey.arrowUp,
|
||||
isShiftPressed: true,
|
||||
);
|
||||
}
|
||||
@ -250,7 +250,7 @@ void main() async {
|
||||
);
|
||||
for (int i = 0; i < 7; i++) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowDown,
|
||||
key: LogicalKeyboardKey.arrowDown,
|
||||
isShiftPressed: true,
|
||||
);
|
||||
}
|
||||
@ -262,7 +262,7 @@ void main() async {
|
||||
);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowUp,
|
||||
key: LogicalKeyboardKey.arrowUp,
|
||||
isShiftPressed: true,
|
||||
);
|
||||
}
|
||||
@ -284,18 +284,18 @@ void main() async {
|
||||
final selection = Selection.single(path: [0], startOffset: 8);
|
||||
await editor.updateSelection(selection);
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowDown,
|
||||
key: LogicalKeyboardKey.arrowDown,
|
||||
isShiftPressed: true,
|
||||
);
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowRight,
|
||||
key: LogicalKeyboardKey.arrowRight,
|
||||
isShiftPressed: true,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowRight,
|
||||
key: LogicalKeyboardKey.arrowRight,
|
||||
isShiftPressed: true,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
@ -318,18 +318,18 @@ void main() async {
|
||||
final selection = Selection.single(path: [1], startOffset: 8);
|
||||
await editor.updateSelection(selection);
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowUp,
|
||||
key: LogicalKeyboardKey.arrowUp,
|
||||
isShiftPressed: true,
|
||||
);
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowLeft,
|
||||
key: LogicalKeyboardKey.arrowLeft,
|
||||
isShiftPressed: true,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowLeft,
|
||||
key: LogicalKeyboardKey.arrowLeft,
|
||||
isShiftPressed: true,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
@ -352,7 +352,7 @@ void main() async {
|
||||
final selection = Selection.single(path: [1], startOffset: 10);
|
||||
await editor.updateSelection(selection);
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowLeft,
|
||||
key: LogicalKeyboardKey.arrowLeft,
|
||||
isShiftPressed: true,
|
||||
isAltPressed: true,
|
||||
);
|
||||
@ -364,7 +364,7 @@ void main() async {
|
||||
),
|
||||
);
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowLeft,
|
||||
key: LogicalKeyboardKey.arrowLeft,
|
||||
isShiftPressed: true,
|
||||
isAltPressed: true,
|
||||
);
|
||||
@ -376,7 +376,7 @@ void main() async {
|
||||
),
|
||||
);
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowLeft,
|
||||
key: LogicalKeyboardKey.arrowLeft,
|
||||
isShiftPressed: true,
|
||||
isAltPressed: true,
|
||||
);
|
||||
@ -388,7 +388,7 @@ void main() async {
|
||||
),
|
||||
);
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowLeft,
|
||||
key: LogicalKeyboardKey.arrowLeft,
|
||||
isShiftPressed: true,
|
||||
isAltPressed: true,
|
||||
);
|
||||
@ -412,7 +412,7 @@ void main() async {
|
||||
final selection = Selection.single(path: [0], startOffset: 10);
|
||||
await editor.updateSelection(selection);
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowRight,
|
||||
key: LogicalKeyboardKey.arrowRight,
|
||||
isShiftPressed: true,
|
||||
isAltPressed: true,
|
||||
);
|
||||
@ -424,7 +424,7 @@ void main() async {
|
||||
),
|
||||
);
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowRight,
|
||||
key: LogicalKeyboardKey.arrowRight,
|
||||
isShiftPressed: true,
|
||||
isAltPressed: true,
|
||||
);
|
||||
@ -436,12 +436,12 @@ void main() async {
|
||||
),
|
||||
);
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowRight,
|
||||
key: LogicalKeyboardKey.arrowRight,
|
||||
isShiftPressed: true,
|
||||
isAltPressed: true,
|
||||
);
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowRight,
|
||||
key: LogicalKeyboardKey.arrowRight,
|
||||
isShiftPressed: true,
|
||||
isAltPressed: true,
|
||||
);
|
||||
@ -453,7 +453,7 @@ void main() async {
|
||||
),
|
||||
);
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowRight,
|
||||
key: LogicalKeyboardKey.arrowRight,
|
||||
isShiftPressed: true,
|
||||
isAltPressed: true,
|
||||
);
|
||||
@ -478,12 +478,12 @@ void main() async {
|
||||
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.backspace,
|
||||
key: LogicalKeyboardKey.backspace,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.backspace,
|
||||
key: LogicalKeyboardKey.backspace,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
}
|
||||
@ -499,12 +499,12 @@ void main() async {
|
||||
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.backspace,
|
||||
key: LogicalKeyboardKey.backspace,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.backspace,
|
||||
key: LogicalKeyboardKey.backspace,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
}
|
||||
@ -521,12 +521,12 @@ void main() async {
|
||||
for (var i = 0; i < words.length; i++) {
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.backspace,
|
||||
key: LogicalKeyboardKey.backspace,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.backspace,
|
||||
key: LogicalKeyboardKey.backspace,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
}
|
||||
@ -550,12 +550,12 @@ void main() async {
|
||||
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.backspace,
|
||||
key: LogicalKeyboardKey.backspace,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.backspace,
|
||||
key: LogicalKeyboardKey.backspace,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
}
|
||||
@ -575,12 +575,12 @@ void main() async {
|
||||
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.backspace,
|
||||
key: LogicalKeyboardKey.backspace,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.backspace,
|
||||
key: LogicalKeyboardKey.backspace,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
}
|
||||
@ -610,11 +610,11 @@ Future<void> _testPressArrowKeyInNotCollapsedSelection(
|
||||
end: isBackward ? end : start,
|
||||
);
|
||||
await editor.updateSelection(selection);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.arrowLeft);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.arrowLeft);
|
||||
expect(editor.documentSelection?.start, start);
|
||||
|
||||
await editor.updateSelection(selection);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.arrowRight);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.arrowRight);
|
||||
expect(editor.documentSelection?.end, end);
|
||||
}
|
||||
|
||||
@ -652,12 +652,12 @@ Future<void> _testPressArrowKeyWithMetaInSelection(
|
||||
await editor.updateSelection(selection);
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowLeft,
|
||||
key: LogicalKeyboardKey.arrowLeft,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowLeft,
|
||||
key: LogicalKeyboardKey.arrowLeft,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
}
|
||||
@ -669,12 +669,12 @@ Future<void> _testPressArrowKeyWithMetaInSelection(
|
||||
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowRight,
|
||||
key: LogicalKeyboardKey.arrowRight,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowRight,
|
||||
key: LogicalKeyboardKey.arrowRight,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
}
|
||||
@ -686,12 +686,12 @@ Future<void> _testPressArrowKeyWithMetaInSelection(
|
||||
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowUp,
|
||||
key: LogicalKeyboardKey.arrowUp,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowUp,
|
||||
key: LogicalKeyboardKey.arrowUp,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
}
|
||||
@ -703,12 +703,12 @@ Future<void> _testPressArrowKeyWithMetaInSelection(
|
||||
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowDown,
|
||||
key: LogicalKeyboardKey.arrowDown,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowDown,
|
||||
key: LogicalKeyboardKey.arrowDown,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ void main() async {
|
||||
// Pressing the backspace key continuously.
|
||||
for (int i = 1; i <= 1; i++) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.backspace,
|
||||
key: LogicalKeyboardKey.backspace,
|
||||
);
|
||||
expect(editor.documentLength, 1);
|
||||
expect(editor.documentSelection,
|
||||
@ -112,7 +112,7 @@ void main() async {
|
||||
await editor.updateSelection(
|
||||
Selection.single(path: [0], startOffset: text.length),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.delete);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.delete);
|
||||
|
||||
expect(editor.documentLength, 1);
|
||||
expect(editor.documentSelection,
|
||||
@ -207,7 +207,7 @@ void main() async {
|
||||
),
|
||||
);
|
||||
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.backspace);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.backspace);
|
||||
expect(editor.documentLength, 3);
|
||||
expect(find.byType(ImageNodeWidget), findsNothing);
|
||||
expect(
|
||||
@ -249,20 +249,20 @@ void main() async {
|
||||
final textNode = editor.nodeAtPath([0]) as TextNode;
|
||||
|
||||
await editor.insertText(textNode, '#', 0);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
expect(
|
||||
(editor.nodeAtPath([0]) as TextNode).attributes.heading,
|
||||
BuiltInAttributeKey.h1,
|
||||
);
|
||||
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.backspace);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.backspace);
|
||||
expect(
|
||||
textNode.attributes.heading,
|
||||
null,
|
||||
);
|
||||
|
||||
await editor.insertText(textNode, '#', 0);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
expect(
|
||||
(editor.nodeAtPath([0]) as TextNode).attributes.heading,
|
||||
BuiltInAttributeKey.h1,
|
||||
@ -296,17 +296,17 @@ void main() async {
|
||||
await editor.updateSelection(
|
||||
Selection.single(path: [0, 0, 0], startOffset: 0),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.backspace);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.backspace);
|
||||
expect(editor.nodeAtPath([0, 0, 0])?.subtype, null);
|
||||
await editor.updateSelection(
|
||||
Selection.single(path: [0, 0, 0], startOffset: 0),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.backspace);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.backspace);
|
||||
expect(editor.nodeAtPath([0, 1]) != null, true);
|
||||
await editor.updateSelection(
|
||||
Selection.single(path: [0, 1], startOffset: 0),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.backspace);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.backspace);
|
||||
expect(editor.nodeAtPath([1]) != null, true);
|
||||
await editor.updateSelection(
|
||||
Selection.single(path: [1], startOffset: 0),
|
||||
@ -314,7 +314,7 @@ void main() async {
|
||||
|
||||
// * Welcome to Appflowy 😁
|
||||
// * Welcome to Appflowy 😁Welcome to Appflowy 😁
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.backspace);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.backspace);
|
||||
expect(
|
||||
editor.documentSelection,
|
||||
Selection.single(path: [0, 0], startOffset: text.length),
|
||||
@ -356,7 +356,7 @@ void main() async {
|
||||
await editor.updateSelection(
|
||||
Selection.single(path: [0, 1], startOffset: 0),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.backspace);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.backspace);
|
||||
expect(
|
||||
editor.nodeAtPath([0, 1])!.subtype != BuiltInAttributeKey.bulletedList,
|
||||
true,
|
||||
@ -382,7 +382,7 @@ void main() async {
|
||||
// * Welcome to Appflowy 😁Welcome to Appflowy 😁
|
||||
// * Welcome to Appflowy 😁
|
||||
// * Welcome to Appflowy 😁
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.backspace);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.backspace);
|
||||
expect(
|
||||
editor.nodeAtPath([0, 0])!.subtype == BuiltInAttributeKey.bulletedList,
|
||||
true,
|
||||
@ -424,7 +424,7 @@ Future<void> _deleteFirstImage(WidgetTester tester, bool isBackward) async {
|
||||
),
|
||||
);
|
||||
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.backspace);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.backspace);
|
||||
expect(editor.documentLength, 2);
|
||||
expect(find.byType(ImageNodeWidget), findsNothing);
|
||||
expect(editor.documentSelection, Selection.collapsed(start));
|
||||
@ -453,7 +453,7 @@ Future<void> _deleteLastImage(WidgetTester tester, bool isBackward) async {
|
||||
),
|
||||
);
|
||||
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.backspace);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.backspace);
|
||||
expect(editor.documentLength, 2);
|
||||
expect(find.byType(ImageNodeWidget), findsNothing);
|
||||
expect(editor.documentSelection, Selection.collapsed(start));
|
||||
@ -483,12 +483,12 @@ Future<void> _deleteStyledTextByBackspace(
|
||||
Selection.single(path: [2], startOffset: 0),
|
||||
);
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.backspace,
|
||||
key: LogicalKeyboardKey.backspace,
|
||||
);
|
||||
expect(editor.documentSelection, Selection.single(path: [2], startOffset: 0));
|
||||
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.backspace,
|
||||
key: LogicalKeyboardKey.backspace,
|
||||
);
|
||||
expect(editor.documentLength, 2);
|
||||
expect(editor.documentSelection,
|
||||
@ -500,7 +500,7 @@ Future<void> _deleteStyledTextByBackspace(
|
||||
Selection.single(path: [1], startOffset: 0),
|
||||
);
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.backspace,
|
||||
key: LogicalKeyboardKey.backspace,
|
||||
);
|
||||
expect(editor.documentLength, 2);
|
||||
expect(editor.documentSelection, Selection.single(path: [1], startOffset: 0));
|
||||
@ -531,7 +531,7 @@ Future<void> _deleteStyledTextByDelete(
|
||||
);
|
||||
for (var i = 1; i < text.length; i++) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.delete,
|
||||
key: LogicalKeyboardKey.delete,
|
||||
);
|
||||
expect(
|
||||
editor.documentSelection, Selection.single(path: [1], startOffset: 0));
|
||||
@ -541,7 +541,7 @@ Future<void> _deleteStyledTextByDelete(
|
||||
}
|
||||
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.delete,
|
||||
key: LogicalKeyboardKey.delete,
|
||||
);
|
||||
expect(editor.documentLength, 2);
|
||||
expect(editor.documentSelection, Selection.single(path: [1], startOffset: 0));
|
||||
@ -562,7 +562,7 @@ Future<void> _deleteTextByBackspace(
|
||||
await editor.updateSelection(
|
||||
Selection.single(path: [1], startOffset: 10),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.backspace);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.backspace);
|
||||
|
||||
expect(editor.documentLength, 3);
|
||||
expect(editor.documentSelection, Selection.single(path: [1], startOffset: 9));
|
||||
@ -573,7 +573,7 @@ Future<void> _deleteTextByBackspace(
|
||||
await editor.updateSelection(
|
||||
Selection.single(path: [2], startOffset: 8, endOffset: 11),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.backspace);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.backspace);
|
||||
expect(editor.documentLength, 3);
|
||||
expect(editor.documentSelection, Selection.single(path: [2], startOffset: 8));
|
||||
expect((editor.nodeAtPath([2]) as TextNode).toPlainText(),
|
||||
@ -587,7 +587,7 @@ Future<void> _deleteTextByBackspace(
|
||||
await editor.updateSelection(Selection(
|
||||
start: isBackwardSelection ? start : end,
|
||||
end: isBackwardSelection ? end : start));
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.backspace);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.backspace);
|
||||
expect(editor.documentLength, 1);
|
||||
expect(
|
||||
editor.documentSelection, Selection.single(path: [0], startOffset: 11));
|
||||
@ -608,7 +608,7 @@ Future<void> _deleteTextByDelete(
|
||||
await editor.updateSelection(
|
||||
Selection.single(path: [1], startOffset: 9),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.delete);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.delete);
|
||||
|
||||
expect(editor.documentLength, 3);
|
||||
expect(editor.documentSelection, Selection.single(path: [1], startOffset: 9));
|
||||
@ -619,7 +619,7 @@ Future<void> _deleteTextByDelete(
|
||||
await editor.updateSelection(
|
||||
Selection.single(path: [2], startOffset: 8, endOffset: 11),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.delete);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.delete);
|
||||
expect(editor.documentLength, 3);
|
||||
expect(editor.documentSelection, Selection.single(path: [2], startOffset: 8));
|
||||
expect((editor.nodeAtPath([2]) as TextNode).toPlainText(),
|
||||
@ -633,7 +633,7 @@ Future<void> _deleteTextByDelete(
|
||||
await editor.updateSelection(Selection(
|
||||
start: isBackwardSelection ? start : end,
|
||||
end: isBackwardSelection ? end : start));
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.delete);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.delete);
|
||||
expect(editor.documentLength, 1);
|
||||
expect(
|
||||
editor.documentSelection, Selection.single(path: [0], startOffset: 11));
|
||||
|
@ -47,12 +47,12 @@ void main() async {
|
||||
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.enter,
|
||||
key: LogicalKeyboardKey.enter,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.enter,
|
||||
key: LogicalKeyboardKey.enter,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
}
|
||||
@ -65,12 +65,12 @@ void main() async {
|
||||
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.enter,
|
||||
key: LogicalKeyboardKey.enter,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.enter,
|
||||
key: LogicalKeyboardKey.enter,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
}
|
||||
@ -145,12 +145,12 @@ void main() async {
|
||||
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.enter,
|
||||
key: LogicalKeyboardKey.enter,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.enter,
|
||||
key: LogicalKeyboardKey.enter,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
}
|
||||
@ -223,12 +223,12 @@ void main() async {
|
||||
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.enter,
|
||||
key: LogicalKeyboardKey.enter,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.enter,
|
||||
key: LogicalKeyboardKey.enter,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ void main() async {
|
||||
// Pressing the enter key continuously.
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.enter,
|
||||
key: LogicalKeyboardKey.enter,
|
||||
);
|
||||
expect(editor.documentLength, i + 1);
|
||||
expect(editor.documentSelection,
|
||||
@ -64,7 +64,7 @@ void main() async {
|
||||
Selection.single(path: [lines - 1], startOffset: 0),
|
||||
);
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.enter,
|
||||
key: LogicalKeyboardKey.enter,
|
||||
);
|
||||
lines += 1;
|
||||
expect(editor.documentLength, lines);
|
||||
@ -132,7 +132,7 @@ void main() async {
|
||||
await editor.updateSelection(
|
||||
Selection.single(path: [0], startOffset: 0),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.enter);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.enter);
|
||||
expect(editor.documentLength, 2);
|
||||
expect((editor.nodeAtPath([1]) as TextNode).toPlainText(), text);
|
||||
});
|
||||
@ -159,7 +159,7 @@ Future<void> _testStyleNeedToBeCopy(WidgetTester tester, String style) async {
|
||||
Selection.single(path: [1], startOffset: 0),
|
||||
);
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.enter,
|
||||
key: LogicalKeyboardKey.enter,
|
||||
);
|
||||
expect(editor.documentSelection, Selection.single(path: [2], startOffset: 0));
|
||||
|
||||
@ -167,7 +167,7 @@ Future<void> _testStyleNeedToBeCopy(WidgetTester tester, String style) async {
|
||||
Selection.single(path: [3], startOffset: text.length),
|
||||
);
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.enter,
|
||||
key: LogicalKeyboardKey.enter,
|
||||
);
|
||||
expect(editor.documentSelection, Selection.single(path: [4], startOffset: 0));
|
||||
|
||||
@ -176,7 +176,7 @@ Future<void> _testStyleNeedToBeCopy(WidgetTester tester, String style) async {
|
||||
expect(editor.nodeAtPath([4])?.subtype, null);
|
||||
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.enter,
|
||||
key: LogicalKeyboardKey.enter,
|
||||
);
|
||||
expect(
|
||||
editor.documentSelection, Selection.single(path: [5], startOffset: 0));
|
||||
@ -185,7 +185,7 @@ Future<void> _testStyleNeedToBeCopy(WidgetTester tester, String style) async {
|
||||
expect(editor.nodeAtPath([4])?.subtype, style);
|
||||
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.enter,
|
||||
key: LogicalKeyboardKey.enter,
|
||||
);
|
||||
expect(
|
||||
editor.documentSelection, Selection.single(path: [4], startOffset: 0));
|
||||
@ -223,7 +223,7 @@ Future<void> _testMultipleSelection(
|
||||
end: isBackwardSelection ? end : start,
|
||||
));
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.enter,
|
||||
key: LogicalKeyboardKey.enter,
|
||||
);
|
||||
|
||||
expect(editor.documentLength, 2);
|
||||
|
@ -45,6 +45,6 @@ Future<void> _testSelection(
|
||||
EditorWidgetTester editor, Selection selection) async {
|
||||
await editor.updateSelection(selection);
|
||||
expect(editor.documentSelection, selection);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.escape);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.escape);
|
||||
expect(editor.documentSelection, null);
|
||||
}
|
||||
|
@ -95,13 +95,13 @@ Future<void> _testUpdateTextStyleByCommandX(
|
||||
await editor.updateSelection(selection);
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
key,
|
||||
key: key,
|
||||
isShiftPressed: isShiftPressed,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
key,
|
||||
key: key,
|
||||
isShiftPressed: isShiftPressed,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
@ -122,13 +122,13 @@ Future<void> _testUpdateTextStyleByCommandX(
|
||||
await editor.updateSelection(selection);
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
key,
|
||||
key: key,
|
||||
isShiftPressed: isShiftPressed,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
key,
|
||||
key: key,
|
||||
isShiftPressed: isShiftPressed,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
@ -147,13 +147,13 @@ Future<void> _testUpdateTextStyleByCommandX(
|
||||
await editor.updateSelection(selection);
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
key,
|
||||
key: key,
|
||||
isShiftPressed: isShiftPressed,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
key,
|
||||
key: key,
|
||||
isShiftPressed: isShiftPressed,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
@ -169,13 +169,13 @@ Future<void> _testUpdateTextStyleByCommandX(
|
||||
await editor.updateSelection(selection);
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
key,
|
||||
key: key,
|
||||
isShiftPressed: isShiftPressed,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
key,
|
||||
key: key,
|
||||
isShiftPressed: isShiftPressed,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
@ -204,13 +204,13 @@ Future<void> _testUpdateTextStyleByCommandX(
|
||||
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
key,
|
||||
key: key,
|
||||
isShiftPressed: isShiftPressed,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
key,
|
||||
key: key,
|
||||
isShiftPressed: isShiftPressed,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
@ -250,9 +250,11 @@ Future<void> _testLinkMenuInSingleTextSelection(WidgetTester tester) async {
|
||||
|
||||
// trigger the link menu
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.keyK, isControlPressed: true);
|
||||
await editor.pressLogicKey(
|
||||
key: LogicalKeyboardKey.keyK, isControlPressed: true);
|
||||
} else {
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.keyK, isMetaPressed: true);
|
||||
await editor.pressLogicKey(
|
||||
key: LogicalKeyboardKey.keyK, isMetaPressed: true);
|
||||
}
|
||||
expect(find.byType(LinkMenu), findsOneWidget);
|
||||
|
||||
@ -273,9 +275,11 @@ Future<void> _testLinkMenuInSingleTextSelection(WidgetTester tester) async {
|
||||
|
||||
await editor.updateSelection(selection);
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.keyK, isControlPressed: true);
|
||||
await editor.pressLogicKey(
|
||||
key: LogicalKeyboardKey.keyK, isControlPressed: true);
|
||||
} else {
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.keyK, isMetaPressed: true);
|
||||
await editor.pressLogicKey(
|
||||
key: LogicalKeyboardKey.keyK, isMetaPressed: true);
|
||||
}
|
||||
expect(find.byType(LinkMenu), findsOneWidget);
|
||||
expect(
|
||||
@ -290,9 +294,11 @@ Future<void> _testLinkMenuInSingleTextSelection(WidgetTester tester) async {
|
||||
|
||||
// Remove link
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.keyK, isControlPressed: true);
|
||||
await editor.pressLogicKey(
|
||||
key: LogicalKeyboardKey.keyK, isControlPressed: true);
|
||||
} else {
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.keyK, isMetaPressed: true);
|
||||
await editor.pressLogicKey(
|
||||
key: LogicalKeyboardKey.keyK, isMetaPressed: true);
|
||||
}
|
||||
final removeLink = find.text('Remove link');
|
||||
expect(removeLink, findsOneWidget);
|
||||
|
@ -17,7 +17,7 @@ void main() async {
|
||||
}) async {
|
||||
for (var i = 0; i < repeat; i++) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.backquote,
|
||||
key: LogicalKeyboardKey.backquote,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -99,7 +99,7 @@ void main() async {
|
||||
}) async {
|
||||
for (var i = 0; i < repeat; i++) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.backquote,
|
||||
key: LogicalKeyboardKey.backquote,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -157,10 +157,7 @@ void main() async {
|
||||
int repeat = 1,
|
||||
}) async {
|
||||
for (var i = 0; i < repeat; i++) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.tilde,
|
||||
isShiftPressed: true,
|
||||
);
|
||||
await editor.pressLogicKey(character: '~');
|
||||
}
|
||||
}
|
||||
|
||||
@ -264,10 +261,7 @@ void main() async {
|
||||
int repeat = 1,
|
||||
}) async {
|
||||
for (var i = 0; i < repeat; i++) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.digit8,
|
||||
isShiftPressed: true,
|
||||
);
|
||||
await editor.pressLogicKey(character: '*');
|
||||
}
|
||||
}
|
||||
|
||||
@ -358,10 +352,7 @@ void main() async {
|
||||
int repeat = 1,
|
||||
}) async {
|
||||
for (var i = 0; i < repeat; i++) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.underscore,
|
||||
isShiftPressed: true,
|
||||
);
|
||||
await editor.pressLogicKey(character: '_');
|
||||
}
|
||||
}
|
||||
|
||||
@ -378,8 +369,13 @@ void main() async {
|
||||
|
||||
await insertUnderscore(editor);
|
||||
|
||||
final allBold = textNode.allSatisfyBoldInSelection(Selection.single(
|
||||
path: [0], startOffset: 0, endOffset: textNode.toPlainText().length));
|
||||
final allBold = textNode.allSatisfyBoldInSelection(
|
||||
Selection.single(
|
||||
path: [0],
|
||||
startOffset: 0,
|
||||
endOffset: textNode.toPlainText().length,
|
||||
),
|
||||
);
|
||||
|
||||
expect(allBold, true);
|
||||
expect(textNode.toPlainText(), 'AppFlowy');
|
||||
|
@ -38,7 +38,7 @@ void main() async {
|
||||
var currentOffsetY = 0.0;
|
||||
for (int i = 1; i <= page!; i++) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.pageDown,
|
||||
key: LogicalKeyboardKey.pageDown,
|
||||
);
|
||||
if (i == page) {
|
||||
currentOffsetY = scrollService.maxScrollExtent;
|
||||
@ -51,7 +51,7 @@ void main() async {
|
||||
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.pageDown,
|
||||
key: LogicalKeyboardKey.pageDown,
|
||||
);
|
||||
final dy = scrollService.dy;
|
||||
expect(dy == scrollService.maxScrollExtent, true);
|
||||
@ -60,7 +60,7 @@ void main() async {
|
||||
// Pressing the pageUp key continuously.
|
||||
for (int i = page; i >= 1; i--) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.pageUp,
|
||||
key: LogicalKeyboardKey.pageUp,
|
||||
);
|
||||
if (i == 1) {
|
||||
currentOffsetY = scrollService.minScrollExtent;
|
||||
@ -73,7 +73,7 @@ void main() async {
|
||||
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.pageUp,
|
||||
key: LogicalKeyboardKey.pageUp,
|
||||
);
|
||||
final dy = scrollService.dy;
|
||||
expect(dy == scrollService.minScrollExtent, true);
|
||||
|
@ -40,17 +40,17 @@ Future<void> _testBackspaceUndoRedo(
|
||||
end: isDownwardSelection ? end : start,
|
||||
);
|
||||
await editor.updateSelection(selection);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.backspace);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.backspace);
|
||||
expect(editor.documentLength, 2);
|
||||
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.keyZ,
|
||||
key: LogicalKeyboardKey.keyZ,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.keyZ,
|
||||
key: LogicalKeyboardKey.keyZ,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
}
|
||||
@ -61,13 +61,13 @@ Future<void> _testBackspaceUndoRedo(
|
||||
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.keyZ,
|
||||
key: LogicalKeyboardKey.keyZ,
|
||||
isControlPressed: true,
|
||||
isShiftPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.keyZ,
|
||||
key: LogicalKeyboardKey.keyZ,
|
||||
isMetaPressed: true,
|
||||
isShiftPressed: true,
|
||||
);
|
||||
|
@ -29,9 +29,11 @@ Future<void> _testSelectAllHandler(WidgetTester tester, int lines) async {
|
||||
}
|
||||
await editor.startTesting();
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.keyA, isControlPressed: true);
|
||||
await editor.pressLogicKey(
|
||||
key: LogicalKeyboardKey.keyA, isControlPressed: true);
|
||||
} else {
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.keyA, isMetaPressed: true);
|
||||
await editor.pressLogicKey(
|
||||
key: LogicalKeyboardKey.keyA, isMetaPressed: true);
|
||||
}
|
||||
|
||||
expect(
|
||||
|
@ -1,5 +1,4 @@
|
||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
import 'package:appflowy_editor/src/render/selection_menu/selection_menu_item_widget.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import '../../infra/test_editor.dart';
|
||||
@ -20,7 +19,7 @@ void main() async {
|
||||
}
|
||||
await editor.startTesting();
|
||||
await editor.updateSelection(Selection.single(path: [1], startOffset: 0));
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.slash);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.slash);
|
||||
|
||||
await tester.pumpAndSettle(const Duration(milliseconds: 1000));
|
||||
|
||||
@ -53,7 +52,7 @@ void main() async {
|
||||
}
|
||||
await editor.startTesting();
|
||||
await editor.updateSelection(Selection.single(path: [1], startOffset: 5));
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.slash);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.slash);
|
||||
|
||||
await tester.pumpAndSettle(const Duration(milliseconds: 1000));
|
||||
|
||||
|
@ -24,7 +24,7 @@ void main() async {
|
||||
await editor.updateSelection(
|
||||
Selection.single(path: [i], startOffset: 1),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
expect(
|
||||
(editor.nodeAtPath([i]) as TextNode).toPlainText(),
|
||||
'W elcome to Appflowy 😁',
|
||||
@ -34,7 +34,7 @@ void main() async {
|
||||
await editor.updateSelection(
|
||||
Selection.single(path: [i], startOffset: text.length + 1),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
expect(
|
||||
(editor.nodeAtPath([i]) as TextNode).toPlainText(),
|
||||
'W elcome to Appflowy 😁 ',
|
||||
|
@ -18,7 +18,7 @@ void main() async {
|
||||
|
||||
var selection = Selection.single(path: [0], startOffset: 0);
|
||||
await editor.updateSelection(selection);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.tab);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.tab);
|
||||
|
||||
expect(
|
||||
editor.documentSelection,
|
||||
@ -27,7 +27,7 @@ void main() async {
|
||||
|
||||
selection = Selection.single(path: [1], startOffset: 0);
|
||||
await editor.updateSelection(selection);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.tab);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.tab);
|
||||
|
||||
expect(
|
||||
editor.documentSelection,
|
||||
@ -61,7 +61,7 @@ void main() async {
|
||||
|
||||
var selection = Selection.single(path: [0], startOffset: 0);
|
||||
await editor.updateSelection(selection);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.tab);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.tab);
|
||||
|
||||
// nothing happens
|
||||
expect(
|
||||
@ -82,7 +82,7 @@ void main() async {
|
||||
selection = Selection.single(path: [1], startOffset: 0);
|
||||
await editor.updateSelection(selection);
|
||||
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.tab);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.tab);
|
||||
|
||||
expect(
|
||||
editor.documentSelection,
|
||||
@ -96,7 +96,7 @@ void main() async {
|
||||
|
||||
selection = Selection.single(path: [1], startOffset: 0);
|
||||
await editor.updateSelection(selection);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.tab);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.tab);
|
||||
|
||||
expect(
|
||||
editor.documentSelection,
|
||||
@ -121,7 +121,7 @@ void main() async {
|
||||
document = editor.document;
|
||||
selection = Selection.single(path: [0, 0], startOffset: 0);
|
||||
await editor.updateSelection(selection);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.tab);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.tab);
|
||||
|
||||
expect(
|
||||
editor.documentSelection,
|
||||
@ -131,7 +131,7 @@ void main() async {
|
||||
|
||||
selection = Selection.single(path: [0, 1], startOffset: 0);
|
||||
await editor.updateSelection(selection);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.tab);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.tab);
|
||||
|
||||
expect(
|
||||
editor.documentSelection,
|
||||
@ -182,7 +182,7 @@ void main() async {
|
||||
|
||||
var selection = Selection.single(path: [0], startOffset: 0);
|
||||
await editor.updateSelection(selection);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.tab);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.tab);
|
||||
|
||||
// nothing happens
|
||||
expect(
|
||||
@ -203,7 +203,7 @@ void main() async {
|
||||
selection = Selection.single(path: [1], startOffset: 0);
|
||||
await editor.updateSelection(selection);
|
||||
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.tab);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.tab);
|
||||
|
||||
expect(
|
||||
editor.documentSelection,
|
||||
@ -216,7 +216,7 @@ void main() async {
|
||||
|
||||
selection = Selection.single(path: [1], startOffset: 0);
|
||||
await editor.updateSelection(selection);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.tab);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.tab);
|
||||
|
||||
expect(
|
||||
editor.documentSelection,
|
||||
@ -239,7 +239,7 @@ void main() async {
|
||||
document = editor.document;
|
||||
selection = Selection.single(path: [0, 0], startOffset: 0);
|
||||
await editor.updateSelection(selection);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.tab);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.tab);
|
||||
|
||||
expect(
|
||||
editor.documentSelection,
|
||||
@ -249,7 +249,7 @@ void main() async {
|
||||
|
||||
selection = Selection.single(path: [0, 1], startOffset: 0);
|
||||
await editor.updateSelection(selection);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.tab);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.tab);
|
||||
|
||||
expect(
|
||||
editor.documentSelection,
|
||||
|
@ -40,7 +40,7 @@ void main() async {
|
||||
await editor.updateSelection(
|
||||
Selection.single(path: [i - 1], startOffset: i),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
|
||||
final textNode = (editor.nodeAtPath([i - 1]) as TextNode);
|
||||
|
||||
@ -80,7 +80,7 @@ void main() async {
|
||||
await editor.updateSelection(
|
||||
Selection.single(path: [i - 1], startOffset: i),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
|
||||
final textNode = (editor.nodeAtPath([i - 1]) as TextNode);
|
||||
|
||||
@ -114,7 +114,7 @@ void main() async {
|
||||
final textNode = (editor.nodeAtPath([0]) as TextNode);
|
||||
|
||||
await editor.insertText(textNode, '#' * i, 0);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
|
||||
expect(textNode.subtype, BuiltInAttributeKey.heading);
|
||||
// BuiltInAttributeKey.h2 ~ BuiltInAttributeKey.h6
|
||||
@ -134,7 +134,7 @@ void main() async {
|
||||
Selection.single(path: [0], startOffset: 0),
|
||||
);
|
||||
await editor.insertText(textNode, symbol, 0);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
expect(textNode.subtype, BuiltInAttributeKey.checkbox);
|
||||
expect(textNode.attributes.check, false);
|
||||
}
|
||||
@ -152,7 +152,7 @@ void main() async {
|
||||
Selection.single(path: [0], startOffset: 0),
|
||||
);
|
||||
await editor.insertText(textNode, symbol, 0);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
expect(textNode.subtype, BuiltInAttributeKey.checkbox);
|
||||
expect(textNode.attributes.check, true);
|
||||
}
|
||||
@ -169,7 +169,7 @@ void main() async {
|
||||
Selection.single(path: [0], startOffset: 0),
|
||||
);
|
||||
await editor.insertText(textNode, symbol, 0);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
expect(textNode.subtype, BuiltInAttributeKey.bulletedList);
|
||||
}
|
||||
});
|
||||
@ -185,34 +185,34 @@ void main() async {
|
||||
);
|
||||
|
||||
await editor.insertText(textNode, '>', 0);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
expect(textNode.subtype, BuiltInAttributeKey.quote);
|
||||
|
||||
await editor.insertText(textNode, '*', 0);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
expect(textNode.subtype, BuiltInAttributeKey.bulletedList);
|
||||
|
||||
await editor.insertText(textNode, '[]', 0);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
expect(textNode.subtype, BuiltInAttributeKey.checkbox);
|
||||
expect(textNode.attributes.check, false);
|
||||
|
||||
await editor.insertText(textNode, '1.', 0);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
expect(textNode.subtype, BuiltInAttributeKey.numberList);
|
||||
|
||||
await editor.insertText(textNode, '#', 0);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
expect(textNode.subtype, BuiltInAttributeKey.heading);
|
||||
|
||||
await editor.insertText(textNode, '[x]', 0);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
expect(textNode.subtype, BuiltInAttributeKey.checkbox);
|
||||
expect(textNode.attributes.check, true);
|
||||
|
||||
const insertedText = '[]AppFlowy';
|
||||
await editor.insertText(textNode, insertedText, 0);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
expect(textNode.subtype, BuiltInAttributeKey.checkbox);
|
||||
expect(textNode.attributes.check, true);
|
||||
expect(textNode.toPlainText(), insertedText);
|
||||
@ -227,7 +227,7 @@ void main() async {
|
||||
await editor.updateSelection(
|
||||
Selection.single(path: [0], startOffset: text.length),
|
||||
);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
expect(textNode.subtype, null);
|
||||
expect(textNode.toPlainText(), text);
|
||||
});
|
||||
@ -243,7 +243,7 @@ void main() async {
|
||||
|
||||
final textNode = editor.nodeAtPath([0]) as TextNode;
|
||||
await editor.insertText(textNode, '>', 0);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
expect(textNode.subtype, BuiltInAttributeKey.quote);
|
||||
for (var i = 0; i < text.length; i++) {
|
||||
await editor.insertText(textNode, text[i], i);
|
||||
@ -263,7 +263,7 @@ void main() async {
|
||||
for (var i = 0; i < text.length; i++) {
|
||||
await editor.insertText(textNode, text[i], i);
|
||||
}
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
final isQuote = textNode.subtype == BuiltInAttributeKey.quote;
|
||||
expect(isQuote, false);
|
||||
expect(textNode.toPlainText(), text);
|
||||
@ -284,7 +284,7 @@ void main() async {
|
||||
Selection.single(path: [0], startOffset: 0),
|
||||
);
|
||||
await editor.insertText(textNode, '>', 0);
|
||||
await editor.pressLogicKey(LogicalKeyboardKey.space);
|
||||
await editor.pressLogicKey(key: LogicalKeyboardKey.space);
|
||||
|
||||
final isQuote = textNode.subtype == BuiltInAttributeKey.quote;
|
||||
expect(isQuote, true);
|
||||
|
@ -41,12 +41,12 @@ void main() async {
|
||||
);
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowLeft,
|
||||
key: LogicalKeyboardKey.arrowLeft,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowLeft,
|
||||
key: LogicalKeyboardKey.arrowLeft,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
}
|
||||
@ -69,12 +69,12 @@ void main() async {
|
||||
}
|
||||
if (Platform.isWindows || Platform.isMacOS || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowLeft,
|
||||
key: LogicalKeyboardKey.arrowLeft,
|
||||
isAltPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowLeft,
|
||||
key: LogicalKeyboardKey.arrowLeft,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
}
|
||||
@ -97,12 +97,12 @@ void main() async {
|
||||
);
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowRight,
|
||||
key: LogicalKeyboardKey.arrowRight,
|
||||
isControlPressed: true,
|
||||
);
|
||||
} else {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowRight,
|
||||
key: LogicalKeyboardKey.arrowRight,
|
||||
isMetaPressed: true,
|
||||
);
|
||||
}
|
||||
@ -124,7 +124,7 @@ void main() async {
|
||||
}
|
||||
}
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.arrowRight,
|
||||
key: LogicalKeyboardKey.arrowRight,
|
||||
isAltPressed: true,
|
||||
);
|
||||
expect(
|
||||
@ -145,7 +145,7 @@ void main() async {
|
||||
);
|
||||
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.home,
|
||||
key: LogicalKeyboardKey.home,
|
||||
);
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ void main() async {
|
||||
}
|
||||
if (Platform.isWindows || Platform.isMacOS || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.home,
|
||||
key: LogicalKeyboardKey.home,
|
||||
);
|
||||
}
|
||||
expect(
|
||||
@ -188,7 +188,7 @@ void main() async {
|
||||
);
|
||||
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.end,
|
||||
key: LogicalKeyboardKey.end,
|
||||
);
|
||||
}
|
||||
|
||||
@ -211,7 +211,7 @@ void main() async {
|
||||
}
|
||||
if (Platform.isWindows || Platform.isMacOS || Platform.isLinux) {
|
||||
await editor.pressLogicKey(
|
||||
LogicalKeyboardKey.end,
|
||||
key: LogicalKeyboardKey.end,
|
||||
);
|
||||
}
|
||||
expect(
|
||||
|
Loading…
Reference in New Issue
Block a user