From 071ff06d47bc2b3ce18cb2d6d94e97a0c6c7a167 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Tue, 30 Aug 2022 17:42:28 +0800 Subject: [PATCH] feat: / supports inserting Quote #936 --- .../packages/appflowy_editor/assets/images/quote.svg | 2 +- .../assets/images/selection_menu/quote.svg | 4 ++++ .../render/selection_menu/selection_menu_service.dart | 8 ++++++++ .../selection_menu/selection_menu_widget_test.dart | 10 +++++----- 4 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 frontend/app_flowy/packages/appflowy_editor/assets/images/selection_menu/quote.svg diff --git a/frontend/app_flowy/packages/appflowy_editor/assets/images/quote.svg b/frontend/app_flowy/packages/appflowy_editor/assets/images/quote.svg index 0f3d33f6d3..1393e71556 100644 --- a/frontend/app_flowy/packages/appflowy_editor/assets/images/quote.svg +++ b/frontend/app_flowy/packages/appflowy_editor/assets/images/quote.svg @@ -1,3 +1,3 @@ - + \ No newline at end of file diff --git a/frontend/app_flowy/packages/appflowy_editor/assets/images/selection_menu/quote.svg b/frontend/app_flowy/packages/appflowy_editor/assets/images/selection_menu/quote.svg new file mode 100644 index 0000000000..5c1cbb4a50 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_editor/assets/images/selection_menu/quote.svg @@ -0,0 +1,4 @@ + + + + diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/selection_menu/selection_menu_service.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/selection_menu/selection_menu_service.dart index 7f4f803610..f4f2006af4 100644 --- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/selection_menu/selection_menu_service.dart +++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/selection_menu/selection_menu_service.dart @@ -169,6 +169,14 @@ final List _defaultSelectionMenuItems = [ insertCheckboxAfterSelection(editorState); }, ), + SelectionMenuItem( + name: 'Quote', + icon: _selectionMenuIcon('quote'), + keywords: ['quote', 'refer'], + handler: (editorState, _, __) { + insertQuoteAfterSelection(editorState); + }, + ), ]; Widget _selectionMenuIcon(String name) { diff --git a/frontend/app_flowy/packages/appflowy_editor/test/render/selection_menu/selection_menu_widget_test.dart b/frontend/app_flowy/packages/appflowy_editor/test/render/selection_menu/selection_menu_widget_test.dart index 2711921352..6006fe6a7a 100644 --- a/frontend/app_flowy/packages/appflowy_editor/test/render/selection_menu/selection_menu_widget_test.dart +++ b/frontend/app_flowy/packages/appflowy_editor/test/render/selection_menu/selection_menu_widget_test.dart @@ -38,17 +38,17 @@ void main() async { await editor.pressLogicKey(LogicalKeyboardKey.keyE); expect( find.byType(SelectionMenuItemWidget, skipOffstage: false), - findsNWidgets(2), + findsNWidgets(3), ); await editor.pressLogicKey(LogicalKeyboardKey.backspace); expect( find.byType(SelectionMenuItemWidget, skipOffstage: false), - findsNWidgets(3), + findsNWidgets(4), ); await editor.pressLogicKey(LogicalKeyboardKey.keyE); expect( find.byType(SelectionMenuItemWidget, skipOffstage: false), - findsNWidgets(2), + findsNWidgets(3), ); await editor.pressLogicKey(LogicalKeyboardKey.keyX); expect( @@ -73,7 +73,7 @@ void main() async { await editor.pressLogicKey(LogicalKeyboardKey.keyE); expect( find.byType(SelectionMenuItemWidget, skipOffstage: false), - findsNWidgets(2), + findsNWidgets(3), ); await editor.pressLogicKey(LogicalKeyboardKey.escape); expect( @@ -89,7 +89,7 @@ void main() async { await editor.pressLogicKey(LogicalKeyboardKey.keyE); expect( find.byType(SelectionMenuItemWidget, skipOffstage: false), - findsNWidgets(2), + findsNWidgets(3), ); await editor.pressLogicKey(LogicalKeyboardKey.backspace); await editor.pressLogicKey(LogicalKeyboardKey.backspace);