瀏覽代碼

feat: / supports inserting Quote #936

Lucas.Xu 2 年之前
父節點
當前提交
071ff06d47

+ 1 - 1
frontend/app_flowy/packages/appflowy_editor/assets/images/quote.svg

@@ -1,3 +1,3 @@
 <svg width="200" height="200" xmlns="http://www.w3.org/2000/svg">
-  <rect width="40" height="160" x="80" y="20" fill="#00BCF0"/>
+  <rect width="40" height="200" x="80" y="0" fill="#00BCF0"/>
 </svg>

+ 4 - 0
frontend/app_flowy/packages/appflowy_editor/assets/images/selection_menu/quote.svg

@@ -0,0 +1,4 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M12.4742 9.35161C12.8007 8.99566 13 8.52111 13 8C13 6.89543 12.1046 6 11 6C9.89543 6 9 6.89543 9 8C9 9.04413 9.80011 9.90137 10.8207 9.99207L10.0124 11.1682L10.8365 11.7346L12.4742 9.35161Z" fill="black"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M6.47395 7.35186C6.80061 6.99588 7 6.52123 7 6C7 4.89543 6.10457 4 5 4C3.89543 4 3 4.89543 3 6C3 7.04411 3.80008 7.90134 4.82061 7.99206L4.01231 9.16823L4.83645 9.73461L6.47395 7.35186Z" fill="black"/>
+</svg>

+ 8 - 0
frontend/app_flowy/packages/appflowy_editor/lib/src/render/selection_menu/selection_menu_service.dart

@@ -169,6 +169,14 @@ final List<SelectionMenuItem> _defaultSelectionMenuItems = [
       insertCheckboxAfterSelection(editorState);
     },
   ),
+  SelectionMenuItem(
+    name: 'Quote',
+    icon: _selectionMenuIcon('quote'),
+    keywords: ['quote', 'refer'],
+    handler: (editorState, _, __) {
+      insertQuoteAfterSelection(editorState);
+    },
+  ),
 ];
 
 Widget _selectionMenuIcon(String name) {

+ 5 - 5
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);