Parcourir la source

Internal: Schema#findAllowedParent should not allow to split objects.

Oskar Wróbel il y a 7 ans
Parent
commit
caa5a10fec

+ 2 - 1
packages/ckeditor5-engine/src/model/schema.js

@@ -736,7 +736,8 @@ export default class Schema {
 				return parent;
 			}
 
-			if ( this.isLimit( parent ) ) {
+			// Do not split limit elements and objects.
+			if ( this.isLimit( parent ) || this.isObject( parent ) ) {
 				return null;
 			}
 

+ 17 - 3
packages/ckeditor5-engine/tests/model/schema.js

@@ -1386,7 +1386,7 @@ describe( 'Schema', () => {
 			} );
 		} );
 
-		it( 'should return position ancestor that allows to insert given note to it', () => {
+		it( 'should return position ancestor that allows to insert given node to it', () => {
 			const node = new Element( 'paragraph' );
 
 			const allowedParent = schema.findAllowedParent( node, Position.createAt( r1bQp ) );
@@ -1394,7 +1394,7 @@ describe( 'Schema', () => {
 			expect( allowedParent ).to.equal( r1bQ );
 		} );
 
-		it( 'should return position ancestor that allows to insert given note to it when position is already i such an element', () => {
+		it( 'should return position ancestor that allows to insert given node to it when position is already i such an element', () => {
 			const node = new Text( 'text' );
 
 			const parent = schema.findAllowedParent( node, Position.createAt( r1bQp ) );
@@ -1402,7 +1402,7 @@ describe( 'Schema', () => {
 			expect( parent ).to.equal( r1bQp );
 		} );
 
-		it( 'should return null when limit element will be reached before allowed parent', () => {
+		it( 'should return null when limit element is reached before allowed parent', () => {
 			schema.extend( 'blockQuote', {
 				isLimit: true
 			} );
@@ -1416,6 +1416,20 @@ describe( 'Schema', () => {
 			expect( parent ).to.null;
 		} );
 
+		it( 'should return null when object element is reached before allowed parent', () => {
+			schema.extend( 'blockQuote', {
+				isObject: true
+			} );
+			schema.register( 'div', {
+				allowIn: '$root'
+			} );
+			const node = new Element( 'div' );
+
+			const parent = schema.findAllowedParent( node, Position.createAt( r1bQp ) );
+
+			expect( parent ).to.null;
+		} );
+
 		it( 'should return null when there is no allowed ancestor for given position', () => {
 			const node = new Element( 'section' );