Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
chore: update editor version to 1.2.3 (#3153)
Lucas.Xuc9ee82ec7500
diff --git a/frontend/appflowy_flutter/integration_test/document/document_copy_and_paste_test.dart b/frontend/appflowy_flutter/integration_test/document/document_copy_and_paste_test.dartnew file mode 100644index 0000000000..296f71be82--- /dev/null+++ b/frontend/appflowy_flutter/integration_test/document/document_copy_and_paste_test.dart@@ -0,0 +1,47 @@+import 'dart:io';++import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:flutter/services.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:integration_test/integration_test.dart';++import '../util/util.dart';++void main() {+ IntegrationTestWidgetsFlutterBinding.ensureInitialized();++ group('copy and paste in document', () {+ testWidgets('paste multiple lines at the first line', (tester) async {+ await tester.initializeAppFlowy();+ await tester.tapGoButton();++ // create a new document+ await tester.createNewPageWithName();++ // mock the clipboard+ const lines = 3;+ AppFlowyClipboard.mockSetData(+ AppFlowyClipboardData(+ text: List.generate(lines, (index) => 'line $index').join('\n'),+ ),+ );++ // paste the text+ await tester.simulateKeyEvent(+ LogicalKeyboardKey.keyV,+ isControlPressed: Platform.isLinux || Platform.isWindows,+ isMetaPressed: Platform.isMacOS,+ );+ await tester.pumpAndSettle();++ final editorState = tester.editor.getCurrentEditorState();+ expect(editorState.document.root.children.length, 4);+ for (var i = 0; i < lines; i++) {+ expect(+ editorState.getNodeAtPath([i])!.delta!.toPlainText(),+ 'line $i',+ );+ }+ });+ });+}diff --git a/frontend/appflowy_flutter/integration_test/document/document_test_runner.dart b/frontend/appflowy_flutter/integration_test/document/document_test_runner.dartindex c8d1576b05..1d05ef55d0 100644--- a/frontend/appflowy_flutter/integration_test/document/document_test_runner.dart+++ b/frontend/appflowy_flutter/integration_test/document/document_test_runner.dart@@ -10,6 +10,7 @@ import 'document_with_inline_page_test.dart' as document_with_inline_page_test;import 'document_with_toggle_list_test.dart' as document_with_toggle_list_test;import 'edit_document_test.dart' as document_edit_test;import 'document_with_outline_block_test.dart' as document_with_outline_block;+import 'document_copy_and_paste_test.dart' as document_copy_and_paste_test;void startTesting() {IntegrationTestWidgetsFlutterBinding.ensureInitialized();@@ -23,4 +24,5 @@ void startTesting() {document_with_cover_image_test.main();document_with_outline_block.main();document_with_toggle_list_test.main();+ document_copy_and_paste_test.main();}diff --git a/frontend/appflowy_flutter/integration_test/share_markdown_test.dart b/frontend/appflowy_flutter/integration_test/share_markdown_test.dartindex 60b430613e..2565c62741 100644--- a/frontend/appflowy_flutter/integration_test/share_markdown_test.dart+++ b/frontend/appflowy_flutter/integration_test/share_markdown_test.dart@@ -94,6 +94,13 @@ const expectedMarkdown = r'''1. Keyboard shortcuts [guide](https://appflowy.gitbook.io/docs/essential-documentation/shortcuts)1. Markdown [reference](https://appflowy.gitbook.io/docs/essential-documentation/markdown)1. Type `/code` to insert a code block+```rust+// This is the main function.+fn main() {+ // Print text to the console.+ println!("Hello World!");+}+```## Have a question❓> Click `?` at the bottom right for help and support.diff --git a/frontend/appflowy_flutter/integration_test/util/editor_test_operations.dart b/frontend/appflowy_flutter/integration_test/util/editor_test_operations.dartindex fcf4cd0d37..886b4a2b16 100644--- a/frontend/appflowy_flutter/integration_test/util/editor_test_operations.dart+++ b/frontend/appflowy_flutter/integration_test/util/editor_test_operations.dart@@ -87,7 +87,7 @@ class EditorOperations {Future<void> switchSolidColorBackground() async {final findPurpleButton = find.byWidgetPredicate(- (widget) => widget is ColorItem && widget.option.colorHex == "ffe8e0ff",+ (widget) => widget is ColorItem && widget.option.name == 'Purple',);await tester.tapButton(findPurpleButton);}diff --git a/frontend/appflowy_flutter/lib/plugins/document/application/editor_transaction_adapter.dart b/frontend/appflowy_flutter/lib/plugins/document/application/editor_transaction_adapter.dartindex 79eb3aa7be..e1020fa53f 100644--- a/frontend/appflowy_flutter/lib/plugins/document/application/editor_transaction_adapter.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/application/editor_transaction_adapter.dart@@ -1,5 +1,6 @@import 'package:appflowy/plugins/document/application/document_data_pb_extension.dart';import 'package:appflowy/plugins/document/application/doc_service.dart';+import 'package:appflowy_backend/log.dart';import 'package:appflowy_backend/protobuf/flowy-document2/protobuf.dart';import 'package:appflowy_editor/appflowy_editor.dart'show@@ -31,13 +32,13 @@ class TransactionAdapter {final String documentId;Future<void> apply(Transaction transaction, EditorState editorState) async {- // Log.debug('transaction => ${transaction.toJson()}');+ Log.debug('transaction => ${transaction.toJson()}');final actions = transaction.operations.map((op) => op.toBlockAction(editorState)).whereNotNull().expand((element) => element).toList(growable: false); // avoid lazy evaluation- // Log.debug('actions => $actions');+ Log.debug('actions => $actions');await documentService.applyAction(documentId: documentId,actions: actions,@@ -72,7 +73,7 @@ extension on InsertOperation {editorState.getNodeAtPath(path.previous)?.id ??'';assert(parentId.isNotEmpty);- if (path.equals(path.previous)) {+ if (path.equals(path.previous) && !path.equals([0])) {prevId = '';} else {assert(prevId.isNotEmpty && prevId != node.id);diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/callout/callout_block_component.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/callout/callout_block_component.dartindex 9ee48c4e53..40837576a9 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/callout/callout_block_component.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/callout/callout_block_component.dart@@ -48,7 +48,7 @@ SelectionMenuItem calloutItem = SelectionMenuItem.node(name: 'Callout',iconData: Icons.note,keywords: ['callout'],- nodeBuilder: (editorState) => calloutNode(),+ nodeBuilder: (editorState, _) => calloutNode(),replace: (_, node) => node.delta?.isEmpty ?? false,updateSelection: (_, path, __, ___) {return Selection.single(path: path, startOffset: 0);diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/code_block/code_block_component.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/code_block/code_block_component.dartindex 5048ffc0c8..84eefc5738 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/code_block/code_block_component.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/code_block/code_block_component.dart@@ -43,7 +43,7 @@ SelectionMenuItem codeBlockItem = SelectionMenuItem.node(name: 'Code Block',iconData: Icons.abc,keywords: ['code', 'codeblock'],- nodeBuilder: (editorState) => codeBlockNode(),+ nodeBuilder: (editorState, _) => codeBlockNode(),replace: (_, node) => node.delta?.isEmpty ?? false,);diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/math_equation/math_equation_block_component.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/math_equation/math_equation_block_component.dartindex b75eabb615..d4b93ee1d4 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/math_equation/math_equation_block_component.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/math_equation/math_equation_block_component.dart@@ -37,7 +37,7 @@ SelectionMenuItem mathEquationItem = SelectionMenuItem.node(name: 'MathEquation',iconData: Icons.text_fields_rounded,keywords: ['tex, latex, katex', 'math equation', 'formula'],- nodeBuilder: (editorState) => mathEquationNode(),+ nodeBuilder: (editorState, _) => mathEquationNode(),replace: (_, node) => node.delta?.isEmpty ?? false,updateSelection: (editorState, path, __, ___) {WidgetsBinding.instance.addPostFrameCallback((timeStamp) {diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/auto_completion_node_widget.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/auto_completion_node_widget.dartindex eb36767e80..e0d8355d6f 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/auto_completion_node_widget.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/auto_completion_node_widget.dart@@ -45,7 +45,7 @@ SelectionMenuItem autoGeneratorMenuItem = SelectionMenuItem.node(name: LocaleKeys.document_plugins_autoGeneratorMenuItemName.tr(),iconData: Icons.generating_tokens,keywords: ['ai', 'openai' 'writer', 'autogenerator'],- nodeBuilder: (editorState) {+ nodeBuilder: (editorState, _) {final node = autoCompletionNode(start: editorState.selection!);return node;},diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/outline/outline_block_component.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/outline/outline_block_component.dartindex 5f9740b0a7..14ab936246 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/outline/outline_block_component.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/outline/outline_block_component.dart@@ -19,7 +19,7 @@ SelectionMenuItem outlineItem = SelectionMenuItem.node(name: LocaleKeys.document_selectionMenu_outline.tr(),iconData: Icons.list_alt,keywords: ['outline', 'table of contents'],- nodeBuilder: (editorState) => outlineBlockNode(),+ nodeBuilder: (editorState, _) => outlineBlockNode(),replace: (_, node) => node.delta?.isEmpty ?? false,);diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toggle/toggle_block_component.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toggle/toggle_block_component.dartindex ad43d8264b..7ccf822641 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toggle/toggle_block_component.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toggle/toggle_block_component.dart@@ -49,7 +49,7 @@ SelectionMenuItem toggleListBlockItem = SelectionMenuItem.node(name: LocaleKeys.document_plugins_toggleList.tr(),iconData: Icons.arrow_right,keywords: ['collapsed list', 'toggle list', 'list'],- nodeBuilder: (editorState) => toggleListBlockNode(),+ nodeBuilder: (editorState, _) => toggleListBlockNode(),replace: (_, node) => node.delta?.isEmpty ?? false,);diff --git a/frontend/appflowy_flutter/pubspec.lock b/frontend/appflowy_flutter/pubspec.lockindex 52dc094746..769a1718fb 100644--- a/frontend/appflowy_flutter/pubspec.lock+++ b/frontend/appflowy_flutter/pubspec.lock@@ -53,10 +53,10 @@ packages:dependency: "direct main"description:name: appflowy_editor- sha256: b30f645eac57639ff003e6920d04432b9c80a4e2f6e177326e81c221608d7044+ sha256: "6886c32ab8c3f5385ec9eb333f3fca596fe5f5ee94da84484c7f56a322a026e7"url: "https://pub.dev"source: hosted- version: "1.2.1"+ version: "1.2.3"appflowy_popover:dependency: "direct main"description:diff --git a/frontend/appflowy_flutter/pubspec.yaml b/frontend/appflowy_flutter/pubspec.yamlindex 3bb4fcf78b..a0a067cdbf 100644--- a/frontend/appflowy_flutter/pubspec.yaml+++ b/frontend/appflowy_flutter/pubspec.yaml@@ -42,7 +42,7 @@ dependencies:git:url: https://github.com/AppFlowy-IO/appflowy-board.gitref: a183c57- appflowy_editor: ^1.2.1+ appflowy_editor: 1.2.3appflowy_popover:path: packages/appflowy_popover