mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: Should not add a new line below after pressing enter at the front of the first line of text.
This commit is contained in:
parent
cde48926e2
commit
c07af9007c
@ -62,10 +62,17 @@ class StateTree {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (var i = 0; i < nodes.length; i++) {
|
if (path.last <= 0) {
|
||||||
final node = nodes[i];
|
for (var i = 0; i < nodes.length; i++) {
|
||||||
insertedNode!.insertAfter(node);
|
final node = nodes[i];
|
||||||
insertedNode = node;
|
insertedNode.insertBefore(node);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (var i = 0; i < nodes.length; i++) {
|
||||||
|
final node = nodes[i];
|
||||||
|
insertedNode!.insertAfter(node);
|
||||||
|
insertedNode = node;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -116,6 +116,27 @@ void main() async {
|
|||||||
(tester) async {
|
(tester) async {
|
||||||
_testMultipleSelection(tester, false);
|
_testMultipleSelection(tester, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('Presses enter key in the first line', (tester) async {
|
||||||
|
// Before
|
||||||
|
//
|
||||||
|
// Welcome to Appflowy 😁
|
||||||
|
//
|
||||||
|
// After
|
||||||
|
//
|
||||||
|
// [Empty Line]
|
||||||
|
// Welcome to Appflowy 😁
|
||||||
|
//
|
||||||
|
const text = 'Welcome to Appflowy 😁';
|
||||||
|
final editor = tester.editor..insertTextNode(text);
|
||||||
|
await editor.startTesting();
|
||||||
|
await editor.updateSelection(
|
||||||
|
Selection.single(path: [0], startOffset: 0),
|
||||||
|
);
|
||||||
|
await editor.pressLogicKey(LogicalKeyboardKey.enter);
|
||||||
|
expect(editor.documentLength, 2);
|
||||||
|
expect((editor.nodeAtPath([1]) as TextNode).toRawString(), text);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user