8
0
فهرست منبع

Fix: Heading drop-down stopped working after HeadingCommand changes.

Maciej Gołaszewski 7 سال پیش
والد
کامیت
a5cde36b8a
2فایلهای تغییر یافته به همراه15 افزوده شده و 3 حذف شده
  1. 1 1
      packages/ckeditor5-heading/src/headingui.js
  2. 14 2
      packages/ckeditor5-heading/tests/headingui.js

+ 1 - 1
packages/ckeditor5-heading/src/headingui.js

@@ -95,7 +95,7 @@ export default class HeadingUI extends Plugin {
 
 			// Execute command when an item from the dropdown is selected.
 			this.listenTo( dropdownView, 'execute', evt => {
-				editor.execute( evt.source.commandName );
+				editor.execute( evt.source.commandName, evt.source.commandValue ? { value: evt.source.commandValue } : undefined );
 				editor.editing.view.focus();
 			} );
 

+ 14 - 2
packages/ckeditor5-heading/tests/headingui.js

@@ -76,7 +76,7 @@ describe( 'HeadingUI', () => {
 			expect( dropdown.buttonView.tooltip ).to.equal( 'Heading' );
 		} );
 
-		it( 'should execute format command on model execute event', () => {
+		it( 'should execute format command on model execute event for paragraph', () => {
 			const executeSpy = testUtils.sinon.spy( editor, 'execute' );
 			const dropdown = editor.ui.componentFactory.create( 'heading' );
 
@@ -84,7 +84,19 @@ describe( 'HeadingUI', () => {
 			dropdown.fire( 'execute' );
 
 			sinon.assert.calledOnce( executeSpy );
-			sinon.assert.calledWithExactly( executeSpy, 'paragraph' );
+			sinon.assert.calledWithExactly( executeSpy, 'paragraph', undefined );
+		} );
+
+		it( 'should execute format command on model execute event for heading', () => {
+			const executeSpy = testUtils.sinon.spy( editor, 'execute' );
+			const dropdown = editor.ui.componentFactory.create( 'heading' );
+
+			dropdown.commandName = 'heading';
+			dropdown.commandValue = 'heading1';
+			dropdown.fire( 'execute' );
+
+			sinon.assert.calledOnce( executeSpy );
+			sinon.assert.calledWithExactly( executeSpy, 'heading', { value: 'heading1' } );
 		} );
 
 		it( 'should focus view after command execution', () => {