Browse Source

Merge pull request #8212 from ckeditor/i/7919

Fix (link): Do not show up link UI on <kbd>Ctrl</kbd>+<kbd>K</kbd> when `LinkCommand` is disabled. Closes #7919.
Maciej 5 years ago
parent
commit
242d21c67e
2 changed files with 18 additions and 1 deletions
  1. 3 1
      packages/ckeditor5-link/src/linkui.js
  2. 15 0
      packages/ckeditor5-link/tests/linkui.js

+ 3 - 1
packages/ckeditor5-link/src/linkui.js

@@ -219,7 +219,9 @@ export default class LinkUI extends Plugin {
 			// Prevent focusing the search bar in FF, Chrome and Edge. See https://github.com/ckeditor/ckeditor5/issues/4811.
 			cancel();
 
-			this._showUI( true );
+			if ( linkCommand.isEnabled ) {
+				this._showUI( true );
+			}
 		} );
 
 		editor.ui.componentFactory.add( 'link', locale => {

+ 15 - 0
packages/ckeditor5-link/tests/linkui.js

@@ -795,6 +795,21 @@ describe( 'LinkUI', () => {
 			sinon.assert.calledWithExactly( spy, true );
 		} );
 
+		it( 'should not show the UI on Ctrl+K keystroke on content with LinkCommand disabled', () => {
+			const spy = testUtils.sinon.stub( linkUIFeature, '_showUI' ).returns( {} );
+			const command = editor.commands.get( 'link' );
+			command.isEnabled = false;
+
+			editor.keystrokes.press( {
+				keyCode: keyCodes.k,
+				ctrlKey: true,
+				preventDefault: sinon.spy(),
+				stopPropagation: sinon.spy()
+			} );
+
+			sinon.assert.notCalled( spy );
+		} );
+
 		it( 'should prevent default action on Ctrl+K keystroke', () => {
 			const preventDefaultSpy = sinon.spy();
 			const stopPropagationSpy = sinon.spy();