Ver Fonte

Added: Execute highight command on split button action button.

Maciej Gołaszewski há 8 anos atrás
pai
commit
c88b887b18

+ 7 - 0
packages/ckeditor5-highlight/src/highlightui.js

@@ -83,6 +83,7 @@ export default class HighlightUI extends Plugin {
 	_addHighlighterButton( option ) {
 		const command = this.editor.commands.get( 'highlight' );
 
+		// TODO: change naming
 		this._addButton( 'highlight:' + option.model, option.title, getIconForType( option.type ), option.model, decorateHighlightButton );
 
 		function decorateHighlightButton( button ) {
@@ -212,6 +213,12 @@ export default class HighlightUI extends Plugin {
 				}
 			} );
 
+			// Execute current action from dropdown's split button action button.
+			dropdownView.buttonView.on( 'execute', () => {
+				editor.execute( 'highlight', { value: model.commandValue } );
+				editor.editing.view.focus();
+			} );
+
 			// Returns active highlighter option depending on current command value.
 			// If current is not set or it is the same as last execute this method will return the option key (like icon or color)
 			// of last executed highlighter. Otherwise it will return option key for current one.

+ 1 - 1
packages/ckeditor5-highlight/tests/highlightui.js

@@ -132,7 +132,7 @@ describe( 'HighlightUI', () => {
 
 			function validateButton( which ) {
 				expect( button.icon ).to.equal( buttons[ which ].icon );
-				expect( button.buttonView.iconView.color ).to.equal( options[ which ].color );
+				expect( button.actionView.color ).to.equal( options[ which ].color );
 			}
 
 			it( 'should have properties of first defined highlighter', () => {