瀏覽代碼

Merge pull request #102 from ckeditor/t/ckeditor5/890

Other: Remove silent validation in the command. See ckeditor/ckeditor5#890.
Piotrek Koszuliński 7 年之前
父節點
當前提交
649c6f1564
共有 2 個文件被更改,包括 3 次插入15 次删除
  1. 1 5
      packages/ckeditor5-heading/src/headingcommand.js
  2. 2 10
      packages/ckeditor5-heading/tests/headingcommand.js

+ 1 - 5
packages/ckeditor5-heading/src/headingcommand.js

@@ -63,16 +63,12 @@ export default class HeadingCommand extends Command {
 	 * @param {String} options.value Name of the element which this command will apply in the model.
 	 * @fires execute
 	 */
-	execute( options = {} ) {
+	execute( options ) {
 		const model = this.editor.model;
 		const document = model.document;
 
 		const modelElement = options.value;
 
-		if ( !this.modelElements.includes( modelElement ) ) {
-			return;
-		}
-
 		model.change( writer => {
 			const blocks = Array.from( document.selection.getSelectedBlocks() )
 				.filter( block => {

+ 2 - 10
packages/ckeditor5-heading/tests/headingcommand.js

@@ -174,17 +174,9 @@ describe( 'HeadingCommand', () => {
 			} );
 		} );
 
-		it( 'should do nothing on non-registered model elements', () => {
+		it( 'should do nothing with non-registered model elements', () => {
 			setData( model, '<heading1>[]</heading1>' );
-			command.execute( { value: 'paragraph' } );
-
-			expect( getData( model ) ).to.equal( '<heading1>[]</heading1>' );
-			expect( command.value ).to.equal( 'heading1' );
-		} );
-
-		it( 'should do nothing when empty value is passed', () => {
-			setData( model, '<heading1>[]</heading1>' );
-			command.execute();
+			command.execute( { value: 'heading5' } );
 
 			expect( getData( model ) ).to.equal( '<heading1>[]</heading1>' );
 			expect( command.value ).to.equal( 'heading1' );