From 29e65a03419269c367715521dd4ccb33530d0153 Mon Sep 17 00:00:00 2001 From: Kamil Piechaczek Date: Fri, 24 Jan 2020 13:08:19 +0100 Subject: [PATCH] Link UI will be displayed even if the command is disabled. --- src/linkui.js | 14 ++------------ tests/linkui.js | 22 ---------------------- 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/src/linkui.js b/src/linkui.js index d73246b..746a699 100644 --- a/src/linkui.js +++ b/src/linkui.js @@ -188,9 +188,7 @@ export default class LinkUI extends Plugin { // Prevent focusing the search bar in FF and opening new tab in Edge. #153, #154. cancel(); - if ( linkCommand.isEnabled ) { - this._showUI( true ); - } + this._showUI( true ); } ); editor.ui.componentFactory.add( 'link', locale => { @@ -355,20 +353,12 @@ export default class LinkUI extends Plugin { } /** - * Shows the correct UI type for the current state of the command. It is either - * {@link #formView} or {@link #actionsView}. + * Shows the correct UI type. It is either {@link #formView} or {@link #actionsView}. * * @param {Boolean} forceVisible * @private */ _showUI( forceVisible = false ) { - const editor = this.editor; - const linkCommand = editor.commands.get( 'link' ); - - if ( !linkCommand.isEnabled ) { - return; - } - // When there's no link under the selection, go straight to the editing UI. if ( !this._getSelectedLinkElement() ) { this._addActionsView(); diff --git a/tests/linkui.js b/tests/linkui.js index fd454f9..9a5f97f 100644 --- a/tests/linkui.js +++ b/tests/linkui.js @@ -122,15 +122,6 @@ describe( 'LinkUI', () => { editor.editing.view.document.isFocused = true; } ); - it( 'should not work if the link command is disabled', () => { - setModelData( editor.model, 'f[o]o' ); - editor.commands.get( 'link' ).isEnabled = false; - - linkUIFeature._showUI(); - - expect( balloon.visibleView ).to.be.null; - } ); - it( 'should not throw if the UI is already visible', () => { setModelData( editor.model, 'f[o]o' ); @@ -532,19 +523,6 @@ describe( 'LinkUI', () => { describe( 'keyboard support', () => { it( 'should show the UI on Ctrl+K keystroke', () => { 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 ); - - command.isEnabled = true; editor.keystrokes.press( { keyCode: keyCodes.k,