mirror of
				https://github.com/AppFlowy-IO/AppFlowy.git
				synced 2025-11-04 03:54:44 +00:00 
			
		
		
		
	fix: Should not add a new line below after pressing enter at the front of the first line of text.
This commit is contained in:
		
							parent
							
								
									cde48926e2
								
							
						
					
					
						commit
						c07af9007c
					
				@ -62,10 +62,17 @@ class StateTree {
 | 
			
		||||
      }
 | 
			
		||||
      return false;
 | 
			
		||||
    }
 | 
			
		||||
    for (var i = 0; i < nodes.length; i++) {
 | 
			
		||||
      final node = nodes[i];
 | 
			
		||||
      insertedNode!.insertAfter(node);
 | 
			
		||||
      insertedNode = node;
 | 
			
		||||
    if (path.last <= 0) {
 | 
			
		||||
      for (var i = 0; i < nodes.length; i++) {
 | 
			
		||||
        final node = nodes[i];
 | 
			
		||||
        insertedNode.insertBefore(node);
 | 
			
		||||
      }
 | 
			
		||||
    } else {
 | 
			
		||||
      for (var i = 0; i < nodes.length; i++) {
 | 
			
		||||
        final node = nodes[i];
 | 
			
		||||
        insertedNode!.insertAfter(node);
 | 
			
		||||
        insertedNode = node;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return true;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -116,6 +116,27 @@ void main() async {
 | 
			
		||||
        (tester) async {
 | 
			
		||||
      _testMultipleSelection(tester, false);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    testWidgets('Presses enter key in the first line', (tester) async {
 | 
			
		||||
      // Before
 | 
			
		||||
      //
 | 
			
		||||
      // Welcome to Appflowy 😁
 | 
			
		||||
      //
 | 
			
		||||
      // After
 | 
			
		||||
      //
 | 
			
		||||
      // [Empty Line]
 | 
			
		||||
      // Welcome to Appflowy 😁
 | 
			
		||||
      //
 | 
			
		||||
      const text = 'Welcome to Appflowy 😁';
 | 
			
		||||
      final editor = tester.editor..insertTextNode(text);
 | 
			
		||||
      await editor.startTesting();
 | 
			
		||||
      await editor.updateSelection(
 | 
			
		||||
        Selection.single(path: [0], startOffset: 0),
 | 
			
		||||
      );
 | 
			
		||||
      await editor.pressLogicKey(LogicalKeyboardKey.enter);
 | 
			
		||||
      expect(editor.documentLength, 2);
 | 
			
		||||
      expect((editor.nodeAtPath([1]) as TextNode).toRawString(), text);
 | 
			
		||||
    });
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user