diff --git a/frontend/appflowy_flutter/integration_test/desktop/document/document_copy_and_paste_test.dart b/frontend/appflowy_flutter/integration_test/desktop/document/document_copy_and_paste_test.dart index 4a20398c4c..30cb095e5b 100644 --- a/frontend/appflowy_flutter/integration_test/desktop/document/document_copy_and_paste_test.dart +++ b/frontend/appflowy_flutter/integration_test/desktop/document/document_copy_and_paste_test.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/plugins/document/presentation/editor_plugins/block_menu/block_menu_button.dart'; import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_paste/clipboard_service.dart'; +import 'package:appflowy/plugins/document/presentation/editor_plugins/image/custom_image_block_component/custom_image_block_component.dart'; import 'package:appflowy/plugins/document/presentation/editor_plugins/link_preview/custom_link_preview.dart'; import 'package:appflowy/startup/startup.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; @@ -388,6 +389,59 @@ void main() { }, ); + testWidgets( + 'paste the nodes start with non-delta node', + (tester) async { + await tester.pasteContent((_) {}); + const text = 'Hello World'; + final editorState = tester.editor.getCurrentEditorState(); + final transaction = editorState.transaction; + // [image_block] + // [paragraph_block] + transaction.insertNodes([ + 0, + ], [ + customImageNode(url: ''), + paragraphNode(text: text), + ]); + await editorState.apply(transaction); + await tester.pumpAndSettle(); + + await tester.editor.tapLineOfEditorAt(0); + // select all and copy + await tester.simulateKeyEvent( + LogicalKeyboardKey.keyA, + isControlPressed: + UniversalPlatform.isLinux || UniversalPlatform.isWindows, + isMetaPressed: UniversalPlatform.isMacOS, + ); + await tester.simulateKeyEvent( + LogicalKeyboardKey.keyC, + isControlPressed: + UniversalPlatform.isLinux || UniversalPlatform.isWindows, + isMetaPressed: UniversalPlatform.isMacOS, + ); + + // put the cursor to the end of the paragraph block + await tester.editor.tapLineOfEditorAt(0); + + // paste the content + await tester.simulateKeyEvent( + LogicalKeyboardKey.keyV, + isControlPressed: + UniversalPlatform.isLinux || UniversalPlatform.isWindows, + isMetaPressed: UniversalPlatform.isMacOS, + ); + await tester.pumpAndSettle(); + + // expect the image and the paragraph block are inserted below the cursor + expect(editorState.getNodeAtPath([0])!.type, CustomImageBlockKeys.type); + expect(editorState.getNodeAtPath([1])!.type, ParagraphBlockKeys.type); + expect(editorState.getNodeAtPath([2])!.type, CustomImageBlockKeys.type); + expect(editorState.getNodeAtPath([3])!.type, ParagraphBlockKeys.type); + }, + ); + testWidgets('paste the url without protocol', (tester) async { // paste the image that from local file const plainText = '1.jpg'; diff --git a/frontend/appflowy_flutter/integration_test/shared/document_test_operations.dart b/frontend/appflowy_flutter/integration_test/shared/document_test_operations.dart index 3f07f69101..dac4fad44f 100644 --- a/frontend/appflowy_flutter/integration_test/shared/document_test_operations.dart +++ b/frontend/appflowy_flutter/integration_test/shared/document_test_operations.dart @@ -44,7 +44,10 @@ class EditorOperations { Future tapLineOfEditorAt(int index) async { final textBlocks = find.byType(AppFlowyRichText); index = index.clamp(0, textBlocks.evaluate().length - 1); - await tester.tapAt(tester.getTopRight(textBlocks.at(index))); + final center = tester.getCenter(textBlocks.at(index)); + final right = tester.getTopRight(textBlocks.at(index)); + final centerRight = Offset(right.dx, center.dy); + await tester.tapAt(centerRight); await tester.pumpAndSettle(); } diff --git a/frontend/appflowy_flutter/pubspec.lock b/frontend/appflowy_flutter/pubspec.lock index 13ea0cb4e3..7c31ed53fe 100644 --- a/frontend/appflowy_flutter/pubspec.lock +++ b/frontend/appflowy_flutter/pubspec.lock @@ -53,8 +53,8 @@ packages: dependency: "direct main" description: path: "." - ref: c5de9ed - resolved-ref: c5de9ed84dbc7461e5542ce598d803e37838a65a + ref: "3bbdccd" + resolved-ref: "3bbdccd9b1b583027c2ac9121de04b8c76bfef73" url: "https://github.com/AppFlowy-IO/appflowy-editor.git" source: git version: "3.3.0" diff --git a/frontend/appflowy_flutter/pubspec.yaml b/frontend/appflowy_flutter/pubspec.yaml index 0cf1de25a2..35e0940a5e 100644 --- a/frontend/appflowy_flutter/pubspec.yaml +++ b/frontend/appflowy_flutter/pubspec.yaml @@ -170,7 +170,7 @@ dependency_overrides: appflowy_editor: git: url: https://github.com/AppFlowy-IO/appflowy-editor.git - ref: "c5de9ed" + ref: "3bbdccd" appflowy_editor_plugins: git: