Kaynağa Gözat

Fixed creating position after TextProxy.

Oskar Wrobel 9 yıl önce
ebeveyn
işleme
ba19a22ec5

+ 1 - 1
packages/ckeditor5-engine/src/view/position.js

@@ -196,7 +196,7 @@ export default class Position {
 	static createAfter( node ) {
 		// {@link engine.view.TextProxy} is not a instance of {@link engine.view.Node} so we need do handle it in specific way.
 		if ( node instanceof TextProxy ) {
-			return new Position( node._textNode, node._index + 1 );
+			return new Position( node._textNode, node._index + node._data.length );
 		}
 
 		if ( !node.parent ) {

+ 3 - 3
packages/ckeditor5-engine/tests/view/position.js

@@ -330,10 +330,10 @@ describe( 'Position', () => {
 		} );
 
 		it( 'should create positions after `TextProxy`', () => {
-			const text = new Text( 'abc' );
+			const text = new Text( 'abcd' );
 
-			const textProxy = new TextProxy( text, 1, 1 );
-			const position = new Position( text, 2 );
+			const textProxy = new TextProxy( text, 1, 2 );
+			const position = new Position( text, 3 );
 
 			expect( Position.createAfter( textProxy ) ).deep.equal( position );
 		} );