|
@@ -256,5 +256,76 @@ void main() async {
|
|
|
expect(textNode.toPlainText(), text);
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ group('convert geater to blockquote', () {
|
|
|
+ Future<void> insertGreater(
|
|
|
+ EditorWidgetTester editor, {
|
|
|
+ int repeat = 1,
|
|
|
+ }) async {
|
|
|
+ for (var i = 0; i < repeat; i++) {
|
|
|
+ await editor.pressLogicKey(
|
|
|
+ LogicalKeyboardKey.greater,
|
|
|
+ isShiftPressed: true,
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ testWidgets('>AppFlowy to blockquote AppFlowy', (tester) async {
|
|
|
+ const text = 'AppFlowy';
|
|
|
+ final editor = tester.editor..insertTextNode('');
|
|
|
+ await editor.startTesting();
|
|
|
+ await editor.updateSelection(
|
|
|
+ Selection.single(path: [0], startOffset: 0),
|
|
|
+ );
|
|
|
+ await insertGreater(editor);
|
|
|
+ final textNode = editor.nodeAtPath([0]) as TextNode;
|
|
|
+ for (var i = 0; i < text.length; i++) {
|
|
|
+ await editor.insertText(textNode, text[i], i);
|
|
|
+ }
|
|
|
+
|
|
|
+ final isQuote = textNode.subtype == BuiltInAttributeKey.quote;
|
|
|
+ expect(isQuote, true);
|
|
|
+ expect(textNode.toPlainText(), 'AppFlowy');
|
|
|
+ });
|
|
|
+
|
|
|
+ testWidgets('AppFlowy> nothing changes', (tester) async {
|
|
|
+ const text = 'AppFlowy';
|
|
|
+ final editor = tester.editor..insertTextNode('');
|
|
|
+ await editor.startTesting();
|
|
|
+ await editor.updateSelection(
|
|
|
+ Selection.single(path: [0], startOffset: 0),
|
|
|
+ );
|
|
|
+ final textNode = editor.nodeAtPath([0]) as TextNode;
|
|
|
+ for (var i = 0; i < text.length; i++) {
|
|
|
+ await editor.insertText(textNode, text[i], i);
|
|
|
+ }
|
|
|
+ await insertGreater(editor);
|
|
|
+
|
|
|
+ final isQuote = textNode.subtype == BuiltInAttributeKey.quote;
|
|
|
+ expect(isQuote, false);
|
|
|
+ expect(textNode.toPlainText(), text);
|
|
|
+ });
|
|
|
+
|
|
|
+ testWidgets('> in front of text to blockquote', (tester) async {
|
|
|
+ const text = 'AppFlowy';
|
|
|
+ final editor = tester.editor..insertTextNode('');
|
|
|
+ await editor.startTesting();
|
|
|
+ await editor.updateSelection(
|
|
|
+ Selection.single(path: [0], startOffset: 0),
|
|
|
+ );
|
|
|
+ final textNode = editor.nodeAtPath([0]) as TextNode;
|
|
|
+ for (var i = 0; i < text.length; i++) {
|
|
|
+ await editor.insertText(textNode, text[i], i);
|
|
|
+ }
|
|
|
+ await editor.updateSelection(
|
|
|
+ Selection.single(path: [0], startOffset: 0),
|
|
|
+ );
|
|
|
+ await insertGreater(editor);
|
|
|
+
|
|
|
+ final isQuote = textNode.subtype == BuiltInAttributeKey.quote;
|
|
|
+ expect(isQuote, true);
|
|
|
+ expect(textNode.toPlainText(), text);
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|
|
|
}
|