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

Commit

Permalink
Merge e19366b into 0069dc7
Browse files Browse the repository at this point in the history
  • Loading branch information
oskarwrobel committed May 27, 2019
2 parents 0069dc7 + e19366b commit d860b2c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/linkui.js
Expand Up @@ -188,7 +188,7 @@ export default class LinkUI extends Plugin {
cancel();

if ( linkCommand.isEnabled ) {
this._showUI();
this._showUI( true );
}
} );

Expand Down Expand Up @@ -380,6 +380,11 @@ export default class LinkUI extends Plugin {
else {
this._addActionsView();
}

// Be sure panel with link is visible.
if ( forceVisible ) {
this._balloon.showStack( 'main' );
}
}

// Begin responding to ui#update once the UI is added.
Expand Down
53 changes: 52 additions & 1 deletion tests/linkui.js
Expand Up @@ -486,7 +486,7 @@ describe( 'LinkUI', () => {
preventDefault: sinon.spy(),
stopPropagation: sinon.spy()
} );
sinon.assert.calledWithExactly( spy );
sinon.assert.calledWithExactly( spy, true );
} );

it( 'should prevent default action on Ctrl+K keystroke', () => {
Expand All @@ -504,6 +504,57 @@ describe( 'LinkUI', () => {
sinon.assert.calledOnce( stopPropagationSpy );
} );

it( 'should make stack with link visible on Ctrl+K keystroke - no link', () => {
const command = editor.commands.get( 'link' );

command.isEnabled = true;

balloon.add( {
view: new View(),
stackId: 'custom'
} );

editor.keystrokes.press( {
keyCode: keyCodes.k,
ctrlKey: true,
preventDefault: sinon.spy(),
stopPropagation: sinon.spy()
} );

expect( balloon.visibleView ).to.equal( formView );
} );

it( 'should make stack with link visible on Ctrl+K keystroke - link', () => {
setModelData( editor.model, '<paragraph><$text linkHref="foo.html">f[]oo</$text></paragraph>' );

const customView = new View();

balloon.add( {
view: customView,
stackId: 'custom'
} );

expect( balloon.visibleView ).to.equal( customView );

editor.keystrokes.press( {
keyCode: keyCodes.k,
ctrlKey: true,
preventDefault: sinon.spy(),
stopPropagation: sinon.spy()
} );

expect( balloon.visibleView ).to.equal( actionsView );

editor.keystrokes.press( {
keyCode: keyCodes.k,
ctrlKey: true,
preventDefault: sinon.spy(),
stopPropagation: sinon.spy()
} );

expect( balloon.visibleView ).to.equal( formView );
} );

it( 'should focus the the #actionsView on `Tab` key press when #actionsView is visible', () => {
const keyEvtData = {
keyCode: keyCodes.tab,
Expand Down

0 comments on commit d860b2c

Please sign in to comment.