Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge 29e65a0 into 73d5596
Browse files Browse the repository at this point in the history
  • Loading branch information
pomek committed Jan 24, 2020
2 parents 73d5596 + 29e65a0 commit 885def7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 34 deletions.
14 changes: 2 additions & 12 deletions src/linkui.js
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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();
Expand Down
22 changes: 0 additions & 22 deletions tests/linkui.js
Expand Up @@ -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, '<paragraph>f[o]o</paragraph>' );
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, '<paragraph>f[o]o</paragraph>' );

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 885def7

Please sign in to comment.