Procházet zdrojové kódy

Removed schema object checking in ParagraphCommand's _checkEnabled method.

Szymon Kupś před 8 roky
rodič
revize
09fa65c4e9

+ 1 - 8
packages/ckeditor5-paragraph/src/paragraphcommand.js

@@ -83,16 +83,9 @@ export default class ParagraphCommand extends Command {
 	_checkEnabled() {
 		const block = first( this.editor.document.selection.getSelectedBlocks() );
 
-		if ( !block ) {
-			return false;
-		}
-
-		const schema = this.editor.document.schema;
-		const isParagraphAllowed = schema.check( {
+		return !!block && this.editor.document.schema.check( {
 			name: 'paragraph',
 			inside: Position.createBefore( block )
 		} );
-
-		return isParagraphAllowed && !schema.objects.has( block.name );
 	}
 }

+ 2 - 13
packages/ckeditor5-paragraph/tests/paragraphcommand.js

@@ -27,11 +27,6 @@ describe( 'ParagraphCommand', () => {
 			schema.registerItem( 'notBlock' );
 			schema.allow( { name: 'notBlock', inside: '$root' } );
 			schema.allow( { name: '$text', inside: 'notBlock' } );
-
-			schema.registerItem( 'object' );
-			schema.allow( { name: 'object', inside: '$root' } );
-			schema.allow( { name: '$text', inside: 'object' } );
-			schema.objects.add( 'object' );
 		} );
 	} );
 
@@ -197,14 +192,8 @@ describe( 'ParagraphCommand', () => {
 			expect( command.isEnabled ).to.be.false;
 		} );
 
-		it( 'should be disabled if inside object', () => {
-			setData( document, '<object>f{}oo</object>' );
-
-			expect( command.isEnabled ).to.be.false;
-		} );
-
-		it( 'should be disabled if selection is placed on object', () => {
-			setData( document, '[<object>foo</object>]' );
+		it( 'should be disabled if selection is placed on non-block element', () => {
+			setData( document, '[<notBlock>foo</notBlock>]' );
 
 			expect( command.isEnabled ).to.be.false;
 		} );