You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reworked PasteEditorCommand to handle insertion of text with afterwards correctly placed selection when a) text spanning a single text node is pasted inside a node or at the end of a node, b) text spanning several text nodes is pasted inside a node or at the end of a node. Added test for behavior with multiple nodes. Renamed documentPositionAfterPast > selectionAfterPaste
'pastes some text with newlines in the middle of a paragraph, correctly splitting it, inserting nodes and placing the caret at the end of the pasted text',
93
+
(
94
+
tester, {
95
+
requiredTextInputSource inputSource,
96
+
}) async {
97
+
final testContext =await tester //
98
+
.createDocument()
99
+
.withSingleEmptyParagraph()
100
+
.withInputSource(inputSource)
101
+
.pump();
102
+
103
+
// Place the caret at the empty paragraph.
104
+
await tester.placeCaretInParagraph('1', 0);
105
+
106
+
// Type some text.
107
+
switch (inputSource) {
108
+
caseTextInputSource.keyboard:
109
+
await tester.typeKeyboardText('This is a paragraph.');
110
+
caseTextInputSource.ime:
111
+
await tester.typeImeText('This is a paragraph.');
112
+
}
113
+
114
+
// Place the cursor somewhere in the middle of the text.
115
+
await tester.placeCaretInParagraph('1', 8);
116
+
117
+
// Simulate pasting multiple lines.
118
+
tester
119
+
..simulateClipboard()
120
+
..setSimulatedClipboardContent('''some content in a paragraph.
121
+
There is a second paragraph here.
122
+
And a third one is also ''');
123
+
if (defaultTargetPlatform ==TargetPlatform.macOS) {
124
+
await tester.pressCmdV();
125
+
} else {
126
+
await tester.pressCtlV();
127
+
}
128
+
129
+
// Ensure the text is correctly pasted and the caret is placed at the
130
+
// end of the pasted text.
131
+
final doc = testContext.document;
132
+
expect(doc.nodeCount, 3);
133
+
expect((doc.getNodeAt(0)!asParagraphNode).text.toPlainText(), 'This is some content in a paragraph.');
134
+
expect((doc.getNodeAt(1)!asParagraphNode).text.toPlainText(), 'There is a second paragraph here.');
135
+
expect((doc.getNodeAt(2)!asParagraphNode).text.toPlainText(), 'And a third one is also a paragraph.');
0 commit comments