8
0
Просмотр исходного кода

Changed: Block filler should be rendered after all element's children.

Szymon Cofalik 8 лет назад
Родитель
Сommit
de4f8bc619

+ 2 - 1
packages/ckeditor5-engine/src/view/attributeelement.js

@@ -120,7 +120,8 @@ function getFillerOffset() {
 		return null;
 		return null;
 	}
 	}
 
 
-	return 0;
+	// Render block filler at the end of element (after all ui elements).
+	return this.childCount;
 }
 }
 
 
 // Returns total count of children that are not {@link module:engine/view/uielement~UIElement UIElements}.
 // Returns total count of children that are not {@link module:engine/view/uielement~UIElement UIElements}.

+ 2 - 1
packages/ckeditor5-engine/src/view/containerelement.js

@@ -78,5 +78,6 @@ export default class ContainerElement extends Element {
 //
 //
 // @returns {Number|null} Block filler offset or `null` if block filler is not needed.
 // @returns {Number|null} Block filler offset or `null` if block filler is not needed.
 function getFillerOffset() {
 function getFillerOffset() {
-	return Array.from( this.getChildren() ).some( element => !element.is( 'uiElement' ) ) ? null : 0;
+	// Render block filler at the end of element (after all ui elements).
+	return Array.from( this.getChildren() ).some( element => !element.is( 'uiElement' ) ) ? null : this.childCount;
 }
 }

+ 5 - 5
packages/ckeditor5-engine/tests/view/attributeelement.js

@@ -138,19 +138,19 @@ describe( 'AttributeElement', () => {
 			expect( attribute.getFillerOffset() ).to.be.null;
 			expect( attribute.getFillerOffset() ).to.be.null;
 		} );
 		} );
 
 
-		it( 'should return position 0 if it is the only nested element in the container and has UIElement inside', () => {
+		it( 'should return offset after all children if it is the only nested element in the container and has UIElement inside', () => {
 			const { selection } = parse(
 			const { selection } = parse(
 				'<container:p><attribute:b><attribute:i>[]<ui:span></ui:span></attribute:i></attribute:b></container:p>' );
 				'<container:p><attribute:b><attribute:i>[]<ui:span></ui:span></attribute:i></attribute:b></container:p>' );
 			const attribute = selection.getFirstPosition().parent;
 			const attribute = selection.getFirstPosition().parent;
 
 
-			expect( attribute.getFillerOffset() ).to.equals( 0 );
+			expect( attribute.getFillerOffset() ).to.equal( 1 );
 		} );
 		} );
 
 
-		it( 'should return 0 if there is no parent container element and has UIElement inside', () => {
-			const { selection } = parse( '<attribute:b>[]<ui:span></ui:span></attribute:b>' );
+		it( 'should return offset after all children if there is no parent container element and has UIElement inside', () => {
+			const { selection } = parse( '<attribute:b>[]<ui:span></ui:span><ui:span></ui:span></attribute:b>' );
 			const attribute = selection.getFirstPosition().parent;
 			const attribute = selection.getFirstPosition().parent;
 
 
-			expect( attribute.getFillerOffset() ).to.equal( 0 );
+			expect( attribute.getFillerOffset() ).to.equal( 2 );
 		} );
 		} );
 	} );
 	} );
 } );
 } );

+ 2 - 2
packages/ckeditor5-engine/tests/view/containerelement.js

@@ -52,8 +52,8 @@ describe( 'ContainerElement', () => {
 			expect( parse( '<container:p></container:p>' ).getFillerOffset() ).to.equals( 0 );
 			expect( parse( '<container:p></container:p>' ).getFillerOffset() ).to.equals( 0 );
 		} );
 		} );
 
 
-		it( 'should return position 0 if element contains only ui elements', () => {
-			expect( parse( '<container:p><ui:span></ui:span></container:p>' ).getFillerOffset() ).to.equals( 0 );
+		it( 'should return offset after all children if element contains only ui elements', () => {
+			expect( parse( '<container:p><ui:span></ui:span><ui:span></ui:span></container:p>' ).getFillerOffset() ).to.equals( 2 );
 		} );
 		} );
 
 
 		it( 'should return null if element is not empty', () => {
 		it( 'should return null if element is not empty', () => {