From 40c3f07be431606136b603cfdff266d193f0b666 Mon Sep 17 00:00:00 2001 From: Vincent Chan Date: Mon, 1 Aug 2022 18:20:10 +0800 Subject: [PATCH] feat: use patch nodes --- .../copy_paste_handler.dart | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/copy_paste_handler.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/copy_paste_handler.dart index dd20f39ca9..01149af9ca 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/copy_paste_handler.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/copy_paste_handler.dart @@ -17,10 +17,14 @@ _pasteHTML(EditorState editorState, String html) { return; } - final tb = TransactionBuilder(editorState); - for (final node in nodes) { - tb.insertNode(selection.end.path, node); + final path = [...selection.end.path]; + if (path.isEmpty) { + return; } + path[path.length - 1]++; + + final tb = TransactionBuilder(editorState); + tb.insertNodes(path, nodes); tb.commit(); }