Maciej Bukowski 8 lat temu
rodzic
commit
01bcd4380b

+ 2 - 2
packages/ckeditor5-link/src/link.js

@@ -132,10 +132,10 @@ export default class Link extends Plugin {
 		const t = editor.t;
 
 		// Handle the `Ctrl+K` keystroke and show the panel.
-		editor.keystrokes.set( linkKeystroke, ( keyEvtData, stop ) => {
+		editor.keystrokes.set( linkKeystroke, ( keyEvtData, cancel ) => {
 			// Stop the event in the DOM to prevent default browser action.
 			// See https://github.com/ckeditor/ckeditor5-link/issues/153.
-			stop();
+			cancel();
 
 			if ( linkCommand.isEnabled ) {
 				this._showPanel( true );

+ 27 - 2
packages/ckeditor5-link/tests/link.js

@@ -442,14 +442,39 @@ describe( 'Link', () => {
 			const command = editor.commands.get( 'link' );
 
 			command.isEnabled = false;
-			editor.keystrokes.press( { keyCode: keyCodes.k, ctrlKey: true } );
+			editor.keystrokes.press( {
+				keyCode: keyCodes.k,
+				ctrlKey: true,
+				preventDefault: sinon.spy(),
+				stopPropagation: sinon.spy()
+			} );
 			sinon.assert.notCalled( spy );
 
 			command.isEnabled = true;
-			editor.keystrokes.press( { keyCode: keyCodes.k, ctrlKey: true } );
+			editor.keystrokes.press( {
+				keyCode: keyCodes.k,
+				ctrlKey: true,
+				preventDefault: sinon.spy(),
+				stopPropagation: sinon.spy()
+			} );
 			sinon.assert.calledWithExactly( spy, true );
 		} );
 
+		it( 'should show prevent default actions on Ctrl+K keystroke', () => {
+			const preventDefaultSpy = sinon.spy();
+			const stopPropagationSpy = sinon.spy();
+
+			editor.keystrokes.press( {
+				keyCode: keyCodes.k,
+				ctrlKey: true,
+				preventDefault: preventDefaultSpy,
+				stopPropagation: stopPropagationSpy
+			} );
+
+			sinon.assert.calledOnce( preventDefaultSpy );
+			sinon.assert.calledOnce( stopPropagationSpy );
+		} );
+
 		it( 'should focus the the #formView on `Tab` key press when the #_balloon is open', () => {
 			const keyEvtData = {
 				keyCode: keyCodes.tab,