Merge pull request #939 from LucasXu0/feat/936

feat: "/" supports inserting Quote #936
This commit is contained in:
Nathan.fooo 2022-08-30 22:05:14 +08:00 committed by GitHub
commit d068370f6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 6 deletions

View File

@ -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>

Before

Width:  |  Height:  |  Size: 135 B

After

Width:  |  Height:  |  Size: 134 B

View File

@ -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>

After

Width:  |  Height:  |  Size: 609 B

View File

@ -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) {

View File

@ -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);