Browse Source

Implemented tooltips with keystroke information next to Bold and Italic buttons.

Aleksander Nowodzinski 9 years ago
parent
commit
aa80718e55

+ 4 - 2
packages/ckeditor5-basic-styles/src/bold.js

@@ -32,13 +32,15 @@ export default class Bold extends Feature {
 		const editor = this.editor;
 		const t = editor.t;
 		const command = editor.commands.get( 'bold' );
+		const keystroke = 'CTRL+B';
 
 		// Create button model.
 		const buttonModel = new Model( {
 			isEnabled: true,
 			isOn: false,
 			label: t( 'Bold' ),
-			icon: 'bold'
+			icon: 'bold',
+			keystroke
 		} );
 
 		// Bind button model to command.
@@ -51,6 +53,6 @@ export default class Bold extends Feature {
 		editor.ui.featureComponents.add( 'bold', ButtonController, ButtonView, buttonModel );
 
 		// Set the Ctrl+B keystroke.
-		editor.keystrokes.set( 'CTRL+B', 'bold' );
+		editor.keystrokes.set( keystroke, 'bold' );
 	}
 }

+ 4 - 2
packages/ckeditor5-basic-styles/src/italic.js

@@ -32,13 +32,15 @@ export default class Italic extends Feature {
 		const editor = this.editor;
 		const t = editor.t;
 		const command = editor.commands.get( 'italic' );
+		const keystroke = 'CTRL+I';
 
 		// Create button model.
 		const buttonModel = new Model( {
 			isEnabled: true,
 			isOn: false,
 			label: t( 'Italic' ),
-			icon: 'italic'
+			icon: 'italic',
+			keystroke
 		} );
 
 		// Bind button model to command.
@@ -51,6 +53,6 @@ export default class Italic extends Feature {
 		editor.ui.featureComponents.add( 'italic', ButtonController, ButtonView, buttonModel );
 
 		// Set the Ctrl+I keystroke.
-		editor.keystrokes.set( 'CTRL+I', 'italic' );
+		editor.keystrokes.set( keystroke, 'italic' );
 	}
 }

+ 5 - 1
packages/ckeditor5-basic-styles/tests/bold.js

@@ -72,7 +72,11 @@ describe( 'Bold', () => {
 		expect( model.isEnabled ).to.be.false;
 	} );
 
-	it( 'should set CTRL+B keystroke', () => {
+	it( 'should set keystroke in the model', () => {
+		expect( boldController.model.keystroke ).to.equal( 'CTRL+B' );
+	} );
+
+	it( 'should set editor keystroke', () => {
 		const spy = sinon.spy( editor, 'execute' );
 
 		const wasHandled = editor.keystrokes.press( { keyCode: keyCodes.b, ctrlKey: true } );

+ 5 - 1
packages/ckeditor5-basic-styles/tests/italic.js

@@ -72,7 +72,11 @@ describe( 'Italic', () => {
 		expect( model.isEnabled ).to.be.false;
 	} );
 
-	it( 'should set CTRL+I keystroke', () => {
+	it( 'should set keystroke in the model', () => {
+		expect( italicController.model.keystroke ).to.equal( 'CTRL+I' );
+	} );
+
+	it( 'should set editor keystroke', () => {
 		const spy = sinon.spy( editor, 'execute' );
 
 		const wasHandled = editor.keystrokes.press( { keyCode: keyCodes.i, ctrlKey: true } );