Przeglądaj źródła

Remove superfluous schema child check for codeBlock in code block.

Maciej Gołaszewski 6 lat temu
rodzic
commit
cecb08f4d3

+ 0 - 7
packages/ckeditor5-code-block/src/codeblockediting.js

@@ -113,13 +113,6 @@ export default class CodeBlockEditing extends Plugin {
 			allowAttributes: [ 'language' ]
 		} );
 
-		// Disallow codeBlock in codeBlock.
-		schema.addChildCheck( ( context, childDef ) => {
-			if ( context.endsWith( 'codeBlock' ) && childDef.name === 'codeBlock' ) {
-				return false;
-			}
-		} );
-
 		// Disallow all attributes in `codeBlock`.
 		schema.addAttributeCheck( ( context, attributeName ) => {
 			if ( context.endsWith( 'codeBlock' ) || context.endsWith( 'codeBlock $text' ) ) {

+ 4 - 0
packages/ckeditor5-code-block/tests/codeblockediting.js

@@ -184,6 +184,10 @@ describe( 'CodeBlockEditing', () => {
 		expect( model.schema.checkChild( [ '$root' ], 'codeBlock' ) ).to.be.true;
 	} );
 
+	it( 'disallows for codeBlock in the other codeBlock', () => {
+		expect( model.schema.checkChild( [ '$root', 'codeBlock' ], 'codeBlock' ) ).to.be.false;
+	} );
+
 	it( 'allows only for $text in codeBlock', () => {
 		expect( model.schema.checkChild( [ '$root', 'codeBlock' ], '$text' ) ).to.equal( true );
 		expect( model.schema.checkChild( [ '$root', 'codeBlock' ], '$block' ) ).to.equal( false );