diff --git a/lib/src/editor/editor_component/editor_component.dart b/lib/src/editor/editor_component/editor_component.dart index 0dd02c62a..89228bbad 100644 --- a/lib/src/editor/editor_component/editor_component.dart +++ b/lib/src/editor/editor_component/editor_component.dart @@ -21,6 +21,7 @@ export 'service/scroll_service.dart'; export 'service/scroll_service_widget.dart'; export 'service/selection_service.dart'; export 'service/selection_service_widget.dart'; +export 'service/shortcuts/command/copy_paste_extension.dart'; // shortcuts export 'service/shortcut_events.dart'; export 'style/default_text_span_decorator_for_attribute.dart'; diff --git a/lib/src/editor/editor_component/service/shortcuts/command/copy_paste_extension.dart b/lib/src/editor/editor_component/service/shortcuts/command/copy_paste_extension.dart index 2f3955ea2..d566478ea 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command/copy_paste_extension.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command/copy_paste_extension.dart @@ -1,5 +1,11 @@ import 'package:appflowy_editor/appflowy_editor.dart'; +final _listTypes = [ + BulletedListBlockKeys.type, + TodoListBlockKeys.type, + NumberedListBlockKeys.type, +]; + extension EditorCopyPaste on EditorState { Future pasteSingleLineNode(Node insertedNode) async { final selection = await deleteSelectionIfNeeded(); @@ -31,6 +37,9 @@ extension EditorCopyPaste on EditorState { } else if (insertedDelta != null) { // if the node is not empty, insert the delta from inserted node after the selection. transaction.insertTextDelta(node, selection.endIndex, insertedDelta); + if (_listTypes.contains(node.type) && insertedNode.children.isNotEmpty) { + transaction.insertNodes(node.path + [0], insertedNode.children); + } } await apply(transaction); } diff --git a/lib/src/editor/editor_component/service/shortcuts/command/paste_command.dart b/lib/src/editor/editor_component/service/shortcuts/command/paste_command.dart index 9c7733b59..192521ab7 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command/paste_command.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command/paste_command.dart @@ -1,5 +1,4 @@ import 'package:appflowy_editor/appflowy_editor.dart'; -import 'package:appflowy_editor/src/editor/editor_component/service/shortcuts/command/copy_paste_extension.dart'; import 'package:flutter/material.dart'; final List pasteCommands = [